diff options
| author | Andrew John Hughes <gnu_andrew@member.fsf.org> | 2014-10-13 20:00:13 +0100 |
|---|---|---|
| committer | Andrew John Hughes <gnu_andrew@member.fsf.org> | 2014-10-13 20:00:13 +0100 |
| commit | 82c3cd04a94740401ccfce52e67dcc2ed588e40d (patch) | |
| tree | 5f0472b7d1f3e2e9f0a03b6b03e19ee84703c351 /gnu/java/security/x509 | |
| parent | 89e04db227083da5489c41ebfd003b140283d4d8 (diff) | |
| download | classpath-82c3cd04a94740401ccfce52e67dcc2ed588e40d.tar.gz | |
Fix majority of warnings in gnu.java.security.* and java.security.*.
Also fixes PR58688 as a consequence.
2014-10-09 Andrew John Hughes <gnu_andrew@member.fsf.org>
* NEWS: Updated.
* gnu/java/security/util/IntegerUtil.java: Removed.
Methods are available in java.lang.Integer.
* gnu/java/security/Engine.java:
Add missing type parameters to Class, Constructor and
Enumeration.
* gnu/java/security/OID.java:
Add type parameter to Comparable implementation.
(compareTo(OID)): Changed from compareTo(Object).
Remove now redundant cast.
* gnu/java/security/Properties.java:
Add type parameters to HashMap.
(getProperty(String)): Remove redundant cast.
(init()): Use generic implementation of PrivilegedAction.
Add properties in a for-each loop to get correct types.
* gnu/java/security/action/SetAccessibleAction.java:
Use generic implementation of PrivilegedAction.
* gnu/java/security/ber/BEREncodingException.java:
Add explicit serialVersionUID.
* gnu/java/security/der/BitString.java:
Add type parameter to Comparable implementation.
(compareTo(BitString)): Changed from compareTo(Object).
Remove now redundant cast.
* gnu/java/security/der/DEREncodingException.java:
Add explicit serialVersionUID.
* gnu/java/security/der/DERWriter.java:
(write(OutputStream,DERValue)): Cast List and Set
to correct generic versions.
(writeSequence(OutputStream,List)): Add type parameters.
Drop now redundant cast.
(writeSet(OutputStream,Set)): Likewise.
* gnu/java/security/hash/HashFactory.java:
(getNames()): Add type parameters.
* gnu/java/security/hash/Whirlpool.java:
Drop unused byte array.
* gnu/java/security/jce/prng/HavalRandomSpi.java:
Add explicit serialVersionUID.
* gnu/java/security/jce/prng/MD2RandomSpi.java: Likewise.
* gnu/java/security/jce/prng/MD4RandomSpi.java: Likewise.
* gnu/java/security/jce/prng/MD5RandomSpi.java: Likewise.
* gnu/java/security/jce/prng/RipeMD128RandomSpi.java: Likewise.
* gnu/java/security/jce/prng/RipeMD160RandomSpi.java: Likewise.
* gnu/java/security/jce/prng/SecureRandomAdapter.java:
Likewise. Drop unused mdName variable. Remove redundant casts.
Add Override annotation to interface implementation.
* gnu/java/security/jce/prng/Sha160RandomSpi.java:
Add explicit serialVersionUID.
* gnu/java/security/jce/prng/Sha256RandomSpi.java: Likewise.
* gnu/java/security/jce/prng/Sha384RandomSpi.java: Likewise.
* gnu/java/security/jce/prng/Sha512RandomSpi.java: Likewise.
* gnu/java/security/jce/prng/TigerRandomSpi.java: Likewise.
* gnu/java/security/jce/prng/WhirlpoolRandomSpi.java: Likewise.
* gnu/java/security/jce/sig/DSSKeyFactory.java: Add Override
annotation to interface implementation.
(engineGetKeySpec(Key,Class)): Update return type. Use
keySpec.cast to cast newly created instances to the correct type.
* gnu/java/security/jce/sig/DSSKeyPairGeneratorSpi.java:
Add missing type parameters and Override annotations.
* gnu/java/security/jce/sig/DSSParameters.java:
Add Override annotation to interface implementation.
(engineGetParameterSpec(Class)): Update return type. Use
paramSpec.cast to cast new instances to correct type.
(engineGetEncoded()): Add missing type parameter to list.
* gnu/java/security/jce/sig/EncodedKeyFactory.java:
Add type parameters and Override annotations.
(engineGetKeySpec(Key,Class)): Update return type. Use
keySpec.cast to cast new instances to correct type.
* gnu/java/security/jce/sig/RSAKeyFactory.java:
Add @Override annotation. Drop unused variables.
(engineGetKeySpec(Key,Class)): Update return type. Use
keySpec.cast to cast new instances to correct type.
* gnu/java/security/jce/sig/RSAKeyPairGeneratorSpi.java:
Add type parameters.
* gnu/java/security/jce/sig/SignatureAdapter.java:
Add type parameters and Override annotation.
* gnu/java/security/key/IKeyPairGenerator.java:
(setup(Map)): Add type parameters.
* gnu/java/security/key/KeyPairCodecFactory.java:
Add type parameters.
* gnu/java/security/key/KeyPairGeneratorFactory.java: Likewise.
* gnu/java/security/key/dss/DSSKey.java:
Add explicit serialVersionUID.
* gnu/java/security/key/dss/DSSKeyPairGenerator.java:
Add type parameters and Override annotations.
* gnu/java/security/key/dss/DSSKeyPairPKCS8Codec.java:
Likewise.
* gnu/java/security/key/dss/DSSKeyPairX509Codec.java:
Add type parameters.
* gnu/java/security/key/dss/DSSPrivateKey.java:
Add explicit serialVersionUID.
* gnu/java/security/key/dss/DSSPublicKey.java: Likewise.
* gnu/java/security/key/rsa/GnuRSAKey.java: Likewise.
* gnu/java/security/key/rsa/GnuRSAPrivateKey.java: Likewise.
* gnu/java/security/key/rsa/GnuRSAPublicKey.java: Likewise.
* gnu/java/security/key/rsa/RSAKeyPairGenerator.java:
Add Override annotations and type parameters.
* gnu/java/security/key/rsa/RSAKeyPairPKCS8Codec.java:
Add missing type parameters on ArrayList instances.
* gnu/java/security/key/rsa/RSAKeyPairX509Codec.java:
Add Override annotations and type parameters.
* gnu/java/security/pkcs/PKCS7SignedData.java:
(PKCS7SignedData(BERReader)): Add a type parameter to
the algId list and ensure all additions are homogenous.
Add other missing type parameters.
(PKCS7SignedData(Set,PKCS7Data,Certificate[],X509CRL[],Set)):
Add missing type parameters.
(getDigestAlgorithms()): Do a deep copy of the set.
(getSignerInfos()): Add type parameters.
(encode(OutputStream)): Likewise.
* gnu/java/security/pkcs/SignerInfo.java:
Drop unused variable, count. Add type parameters.
(encode(OutputStream)): Include derAuthenticatedAttributes
and derUnauthenticatedAttributes in signerInfo.
* gnu/java/security/prng/BasePRNG.java:
Add type parameters and Override annotations.
* gnu/java/security/prng/IRandom.java: Add type parameters.
* gnu/java/security/prng/LimitReachedException.java:
Add explicit serialVersionUID.
* gnu/java/security/prng/MDGenerator.java:
Add type parameters and Override annotations.
* gnu/java/security/prng/PRNGFactory.java:
Add missing type parameters.
* gnu/java/security/prng/RandomEvent.java:
Add explicit serialVersionUID.
* gnu/java/security/provider/CollectionCertStoreImpl.java:
Add Override annotation and missing type parameters.
* gnu/java/security/provider/Gnu.java:
Add explicit serialVersionUID. Parameterise implementation
of PrivilegedAction.
* gnu/java/security/provider/PKIXCertPathValidatorImpl.java:
Add missing type parameters. Remove unused qualifierInfos
variable.
* gnu/java/security/provider/X509CertificateFactory.java:
Add Override annotations and type parameters.
* gnu/java/security/sig/BaseSignature.java: Likewise.
* gnu/java/security/sig/ISignature.java: Add type parameters.
* gnu/java/security/sig/SignatureCodecFactory.java: Likewise.
* gnu/java/security/sig/SignatureFactory.java: Likewise.
* gnu/java/security/sig/dss/DSSSignature.java:
Add Override annotations and type parameters.
* gnu/java/security/sig/dss/DSSSignatureX509Codec.java: Add
type parameter to ArrayList instance.
* gnu/java/security/sig/rsa/EMSA_PKCS1_V1_5.java:
Remove unused hLen variable.
* gnu/java/security/sig/rsa/RSASignatureFactory.java:
Add type parameters.
* gnu/java/security/util/PRNG.java:
(getInstance()): Move initialisation code to shared
method, initialiseDelegate.
(nextBytes(byte[],int,int)): Call out to initialiseDelegate
to re-initialise.
(initialiseDelegate(IRandom)): New common method for
shared code.
* gnu/java/security/util/Sequence.java:
Add Override annotation and type parameters.
* gnu/java/security/util/SimpleList.java:
Add type parameters.
* gnu/java/security/x509/GnuPKIExtension.java: Likewise.
* gnu/java/security/x509/PolicyNodeImpl.java:
Add type parameters and Override annotations.
(addAllPolicyQualifiers(Collection)): Qualify reference
to addAll.
* gnu/java/security/x509/X500DistinguishedName.java:
Add type parameters.
* gnu/java/security/x509/X509CRL.java:
Remove unused variable algParams. Add type parameters
and Override annotations.
* gnu/java/security/x509/X509CRLEntry.java:
Add type parameters and Override annotations.
* gnu/java/security/x509/X509CRLSelectorImpl.java:
Likewise.
* gnu/java/security/x509/X509CertPath.java:
Add type parameters.
(pkcsEncoded): Renamed from pkcs_encoded.
(pkiEncoded): Renamed from pki_encoded.
* gnu/java/security/x509/X509CertSelectorImpl.java:
Add type parameters and Override annotations.
* gnu/java/security/x509/X509Certificate.java: Likewise.
* gnu/java/security/x509/ext/BasicConstraints.java:
Add type parameters.
* gnu/java/security/x509/ext/CertificatePolicies.java:
Likewise.
* gnu/java/security/x509/ext/PolicyMappings.java:
Likewise.
* gnu/javax/crypto/cipher/IBlockCipher.java:
Add type parameters.
* gnu/javax/crypto/jce/prng/FortunaImpl.java:
(engineSetSeed(byte[])): Add cast for singletonMap
invocation.
* gnu/javax/crypto/key/dh/DHKeyPairPKCS8Codec.java:
Add type parameters.
* gnu/javax/crypto/key/dh/DHKeyPairX509Codec.java:
Likewise.
* gnu/javax/crypto/mac/IMac.java: Likewise.
* gnu/javax/crypto/mode/BaseMode.java:
Add Override annotations and type parameters.
* gnu/javax/crypto/mode/EAX.java:
Add Override annotations, type parameters and
casts for singletonMap invocations.
* gnu/javax/crypto/prng/Fortuna.java: Likewise.
* gnu/javax/net/ssl/Session.java:
Add Override annotations and type parameters.
* gnu/javax/net/ssl/provider/AbstractHandshake.java:
Fix type parameters.
* gnu/javax/net/ssl/provider/SSLRandom.java:
Add Override annotations and type parameters.
* gnu/javax/net/ssl/provider/TLSRandom.java:
Likewise.
(hmacSHA): Renamed from hmac_sha.
(hmacMD5): Renamed from hmac_md5.
* gnu/javax/net/ssl/provider/Util.java:
(transform(Object,Class,String,Object[])): Use
a type parameter T rather than Object.
* gnu/javax/net/ssl/provider/X509KeyManagerFactory.java:
Add type parameters.
* gnu/javax/net/ssl/provider/X509TrustManagerFactory.java:
Likewise.
* gnu/javax/security/auth/callback/AWTCallbackHandler.java:
Replace calls to deprecated show() with setVisible(true).
(ACTION_NO): Remove unused variable.
(ACTION_YES): Likewise.
* gnu/javax/security/auth/callback/ConsoleCallbackHandler.java:
Add type parameters.
* gnu/javax/security/auth/callback/GnuCallbacks.java:
Add explicit serialVersionUID. Convert PrivilegedAction
implementation to parameterised version.
* gnu/javax/security/auth/login/ConfigFileParser.java:
Add type parameters.
* gnu/javax/security/auth/login/GnuConfiguration.java:
Likewise. Fix typo.
* java/security/AccessControlContext.java:
Add type parameters.
* java/security/AllPermission.java:
Add Override annotations.
(AllPermissionCollection.elements()): Add type parameter
to return type and return appropriately typed enumerations.
* java/security/BasicPermission.java:
Add type parameters and Override annotations.
* java/security/CodeSource.java: Likewise.
* java/security/DummySignature.java:
Add Override annotations.
* java/security/Identity.java:
Add type parameters.
* java/security/IntersectingDomainCombiner.java:
Likewise.
* java/security/KeyPairGenerator.java:
Add Override annotations.
* java/security/Permissions.java:
Add type parameters and Override annotations.
(elements()): Rename main_enum and sub_enum
to mainEnum and subEnum respectively.
* java/security/Policy.java: Add type parameters.
* java/security/SecureRandom.java: Add missing
type parameter. Remove unused imports.
* java/security/Security.java:
Add type parameters. Fix mis-spelling of 'query'.
* java/security/SignatureSpi.java: Add
Override annotation.
* java/security/UnresolvedPermission.java:
Add Override annotations and type parameters.
(elements()): Rename main_enum and sub_enum
to mainEnum and subEnum respectively.
* java/security/cert/CertPath.java:
Add type parameters.
* java/security/cert/CertPathValidator.java:
(getDefaultType()): Use GetSecurityPropertyAction
rather than implementing PrivilegedAction locally.
* java/security/cert/CertStore.java:
(getDefaultType()): Use GetSecurityPropertyAction
rather than implementing PrivilegedAction locally.
* java/security/cert/CollectionCertStoreParameters.java:
Add type parameters and Override annotations.
* java/security/cert/PKIXParameters.java:
Add type parameters.
* java/security/cert/X509CRLSelector.java:
Add type parameters.
(getIssuerNames()): Return a deep copy.
* java/security/cert/X509CertSelector.java:
Add type parameters.
* java/util/Properties.java:
Add type parameters.
(stringPropertyNames()): Implemented.
* javax/naming/directory/BasicAttribute.java:
Add Override annotations and missing type parameter.
* javax/security/auth/AuthPermission.java:
Add explicit serialVersionUID.
* javax/security/auth/DestroyFailedException.java:
Likewise.
* javax/security/auth/PrivateCredentialPermission.java:
Add type parameters.
(equals(Object)): Use thatPrincipals instead of
that_principals.
(implies(Permission)): Likewise.
(CredOwner): Add explicit serialVersionUID.
* javax/security/auth/RefreshFailedException.java:
Add explicit serialVersionUID.
* javax/security/auth/Subject.java:
Add type parameters and Override annotations.
* javax/security/auth/SubjectDomainCombiner.java:
Add type parameters.
* javax/security/auth/callback/ChoiceCallback.java:
Add explicit serialVersionUID.
* javax/security/auth/callback/ConfirmationCallback.java:
Likewise.
* javax/security/auth/callback/LanguageCallback.java:
Likewise.
* javax/security/auth/callback/NameCallback.java:
Likewise.
* javax/security/auth/callback/PasswordCallback.java:
Likewise.
* javax/security/auth/callback/TextInputCallback.java:
Likewise.
* javax/security/auth/callback/TextOutputCallback.java:
Likewise.
* javax/security/auth/callback/UnsupportedCallbackException.java:
Likewise.
* javax/security/auth/kerberos/DelegationPermission.java:
Re-enable explicit serialVersionUID. Add Override annotations
and type parameters.
* javax/security/auth/kerberos/KerberosPrincipal.java:
Re-enable explicit serialVersionUID.
* javax/security/auth/kerberos/KerberosTicket.java:
Suppress warning about unused asn1Encoding variable.
* javax/security/auth/kerberos/KeyImpl.java:
Re-enable explicit serialVersionUID.
* javax/security/auth/kerberos/ServicePermission.java:
Re-enable explicit serialVersionUID. Add Override annotations
and type parameters.
* javax/security/auth/login/AppConfigurationEntry.java:
Add type parameters.
* javax/security/auth/login/Configuration.java: Likewise.
* javax/security/auth/login/LoginContext.java: Likewise.
* javax/security/auth/x500/X500Principal.java: Likewise.
(fixed): Remove unused variable.
* javax/security/cert/CertificateEncodingException.java:
Add explicit serialVersionUID.
* javax/security/cert/CertificateException.java: Likewise.
* javax/security/cert/CertificateExpiredException.java:
Likewise.
* javax/security/cert/CertificateNotYetValidException.java:
Likewise.
* javax/security/cert/CertificateParsingException.java:
Likewise.
* javax/security/sasl/AuthenticationException.java:
Likewise.
* javax/security/sasl/RealmCallback.java: Likewise.
* javax/security/sasl/RealmChoiceCallback.java: Likewise.
* javax/security/sasl/Sasl.java: Add type parameters.
* tools/gnu/classpath/tools/jarsigner/SFHelper.java:
Likewise.
Signed-off-by: Andrew John Hughes <gnu_andrew@member.fsf.org>
Diffstat (limited to 'gnu/java/security/x509')
| -rw-r--r-- | gnu/java/security/x509/GnuPKIExtension.java | 4 | ||||
| -rw-r--r-- | gnu/java/security/x509/PolicyNodeImpl.java | 39 | ||||
| -rw-r--r-- | gnu/java/security/x509/X500DistinguishedName.java | 80 | ||||
| -rw-r--r-- | gnu/java/security/x509/X509CRL.java | 57 | ||||
| -rw-r--r-- | gnu/java/security/x509/X509CRLEntry.java | 37 | ||||
| -rw-r--r-- | gnu/java/security/x509/X509CRLSelectorImpl.java | 16 | ||||
| -rw-r--r-- | gnu/java/security/x509/X509CertPath.java | 46 | ||||
| -rw-r--r-- | gnu/java/security/x509/X509CertSelectorImpl.java | 28 | ||||
| -rw-r--r-- | gnu/java/security/x509/X509Certificate.java | 17 | ||||
| -rw-r--r-- | gnu/java/security/x509/ext/BasicConstraints.java | 4 | ||||
| -rw-r--r-- | gnu/java/security/x509/ext/CertificatePolicies.java | 57 | ||||
| -rw-r--r-- | gnu/java/security/x509/ext/PolicyMappings.java | 8 |
12 files changed, 221 insertions, 172 deletions
diff --git a/gnu/java/security/x509/GnuPKIExtension.java b/gnu/java/security/x509/GnuPKIExtension.java index 8e74b8b24..774a8a55e 100644 --- a/gnu/java/security/x509/GnuPKIExtension.java +++ b/gnu/java/security/x509/GnuPKIExtension.java @@ -1,5 +1,5 @@ /* GnuPKIExtension.java -- interface for GNU PKI extensions. - Copyright (C) 2004 Free Software Foundation, Inc. + Copyright (C) 2004, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -55,5 +55,5 @@ public interface GnuPKIExtension extends X509Extension */ Extension getExtension(OID oid); - Collection getExtensions(); + Collection<Extension> getExtensions(); } diff --git a/gnu/java/security/x509/PolicyNodeImpl.java b/gnu/java/security/x509/PolicyNodeImpl.java index 60d35574d..65dd472c7 100644 --- a/gnu/java/security/x509/PolicyNodeImpl.java +++ b/gnu/java/security/x509/PolicyNodeImpl.java @@ -1,5 +1,5 @@ /* PolicyNodeImpl.java -- An implementation of a policy tree node. - Copyright (C) 2004 Free Software Foundation, Inc. + Copyright (C) 2004, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -56,9 +56,9 @@ public final class PolicyNodeImpl implements PolicyNode // ------------------------------------------------------------------------- private String policy; - private final Set expectedPolicies; - private final Set qualifiers; - private final Set children; + private final Set<String> expectedPolicies; + private final Set<PolicyQualifierInfo> qualifiers; + private final Set<PolicyNode> children; private PolicyNodeImpl parent; private int depth; private boolean critical; @@ -69,9 +69,9 @@ public final class PolicyNodeImpl implements PolicyNode public PolicyNodeImpl() { - expectedPolicies = new HashSet(); - qualifiers = new HashSet(); - children = new HashSet(); + expectedPolicies = new HashSet<String>(); + qualifiers = new HashSet<PolicyQualifierInfo>(); + children = new HashSet<PolicyNode>(); readOnly = false; critical = false; } @@ -90,11 +90,13 @@ public final class PolicyNodeImpl implements PolicyNode children.add(node); } - public Iterator getChildren() + @Override + public Iterator<? extends PolicyNode> getChildren() { return Collections.unmodifiableSet(children).iterator(); } + @Override public int getDepth() { return depth; @@ -107,7 +109,7 @@ public final class PolicyNodeImpl implements PolicyNode this.depth = depth; } - public void addAllExpectedPolicies(Set policies) + public void addAllExpectedPolicies(Set<String> policies) { if (readOnly) throw new IllegalStateException("read only"); @@ -121,24 +123,26 @@ public final class PolicyNodeImpl implements PolicyNode expectedPolicies.add(policy); } - public Set getExpectedPolicies() + @Override + public Set<String> getExpectedPolicies() { return Collections.unmodifiableSet(expectedPolicies); } + @Override public PolicyNode getParent() { return parent; } - public void addAllPolicyQualifiers (Collection qualifiers) + public void addAllPolicyQualifiers (Collection<? extends PolicyQualifierInfo> qualifiers) { - for (Iterator it = qualifiers.iterator(); it.hasNext(); ) + for (Iterator<? extends PolicyQualifierInfo> it = qualifiers.iterator(); it.hasNext(); ) { if (!(it.next() instanceof PolicyQualifierInfo)) throw new IllegalArgumentException ("can only add PolicyQualifierInfos"); } - qualifiers.addAll (qualifiers); + this.qualifiers.addAll (qualifiers); } public void addPolicyQualifier (PolicyQualifierInfo qualifier) @@ -148,11 +152,13 @@ public final class PolicyNodeImpl implements PolicyNode qualifiers.add(qualifier); } - public Set getPolicyQualifiers() + @Override + public Set<? extends PolicyQualifierInfo> getPolicyQualifiers() { return Collections.unmodifiableSet(qualifiers); } + @Override public String getValidPolicy() { return policy; @@ -165,6 +171,7 @@ public final class PolicyNodeImpl implements PolicyNode this.policy = policy; } + @Override public boolean isCritical() { return critical; @@ -182,7 +189,7 @@ public final class PolicyNodeImpl implements PolicyNode if (readOnly) return; readOnly = true; - for (Iterator it = getChildren(); it.hasNext(); ) + for (Iterator<? extends PolicyNode> it = getChildren(); it.hasNext(); ) ((PolicyNodeImpl) it.next()).setReadOnly(); } @@ -205,7 +212,7 @@ public final class PolicyNodeImpl implements PolicyNode buf.append(expectedPolicies); buf.append(") (children ("); final String nl = System.getProperty("line.separator"); - for (Iterator it = getChildren(); it.hasNext(); ) + for (Iterator<? extends PolicyNode> it = getChildren(); it.hasNext(); ) { buf.append(nl); buf.append(it.next().toString()); diff --git a/gnu/java/security/x509/X500DistinguishedName.java b/gnu/java/security/x509/X500DistinguishedName.java index e2e05c57e..ab7f99aa9 100644 --- a/gnu/java/security/x509/X500DistinguishedName.java +++ b/gnu/java/security/x509/X500DistinguishedName.java @@ -1,5 +1,5 @@ /* X500DistinguishedName.java -- X.500 distinguished name. - Copyright (C) 2004, 2006 Free Software Foundation, Inc. + Copyright (C) 2004, 2006, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -83,8 +83,8 @@ public class X500DistinguishedName implements Principal public static final OID DC = new OID("0.9.2342.19200300.100.1.25"); public static final OID UID = new OID("0.9.2342.19200300.100.1.1"); - private List components; - private Map currentRdn; + private List<Map<OID,String>> components; + private Map<OID,String> currentRdn; private boolean fixed; private String stringRep; private byte[] encoded; @@ -94,8 +94,8 @@ public class X500DistinguishedName implements Principal public X500DistinguishedName() { - components = new LinkedList(); - currentRdn = new LinkedHashMap(); + components = new LinkedList<Map<OID,String>>(); + currentRdn = new LinkedHashMap<OID,String>(); components.add(currentRdn); } @@ -135,7 +135,7 @@ public class X500DistinguishedName implements Principal public void newRelativeDistinguishedName() { if (fixed || currentRdn.isEmpty()) return; - currentRdn = new LinkedHashMap(); + currentRdn = new LinkedHashMap<OID,String>(); components.add(currentRdn); } @@ -147,19 +147,19 @@ public class X500DistinguishedName implements Principal public int countComponents() { int count = 0; - for (Iterator it = components.iterator(); it.hasNext(); ) + for (Iterator<Map<OID,String>> it = components.iterator(); it.hasNext(); ) { - count += ((Map) it.next()).size(); + count += it.next().size(); } return count; } public boolean containsComponent(OID oid, String value) { - for (Iterator it = components.iterator(); it.hasNext(); ) + for (Iterator<Map<OID,String>> it = components.iterator(); it.hasNext(); ) { - Map rdn = (Map) it.next(); - String s = (String) rdn.get(oid); + Map<OID,String> rdn = it.next(); + String s = rdn.get(oid); if (s == null) continue; if (compressWS(value).equalsIgnoreCase(compressWS(s))) @@ -170,11 +170,11 @@ public class X500DistinguishedName implements Principal public String getComponent(OID oid) { - for (Iterator it = components.iterator(); it.hasNext(); ) + for (Iterator<Map<OID,String>> it = components.iterator(); it.hasNext(); ) { - Map rdn = (Map) it.next(); + Map<OID,String> rdn = it.next(); if (rdn.containsKey(oid)) - return (String) rdn.get(oid); + return rdn.get(oid); } return null; } @@ -183,7 +183,7 @@ public class X500DistinguishedName implements Principal { if (rdn >= size()) return null; - return (String) ((Map) components.get(rdn)).get(oid); + return components.get(rdn).get(oid); } public void putComponent(OID oid, String value) @@ -234,26 +234,26 @@ public class X500DistinguishedName implements Principal { if (fixed) return; fixed = true; - List newComps = new ArrayList(components.size()); - for (Iterator it = components.iterator(); it.hasNext(); ) + List<Map<OID,String>> newComps = + new ArrayList<Map<OID,String>>(components.size()); + for (Iterator<Map<OID,String>> it = components.iterator(); it.hasNext(); ) { - Map rdn = (Map) it.next(); + Map<OID,String> rdn = it.next(); rdn = Collections.unmodifiableMap(rdn); newComps.add(rdn); } components = Collections.unmodifiableList(newComps); - currentRdn = Collections.EMPTY_MAP; + currentRdn = Collections.emptyMap(); } public int hashCode() { int sum = 0; - for (Iterator it = components.iterator(); it.hasNext(); ) + for (Iterator<Map<OID,String>> it = components.iterator(); it.hasNext(); ) { - Map m = (Map) it.next(); - for (Iterator it2 = m.entrySet().iterator(); it2.hasNext(); ) + Map<OID,String> m = it.next(); + for (Map.Entry<OID,String> e : m.entrySet()) { - Map.Entry e = (Map.Entry) it2.next(); sum += e.getKey().hashCode(); sum += e.getValue().hashCode(); } @@ -269,12 +269,11 @@ public class X500DistinguishedName implements Principal return false; for (int i = 0; i < size(); i++) { - Map m = (Map) components.get(i); - for (Iterator it2 = m.entrySet().iterator(); it2.hasNext(); ) + Map<OID,String> m = components.get(i); + for (Map.Entry<OID,String> e : m.entrySet()) { - Map.Entry e = (Map.Entry) it2.next(); - OID oid = (OID) e.getKey(); - String v1 = (String) e.getValue(); + OID oid = e.getKey(); + String v1 = e.getValue(); String v2 = ((X500DistinguishedName) o).getComponent(oid, i); if (!compressWS(v1).equalsIgnoreCase(compressWS(v2))) return false; @@ -288,14 +287,15 @@ public class X500DistinguishedName implements Principal if (fixed && stringRep != null) return stringRep; CPStringBuilder str = new CPStringBuilder(); - for (Iterator it = components.iterator(); it.hasNext(); ) + for (Iterator<Map<OID,String>> it = components.iterator(); it.hasNext(); ) { - Map m = (Map) it.next(); - for (Iterator it2 = m.entrySet().iterator(); it2.hasNext(); ) + Map<OID,String> m = it.next(); + for (Iterator<Map.Entry<OID,String>> it2 = m.entrySet().iterator(); + it2.hasNext(); ) { - Map.Entry entry = (Map.Entry) it2.next(); - OID oid = (OID) entry.getKey(); - String value = (String) entry.getValue(); + Map.Entry<OID,String> entry = it2.next(); + OID oid = entry.getKey(); + String value = entry.getValue(); if (oid.equals(CN)) str.append("CN"); else if (oid.equals(C)) @@ -334,18 +334,16 @@ public class X500DistinguishedName implements Principal if (fixed && encoded != null) return (byte[]) encoded.clone(); - ArrayList name = new ArrayList(components.size()); - for (Iterator it = components.iterator(); it.hasNext(); ) + ArrayList<DERValue> name = new ArrayList<DERValue>(components.size()); + for (Map<OID,String> m : components) { - Map m = (Map) it.next(); if (m.isEmpty()) continue; - Set rdn = new HashSet(); - for (Iterator it2 = m.entrySet().iterator(); it2.hasNext(); ) + Set<DERValue> rdn = new HashSet<DERValue>(); + for (Map.Entry<OID,String> e : m.entrySet()) { - Map.Entry e = (Map.Entry) it2.next(); - ArrayList atav = new ArrayList(2); + ArrayList<DERValue> atav = new ArrayList<DERValue>(2); atav.add(new DERValue(DER.OBJECT_IDENTIFIER, e.getKey())); atav.add(new DERValue(DER.UTF8_STRING, e.getValue())); rdn.add(new DERValue(DER.SEQUENCE|DER.CONSTRUCTED, atav)); diff --git a/gnu/java/security/x509/X509CRL.java b/gnu/java/security/x509/X509CRL.java index 518edaa24..9e1ed0f5c 100644 --- a/gnu/java/security/x509/X509CRL.java +++ b/gnu/java/security/x509/X509CRL.java @@ -1,5 +1,5 @@ /* X509CRL.java -- X.509 certificate revocation list. - Copyright (C) 2003, 2004, 2010 Free Software Foundation, Inc. + Copyright (C) 2003, 2004, 2010, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -63,7 +63,6 @@ import java.util.Collections; import java.util.Date; import java.util.HashMap; import java.util.HashSet; -import java.util.Iterator; import java.util.Set; import java.util.logging.Logger; @@ -92,12 +91,11 @@ public class X509CRL extends java.security.cert.X509CRL private byte[] tbsCRLBytes; private int version; private OID algId; - private byte[] algParams; private Date thisUpdate; private Date nextUpdate; private X500DistinguishedName issuerDN; - private HashMap revokedCerts; - private HashMap extensions; + private HashMap<BigInteger,X509CRLEntry> revokedCerts; + private HashMap<OID,Extension> extensions; private OID sigAlg; private byte[] sigAlgParams; @@ -117,8 +115,8 @@ public class X509CRL extends java.security.cert.X509CRL public X509CRL(InputStream encoded) throws CRLException, IOException { super(); - revokedCerts = new HashMap(); - extensions = new HashMap(); + revokedCerts = new HashMap<BigInteger,X509CRLEntry>(); + extensions = new HashMap<OID,Extension>(); try { parse(encoded); @@ -150,11 +148,13 @@ public class X509CRL extends java.security.cert.X509CRL return revokedCerts.hashCode(); } + @Override public byte[] getEncoded() throws CRLException { return (byte[]) encoded.clone(); } + @Override public void verify(PublicKey key) throws CRLException, NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException, SignatureException @@ -163,6 +163,7 @@ public class X509CRL extends java.security.cert.X509CRL doVerify(sig, key); } + @Override public void verify(PublicKey key, String provider) throws CRLException, NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException, SignatureException @@ -171,11 +172,13 @@ public class X509CRL extends java.security.cert.X509CRL doVerify(sig, key); } + @Override public int getVersion() { return version; } + @Override public Principal getIssuerDN() { return issuerDN; @@ -186,11 +189,13 @@ public class X509CRL extends java.security.cert.X509CRL return new X500Principal(issuerDN.getDer()); } + @Override public Date getThisUpdate() { return (Date) thisUpdate.clone(); } + @Override public Date getNextUpdate() { if (nextUpdate != null) @@ -198,26 +203,31 @@ public class X509CRL extends java.security.cert.X509CRL return null; } + @Override public java.security.cert.X509CRLEntry getRevokedCertificate(BigInteger serialNo) { - return (java.security.cert.X509CRLEntry) revokedCerts.get(serialNo); + return revokedCerts.get(serialNo); } - public Set getRevokedCertificates() + @Override + public Set<? extends X509CRLEntry> getRevokedCertificates() { - return Collections.unmodifiableSet(new HashSet(revokedCerts.values())); + return Collections.unmodifiableSet(new HashSet<X509CRLEntry>(revokedCerts.values())); } + @Override public byte[] getTBSCertList() throws CRLException { return (byte[]) tbsCRLBytes.clone(); } + @Override public byte[] getSignature() { return (byte[]) rawSig.clone(); } + @Override public String getSigAlgName() { if (sigAlg.equals(ID_DSA_WITH_SHA1)) @@ -231,11 +241,13 @@ public class X509CRL extends java.security.cert.X509CRL return "unknown"; } + @Override public String getSigAlgOID() { return sigAlg.toString(); } + @Override public byte[] getSigAlgParams() { if (sigAlgParams != null) @@ -248,33 +260,30 @@ public class X509CRL extends java.security.cert.X509CRL public boolean hasUnsupportedCriticalExtension() { - for (Iterator it = extensions.values().iterator(); it.hasNext(); ) + for (Extension e : extensions.values()) { - Extension e = (Extension) it.next(); if (e.isCritical() && !e.isSupported()) return true; } return false; } - public Set getCriticalExtensionOIDs() + public Set<String> getCriticalExtensionOIDs() { - HashSet s = new HashSet(); - for (Iterator it = extensions.values().iterator(); it.hasNext(); ) + HashSet<String> s = new HashSet<String>(); + for (Extension e : extensions.values()) { - Extension e = (Extension) it.next(); if (e.isCritical()) s.add(e.getOid().toString()); } return Collections.unmodifiableSet(s); } - public Set getNonCriticalExtensionOIDs() + public Set<String> getNonCriticalExtensionOIDs() { - HashSet s = new HashSet(); - for (Iterator it = extensions.values().iterator(); it.hasNext(); ) + HashSet<String> s = new HashSet<String>(); + for (Extension e : extensions.values()) { - Extension e = (Extension) it.next(); if (!e.isCritical()) s.add(e.getOid().toString()); } @@ -294,12 +303,14 @@ public class X509CRL extends java.security.cert.X509CRL // GnuPKIExtension method. // ------------------------------------------------------------------------- + @Override public Extension getExtension(OID oid) { - return (Extension) extensions.get(oid); + return extensions.get(oid); } - public Collection getExtensions() + @Override + public Collection<Extension> getExtensions() { return extensions.values(); } @@ -307,6 +318,7 @@ public class X509CRL extends java.security.cert.X509CRL // CRL methods. // ------------------------------------------------------------------------- + @Override public String toString() { return X509CRL.class.getName(); @@ -382,7 +394,6 @@ public class X509CRL extends java.security.cert.X509CRL val = der.read(); if (Configuration.DEBUG) log.fine("read parameters len == " + val.getEncodedLength()); - algParams = val.getEncoded(); if (val.isConstructed()) in.skip(val.getLength()); } diff --git a/gnu/java/security/x509/X509CRLEntry.java b/gnu/java/security/x509/X509CRLEntry.java index 64adf7f69..b54f8eae6 100644 --- a/gnu/java/security/x509/X509CRLEntry.java +++ b/gnu/java/security/x509/X509CRLEntry.java @@ -1,5 +1,5 @@ /* X509CRLEntry.java -- an entry in a X.509 CRL. - Copyright (C) 2003, 2004, 2010 Free Software Foundation, Inc. + Copyright (C) 2003, 2004, 2010, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -52,7 +52,6 @@ import java.util.Collections; import java.util.Date; import java.util.HashMap; import java.util.HashSet; -import java.util.Iterator; import java.util.Set; import java.util.logging.Logger; @@ -78,7 +77,7 @@ class X509CRLEntry extends java.security.cert.X509CRLEntry private Date revocationDate; /** The CRL entry extensions. */ - private HashMap extensions; + private HashMap<OID,Extension> extensions; // Constructor. // ------------------------------------------------------------------------ @@ -96,7 +95,7 @@ class X509CRLEntry extends java.security.cert.X509CRLEntry throws CRLException, IOException { super(); - extensions = new HashMap(); + extensions = new HashMap<OID,Extension>(); try { parse(version, encoded); @@ -114,6 +113,7 @@ class X509CRLEntry extends java.security.cert.X509CRLEntry // X509CRLEntry methods. // ------------------------------------------------------------------------ + @Override public boolean equals(Object o) { if (!(o instanceof X509CRLEntry)) @@ -122,31 +122,37 @@ class X509CRLEntry extends java.security.cert.X509CRLEntry ((X509CRLEntry) o).getRevocationDate().equals(revocationDate); } + @Override public int hashCode() { return serialNo.hashCode(); } + @Override public byte[] getEncoded() throws CRLException { return (byte[]) encoded.clone(); } + @Override public BigInteger getSerialNumber() { return serialNo; } + @Override public Date getRevocationDate() { return (Date) revocationDate.clone(); } + @Override public boolean hasExtensions() { return ! extensions.isEmpty(); } + @Override public String toString() { return "X509CRLEntry serial=" + serialNo + " revocation date=" @@ -158,33 +164,30 @@ class X509CRLEntry extends java.security.cert.X509CRLEntry public boolean hasUnsupportedCriticalExtension() { - for (Iterator it = extensions.values().iterator(); it.hasNext(); ) + for (Extension e : extensions.values()) { - Extension e = (Extension) it.next(); if (e.isCritical() && !e.isSupported()) return true; } return false; } - public Set getCriticalExtensionOIDs() + public Set<String> getCriticalExtensionOIDs() { - HashSet s = new HashSet(); - for (Iterator it = extensions.values().iterator(); it.hasNext(); ) + HashSet<String> s = new HashSet<String>(); + for (Extension e : extensions.values()) { - Extension e = (Extension) it.next(); if (e.isCritical()) s.add(e.getOid().toString()); } return Collections.unmodifiableSet(s); } - public Set getNonCriticalExtensionOIDs() + public Set<String> getNonCriticalExtensionOIDs() { - HashSet s = new HashSet(); - for (Iterator it = extensions.values().iterator(); it.hasNext(); ) + HashSet<String> s = new HashSet<String>(); + for (Extension e : extensions.values()) { - Extension e = (Extension) it.next(); if (!e.isCritical()) s.add(e.getOid().toString()); } @@ -204,12 +207,14 @@ class X509CRLEntry extends java.security.cert.X509CRLEntry // GnuPKIExtension method. // ------------------------------------------------------------------------- + @Override public Extension getExtension(OID oid) { - return (Extension) extensions.get(oid); + return extensions.get(oid); } - public Collection getExtensions() + @Override + public Collection<Extension> getExtensions() { return extensions.values(); } diff --git a/gnu/java/security/x509/X509CRLSelectorImpl.java b/gnu/java/security/x509/X509CRLSelectorImpl.java index 582d18583..c8f25d58d 100644 --- a/gnu/java/security/x509/X509CRLSelectorImpl.java +++ b/gnu/java/security/x509/X509CRLSelectorImpl.java @@ -1,5 +1,5 @@ /* X509CRLSelectorImpl.java -- implementation of an X509CRLSelector. - Copyright (C) 2004 Free Software Foundation, Inc. + Copyright (C) 2004, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -48,7 +48,6 @@ import java.security.cert.X509CRL; import java.util.Collection; import java.util.Collections; import java.util.HashSet; -import java.util.Iterator; import java.util.Set; import javax.security.auth.x500.X500Principal; @@ -63,14 +62,14 @@ public class X509CRLSelectorImpl implements CRLSelector // Fields. // ------------------------------------------------------------------------- - private Set issuerNames; + private Set<X500DistinguishedName> issuerNames; // Constructor. // ------------------------------------------------------------------------- public X509CRLSelectorImpl() { - issuerNames = new HashSet(); + issuerNames = new HashSet<X500DistinguishedName>(); } // Instance methods. @@ -89,18 +88,19 @@ public class X509CRLSelectorImpl implements CRLSelector public void addIssuerName(Principal issuerName) throws IOException { if (issuerName instanceof X500DistinguishedName) - issuerNames.add(issuerName); + issuerNames.add((X500DistinguishedName) issuerName); else if (issuerName instanceof X500Principal) issuerNames.add(new X500DistinguishedName(((X500Principal) issuerName).getEncoded())); else issuerNames.add(new X500DistinguishedName(issuerName.getName())); } - public Collection getIssuerNames() + public Collection<X500DistinguishedName> getIssuerNames() { return Collections.unmodifiableSet(issuerNames); } + @Override public Object clone() { X509CRLSelectorImpl copy = new X509CRLSelectorImpl(); @@ -108,6 +108,7 @@ public class X509CRLSelectorImpl implements CRLSelector return copy; } + @Override public boolean match(CRL crl) { if (!(crl instanceof X509CRL)) @@ -122,9 +123,8 @@ public class X509CRLSelectorImpl implements CRLSelector thisName = new X500DistinguishedName(((X500Principal) p).getEncoded()); else thisName = new X500DistinguishedName(p.getName()); - for (Iterator it = issuerNames.iterator(); it.hasNext(); ) + for (X500DistinguishedName name : issuerNames) { - X500DistinguishedName name = (X500DistinguishedName) it.next(); if (thisName.equals(name)) return true; } diff --git a/gnu/java/security/x509/X509CertPath.java b/gnu/java/security/x509/X509CertPath.java index e8ed6bf35..d2e12d269 100644 --- a/gnu/java/security/x509/X509CertPath.java +++ b/gnu/java/security/x509/X509CertPath.java @@ -1,5 +1,5 @@ /* X509CertPath.java -- an X.509 certificate path. - Copyright (C) 2004 Free Software Fonudation, Inc. + Copyright (C) 2004, 2014 Free Software Fonudation, Inc. This file is part of GNU Classpath. @@ -71,25 +71,25 @@ public class X509CertPath extends CertPath // Fields. // ------------------------------------------------------------------------- - public static final List ENCODINGS = Collections.unmodifiableList( + public static final List<String> ENCODINGS = Collections.unmodifiableList( Arrays.asList(new String[] { "PkiPath", "PKCS7" })); private static final OID PKCS7_SIGNED_DATA = new OID("1.2.840.113549.1.7.2"); private static final OID PKCS7_DATA = new OID("1.2.840.113549.1.7.1"); /** The certificate path. */ - private List path; + private List<Certificate> path; /** The cached PKCS #7 encoded bytes. */ - private byte[] pkcs_encoded; + private byte[] pkcsEncoded; /** The cached PkiPath encoded bytes. */ - private byte[] pki_encoded; + private byte[] pkiEncoded; // Constructor. // ------------------------------------------------------------------------- - public X509CertPath(List path) + public X509CertPath(List<? extends Certificate> path) { super("X.509"); this.path = Collections.unmodifiableList(path); @@ -97,7 +97,7 @@ public class X509CertPath extends CertPath public X509CertPath(InputStream in) throws CertificateEncodingException { - this(in, (String) ENCODINGS.get(0)); + this(in, ENCODINGS.get(0)); } public X509CertPath(InputStream in, String encoding) @@ -117,53 +117,53 @@ public class X509CertPath extends CertPath // Instance methods. // ------------------------------------------------------------------------- - public List getCertificates() + public List<Certificate> getCertificates() { return path; // already unmodifiable } public byte[] getEncoded() throws CertificateEncodingException { - return getEncoded((String) ENCODINGS.get(0)); + return getEncoded(ENCODINGS.get(0)); } public byte[] getEncoded(String encoding) throws CertificateEncodingException { if (encoding.equalsIgnoreCase("PkiPath")) { - if (pki_encoded == null) + if (pkiEncoded == null) { try { - pki_encoded = encodePki(); + pkiEncoded = encodePki(); } catch (IOException ioe) { throw new CertificateEncodingException(); } } - return (byte[]) pki_encoded.clone(); + return (byte[]) pkiEncoded.clone(); } else if (encoding.equalsIgnoreCase("PKCS7")) { - if (pkcs_encoded == null) + if (pkcsEncoded == null) { try { - pkcs_encoded = encodePKCS(); + pkcsEncoded = encodePKCS(); } catch (IOException ioe) { throw new CertificateEncodingException(); } } - return (byte[]) pkcs_encoded.clone(); + return (byte[]) pkcsEncoded.clone(); } else throw new CertificateEncodingException("unknown encoding: " + encoding); } - public Iterator getEncodings() + public Iterator<String> getEncodings() { return ENCODINGS.iterator(); // already unmodifiable } @@ -233,7 +233,7 @@ public class X509CertPath extends CertPath else throw new CertificateEncodingException("unknown encoding: " + encoding); - LinkedList certs = new LinkedList(); + LinkedList<Certificate> certs = new LinkedList<Certificate>(); int len = 0; while (len < path.getLength()) { @@ -259,9 +259,9 @@ public class X509CertPath extends CertPath synchronized (path) { ByteArrayOutputStream out = new ByteArrayOutputStream(); - for (Iterator i = path.iterator(); i.hasNext(); ) + for (Iterator<Certificate> i = path.iterator(); i.hasNext(); ) { - out.write(((Certificate) i.next()).getEncoded()); + out.write(i.next().getEncoded()); } byte[] b = out.toByteArray(); DERValue val = new DERValue(DER.CONSTRUCTED | DER.SEQUENCE, @@ -275,7 +275,7 @@ public class X509CertPath extends CertPath { synchronized (path) { - ArrayList signedData = new ArrayList(5); + ArrayList<DERValue> signedData = new ArrayList<DERValue>(5); signedData.add(new DERValue(DER.INTEGER, BigInteger.ONE)); signedData.add(new DERValue(DER.CONSTRUCTED | DER.SET, Collections.EMPTY_SET)); @@ -283,9 +283,9 @@ public class X509CertPath extends CertPath Collections.singletonList( new DERValue(DER.OBJECT_IDENTIFIER, PKCS7_DATA)))); ByteArrayOutputStream out = new ByteArrayOutputStream(); - for (Iterator i = path.iterator(); i.hasNext(); ) + for (Iterator<Certificate> i = path.iterator(); i.hasNext(); ) { - out.write(((Certificate) i.next()).getEncoded()); + out.write(i.next().getEncoded()); } byte[] b = out.toByteArray(); signedData.add(new DERValue(DER.CONSTRUCTED | DER.CONTEXT, @@ -293,7 +293,7 @@ public class X509CertPath extends CertPath DERValue sdValue = new DERValue(DER.CONSTRUCTED | DER.SEQUENCE, signedData); - ArrayList contentInfo = new ArrayList(2); + ArrayList<DERValue> contentInfo = new ArrayList<DERValue>(2); contentInfo.add(new DERValue(DER.OBJECT_IDENTIFIER, PKCS7_SIGNED_DATA)); contentInfo.add(new DERValue(DER.CONSTRUCTED | DER.CONTEXT, sdValue)); return new DERValue(DER.CONSTRUCTED | DER.SEQUENCE, diff --git a/gnu/java/security/x509/X509CertSelectorImpl.java b/gnu/java/security/x509/X509CertSelectorImpl.java index 5201a76b9..e7c7ff81b 100644 --- a/gnu/java/security/x509/X509CertSelectorImpl.java +++ b/gnu/java/security/x509/X509CertSelectorImpl.java @@ -1,5 +1,5 @@ /* X509CertSelectorImpl.java -- implementation of an X509CertSelector. - Copyright (C) 2004 Free Software Foundation, Inc. + Copyright (C) 2004, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -61,16 +61,16 @@ public class X509CertSelectorImpl implements CertSelector // Fields. // ------------------------------------------------------------------------- - private Set issuerNames; - private Set subjectNames; + private Set<X500DistinguishedName> issuerNames; + private Set<X500DistinguishedName> subjectNames; // Constructor. // ------------------------------------------------------------------------- public X509CertSelectorImpl() { - issuerNames = new HashSet(); - subjectNames = new HashSet(); + issuerNames = new HashSet<X500DistinguishedName>(); + subjectNames = new HashSet<X500DistinguishedName>(); } // Instance methods. @@ -89,14 +89,14 @@ public class X509CertSelectorImpl implements CertSelector public void addIssuerName(Principal issuerName) throws IOException { if (issuerName instanceof X500DistinguishedName) - issuerNames.add(issuerName); + issuerNames.add((X500DistinguishedName) issuerName); else if (issuerName instanceof X500Principal) issuerNames.add(new X500DistinguishedName(((X500Principal) issuerName).getEncoded())); else issuerNames.add(new X500DistinguishedName(issuerName.getName())); } - public Collection getIssuerNames() + public Collection<X500DistinguishedName> getIssuerNames() { return Collections.unmodifiableSet(issuerNames); } @@ -114,18 +114,19 @@ public class X509CertSelectorImpl implements CertSelector public void addSubjectName(Principal subjectName) throws IOException { if (subjectName instanceof X500DistinguishedName) - subjectNames.add(subjectName); + subjectNames.add((X500DistinguishedName) subjectName); else if (subjectName instanceof X500Principal) subjectNames.add(new X500DistinguishedName(((X500Principal) subjectName).getEncoded())); else subjectNames.add(new X500DistinguishedName(subjectName.getName())); } - public Collection getSubjectNames() + public Collection<X500DistinguishedName> getSubjectNames() { return Collections.unmodifiableSet(subjectNames); } + @Override public Object clone() { X509CertSelectorImpl copy = new X509CertSelectorImpl(); @@ -134,6 +135,7 @@ public class X509CertSelectorImpl implements CertSelector return copy; } + @Override public boolean match(Certificate cert) { if (!(cert instanceof X509Certificate)) @@ -154,9 +156,9 @@ public class X509CertSelectorImpl implements CertSelector matchIssuer = true; else { - for (Iterator it = issuerNames.iterator(); it.hasNext(); ) + for (Iterator<X500DistinguishedName> it = issuerNames.iterator(); it.hasNext(); ) { - X500DistinguishedName name = (X500DistinguishedName) it.next(); + X500DistinguishedName name = it.next(); if (thisName.equals(name)) { matchIssuer = true; @@ -177,9 +179,9 @@ public class X509CertSelectorImpl implements CertSelector matchSubject = true; else { - for (Iterator it = subjectNames.iterator(); it.hasNext(); ) + for (Iterator<X500DistinguishedName> it = subjectNames.iterator(); it.hasNext(); ) { - X500DistinguishedName name = (X500DistinguishedName) it.next(); + X500DistinguishedName name = it.next(); if (thisName.equals(name)) { matchSubject = true; diff --git a/gnu/java/security/x509/X509Certificate.java b/gnu/java/security/x509/X509Certificate.java index 14c565264..c7856bd0c 100644 --- a/gnu/java/security/x509/X509Certificate.java +++ b/gnu/java/security/x509/X509Certificate.java @@ -1,5 +1,5 @@ /* X509Certificate.java -- X.509 certificate. - Copyright (C) 2003, 2004, 2006 Free Software Foundation, Inc. + Copyright (C) 2003, 2004, 2006, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -84,7 +84,6 @@ import java.util.Collections; import java.util.Date; import java.util.HashMap; import java.util.HashSet; -import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; @@ -389,9 +388,8 @@ public class X509Certificate extends java.security.cert.X509Certificate public boolean hasUnsupportedCriticalExtension() { - for (Iterator it = extensions.values().iterator(); it.hasNext(); ) + for (Extension e : extensions.values()) { - Extension e = (Extension) it.next(); if (e.isCritical() && !e.isSupported()) return true; } @@ -433,12 +431,14 @@ public class X509Certificate extends java.security.cert.X509Certificate // GnuPKIExtension method. // ------------------------------------------------------------------------- + @Override public Extension getExtension(OID oid) { - return (Extension) extensions.get(oid); + return extensions.get(oid); } - public Collection getExtensions() + @Override + public Collection<Extension> getExtensions() { return extensions.values(); } @@ -502,9 +502,9 @@ public class X509Certificate extends java.security.cert.X509Certificate out.println(" issuerUniqueId = " + issuerUniqueId + ";"); out.println(" subjectUniqueId = " + subjectUniqueId + ";"); out.println(" extensions = {"); - for (Iterator it = extensions.values().iterator(); it.hasNext(); ) + for (Extension e : extensions.values()) { - out.println(" " + it.next()); + out.println(" " + e); } out.println(" }"); out.println(" }"); @@ -520,6 +520,7 @@ public class X509Certificate extends java.security.cert.X509Certificate return subjectKey; } + @Override public boolean equals(Object other) { if (!(other instanceof X509Certificate)) diff --git a/gnu/java/security/x509/ext/BasicConstraints.java b/gnu/java/security/x509/ext/BasicConstraints.java index d8f5c6158..52d9f39cd 100644 --- a/gnu/java/security/x509/ext/BasicConstraints.java +++ b/gnu/java/security/x509/ext/BasicConstraints.java @@ -1,5 +1,5 @@ /* BasicConstraints.java -- the basic constraints extension. - Copyright (C) 2004 Free Software Foundation, Inc. + Copyright (C) 2004, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -111,7 +111,7 @@ public class BasicConstraints extends Extension.Value { if (encoded == null) { - List bc = new ArrayList (2); + List<DERValue> bc = new ArrayList<DERValue> (2); bc.add (new DERValue (DER.BOOLEAN, Boolean.valueOf (ca))); if (pathLenConstraint >= 0) bc.add (new DERValue (DER.INTEGER, diff --git a/gnu/java/security/x509/ext/CertificatePolicies.java b/gnu/java/security/x509/ext/CertificatePolicies.java index 874b8eeeb..9b36485b2 100644 --- a/gnu/java/security/x509/ext/CertificatePolicies.java +++ b/gnu/java/security/x509/ext/CertificatePolicies.java @@ -1,5 +1,5 @@ /* CertificatePolicies.java -- certificate policy extension. - Copyright (C) 2004, 2006 Free Software Foundation, Inc. + Copyright (C) 2004, 2006, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -113,24 +113,49 @@ public class CertificatePolicies extends Extension.Value public CertificatePolicies (final List<OID> policies, final Map<OID, List<PolicyQualifierInfo>> policyQualifierInfos) { - for (Iterator it = policies.iterator(); it.hasNext(); ) - if (!(it.next() instanceof OID)) - throw new IllegalArgumentException ("policies must be OIDs"); - for (Iterator it = policyQualifierInfos.entrySet().iterator(); it.hasNext();) + List<OID> polCopy = new ArrayList<OID>(policies.size()); + try { - Map.Entry e = (Map.Entry) it.next(); - if (!(e.getKey() instanceof OID) || !policies.contains (e.getKey())) - throw new IllegalArgumentException - ("policyQualifierInfos keys must be OIDs"); - if (!(e.getValue() instanceof List)) - throw new IllegalArgumentException - ("policyQualifierInfos values must be Lists of PolicyQualifierInfos"); - for (Iterator it2 = ((List) e.getValue()).iterator(); it.hasNext(); ) - if (!(it2.next() instanceof PolicyQualifierInfo)) + for (OID o : policies) { polCopy.add(o); } + } + catch (ClassCastException e) + { + throw new IllegalArgumentException ("policies must be OIDs", e); + } + for (Map.Entry<OID,List<PolicyQualifierInfo>> e : policyQualifierInfos.entrySet()) + { + try + { + if (!policies.contains (e.getKey())) + throw new IllegalArgumentException + ("policyQualifierInfos keys must be OIDs"); + } + catch (ClassCastException cce) + { + throw new IllegalArgumentException + ("policyQualifierInfos keys must be OIDs", cce); + } + try + { + e.getValue(); + } + catch (ClassCastException cce) + { + throw new IllegalArgumentException + ("policyQualifierInfos values must be Lists of PolicyQualifierInfos", cce); + } + try + { + for (Iterator<PolicyQualifierInfo> i = e.getValue().iterator(); + i.hasNext(); i.next()); + } + catch (ClassCastException cce) + { throw new IllegalArgumentException - ("policyQualifierInfos values must be Lists of PolicyQualifierInfos"); + ("policyQualifierInfos values must be Lists of PolicyQualifierInfos", cce); + } } - this.policies = Collections.unmodifiableList (new ArrayList<OID>(policies)); + this.policies = Collections.unmodifiableList (polCopy); this.policyQualifierInfos = Collections.unmodifiableMap (new HashMap<OID, List<PolicyQualifierInfo>>(policyQualifierInfos)); } diff --git a/gnu/java/security/x509/ext/PolicyMappings.java b/gnu/java/security/x509/ext/PolicyMappings.java index 0493ed89d..eeac340d3 100644 --- a/gnu/java/security/x509/ext/PolicyMappings.java +++ b/gnu/java/security/x509/ext/PolicyMappings.java @@ -1,5 +1,5 @@ /* PolicyMappings.java -- policy mappings extension. - Copyright (C) 2004 Free Software Foundation, Inc. + Copyright (C) 2004, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -56,7 +56,7 @@ public class PolicyMappings extends Extension.Value public static final OID ID = new OID("2.5.29.33"); - private final Map mappings; + private final Map<OID,OID> mappings; // Constructor. // ------------------------------------------------------------------------- @@ -69,7 +69,7 @@ public class PolicyMappings extends Extension.Value if (!maps.isConstructed()) throw new IOException("malformed PolicyMappings"); int len = 0; - HashMap _mappings = new HashMap(); + HashMap<OID,OID> _mappings = new HashMap<OID,OID>(); while (len < maps.getLength()) { DERValue map = der.read(); @@ -94,7 +94,7 @@ public class PolicyMappings extends Extension.Value public OID getSubjectDomainPolicy(OID issuerDomainPolicy) { - return (OID) mappings.get(issuerDomainPolicy); + return mappings.get(issuerDomainPolicy); } public String toString() |
