Skip to content

Commit c3a7fc0

Browse files
committed
cleanup/compatibility changes
1 parent ea5169d commit c3a7fc0

19 files changed

+346
-110
lines changed

ant/jdk14.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@
102102
<exclude name="**/pqc/**/HPS*.java"/>
103103
<exclude name="**/GetInstanceTest.java"/>
104104
<exclude name="**/SIKE*.java"/>
105+
<exclude name="**/EncryptionKeyTest.java"/>
105106
</fileset>
106107
<fileset dir="pg/src/test/java">
107108
<exclude name="**/keybox/**/*.java"/>

pg/src/main/java/org/bouncycastle/openpgp/PGPPublicKey.java

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ public PGPPublicKey(PublicKeyPacket publicKeyPacket, KeyFingerPrintCalculator fi
178178
this.idSigs = new ArrayList<List<PGPSignature>>(pubKey.idSigs.size());
179179
for (int i = 0; i != pubKey.idSigs.size(); i++)
180180
{
181-
this.idSigs.add(new ArrayList<PGPSignature>(pubKey.idSigs.get(i)));
181+
this.idSigs.add(new ArrayList<PGPSignature>((List<PGPSignature>)pubKey.idSigs.get(i)));
182182
}
183183

184184
if (pubKey.subSigs != null)
@@ -345,7 +345,7 @@ private long getExpirationTimeFromSig(
345345

346346
while (signatures.hasNext())
347347
{
348-
PGPSignature sig = signatures.next();
348+
PGPSignature sig = (PGPSignature)signatures.next();
349349

350350
if (!selfSigned || sig.getKeyID() == this.getKeyID())
351351
{
@@ -554,7 +554,7 @@ public Iterator<PGPSignature> getSignaturesForKeyID(
554554

555555
for (Iterator<PGPSignature> it = getSignatures(); it.hasNext(); )
556556
{
557-
PGPSignature sig = it.next();
557+
PGPSignature sig = (PGPSignature)it.next();
558558

559559
if (sig.getKeyID() == keyID)
560560
{
@@ -576,7 +576,7 @@ private Iterator<PGPSignature> getSignaturesForID(
576576
if (id.equals(ids.get(i)))
577577
{
578578
userIdFound = true;
579-
signatures.addAll(idSigs.get(i));
579+
signatures.addAll((List<PGPSignature>)idSigs.get(i));
580580
}
581581
}
582582

@@ -600,7 +600,7 @@ public Iterator<PGPSignature> getSignaturesForUserAttribute(
600600
if (userAttributes.equals(ids.get(i)))
601601
{
602602
attributeFound = true;
603-
signatures.addAll(idSigs.get(i));
603+
signatures.addAll((List<PGPSignature>)idSigs.get(i));
604604
}
605605
}
606606

@@ -621,7 +621,7 @@ public Iterator<PGPSignature> getSignaturesOfType(
621621

622622
while (it.hasNext())
623623
{
624-
PGPSignature sig = it.next();
624+
PGPSignature sig = (PGPSignature)it.next();
625625

626626
if (sig.getSignatureType() == signatureType)
627627
{
@@ -645,7 +645,7 @@ public Iterator<PGPSignature> getSignatures()
645645

646646
for (int i = 0; i != idSigs.size(); i++)
647647
{
648-
sigs.addAll(idSigs.get(i));
648+
sigs.addAll((List<PGPSignature>)idSigs.get(i));
649649
}
650650

651651
return sigs.iterator();
@@ -747,7 +747,7 @@ public void encode(
747747
{
748748
for (int i = 0; i != keySigs.size(); i++)
749749
{
750-
keySigs.get(i).encode(out);
750+
((PGPSignature)keySigs.get(i)).encode(out);
751751
}
752752

753753
for (int i = 0; i != ids.size(); i++)
@@ -767,21 +767,21 @@ public void encode(
767767

768768
if (!forTransfer && idTrusts.get(i) != null)
769769
{
770-
out.writePacket(idTrusts.get(i));
770+
out.writePacket((TrustPacket)idTrusts.get(i));
771771
}
772772

773-
List<PGPSignature> sigs = idSigs.get(i);
773+
List<PGPSignature> sigs = (List<PGPSignature>)idSigs.get(i);
774774
for (int j = 0; j != sigs.size(); j++)
775775
{
776-
sigs.get(j).encode(out, forTransfer);
776+
((PGPSignature)sigs.get(j)).encode(out, forTransfer);
777777
}
778778
}
779779
}
780780
else
781781
{
782782
for (int j = 0; j != subSigs.size(); j++)
783783
{
784-
subSigs.get(j).encode(out, forTransfer);
784+
((PGPSignature)subSigs.get(j)).encode(out, forTransfer);
785785
}
786786
}
787787
}
@@ -811,7 +811,7 @@ public boolean hasRevocation()
811811
{
812812
while (!revoked && (ns < keySigs.size()))
813813
{
814-
if (keySigs.get(ns++).getSignatureType() == PGPSignature.KEY_REVOCATION)
814+
if (((PGPSignature)keySigs.get(ns++)).getSignatureType() == PGPSignature.KEY_REVOCATION)
815815
{
816816
revoked = true;
817817
}
@@ -821,7 +821,7 @@ public boolean hasRevocation()
821821
{
822822
while (!revoked && (ns < subSigs.size()))
823823
{
824-
if (subSigs.get(ns++).getSignatureType() == PGPSignature.SUBKEY_REVOCATION)
824+
if (((PGPSignature)subSigs.get(ns++)).getSignatureType() == PGPSignature.SUBKEY_REVOCATION)
825825
{
826826
revoked = true;
827827
}
@@ -891,7 +891,7 @@ private static PGPPublicKey addCert(
891891
{
892892
if (id.equals(returnKey.ids.get(i)))
893893
{
894-
sigList = returnKey.idSigs.get(i);
894+
sigList = (List<PGPSignature>)returnKey.idSigs.get(i);
895895
}
896896
}
897897

@@ -1041,7 +1041,7 @@ private static PGPPublicKey removeCert(
10411041
{
10421042
if (id.equals(returnKey.ids.get(i)))
10431043
{
1044-
found = returnKey.idSigs.get(i).remove(certification);
1044+
found = ((List<PGPSignature>)returnKey.idSigs.get(i)).remove(certification);
10451045
}
10461046
}
10471047

@@ -1120,7 +1120,7 @@ public static PGPPublicKey removeCertification(
11201120
{
11211121
for (Iterator<byte[]> it = key.getRawUserIDs(); it.hasNext(); )
11221122
{
1123-
byte[] rawID = it.next();
1123+
byte[] rawID = (byte[])it.next();
11241124
for (Iterator<PGPSignature> sIt = key.getSignaturesForID(rawID); sIt.hasNext(); )
11251125
{
11261126
if (certification == sIt.next())
@@ -1135,7 +1135,7 @@ public static PGPPublicKey removeCertification(
11351135
{
11361136
for (Iterator<PGPUserAttributeSubpacketVector> it = key.getUserAttributes(); it.hasNext(); )
11371137
{
1138-
PGPUserAttributeSubpacketVector id = it.next();
1138+
PGPUserAttributeSubpacketVector id = (PGPUserAttributeSubpacketVector)it.next();
11391139
for (Iterator<PGPSignature> sIt = key.getSignaturesForUserAttribute(id); sIt.hasNext(); )
11401140
{
11411141
if (certification == sIt.next())
@@ -1196,11 +1196,11 @@ public static PGPPublicKey join(
11961196
// key signatures
11971197
for (Iterator<PGPSignature> it = copy.keySigs.iterator(); it.hasNext();)
11981198
{
1199-
PGPSignature keySig = it.next();
1199+
PGPSignature keySig = (PGPSignature)it.next();
12001200
boolean found = false;
12011201
for (int i = 0; i < keySigs.size(); i++)
12021202
{
1203-
PGPSignature existingKeySig = keySigs.get(i);
1203+
PGPSignature existingKeySig = (PGPSignature)keySigs.get(i);
12041204
if (PGPSignature.isSignatureEncodingEqual(existingKeySig, keySig))
12051205
{
12061206
found = true;
@@ -1221,14 +1221,14 @@ public static PGPPublicKey join(
12211221
// user-ids and id sigs
12221222
for (int idIdx = 0; idIdx < copy.ids.size(); idIdx++)
12231223
{
1224-
UserDataPacket copyId = copy.ids.get(idIdx);
1225-
List<PGPSignature> copyIdSigs = new ArrayList<PGPSignature>(copy.idSigs.get(idIdx));
1226-
TrustPacket copyTrust = copy.idTrusts.get(idIdx);
1224+
UserDataPacket copyId = (UserDataPacket)copy.ids.get(idIdx);
1225+
List<PGPSignature> copyIdSigs = new ArrayList<PGPSignature>((List<PGPSignature>)copy.idSigs.get(idIdx));
1226+
TrustPacket copyTrust = (TrustPacket)copy.idTrusts.get(idIdx);
12271227

12281228
int existingIdIndex = -1;
12291229
for (int i = 0; i < ids.size(); i++)
12301230
{
1231-
UserDataPacket existingId = ids.get(i);
1231+
UserDataPacket existingId = (UserDataPacket)ids.get(i);
12321232
if (existingId.equals(copyId))
12331233
{
12341234
existingIdIndex = i;
@@ -1255,22 +1255,22 @@ public static PGPPublicKey join(
12551255
// existing user-id
12561256
if (joinTrustPackets && copyTrust != null)
12571257
{
1258-
TrustPacket existingTrust = idTrusts.get(existingIdIndex);
1258+
TrustPacket existingTrust = (TrustPacket)idTrusts.get(existingIdIndex);
12591259
if (existingTrust == null || Arrays.areEqual(copyTrust.getLevelAndTrustAmount(), existingTrust.getLevelAndTrustAmount()))
12601260
{
12611261
idTrusts.remove(existingIdIndex);
12621262
idTrusts.add(existingIdIndex, copyTrust);
12631263
}
12641264
}
12651265

1266-
List<PGPSignature> existingIdSigs = idSigs.get(existingIdIndex);
1266+
List<PGPSignature> existingIdSigs = (List<PGPSignature>)idSigs.get(existingIdIndex);
12671267
for (Iterator<PGPSignature> it = copyIdSigs.iterator(); it.hasNext();)
12681268
{
1269-
PGPSignature newSig = it.next();
1269+
PGPSignature newSig = (PGPSignature)it.next();
12701270
boolean found = false;
12711271
for (int i = 0; i < existingIdSigs.size(); i++)
12721272
{
1273-
PGPSignature existingSig = existingIdSigs.get(i);
1273+
PGPSignature existingSig = (PGPSignature)existingIdSigs.get(i);
12741274
if (PGPSignature.isSignatureEncodingEqual(newSig, existingSig))
12751275
{
12761276
found = true;
@@ -1299,11 +1299,11 @@ public static PGPPublicKey join(
12991299
{
13001300
for (Iterator<PGPSignature> it = copy.subSigs.iterator(); it.hasNext();)
13011301
{
1302-
PGPSignature copySubSig = it.next();
1302+
PGPSignature copySubSig = (PGPSignature)it.next();
13031303
boolean found = false;
13041304
for (int i = 0; subSigs != null && i < subSigs.size(); i++)
13051305
{
1306-
PGPSignature existingSubSig = subSigs.get(i);
1306+
PGPSignature existingSubSig = (PGPSignature)subSigs.get(i);
13071307
if (PGPSignature.isSignatureEncodingEqual(existingSubSig, copySubSig))
13081308
{
13091309
found = true;

pg/src/main/java/org/bouncycastle/openpgp/PGPPublicKeyRing.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ private static List<PGPPublicKey> checkKeys(List<PGPPublicKey> keys)
5353

5454
for (int i = 0; i != keys.size(); i++)
5555
{
56-
PGPPublicKey k = keys.get(i);
56+
PGPPublicKey k = (PGPPublicKey)keys.get(i);
5757

5858
if (i == 0)
5959
{
@@ -149,7 +149,7 @@ public PGPPublicKeyRing(
149149
*/
150150
public PGPPublicKey getPublicKey()
151151
{
152-
return keys.get(0);
152+
return (PGPPublicKey)keys.get(0);
153153
}
154154

155155
/**
@@ -164,7 +164,7 @@ public PGPPublicKey getPublicKey(
164164
{
165165
for (int i = 0; i != keys.size(); i++)
166166
{
167-
PGPPublicKey k = keys.get(i);
167+
PGPPublicKey k = (PGPPublicKey)keys.get(i);
168168

169169
if (keyID == k.getKeyID())
170170
{
@@ -186,7 +186,7 @@ public PGPPublicKey getPublicKey(byte[] fingerprint)
186186
{
187187
for (int i = 0; i != keys.size(); i++)
188188
{
189-
PGPPublicKey k = keys.get(i);
189+
PGPPublicKey k = (PGPPublicKey)keys.get(i);
190190

191191
if (Arrays.areEqual(fingerprint, k.getFingerprint()))
192192
{
@@ -209,7 +209,7 @@ public Iterator<PGPPublicKey> getKeysWithSignaturesBy(long keyID)
209209

210210
for (int i = 0; i != keys.size(); i++)
211211
{
212-
PGPPublicKey k = keys.get(i);
212+
PGPPublicKey k = (PGPPublicKey)keys.get(i);
213213

214214
Iterator<PGPSignature> sigIt = k.getSignaturesForKeyID(keyID);
215215

@@ -288,7 +288,7 @@ public void encode(
288288
{
289289
for (int i = 0; i != keys.size(); i++)
290290
{
291-
PGPPublicKey k = keys.get(i);
291+
PGPPublicKey k = (PGPPublicKey)keys.get(i);
292292

293293
k.encode(outStream, forTransfer);
294294
}
@@ -312,7 +312,7 @@ public static PGPPublicKeyRing insertPublicKey(
312312

313313
for (int i = 0; i != keys.size(); i++)
314314
{
315-
PGPPublicKey key = keys.get(i);
315+
PGPPublicKey key = (PGPPublicKey)keys.get(i);
316316

317317
if (key.getKeyID() == pubKey.getKeyID())
318318
{
@@ -365,7 +365,7 @@ public static PGPPublicKeyRing removePublicKey(
365365

366366
for (int i = 0; i < count; ++i)
367367
{
368-
PGPPublicKey key = pubRing.keys.get(i);
368+
PGPPublicKey key = (PGPPublicKey)pubRing.keys.get(i);
369369

370370
if (key.getKeyID() == keyID)
371371
{
@@ -460,14 +460,14 @@ public static PGPPublicKeyRing join(
460460
Set<Long> secondKeys = new HashSet<Long>();
461461
for (Iterator<PGPPublicKey> it = second.iterator(); it.hasNext(); )
462462
{
463-
PGPPublicKey key = it.next();
463+
PGPPublicKey key = (PGPPublicKey)it.next();
464464
secondKeys.add(Longs.valueOf(key.getKeyID()));
465465
}
466466

467467
List<PGPPublicKey> merged = new ArrayList<PGPPublicKey>();
468468
for (Iterator<PGPPublicKey> it = first.iterator(); it.hasNext(); )
469469
{
470-
PGPPublicKey key = it.next();
470+
PGPPublicKey key = (PGPPublicKey)it.next();
471471
PGPPublicKey copy = second.getPublicKey(key.getKeyID());
472472
if (copy != null)
473473
{
@@ -482,8 +482,8 @@ public static PGPPublicKeyRing join(
482482

483483
for (Iterator<Long> it = secondKeys.iterator(); it.hasNext(); )
484484
{
485-
long additionalKeyId = it.next();
486-
merged.add(second.getPublicKey(additionalKeyId));
485+
Long additionalKeyId = (Long)it.next();
486+
merged.add(second.getPublicKey(additionalKeyId.longValue()));
487487
}
488488

489489
return new PGPPublicKeyRing(merged);

0 commit comments

Comments
 (0)