Update to new generified Bouncy Castle APIs
Change-Id: I6a1b0657467c8890f48e7afac82a13cdf8fdf0e3
This commit is contained in:
@@ -1174,7 +1174,6 @@ public class AccountIT extends AbstractDaemonTest {
|
|||||||
assertThat(actual.fingerprint)
|
assertThat(actual.fingerprint)
|
||||||
.named(id)
|
.named(id)
|
||||||
.isEqualTo(Fingerprint.toString(expected.getPublicKey().getFingerprint()));
|
.isEqualTo(Fingerprint.toString(expected.getPublicKey().getFingerprint()));
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
List<String> userIds = ImmutableList.copyOf(expected.getPublicKey().getUserIDs());
|
List<String> userIds = ImmutableList.copyOf(expected.getPublicKey().getUserIDs());
|
||||||
assertThat(actual.userIds).named(id).containsExactlyElementsIn(userIds);
|
assertThat(actual.userIds).named(id).containsExactlyElementsIn(userIds);
|
||||||
assertThat(actual.key).named(id).startsWith("-----BEGIN PGP PUBLIC KEY BLOCK-----\n");
|
assertThat(actual.key).named(id).startsWith("-----BEGIN PGP PUBLIC KEY BLOCK-----\n");
|
||||||
|
@@ -176,7 +176,6 @@ public class GerritPublicKeyChecker extends PublicKeyChecker {
|
|||||||
|
|
||||||
private boolean hasAllowedUserId(PGPPublicKey key, Set<String> allowedUserIds)
|
private boolean hasAllowedUserId(PGPPublicKey key, Set<String> allowedUserIds)
|
||||||
throws PGPException {
|
throws PGPException {
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
Iterator<String> userIds = key.getUserIDs();
|
Iterator<String> userIds = key.getUserIDs();
|
||||||
while (userIds.hasNext()) {
|
while (userIds.hasNext()) {
|
||||||
String userId = userIds.next();
|
String userId = userIds.next();
|
||||||
|
@@ -381,7 +381,6 @@ public class PublicKeyChecker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<CheckResult> signerResults = new ArrayList<>();
|
List<CheckResult> signerResults = new ArrayList<>();
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
Iterator<String> userIds = key.getUserIDs();
|
Iterator<String> userIds = key.getUserIDs();
|
||||||
while (userIds.hasNext()) {
|
while (userIds.hasNext()) {
|
||||||
String userId = userIds.next();
|
String userId = userIds.next();
|
||||||
|
@@ -398,7 +398,6 @@ public class PublicKeyStore implements AutoCloseable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String keyToString(PGPPublicKey key) {
|
public static String keyToString(PGPPublicKey key) {
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
Iterator<String> it = key.getUserIDs();
|
Iterator<String> it = key.getUserIDs();
|
||||||
return String.format(
|
return String.format(
|
||||||
"%s %s(%s)",
|
"%s %s(%s)",
|
||||||
|
@@ -219,7 +219,6 @@ public class GpgKeys implements ChildCollection<AccountResource, GpgKey> {
|
|||||||
if (key != null) {
|
if (key != null) {
|
||||||
info.id = PublicKeyStore.keyIdToString(key.getKeyID());
|
info.id = PublicKeyStore.keyIdToString(key.getKeyID());
|
||||||
info.fingerprint = Fingerprint.toString(key.getFingerprint());
|
info.fingerprint = Fingerprint.toString(key.getFingerprint());
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
Iterator<String> userIds = key.getUserIDs();
|
Iterator<String> userIds = key.getUserIDs();
|
||||||
info.userIds = ImmutableList.copyOf(userIds);
|
info.userIds = ImmutableList.copyOf(userIds);
|
||||||
|
|
||||||
|
@@ -374,7 +374,7 @@ public class GerritPublicKeyCheckerTest {
|
|||||||
|
|
||||||
PGPPublicKeyRing keyRingB = keyB().getPublicKeyRing();
|
PGPPublicKeyRing keyRingB = keyB().getPublicKeyRing();
|
||||||
PGPPublicKey keyB = keyRingB.getPublicKey();
|
PGPPublicKey keyB = keyRingB.getPublicKey();
|
||||||
keyB = PGPPublicKey.removeCertification(keyB, (String) keyB.getUserIDs().next());
|
keyB = PGPPublicKey.removeCertification(keyB, keyB.getUserIDs().next());
|
||||||
keyRingB = PGPPublicKeyRing.insertPublicKey(keyRingB, keyB);
|
keyRingB = PGPPublicKeyRing.insertPublicKey(keyRingB, keyB);
|
||||||
add(keyRingB, addUser("userB"));
|
add(keyRingB, addUser("userB"));
|
||||||
|
|
||||||
@@ -392,8 +392,7 @@ public class GerritPublicKeyCheckerTest {
|
|||||||
List<ExternalId> newExtIds = new ArrayList<>(2);
|
List<ExternalId> newExtIds = new ArrayList<>(2);
|
||||||
newExtIds.add(ExternalId.create(toExtIdKey(kr.getPublicKey()), id));
|
newExtIds.add(ExternalId.create(toExtIdKey(kr.getPublicKey()), id));
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
String userId = Iterators.getOnlyElement(kr.getPublicKey().getUserIDs(), null);
|
||||||
String userId = (String) Iterators.getOnlyElement(kr.getPublicKey().getUserIDs(), null);
|
|
||||||
if (userId != null) {
|
if (userId != null) {
|
||||||
String email = PushCertificateIdent.parse(userId).getEmailAddress();
|
String email = PushCertificateIdent.parse(userId).getEmailAddress();
|
||||||
assertThat(email).contains("@");
|
assertThat(email).contains("@");
|
||||||
|
@@ -231,7 +231,6 @@ public class PublicKeyStoreTest {
|
|||||||
|
|
||||||
private void assertUserIds(PGPPublicKeyRing keyRing, String... expected) throws Exception {
|
private void assertUserIds(PGPPublicKeyRing keyRing, String... expected) throws Exception {
|
||||||
List<String> actual = new ArrayList<>();
|
List<String> actual = new ArrayList<>();
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
Iterator<String> userIds =
|
Iterator<String> userIds =
|
||||||
store.get(keyRing.getPublicKey().getKeyID()).iterator().next().getPublicKey().getUserIDs();
|
store.get(keyRing.getPublicKey().getKeyID()).iterator().next().getPublicKey().getUserIDs();
|
||||||
while (userIds.hasNext()) {
|
while (userIds.hasNext()) {
|
||||||
|
@@ -77,7 +77,7 @@ public class TestKey {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getFirstUserId() {
|
public String getFirstUserId() {
|
||||||
return (String) getPublicKey().getUserIDs().next();
|
return getPublicKey().getUserIDs().next();
|
||||||
}
|
}
|
||||||
|
|
||||||
public PGPPrivateKey getPrivateKey() throws PGPException {
|
public PGPPrivateKey getPrivateKey() throws PGPException {
|
||||||
|
Reference in New Issue
Block a user