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 | |
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>
159 files changed, 1766 insertions, 1134 deletions
@@ -1,3 +1,356 @@ +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. + 2014-05-07 Andrew John Hughes <gnu_andrew@member.fsf.org> * java/io/IOException.java: @@ -21,6 +21,7 @@ New in release 0.99.1 (XXX XX, 2012) - PR41689: javax.security.sasl.CREDIENTIALS field is missing - PR55140: Addition of exception to codePointBefore breaks OpenJDK GenerateBreakIteratorData tool - PR57070: VMProcess needs to notifyAll() instead of notify() + - PR58688: gnu.java.security.x509.PolicyNodeImpl#addAllPolicyQualifiers does not work New in release 0.99 (Feb 15, 2012) diff --git a/gnu/java/security/Engine.java b/gnu/java/security/Engine.java index 969fcef6c..8313631be 100644 --- a/gnu/java/security/Engine.java +++ b/gnu/java/security/Engine.java @@ -1,5 +1,5 @@ /* Engine -- generic getInstance method. - Copyright (C) 2003, 2006 Free Software Foundation, Inc. + Copyright (C) 2003, 2006, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -147,7 +147,7 @@ public final class Engine if (initArgs == null) throw new IllegalArgumentException("Constructor's parameters MUST NOT be null"); - Enumeration enumer = provider.propertyNames(); + Enumeration<?> enumer = provider.propertyNames(); String key = null; String alias; int count = 0; @@ -192,9 +192,9 @@ public final class Engine } // Find and instantiate the implementation - Class clazz = null; + Class<?> clazz = null; ClassLoader loader = provider.getClass().getClassLoader(); - Constructor constructor = null; + Constructor<?> constructor = null; String className = provider.getProperty(key); sb.append("Class [").append(className).append("] for algorithm [") .append(algorithm).append("] of type [").append(service) @@ -255,14 +255,14 @@ public final class Engine * @throws NoSuchMethodException If no constructor of the given class * can take the specified argument array. */ - private static Constructor getCompatibleConstructor(Class clazz, - Object[] initArgs) + private static Constructor<?> getCompatibleConstructor(Class<?> clazz, + Object[] initArgs) throws NoSuchMethodException { - Constructor[] c = clazz.getConstructors(); + Constructor<?>[] c = clazz.getConstructors(); outer:for (int i = 0; i < c.length; i++) { - Class[] argTypes = c[i].getParameterTypes(); + Class<?>[] argTypes = c[i].getParameterTypes(); if (argTypes.length != initArgs.length) continue; for (int j = 0; j < argTypes.length; j++) diff --git a/gnu/java/security/OID.java b/gnu/java/security/OID.java index c7efe6557..c6b977e00 100644 --- a/gnu/java/security/OID.java +++ b/gnu/java/security/OID.java @@ -1,5 +1,5 @@ /* OID.java -- numeric representation of an object identifier - Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc. + Copyright (C) 2003, 2004, 2005, 2006, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -67,7 +67,7 @@ import java.util.StringTokenizer; * * @author Casey Marshall (csm@gnu.org) */ -public class OID implements Cloneable, Comparable, java.io.Serializable +public class OID implements Cloneable, Comparable<OID>, java.io.Serializable { // Fields. @@ -410,11 +410,11 @@ public class OID implements Cloneable, Comparable, java.io.Serializable * argument. * @throws ClassCastException If <i>o</i> is not an OID. */ - public int compareTo(Object o) + public int compareTo(OID o) { if (equals(o)) return 0; - int[] components2 = ((OID) o).components; + int[] components2 = o.components; int len = Math.min(components.length, components2.length); for (int i = 0; i < len; i++) { diff --git a/gnu/java/security/Properties.java b/gnu/java/security/Properties.java index 1a4bf2276..7a664fc74 100644 --- a/gnu/java/security/Properties.java +++ b/gnu/java/security/Properties.java @@ -1,5 +1,5 @@ /* Properties.java -- run-time configuration properties. - Copyright (C) 2003, 2004, 2006, 2010 Free Software Foundation, Inc. + Copyright (C) 2003, 2004, 2006, 2010, 2014 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -71,7 +71,8 @@ public final class Properties private static final String FALSE = Boolean.FALSE.toString(); - private static final HashMap props = new HashMap(); + private static final HashMap<String,String> props = + new HashMap<String,String>(); private static Properties singleton = null; @@ -108,7 +109,7 @@ public final class Properties key = key.trim().toLowerCase(); if ("".equals(key)) return null; - return (String) props.get(key); + return props.get(key); } /** @@ -269,9 +270,10 @@ public final class Properties String propFile = null; try { - propFile = (String) AccessController.doPrivileged(new PrivilegedAction() + propFile = AccessController.doPrivileged(new PrivilegedAction<String>() { - public Object run() + @Override + public String run() { return System.getProperty(PROPERTIES_FILE); } @@ -290,7 +292,8 @@ public final class Properties final FileInputStream fin = new FileInputStream(propFile); temp.load(fin); temp.list(System.out); - props.putAll(temp); + for (String key : temp.stringPropertyNames()) + props.put(key, temp.getProperty(key)); } catch (IOException ioe) { diff --git a/gnu/java/security/action/SetAccessibleAction.java b/gnu/java/security/action/SetAccessibleAction.java index d3e3c0f90..e1f58ae71 100644 --- a/gnu/java/security/action/SetAccessibleAction.java +++ b/gnu/java/security/action/SetAccessibleAction.java @@ -1,5 +1,5 @@ /* SetAccessibleAction.java - Copyright (C) 2004 Free Software Foundation, Inc. + Copyright (C) 2004, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -50,7 +50,7 @@ import java.security.PrivilegedAction; * AccessController.doPrivileged(new SetAccessibleAction(dataField)); * </code> */ -public class SetAccessibleAction implements PrivilegedAction +public class SetAccessibleAction implements PrivilegedAction<AccessibleObject> { AccessibleObject member; @@ -63,7 +63,8 @@ public class SetAccessibleAction implements PrivilegedAction this.member = member; } - public Object run() + @Override + public AccessibleObject run() { member.setAccessible(true); return null; diff --git a/gnu/java/security/ber/BEREncodingException.java b/gnu/java/security/ber/BEREncodingException.java index aad10932c..0b2f494f1 100644 --- a/gnu/java/security/ber/BEREncodingException.java +++ b/gnu/java/security/ber/BEREncodingException.java @@ -1,5 +1,5 @@ /* BEREncodingException.java --- BER Encoding Exception - Copyright (C) 2004 Free Software Foundation, Inc. + Copyright (C) 2004, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -42,6 +42,8 @@ import gnu.java.security.der.DEREncodingException; public class BEREncodingException extends DEREncodingException { + private static final long serialVersionUID = 5155616917834322362L; + public BEREncodingException() { super (); diff --git a/gnu/java/security/der/BitString.java b/gnu/java/security/der/BitString.java index ac10be22e..c7032ccfc 100644 --- a/gnu/java/security/der/BitString.java +++ b/gnu/java/security/der/BitString.java @@ -1,5 +1,5 @@ /* BitString.java -- Java representation of the BIT STRING type. - Copyright (C) 2003 Free Software Foundation, Inc. + Copyright (C) 2003, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -55,7 +55,7 @@ import java.util.Arrays; * * @author Casey Marshall (csm@gnu.org) */ -public class BitString implements Cloneable, Comparable +public class BitString implements Cloneable, Comparable<BitString> { // Fields. @@ -273,9 +273,9 @@ public class BitString implements Cloneable, Comparable } } - public int compareTo(Object o) + @Override + public int compareTo(BitString that) { - BitString that = (BitString) o; if (this.equals(that)) return 0; if (this.bytes.length != that.bytes.length) diff --git a/gnu/java/security/der/DEREncodingException.java b/gnu/java/security/der/DEREncodingException.java index 90042a3fc..de3b44426 100644 --- a/gnu/java/security/der/DEREncodingException.java +++ b/gnu/java/security/der/DEREncodingException.java @@ -1,5 +1,5 @@ /* DEREncodingException.java --- DER Encoding Exception - Copyright (C) 1999,2003 Free Software Foundation, Inc. + Copyright (C) 1999,2003,2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -42,6 +42,8 @@ import java.io.IOException; public class DEREncodingException extends IOException { + private static final long serialVersionUID = 5763366374058841017L; + public DEREncodingException() { super (); diff --git a/gnu/java/security/der/DERWriter.java b/gnu/java/security/der/DERWriter.java index cea3fa31d..6f3b1b486 100644 --- a/gnu/java/security/der/DERWriter.java +++ b/gnu/java/security/der/DERWriter.java @@ -1,5 +1,5 @@ /* DERWriter.java -- write Java types in DER format. - Copyright (C) 2003, 2004, 2005, 2010 Free Software Foundation, Inc. + Copyright (C) 2003, 2004, 2005, 2010, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -106,9 +106,17 @@ public class DERWriter implements DER else if (value instanceof String) return writeString(out, object.getExternalTag(), (String) value); else if (value instanceof List) - return writeSequence(out, (List) value); + { + @SuppressWarnings("unchecked") + List<DERValue> dvList = (List<DERValue>) value; + return writeSequence(out, dvList); + } else if (value instanceof Set) - return writeSet(out, (Set) value); + { + @SuppressWarnings("unchecked") + Set<DERValue> dvSet = (Set<DERValue>) value; + return writeSet(out, dvSet); + } else if (value instanceof BitString) return writeBitString(out, (BitString) value); else if (value instanceof OID) @@ -181,13 +189,13 @@ public class DERWriter implements DER return bytes.length; } - private static int writeSequence(OutputStream out, List sequence) + private static int writeSequence(OutputStream out, List<DERValue> sequence) throws IOException { ByteArrayOutputStream bout = new ByteArrayOutputStream(); - for (Iterator i = sequence.iterator(); i.hasNext(); ) + for (Iterator<DERValue> i = sequence.iterator(); i.hasNext(); ) { - write(bout, (DERValue) i.next()); + write(bout, i.next()); } byte[] buf = bout.toByteArray(); writeLength(out, buf.length); @@ -195,13 +203,13 @@ public class DERWriter implements DER return buf.length; } - private static int writeSet(OutputStream out, Set set) + private static int writeSet(OutputStream out, Set<DERValue> set) throws IOException { ByteArrayOutputStream bout = new ByteArrayOutputStream(); - for (Iterator i = set.iterator(); i.hasNext(); ) + for (Iterator<DERValue> i = set.iterator(); i.hasNext(); ) { - write(bout, (DERValue) i.next()); + write(bout, i.next()); } byte[] buf = bout.toByteArray(); writeLength(out, buf.length); diff --git a/gnu/java/security/hash/HashFactory.java b/gnu/java/security/hash/HashFactory.java index 1210ff4db..688afc4c9 100644 --- a/gnu/java/security/hash/HashFactory.java +++ b/gnu/java/security/hash/HashFactory.java @@ -1,5 +1,5 @@ /* HashFactory.java -- - Copyright (C) 2001, 2002, 2003, 2006 Free Software Foundation, Inc. + Copyright (C) 2001, 2002, 2003, 2006, 2014 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -114,9 +114,9 @@ public class HashFactory * * @return a {@link Set} of hash names (Strings). */ - public static final Set getNames() + public static final Set<String> getNames() { - HashSet hs = new HashSet(); + HashSet<String> hs = new HashSet<String>(); hs.add(Registry.WHIRLPOOL_HASH); hs.add(Registry.RIPEMD128_HASH); hs.add(Registry.RIPEMD160_HASH); diff --git a/gnu/java/security/hash/Whirlpool.java b/gnu/java/security/hash/Whirlpool.java index 29eed59ba..bb1174e2e 100644 --- a/gnu/java/security/hash/Whirlpool.java +++ b/gnu/java/security/hash/Whirlpool.java @@ -1,5 +1,5 @@ /* Whirlpool.java -- - Copyright (C) 2001, 2002, 2006, 2010 Free Software Foundation, Inc. + Copyright (C) 2001, 2002, 2006, 2010, 2014 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -136,7 +136,6 @@ public final class Whirlpool int i, r, j; long s1, s2, s4, s5, s8, s9, t; char c; - final byte[] S = new byte[256]; for (i = 0; i < 256; i++) { c = S_box.charAt(i >>> 1); diff --git a/gnu/java/security/jce/prng/HavalRandomSpi.java b/gnu/java/security/jce/prng/HavalRandomSpi.java index ebf80f2d7..bce621cc9 100644 --- a/gnu/java/security/jce/prng/HavalRandomSpi.java +++ b/gnu/java/security/jce/prng/HavalRandomSpi.java @@ -1,5 +1,5 @@ /* HavalRandomSpi.java -- - Copyright (C) 2003, 2006 Free Software Foundation, Inc. + Copyright (C) 2003, 2006, 2014 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -47,6 +47,8 @@ import gnu.java.security.Registry; public class HavalRandomSpi extends SecureRandomAdapter { + private static final long serialVersionUID = -8063732691196112589L; + public HavalRandomSpi() { super(Registry.HAVAL_HASH); diff --git a/gnu/java/security/jce/prng/MD2RandomSpi.java b/gnu/java/security/jce/prng/MD2RandomSpi.java index 8b9abe4e9..96c6ef06d 100644 --- a/gnu/java/security/jce/prng/MD2RandomSpi.java +++ b/gnu/java/security/jce/prng/MD2RandomSpi.java @@ -1,5 +1,5 @@ /* MD2RandomSpi.java -- - Copyright (C) 2001, 2002, 2006 Free Software Foundation, Inc. + Copyright (C) 2001, 2002, 2006, 2014 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -47,6 +47,8 @@ import gnu.java.security.Registry; public class MD2RandomSpi extends SecureRandomAdapter { + private static final long serialVersionUID = -4057743457589764490L; + public MD2RandomSpi() { super(Registry.MD2_HASH); diff --git a/gnu/java/security/jce/prng/MD4RandomSpi.java b/gnu/java/security/jce/prng/MD4RandomSpi.java index 2a71d6a0d..986905c0a 100644 --- a/gnu/java/security/jce/prng/MD4RandomSpi.java +++ b/gnu/java/security/jce/prng/MD4RandomSpi.java @@ -1,5 +1,5 @@ /* MD4RandomSpi.java -- - Copyright (C) 2001, 2002, 2006 Free Software Foundation, Inc. + Copyright (C) 2001, 2002, 2006, 2014 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -47,6 +47,8 @@ import gnu.java.security.Registry; public class MD4RandomSpi extends SecureRandomAdapter { + private static final long serialVersionUID = -2812563232122795714L; + public MD4RandomSpi() { super(Registry.MD4_HASH); diff --git a/gnu/java/security/jce/prng/MD5RandomSpi.java b/gnu/java/security/jce/prng/MD5RandomSpi.java index 8fb50e16f..655e795e7 100644 --- a/gnu/java/security/jce/prng/MD5RandomSpi.java +++ b/gnu/java/security/jce/prng/MD5RandomSpi.java @@ -1,5 +1,5 @@ /* MD5RandomSpi.java -- - Copyright (C) 2001, 2002, 2006 Free Software Foundation, Inc. + Copyright (C) 2001, 2002, 2006, 2014 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -47,6 +47,8 @@ import gnu.java.security.Registry; public class MD5RandomSpi extends SecureRandomAdapter { + private static final long serialVersionUID = -8922813416432084255L; + public MD5RandomSpi() { super(Registry.MD5_HASH); diff --git a/gnu/java/security/jce/prng/RipeMD128RandomSpi.java b/gnu/java/security/jce/prng/RipeMD128RandomSpi.java index 6f8dde0e0..0657ef5b8 100644 --- a/gnu/java/security/jce/prng/RipeMD128RandomSpi.java +++ b/gnu/java/security/jce/prng/RipeMD128RandomSpi.java @@ -1,5 +1,5 @@ /* RipeMD128RandomSpi.java -- - Copyright (C) 2001, 2002, 2006 Free Software Foundation, Inc. + Copyright (C) 2001, 2002, 2006, 2014 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -47,6 +47,8 @@ import gnu.java.security.Registry; public class RipeMD128RandomSpi extends SecureRandomAdapter { + private static final long serialVersionUID = -5746104868781660155L; + public RipeMD128RandomSpi() { super(Registry.RIPEMD128_HASH); diff --git a/gnu/java/security/jce/prng/RipeMD160RandomSpi.java b/gnu/java/security/jce/prng/RipeMD160RandomSpi.java index 6bb4e2b50..3e64dcf71 100644 --- a/gnu/java/security/jce/prng/RipeMD160RandomSpi.java +++ b/gnu/java/security/jce/prng/RipeMD160RandomSpi.java @@ -1,5 +1,5 @@ /* RipeMD160RandomSpi.java -- - Copyright (C) 2001, 2002, 2006 Free Software Foundation, Inc. + Copyright (C) 2001, 2002, 2006, 2014 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -47,6 +47,8 @@ import gnu.java.security.Registry; public class RipeMD160RandomSpi extends SecureRandomAdapter { + private static final long serialVersionUID = -1826833146069540489L; + public RipeMD160RandomSpi() { super(Registry.RIPEMD160_HASH); diff --git a/gnu/java/security/jce/prng/SecureRandomAdapter.java b/gnu/java/security/jce/prng/SecureRandomAdapter.java index 9307cfa7f..0d5b060ed 100644 --- a/gnu/java/security/jce/prng/SecureRandomAdapter.java +++ b/gnu/java/security/jce/prng/SecureRandomAdapter.java @@ -1,5 +1,5 @@ /* SecureRandomAdapter.java -- - Copyright (C) 2001, 2002, 2003, 2006 Free Software Foundation, Inc. + Copyright (C) 2001, 2002, 2003, 2006, 2014 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -71,15 +71,13 @@ import java.net.URL; public abstract class SecureRandomAdapter extends SecureRandomSpi { + private static final long serialVersionUID = 999603727925481878L; private boolean isSeeded = false; /** Our underlying prng instance. */ private MDGenerator adaptee = new MDGenerator(); - /** The name of the message digest algorithm used by the adaptee. */ - private String mdName; - private static final Logger logger = Logger.getLogger(SecureRandom.class.getName()); @@ -95,8 +93,7 @@ public abstract class SecureRandomAdapter { super(); - this.mdName = mdName; - adaptee.init (Collections.singletonMap (MDGenerator.MD_NAME, mdName)); + adaptee.init (Collections.singletonMap (MDGenerator.MD_NAME, (Object) mdName)); } public static final byte[] getSeed(int numBytes) @@ -110,7 +107,7 @@ public abstract class SecureRandomAdapter new GetSecurityPropertyAction(SECURERANDOM_SOURCE); try { - urlStr = (String) AccessController.doPrivileged(action); + urlStr = AccessController.doPrivileged(action); if (urlStr != null) sourceUrl = new URL(urlStr); } @@ -156,11 +153,13 @@ public abstract class SecureRandomAdapter return buffer; } + @Override public byte[] engineGenerateSeed(int numBytes) { return getSeed(numBytes); } + @Override public void engineNextBytes(byte[] bytes) { if (!isSeeded) @@ -176,6 +175,7 @@ public abstract class SecureRandomAdapter } } + @Override public void engineSetSeed(byte[] seed) { adaptee.addRandomBytes (seed); diff --git a/gnu/java/security/jce/prng/Sha160RandomSpi.java b/gnu/java/security/jce/prng/Sha160RandomSpi.java index ba4d22265..674a7095f 100644 --- a/gnu/java/security/jce/prng/Sha160RandomSpi.java +++ b/gnu/java/security/jce/prng/Sha160RandomSpi.java @@ -1,5 +1,5 @@ /* Sha160RandomSpi.java -- - Copyright (C) 2001, 2002, 2006 Free Software Foundation, Inc. + Copyright (C) 2001, 2002, 2006, 2014 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -47,6 +47,8 @@ import gnu.java.security.Registry; public class Sha160RandomSpi extends SecureRandomAdapter { + private static final long serialVersionUID = -225998056826896890L; + public Sha160RandomSpi() { super(Registry.SHA160_HASH); diff --git a/gnu/java/security/jce/prng/Sha256RandomSpi.java b/gnu/java/security/jce/prng/Sha256RandomSpi.java index a6ddb70af..0c8bd6916 100644 --- a/gnu/java/security/jce/prng/Sha256RandomSpi.java +++ b/gnu/java/security/jce/prng/Sha256RandomSpi.java @@ -1,5 +1,5 @@ /* Sha256RandomSpi.java -- - Copyright (C) 2003, 2006 Free Software Foundation, Inc. + Copyright (C) 2003, 2006, 2014 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -47,6 +47,8 @@ import gnu.java.security.Registry; public class Sha256RandomSpi extends SecureRandomAdapter { + private static final long serialVersionUID = -8748894083942397288L; + public Sha256RandomSpi() { super(Registry.SHA256_HASH); diff --git a/gnu/java/security/jce/prng/Sha384RandomSpi.java b/gnu/java/security/jce/prng/Sha384RandomSpi.java index 4954b1be7..e13d875ff 100644 --- a/gnu/java/security/jce/prng/Sha384RandomSpi.java +++ b/gnu/java/security/jce/prng/Sha384RandomSpi.java @@ -1,5 +1,5 @@ /* Sha384RandomSpi.java -- - Copyright (C) 2003, 2006 Free Software Foundation, Inc. + Copyright (C) 2003, 2006, 2014 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -47,6 +47,8 @@ import gnu.java.security.Registry; public class Sha384RandomSpi extends SecureRandomAdapter { + private static final long serialVersionUID = -5865689279889026842L; + public Sha384RandomSpi() { super(Registry.SHA384_HASH); diff --git a/gnu/java/security/jce/prng/Sha512RandomSpi.java b/gnu/java/security/jce/prng/Sha512RandomSpi.java index 27de7f319..8e9d378d4 100644 --- a/gnu/java/security/jce/prng/Sha512RandomSpi.java +++ b/gnu/java/security/jce/prng/Sha512RandomSpi.java @@ -1,5 +1,5 @@ /* Sha512RandomSpi.java -- - Copyright (C) 2003, 2006 Free Software Foundation, Inc. + Copyright (C) 2003, 2006, 2014 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -47,6 +47,8 @@ import gnu.java.security.Registry; public class Sha512RandomSpi extends SecureRandomAdapter { + private static final long serialVersionUID = 3471561597377786188L; + public Sha512RandomSpi() { super(Registry.SHA512_HASH); diff --git a/gnu/java/security/jce/prng/TigerRandomSpi.java b/gnu/java/security/jce/prng/TigerRandomSpi.java index 722ab3279..e6daac297 100644 --- a/gnu/java/security/jce/prng/TigerRandomSpi.java +++ b/gnu/java/security/jce/prng/TigerRandomSpi.java @@ -1,5 +1,5 @@ /* TigerRandomSpi.java -- - Copyright (C) 2003, 2006 Free Software Foundation, Inc. + Copyright (C) 2003, 2006, 2014 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -47,6 +47,8 @@ import gnu.java.security.Registry; public class TigerRandomSpi extends SecureRandomAdapter { + private static final long serialVersionUID = -4562391018186836733L; + public TigerRandomSpi() { super(Registry.TIGER_HASH); diff --git a/gnu/java/security/jce/prng/WhirlpoolRandomSpi.java b/gnu/java/security/jce/prng/WhirlpoolRandomSpi.java index 5da43d77e..1e423d712 100644 --- a/gnu/java/security/jce/prng/WhirlpoolRandomSpi.java +++ b/gnu/java/security/jce/prng/WhirlpoolRandomSpi.java @@ -1,5 +1,5 @@ /* WhirlpoolRandomSpi.java -- - Copyright (C) 2001, 2002, 2006 Free Software Foundation, Inc. + Copyright (C) 2001, 2002, 2006, 2014 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -47,6 +47,8 @@ import gnu.java.security.Registry; public class WhirlpoolRandomSpi extends SecureRandomAdapter { + private static final long serialVersionUID = -3118094409789615934L; + public WhirlpoolRandomSpi() { super(Registry.WHIRLPOOL_HASH); diff --git a/gnu/java/security/jce/sig/DSSKeyFactory.java b/gnu/java/security/jce/sig/DSSKeyFactory.java index ec993432c..d52f09948 100644 --- a/gnu/java/security/jce/sig/DSSKeyFactory.java +++ b/gnu/java/security/jce/sig/DSSKeyFactory.java @@ -1,5 +1,5 @@ /* DSSKeyFactory.java -- JCE DSA key factory Adapter - Copyright (C) 2006 Free Software Foundation, Inc. + Copyright (C) 2006, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -69,6 +69,7 @@ public class DSSKeyFactory { // implicit 0-arguments constructor + @Override protected PublicKey engineGeneratePublic(KeySpec keySpec) throws InvalidKeySpecException { @@ -99,6 +100,7 @@ public class DSSKeyFactory throw new InvalidKeySpecException("Unsupported (public) key specification"); } + @Override protected PrivateKey engineGeneratePrivate(KeySpec keySpec) throws InvalidKeySpecException { @@ -129,7 +131,8 @@ public class DSSKeyFactory throw new InvalidKeySpecException("Unsupported (private) key specification"); } - protected KeySpec engineGetKeySpec(Key key, Class keySpec) + @Override + protected <T extends KeySpec> T engineGetKeySpec(Key key, Class<T> keySpec) throws InvalidKeySpecException { if (key instanceof DSAPublicKey) @@ -141,7 +144,7 @@ public class DSSKeyFactory BigInteger q = dsaKey.getParams().getQ(); BigInteger g = dsaKey.getParams().getG(); BigInteger y = dsaKey.getY(); - return new DSAPublicKeySpec(y, p, q, g); + return keySpec.cast(new DSAPublicKeySpec(y, p, q, g)); } if (keySpec.isAssignableFrom(X509EncodedKeySpec.class)) { @@ -149,12 +152,12 @@ public class DSSKeyFactory { DSSPublicKey dssKey = (DSSPublicKey) key; byte[] encoded = dssKey.getEncoded(Registry.X509_ENCODING_ID); - return new X509EncodedKeySpec(encoded); + return keySpec.cast(new X509EncodedKeySpec(encoded)); } if (Registry.X509_ENCODING_SORT_NAME.equalsIgnoreCase(key.getFormat())) { byte[] encoded = key.getEncoded(); - return new X509EncodedKeySpec(encoded); + return keySpec.cast(new X509EncodedKeySpec(encoded)); } throw new InvalidKeySpecException( "Wrong key type or unsupported (public) key specification"); @@ -170,7 +173,7 @@ public class DSSKeyFactory BigInteger q = dsaKey.getParams().getQ(); BigInteger g = dsaKey.getParams().getG(); BigInteger x = dsaKey.getX(); - return new DSAPrivateKeySpec(x, p, q, g); + return keySpec.cast(new DSAPrivateKeySpec(x, p, q, g)); } if (keySpec.isAssignableFrom(PKCS8EncodedKeySpec.class)) { @@ -178,12 +181,12 @@ public class DSSKeyFactory { DSSPrivateKey dssKey = (DSSPrivateKey) key; byte[] encoded = dssKey.getEncoded(Registry.PKCS8_ENCODING_ID); - return new PKCS8EncodedKeySpec(encoded); + return keySpec.cast(new PKCS8EncodedKeySpec(encoded)); } if (Registry.PKCS8_ENCODING_SHORT_NAME.equalsIgnoreCase(key.getFormat())) { byte[] encoded = key.getEncoded(); - return new PKCS8EncodedKeySpec(encoded); + return keySpec.cast(new PKCS8EncodedKeySpec(encoded)); } throw new InvalidKeySpecException( "Wrong key type or unsupported (private) key specification"); @@ -193,6 +196,7 @@ public class DSSKeyFactory throw new InvalidKeySpecException("Wrong key type or unsupported key specification"); } + @Override protected Key engineTranslateKey(Key key) throws InvalidKeyException { if ((key instanceof DSSPublicKey) || (key instanceof DSSPrivateKey)) diff --git a/gnu/java/security/jce/sig/DSSKeyPairGeneratorSpi.java b/gnu/java/security/jce/sig/DSSKeyPairGeneratorSpi.java index 2d33e1621..971cffe92 100644 --- a/gnu/java/security/jce/sig/DSSKeyPairGeneratorSpi.java +++ b/gnu/java/security/jce/sig/DSSKeyPairGeneratorSpi.java @@ -1,5 +1,5 @@ /* DSSKeyPairGeneratorSpi.java -- - Copyright 2001, 2002, 2006 Free Software Foundation, Inc. + Copyright 2001, 2002, 2006, 2014 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -75,7 +75,7 @@ public class DSSKeyPairGeneratorSpi public void initialize(AlgorithmParameterSpec params, SecureRandom random) throws InvalidAlgorithmParameterException { - HashMap attributes = new HashMap(); + HashMap<String,Object> attributes = new HashMap<String,Object>(); if (params != null) { if (! (params instanceof DSAParameterSpec)) @@ -99,6 +99,7 @@ public class DSSKeyPairGeneratorSpi } } + @Override public void initialize(DSAParams params, SecureRandom random) throws InvalidParameterException { @@ -119,10 +120,11 @@ public class DSSKeyPairGeneratorSpi } } + @Override public void initialize(int modlen, boolean genParams, SecureRandom random) throws InvalidParameterException { - HashMap attributes = new HashMap(); + HashMap<String,Object> attributes = new HashMap<String,Object>(); attributes.put(DSSKeyPairGenerator.MODULUS_LENGTH, Integer.valueOf(modlen)); if (random != null) attributes.put(DSSKeyPairGenerator.SOURCE_OF_RANDOMNESS, random); diff --git a/gnu/java/security/jce/sig/DSSParameters.java b/gnu/java/security/jce/sig/DSSParameters.java index fbf778dae..775ab1a66 100644 --- a/gnu/java/security/jce/sig/DSSParameters.java +++ b/gnu/java/security/jce/sig/DSSParameters.java @@ -1,5 +1,5 @@ /* DSSParameters.java -- DSS parameters DAO - Copyright (C) 2006 Free Software Foundation, Inc. + Copyright (C) 2006, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -85,6 +85,7 @@ public class DSSParameters // default 0-arguments constructor + @Override protected void engineInit(AlgorithmParameterSpec spec) throws InvalidParameterSpecException { @@ -109,6 +110,7 @@ public class DSSParameters * } * </pre> */ + @Override protected void engineInit(byte[] params) throws IOException { DERReader der = new DERReader(params); @@ -127,6 +129,7 @@ public class DSSParameters g = (BigInteger) val.getValue(); } + @Override protected void engineInit(byte[] params, String format) throws IOException { if (format != null) @@ -141,13 +144,14 @@ public class DSSParameters engineInit(params); } - protected AlgorithmParameterSpec engineGetParameterSpec(Class paramSpec) + @Override + protected <T extends AlgorithmParameterSpec> T engineGetParameterSpec(Class<T> paramSpec) throws InvalidParameterSpecException { if (! paramSpec.isAssignableFrom(DSAParameterSpec.class)) throw new InvalidParameterSpecException("Wrong AlgorithmParameterSpec type: " + paramSpec.getName()); - return new DSAParameterSpec(p, q, g); + return paramSpec.cast(new DSAParameterSpec(p, q, g)); } /** @@ -162,13 +166,14 @@ public class DSSParameters * } * </pre> */ + @Override protected byte[] engineGetEncoded() throws IOException { DERValue derP = new DERValue(DER.INTEGER, p); DERValue derQ = new DERValue(DER.INTEGER, q); DERValue derG = new DERValue(DER.INTEGER, g); - ArrayList params = new ArrayList(3); + ArrayList<DERValue> params = new ArrayList<DERValue>(3); params.add(derP); params.add(derQ); params.add(derG); @@ -181,6 +186,7 @@ public class DSSParameters return result; } + @Override protected byte[] engineGetEncoded(String format) throws IOException { if (format != null) @@ -195,6 +201,7 @@ public class DSSParameters return engineGetEncoded(); } + @Override protected String engineToString() { CPStringBuilder sb = new CPStringBuilder("p="); diff --git a/gnu/java/security/jce/sig/EncodedKeyFactory.java b/gnu/java/security/jce/sig/EncodedKeyFactory.java index ec7420138..df8bb14b1 100644 --- a/gnu/java/security/jce/sig/EncodedKeyFactory.java +++ b/gnu/java/security/jce/sig/EncodedKeyFactory.java @@ -1,5 +1,5 @@ /* EncodedKeyFactory.java -- JCE Encoded key factory Adapter - Copyright (C) 2006, 2010 Free Software Foundation, Inc. + Copyright (C) 2006, 2010, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -84,10 +84,10 @@ public class EncodedKeyFactory private static Object invokeConstructor(String className, Object[] params) throws InvalidKeySpecException { - Class clazz = getConcreteClass(className); + Class<?> clazz = getConcreteClass(className); try { - Constructor ctor = getConcreteCtor(clazz); + Constructor<?> ctor = getConcreteCtor(clazz); Object result = ctor.newInstance(params); return result; } @@ -105,12 +105,12 @@ public class EncodedKeyFactory } } - private static Class getConcreteClass(String className) + private static Class<?> getConcreteClass(String className) throws InvalidKeySpecException { try { - Class result = Class.forName(className); + Class<?> result = Class.forName(className); return result; } catch (ClassNotFoundException x) @@ -119,12 +119,12 @@ public class EncodedKeyFactory } } - private static Constructor getConcreteCtor(Class clazz) + private static Constructor<?> getConcreteCtor(Class<?> clazz) throws InvalidKeySpecException { try { - Constructor result = clazz.getConstructor(new Class[] {int.class, + Constructor<?> result = clazz.getConstructor(new Class[] {int.class, BigInteger.class, BigInteger.class, BigInteger.class, @@ -140,7 +140,7 @@ public class EncodedKeyFactory private static Object invokeValueOf(String className, byte[] encoded) throws InvalidKeySpecException { - Class clazz = getConcreteClass(className); + Class<?> clazz = getConcreteClass(className); try { Method valueOf = getValueOfMethod(clazz); @@ -157,7 +157,7 @@ public class EncodedKeyFactory } } - private static Method getValueOfMethod(Class clazz) + private static Method getValueOfMethod(Class<?> clazz) throws InvalidKeySpecException { try @@ -171,6 +171,7 @@ public class EncodedKeyFactory } } + @Override protected PublicKey engineGeneratePublic(KeySpec keySpec) throws InvalidKeySpecException { @@ -222,7 +223,8 @@ public class EncodedKeyFactory log.exiting(this.getClass().getName(), "engineGeneratePublic()", result); return result; } - + + @Override protected PrivateKey engineGeneratePrivate(KeySpec keySpec) throws InvalidKeySpecException { @@ -274,23 +276,25 @@ public class EncodedKeyFactory log.exiting(this.getClass().getName(), "engineGeneratePrivate()", result); return result; } - - protected KeySpec engineGetKeySpec(Key key, Class keySpec) + + @Override + protected <T extends KeySpec> T engineGetKeySpec(Key key, Class<T> keySpec) throws InvalidKeySpecException { if (key instanceof PublicKey && Registry.X509_ENCODING_SORT_NAME.equalsIgnoreCase(key.getFormat()) && keySpec.isAssignableFrom(X509EncodedKeySpec.class)) - return new X509EncodedKeySpec(key.getEncoded()); + return keySpec.cast(new X509EncodedKeySpec(key.getEncoded())); if (key instanceof PrivateKey && Registry.PKCS8_ENCODING_SHORT_NAME.equalsIgnoreCase(key.getFormat()) && keySpec.isAssignableFrom(PKCS8EncodedKeySpec.class)) - return new PKCS8EncodedKeySpec(key.getEncoded()); + return keySpec.cast(new PKCS8EncodedKeySpec(key.getEncoded())); throw new InvalidKeySpecException("Unsupported format or invalid key spec class"); } + @Override protected Key engineTranslateKey(Key key) throws InvalidKeyException { throw new InvalidKeyException("Key translation not supported"); diff --git a/gnu/java/security/jce/sig/RSAKeyFactory.java b/gnu/java/security/jce/sig/RSAKeyFactory.java index 3ba49edc2..07019dae3 100644 --- a/gnu/java/security/jce/sig/RSAKeyFactory.java +++ b/gnu/java/security/jce/sig/RSAKeyFactory.java @@ -1,5 +1,5 @@ /* RSAKeyFactory.java -- RSA key-factory JCE Adapter - Copyright (C) 2006 Free Software Foundation, Inc. + Copyright (C) 2006, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -66,6 +66,7 @@ public class RSAKeyFactory { // implicit 0-arguments constructor + @Override protected PublicKey engineGeneratePublic(KeySpec keySpec) throws InvalidKeySpecException { @@ -80,7 +81,6 @@ public class RSAKeyFactory { X509EncodedKeySpec spec = (X509EncodedKeySpec) keySpec; byte[] encoded = spec.getEncoded(); - PublicKey result; try { return new RSAKeyPairX509Codec().decodePublicKey(encoded); @@ -93,6 +93,7 @@ public class RSAKeyFactory throw new InvalidKeySpecException("Unsupported (public) key specification"); } + @Override protected PrivateKey engineGeneratePrivate(KeySpec keySpec) throws InvalidKeySpecException { @@ -114,7 +115,6 @@ public class RSAKeyFactory { PKCS8EncodedKeySpec spec = (PKCS8EncodedKeySpec) keySpec; byte[] encoded = spec.getEncoded(); - PrivateKey result; try { return new RSAKeyPairPKCS8Codec().decodePrivateKey(encoded); @@ -127,7 +127,8 @@ public class RSAKeyFactory throw new InvalidKeySpecException("Unsupported (private) key specification"); } - protected KeySpec engineGetKeySpec(Key key, Class keySpec) + @Override + protected <T extends KeySpec> T engineGetKeySpec(Key key, Class<T> keySpec) throws InvalidKeySpecException { if (key instanceof RSAPublicKey) @@ -137,7 +138,7 @@ public class RSAKeyFactory RSAPublicKey rsaKey = (RSAPublicKey) key; BigInteger n = rsaKey.getModulus(); BigInteger e = rsaKey.getPublicExponent(); - return new RSAPublicKeySpec(n, e); + return keySpec.cast(new RSAPublicKeySpec(n, e)); } if (keySpec.isAssignableFrom(X509EncodedKeySpec.class)) { @@ -145,13 +146,13 @@ public class RSAKeyFactory { GnuRSAPublicKey rsaKey = (GnuRSAPublicKey) key; byte[] encoded = rsaKey.getEncoded(Registry.X509_ENCODING_ID); - return new X509EncodedKeySpec(encoded); + return keySpec.cast(new X509EncodedKeySpec(encoded)); } if (Registry.X509_ENCODING_SORT_NAME.equalsIgnoreCase(key.getFormat())) { byte[] encoded = key.getEncoded(); - return new X509EncodedKeySpec(encoded); + return keySpec.cast(new X509EncodedKeySpec(encoded)); } throw new InvalidKeySpecException( "Wrong key type or unsupported (public) key specification"); @@ -170,7 +171,7 @@ public class RSAKeyFactory BigInteger dP = rsaKey.getPrimeExponentP(); BigInteger dQ = rsaKey.getPrimeExponentQ(); BigInteger qInv = rsaKey.getCrtCoefficient(); - return new RSAPrivateCrtKeySpec(n, e, d, p, q, dP, dQ, qInv); + return keySpec.cast(new RSAPrivateCrtKeySpec(n, e, d, p, q, dP, dQ, qInv)); } if ((key instanceof RSAPrivateKey) && keySpec.isAssignableFrom(RSAPrivateKeySpec.class)) @@ -178,7 +179,7 @@ public class RSAKeyFactory RSAPrivateKey rsaKey = (RSAPrivateKey) key; BigInteger n = rsaKey.getModulus(); BigInteger d = rsaKey.getPrivateExponent(); - return new RSAPrivateKeySpec(n, d); + return keySpec.cast(new RSAPrivateKeySpec(n, d)); } if (keySpec.isAssignableFrom(PKCS8EncodedKeySpec.class)) { @@ -186,12 +187,12 @@ public class RSAKeyFactory { GnuRSAPrivateKey rsaKey = (GnuRSAPrivateKey) key; byte[] encoded = rsaKey.getEncoded(Registry.PKCS8_ENCODING_ID); - return new PKCS8EncodedKeySpec(encoded); + return keySpec.cast(new PKCS8EncodedKeySpec(encoded)); } if (Registry.PKCS8_ENCODING_SHORT_NAME.equalsIgnoreCase(key.getFormat())) { byte[] encoded = key.getEncoded(); - return new PKCS8EncodedKeySpec(encoded); + return keySpec.cast(new PKCS8EncodedKeySpec(encoded)); } throw new InvalidKeySpecException( "Wrong key type or unsupported (private) key specification"); @@ -200,6 +201,7 @@ public class RSAKeyFactory "Wrong key type or unsupported key specification"); } + @Override protected Key engineTranslateKey(Key key) throws InvalidKeyException { if ((key instanceof GnuRSAPublicKey) || (key instanceof GnuRSAPrivateKey)) diff --git a/gnu/java/security/jce/sig/RSAKeyPairGeneratorSpi.java b/gnu/java/security/jce/sig/RSAKeyPairGeneratorSpi.java index ef53b8115..fa3cbd5a8 100644 --- a/gnu/java/security/jce/sig/RSAKeyPairGeneratorSpi.java +++ b/gnu/java/security/jce/sig/RSAKeyPairGeneratorSpi.java @@ -1,5 +1,5 @@ /* RSAKeyPairGeneratorSpi.java -- JCE RSA KeyPairGenerator Adapter - Copyright (C) 2001, 2002, 2006 Free Software Foundation, Inc. + Copyright (C) 2001, 2002, 2006, 2014 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -65,7 +65,7 @@ public class RSAKeyPairGeneratorSpi public void initialize(int keysize, SecureRandom random) { - HashMap attributes = new HashMap(); + HashMap<String,Object> attributes = new HashMap<String,Object>(); attributes.put(RSAKeyPairGenerator.MODULUS_LENGTH, Integer.valueOf(keysize)); if (random != null) attributes.put(RSAKeyPairGenerator.SOURCE_OF_RANDOMNESS, random); @@ -78,7 +78,7 @@ public class RSAKeyPairGeneratorSpi public void initialize(AlgorithmParameterSpec params, SecureRandom random) throws InvalidAlgorithmParameterException { - HashMap attributes = new HashMap(); + HashMap<String,Object> attributes = new HashMap<String,Object>(); if (params != null) { if (! (params instanceof RSAKeyGenParameterSpec)) diff --git a/gnu/java/security/jce/sig/SignatureAdapter.java b/gnu/java/security/jce/sig/SignatureAdapter.java index efe3681ca..7f7c1569f 100644 --- a/gnu/java/security/jce/sig/SignatureAdapter.java +++ b/gnu/java/security/jce/sig/SignatureAdapter.java @@ -1,5 +1,5 @@ /* SignatureAdapter.java -- - Copyright 2001, 2002, 2006, 2010 Free Software Foundation, Inc. + Copyright 2001, 2002, 2006, 2010, 2014 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -114,9 +114,10 @@ class SignatureAdapter return new SignatureAdapter((ISignature) adaptee.clone(), codec); } + @Override public void engineInitVerify(PublicKey publicKey) throws InvalidKeyException { - HashMap attributes = new HashMap(); + HashMap<String,Object> attributes = new HashMap<String,Object>(); attributes.put(BaseSignature.VERIFIER_KEY, publicKey); try { @@ -128,9 +129,10 @@ class SignatureAdapter } } + @Override public void engineInitSign(PrivateKey privateKey) throws InvalidKeyException { - HashMap attributes = new HashMap(); + HashMap<String,Object> attributes = new HashMap<String,Object>(); attributes.put(BaseSignature.SIGNER_KEY, privateKey); try { @@ -142,10 +144,11 @@ class SignatureAdapter } } + @Override public void engineInitSign(PrivateKey privateKey, SecureRandom random) throws InvalidKeyException { - HashMap attributes = new HashMap(); + HashMap<String,Object> attributes = new HashMap<String,Object>(); attributes.put(BaseSignature.SIGNER_KEY, privateKey); attributes.put(BaseSignature.SOURCE_OF_RANDOMNESS, random); try @@ -158,6 +161,7 @@ class SignatureAdapter } } + @Override public void engineUpdate(byte b) throws SignatureException { try @@ -170,6 +174,7 @@ class SignatureAdapter } } + @Override public void engineUpdate(byte[] b, int off, int len) throws SignatureException { @@ -183,6 +188,7 @@ class SignatureAdapter } } + @Override public byte[] engineSign() throws SignatureException { Object signature = null; @@ -198,6 +204,7 @@ class SignatureAdapter return result; } + @Override public int engineSign(byte[] outbuf, int offset, int len) throws SignatureException { @@ -210,6 +217,7 @@ class SignatureAdapter return result; } + @Override public boolean engineVerify(byte[] sigBytes) throws SignatureException { if (Configuration.DEBUG) @@ -231,18 +239,21 @@ class SignatureAdapter } // Deprecated. Replaced by engineSetParameter. + @Override public void engineSetParameter(String param, Object value) throws InvalidParameterException { throw new InvalidParameterException("deprecated"); } + @Override public void engineSetParameter(AlgorithmParameterSpec params) throws InvalidAlgorithmParameterException { } // Deprecated + @Override public Object engineGetParameter(String param) throws InvalidParameterException { diff --git a/gnu/java/security/key/IKeyPairGenerator.java b/gnu/java/security/key/IKeyPairGenerator.java index 72aac2463..e7d96b22a 100644 --- a/gnu/java/security/key/IKeyPairGenerator.java +++ b/gnu/java/security/key/IKeyPairGenerator.java @@ -1,5 +1,5 @@ /* IKeyPairGenerator.java -- - Copyright 2001, 2002, 2006 Free Software Foundation, Inc. + Copyright 2001, 2002, 2006, 2014 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -61,7 +61,7 @@ public interface IKeyPairGenerator * @exception IllegalArgumentException if at least one of the mandatory * attributes is missing or an invalid value was specified. */ - void setup(Map attributes); + void setup(Map<String,Object> attributes); /** * Generates a new keypair based on the attributes used to configure the diff --git a/gnu/java/security/key/KeyPairCodecFactory.java b/gnu/java/security/key/KeyPairCodecFactory.java index d42866423..b4d96e2e2 100644 --- a/gnu/java/security/key/KeyPairCodecFactory.java +++ b/gnu/java/security/key/KeyPairCodecFactory.java @@ -1,5 +1,5 @@ /* KeyPairCodecFactory.java -- - Copyright 2001, 2002, 2006 Free Software Foundation, Inc. + Copyright 2001, 2002, 2006, 2014 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -62,7 +62,7 @@ import java.util.Set; */ public class KeyPairCodecFactory { - private static Set names; + private static Set<String> names; /** Trivial constructor to enforce Singleton pattern. */ private KeyPairCodecFactory() @@ -194,11 +194,11 @@ public class KeyPairCodecFactory * * @return a {@link Set} of the names of supported key-pair codec (Strings). */ - public static synchronized final Set getNames() + public static synchronized final Set<String> getNames() { if (names == null) { - HashSet hs = new HashSet(); + HashSet<String> hs = new HashSet<String>(); hs.add(Registry.DSS_KPG + "/" + Registry.RAW_ENCODING_SHORT_NAME); hs.add(Registry.DSS_KPG + "/" + Registry.X509_ENCODING_SORT_NAME); hs.add(Registry.DSS_KPG + "/" + Registry.PKCS8_ENCODING_SHORT_NAME); @@ -216,8 +216,8 @@ public class KeyPairCodecFactory { try { - Class c = Class.forName (clazz); - Constructor ctor = c.getConstructor (new Class[0]); + Class<?> c = Class.forName (clazz); + Constructor<?> ctor = c.getConstructor (new Class[0]); return (IKeyPairCodec) ctor.newInstance (new Object[0]); } catch (Exception x) @@ -234,7 +234,7 @@ public class KeyPairCodecFactory { try { - Class c = Class.forName (clazz); + Class<?> c = Class.forName (clazz); return c.isAssignableFrom (o.getClass ()); } catch (Exception x) diff --git a/gnu/java/security/key/KeyPairGeneratorFactory.java b/gnu/java/security/key/KeyPairGeneratorFactory.java index 151cace39..a5ae8997b 100644 --- a/gnu/java/security/key/KeyPairGeneratorFactory.java +++ b/gnu/java/security/key/KeyPairGeneratorFactory.java @@ -1,5 +1,5 @@ /* KeyPairGeneratorFactory.java -- - Copyright 2001, 2002, 2003, 2006 Free Software Foundation, Inc. + Copyright 2001, 2002, 2003, 2006, 2014 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -92,9 +92,9 @@ public class KeyPairGeneratorFactory * * @return a {@link Set} of keypair generator names (Strings). */ - public static final Set getNames() + public static final Set<String> getNames() { - HashSet hs = new HashSet(); + HashSet<String> hs = new HashSet<String>(); hs.add(Registry.DSS_KPG); hs.add(Registry.DSA_KPG); hs.add(Registry.RSA_KPG); @@ -107,8 +107,8 @@ public class KeyPairGeneratorFactory { try { - Class c = Class.forName(clazz); - Constructor ctor = c.getConstructor(new Class[0]); + Class<?> c = Class.forName(clazz); + Constructor<?> ctor = c.getConstructor(new Class[0]); return (IKeyPairGenerator) ctor.newInstance(new Object[0]); } catch (Exception x) diff --git a/gnu/java/security/key/dss/DSSKey.java b/gnu/java/security/key/dss/DSSKey.java index 49f229f7b..0641ff872 100644 --- a/gnu/java/security/key/dss/DSSKey.java +++ b/gnu/java/security/key/dss/DSSKey.java @@ -1,5 +1,5 @@ /* DSSKey.java -- - Copyright 2001, 2002, 2003, 2006 Free Software Foundation, Inc. + Copyright 2001, 2002, 2003, 2006, 2014 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -73,6 +73,8 @@ import java.security.spec.DSAParameterSpec; public abstract class DSSKey implements Key, DSAKey { + private static final long serialVersionUID = -621913609497224901L; + /** * A prime modulus, where * <code>2<sup>L-1</sup> < p < 2<sup>L</sup></code> for diff --git a/gnu/java/security/key/dss/DSSKeyPairGenerator.java b/gnu/java/security/key/dss/DSSKeyPairGenerator.java index 70df734a9..9a19947fe 100644 --- a/gnu/java/security/key/dss/DSSKeyPairGenerator.java +++ b/gnu/java/security/key/dss/DSSKeyPairGenerator.java @@ -1,5 +1,5 @@ /* DSSKeyPairGenerator.java -- - Copyright 2001, 2002, 2003, 2006, 2010 Free Software Foundation, Inc. + Copyright 2001, 2002, 2003, 2006, 2010, 2014 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -211,6 +211,7 @@ public class DSSKeyPairGenerator /** Preferred encoding format of generated keys. */ private int preferredFormat; + @Override public String name() { return Registry.DSS_KPG; @@ -224,7 +225,8 @@ public class DSSKeyPairGenerator * is not greater than 512, less than 1024 and not of the form * <code>512 + 64j</code>. */ - public void setup(Map attributes) + @Override + public void setup(Map<String,Object> attributes) { // find out the modulus length Integer l = (Integer) attributes.get(MODULUS_LENGTH); @@ -299,6 +301,7 @@ public class DSSKeyPairGenerator XKEY = new BigInteger(1, kb).setBit(159).setBit(0); } + @Override public KeyPair generate() { if (p == null) diff --git a/gnu/java/security/key/dss/DSSKeyPairPKCS8Codec.java b/gnu/java/security/key/dss/DSSKeyPairPKCS8Codec.java index 1806ecf58..e99446636 100644 --- a/gnu/java/security/key/dss/DSSKeyPairPKCS8Codec.java +++ b/gnu/java/security/key/dss/DSSKeyPairPKCS8Codec.java @@ -1,5 +1,5 @@ /* DSSKeyPairPKCS8Codec.java -- PKCS#8 Encoding/Decoding handler - Copyright (C) 2006, 2010 Free Software Foundation, Inc. + Copyright (C) 2006, 2010, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -74,6 +74,7 @@ public class DSSKeyPairPKCS8Codec // implicit 0-arguments constructor + @Override public int getFormatID() { return PKCS8_FORMAT; @@ -82,6 +83,7 @@ public class DSSKeyPairPKCS8Codec /** * @throws InvalidParameterException ALWAYS. */ + @Override public byte[] encodePublicKey(PublicKey key) { throw new InvalidParameterException("Wrong format for public keys"); @@ -115,6 +117,7 @@ public class DSSKeyPairPKCS8Codec * @throw InvalidParameterException if an error occurs during the marshalling * process. */ + @Override public byte[] encodePrivateKey(PrivateKey key) { if (! (key instanceof DSSPrivateKey)) @@ -130,13 +133,13 @@ public class DSSKeyPairPKCS8Codec BigInteger g = pk.getParams().getG(); BigInteger x = pk.getX(); - ArrayList params = new ArrayList(3); + ArrayList<DERValue> params = new ArrayList<DERValue>(3); params.add(new DERValue(DER.INTEGER, p)); params.add(new DERValue(DER.INTEGER, q)); params.add(new DERValue(DER.INTEGER, g)); DERValue derParams = new DERValue(DER.CONSTRUCTED | DER.SEQUENCE, params); - ArrayList algorithmID = new ArrayList(2); + ArrayList<DERValue> algorithmID = new ArrayList<DERValue>(2); algorithmID.add(derOID); algorithmID.add(derParams); DERValue derAlgorithmID = new DERValue(DER.CONSTRUCTED | DER.SEQUENCE, @@ -146,7 +149,7 @@ public class DSSKeyPairPKCS8Codec DERValue derX = new DERValue(DER.INTEGER, x); DERValue derPrivateKey = new DERValue(DER.OCTET_STRING, derX.getEncoded()); - ArrayList pki = new ArrayList(3); + ArrayList<DERValue> pki = new ArrayList<DERValue>(3); pki.add(derVersion); pki.add(derAlgorithmID); pki.add(derPrivateKey); @@ -171,6 +174,7 @@ public class DSSKeyPairPKCS8Codec /** * @throws InvalidParameterException ALWAYS. */ + @Override public PublicKey decodePublicKey(byte[] input) { throw new InvalidParameterException("Wrong format for public keys"); @@ -184,6 +188,7 @@ public class DSSKeyPairPKCS8Codec * @throw InvalidParameterException if an exception occurs during the * unmarshalling process. */ + @Override public PrivateKey decodePrivateKey(byte[] input) { if (Configuration.DEBUG) diff --git a/gnu/java/security/key/dss/DSSKeyPairX509Codec.java b/gnu/java/security/key/dss/DSSKeyPairX509Codec.java index 8c26910f1..678924851 100644 --- a/gnu/java/security/key/dss/DSSKeyPairX509Codec.java +++ b/gnu/java/security/key/dss/DSSKeyPairX509Codec.java @@ -1,5 +1,5 @@ /* DSSKeyPairX509Codec.java -- X.509 Encoding/Decoding handler - Copyright (C) 2006 Free Software Foundation, Inc. + Copyright (C) 2006, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -137,14 +137,14 @@ public class DSSKeyPairX509Codec DERValue derQ = new DERValue(DER.INTEGER, q); DERValue derG = new DERValue(DER.INTEGER, g); - ArrayList params = new ArrayList(3); + ArrayList<DERValue> params = new ArrayList<DERValue>(3); params.add(derP); params.add(derQ); params.add(derG); derParams = new DERValue(DER.CONSTRUCTED | DER.SEQUENCE, params); } - ArrayList algorithmID = new ArrayList(2); + ArrayList<DERValue> algorithmID = new ArrayList<DERValue>(2); algorithmID.add(derOID); algorithmID.add(derParams); DERValue derAlgorithmID = new DERValue(DER.CONSTRUCTED | DER.SEQUENCE, @@ -155,7 +155,7 @@ public class DSSKeyPairX509Codec byte[] yBytes = derDSAPublicKey.getEncoded(); DERValue derSPK = new DERValue(DER.BIT_STRING, new BitString(yBytes)); - ArrayList spki = new ArrayList(2); + ArrayList<DERValue> spki = new ArrayList<DERValue>(2); spki.add(derAlgorithmID); spki.add(derSPK); DERValue derSPKI = new DERValue(DER.CONSTRUCTED | DER.SEQUENCE, spki); diff --git a/gnu/java/security/key/dss/DSSPrivateKey.java b/gnu/java/security/key/dss/DSSPrivateKey.java index de3668c01..4b3ccc72d 100644 --- a/gnu/java/security/key/dss/DSSPrivateKey.java +++ b/gnu/java/security/key/dss/DSSPrivateKey.java @@ -1,5 +1,5 @@ /* DSSPrivateKey.java -- - Copyright 2001, 2002, 2003, 2006 Free Software Foundation, Inc. + Copyright 2001, 2002, 2003, 2006, 2014 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -59,6 +59,8 @@ public class DSSPrivateKey extends DSSKey implements PrivateKey, DSAPrivateKey { + private static final long serialVersionUID = -4273348785094844114L; + /** * A randomly or pseudorandomly generated integer with <code>0 < x < * q</code>. diff --git a/gnu/java/security/key/dss/DSSPublicKey.java b/gnu/java/security/key/dss/DSSPublicKey.java index d7c1afe15..0f4c08e78 100644 --- a/gnu/java/security/key/dss/DSSPublicKey.java +++ b/gnu/java/security/key/dss/DSSPublicKey.java @@ -1,5 +1,5 @@ /* DSSPublicKey.java -- - Copyright 2001, 2002, 2003, 2006 Free Software Foundation, Inc. + Copyright 2001, 2002, 2003, 2006, 2014 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -58,6 +58,8 @@ public class DSSPublicKey extends DSSKey implements PublicKey, DSAPublicKey { + private static final long serialVersionUID = 4662188565230532792L; + /** * <code>y = g<sup>x</sup> mod p</code> where <code>x</code> is the * private part of the DSA key. diff --git a/gnu/java/security/key/rsa/GnuRSAKey.java b/gnu/java/security/key/rsa/GnuRSAKey.java index 38530ee4c..f8d89af38 100644 --- a/gnu/java/security/key/rsa/GnuRSAKey.java +++ b/gnu/java/security/key/rsa/GnuRSAKey.java @@ -1,5 +1,5 @@ /* GnuRSAKey.java -- - Copyright 2001, 2002, 2003, 2006 Free Software Foundation, Inc. + Copyright 2001, 2002, 2003, 2006, 2014 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -55,6 +55,8 @@ import java.security.interfaces.RSAKey; public abstract class GnuRSAKey implements Key, RSAKey { + private static final long serialVersionUID = -7321530024326974635L; + /** The public modulus of an RSA key pair. */ private final BigInteger n; diff --git a/gnu/java/security/key/rsa/GnuRSAPrivateKey.java b/gnu/java/security/key/rsa/GnuRSAPrivateKey.java index 39f91cbe4..379650a81 100644 --- a/gnu/java/security/key/rsa/GnuRSAPrivateKey.java +++ b/gnu/java/security/key/rsa/GnuRSAPrivateKey.java @@ -1,5 +1,5 @@ /* GnuRSAPrivateKey.java -- - Copyright 2001, 2002, 2003, 2006 Free Software Foundation, Inc. + Copyright 2001, 2002, 2003, 2006, 2014 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -67,6 +67,8 @@ public class GnuRSAPrivateKey extends GnuRSAKey implements PrivateKey, RSAPrivateCrtKey { + private static final long serialVersionUID = -2208207842306185913L; + /** The first prime divisor of the modulus. */ private final BigInteger p; diff --git a/gnu/java/security/key/rsa/GnuRSAPublicKey.java b/gnu/java/security/key/rsa/GnuRSAPublicKey.java index 0bad92881..b8e1ea5b1 100644 --- a/gnu/java/security/key/rsa/GnuRSAPublicKey.java +++ b/gnu/java/security/key/rsa/GnuRSAPublicKey.java @@ -1,5 +1,5 @@ /* GnuRSAPublicKey.java -- - Copyright 2001, 2002, 2003, 2006 Free Software Foundation, Inc. + Copyright 2001, 2002, 2003, 2006, 2014 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -65,6 +65,8 @@ public class GnuRSAPublicKey extends GnuRSAKey implements PublicKey, RSAPublicKey { + private static final long serialVersionUID = -1206860366945100193L; + /** String representation of this key. Cached for speed. */ private transient String str; diff --git a/gnu/java/security/key/rsa/RSAKeyPairGenerator.java b/gnu/java/security/key/rsa/RSAKeyPairGenerator.java index 99c313944..a7fc21efe 100644 --- a/gnu/java/security/key/rsa/RSAKeyPairGenerator.java +++ b/gnu/java/security/key/rsa/RSAKeyPairGenerator.java @@ -1,5 +1,5 @@ /* RSAKeyPairGenerator.java -- - Copyright 2001, 2002, 2003, 2006, 2010 Free Software Foundation, Inc. + Copyright 2001, 2002, 2003, 2006, 2010, 2014 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -129,6 +129,7 @@ public class RSAKeyPairGenerator // implicit 0-arguments constructor + @Override public String name() { return Registry.RSA_KPG; @@ -141,7 +142,8 @@ public class RSAKeyPairGenerator * @exception IllegalArgumentException if the designated MODULUS_LENGTH value * is less than 1024. */ - public void setup(Map attributes) + @Override + public void setup(Map<String,Object> attributes) { if (Configuration.DEBUG) log.entering(this.getClass().getName(), "setup", attributes); @@ -179,6 +181,7 @@ public class RSAKeyPairGenerator * * @return an RSA keypair. */ + @Override public KeyPair generate() { if (Configuration.DEBUG) diff --git a/gnu/java/security/key/rsa/RSAKeyPairPKCS8Codec.java b/gnu/java/security/key/rsa/RSAKeyPairPKCS8Codec.java index b07ed667c..ec9874d80 100644 --- a/gnu/java/security/key/rsa/RSAKeyPairPKCS8Codec.java +++ b/gnu/java/security/key/rsa/RSAKeyPairPKCS8Codec.java @@ -1,5 +1,5 @@ /* RSAKeyPairPKCS8Codec.java -- PKCS#8 Encoding/Decoding handler - Copyright (C) 2006, 2010 Free Software Foundation, Inc. + Copyright (C) 2006, 2010, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -145,7 +145,7 @@ public class RSAKeyPairPKCS8Codec DERValue derOID = new DERValue(DER.OBJECT_IDENTIFIER, RSA_ALG_OID); - ArrayList algorithmID = new ArrayList(2); + ArrayList<DERValue> algorithmID = new ArrayList<DERValue>(2); algorithmID.add(derOID); algorithmID.add(new DERValue(DER.NULL, null)); DERValue derAlgorithmID = new DERValue(DER.CONSTRUCTED | DER.SEQUENCE, @@ -161,7 +161,7 @@ public class RSAKeyPairPKCS8Codec DERValue derDQ = new DERValue(DER.INTEGER, dQ); DERValue derQInv = new DERValue(DER.INTEGER, qInv); - ArrayList rsaPrivateKey = new ArrayList(); + ArrayList<DERValue> rsaPrivateKey = new ArrayList<DERValue>(); rsaPrivateKey.add(derRSAVersion); rsaPrivateKey.add(derN); rsaPrivateKey.add(derE); @@ -176,7 +176,7 @@ public class RSAKeyPairPKCS8Codec byte[] pkBytes = derRSAPrivateKey.getEncoded(); DERValue derPrivateKey = new DERValue(DER.OCTET_STRING, pkBytes); - ArrayList pki = new ArrayList(3); + ArrayList<DERValue> pki = new ArrayList<DERValue>(3); pki.add(derVersion); pki.add(derAlgorithmID); pki.add(derPrivateKey); diff --git a/gnu/java/security/key/rsa/RSAKeyPairX509Codec.java b/gnu/java/security/key/rsa/RSAKeyPairX509Codec.java index 36fd75c98..3eed1ef25 100644 --- a/gnu/java/security/key/rsa/RSAKeyPairX509Codec.java +++ b/gnu/java/security/key/rsa/RSAKeyPairX509Codec.java @@ -1,5 +1,5 @@ /* RSAKeyPairX509Codec.java -- X.509 Encoding/Decoding handler - Copyright (C) 2006, 2010 Free Software Foundation, Inc. + Copyright (C) 2006, 2010, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -72,6 +72,7 @@ public class RSAKeyPairX509Codec // implicit 0-arguments constructor + @Override public int getFormatID() { return X509_FORMAT; @@ -115,6 +116,7 @@ public class RSAKeyPairX509Codec * of {@link GnuRSAPublicKey} or if an exception occurs during the * marshalling process. */ + @Override public byte[] encodePublicKey(PublicKey key) { if (Configuration.DEBUG) @@ -131,13 +133,13 @@ public class RSAKeyPairX509Codec DERValue derN = new DERValue(DER.INTEGER, n); DERValue derE = new DERValue(DER.INTEGER, e); - ArrayList algorithmID = new ArrayList(2); + ArrayList<DERValue> algorithmID = new ArrayList<DERValue>(2); algorithmID.add(derOID); algorithmID.add(new DERValue(DER.NULL, null)); DERValue derAlgorithmID = new DERValue(DER.CONSTRUCTED | DER.SEQUENCE, algorithmID); - ArrayList publicKey = new ArrayList(2); + ArrayList<DERValue> publicKey = new ArrayList<DERValue>(2); publicKey.add(derN); publicKey.add(derE); DERValue derPublicKey = new DERValue(DER.CONSTRUCTED | DER.SEQUENCE, @@ -145,7 +147,7 @@ public class RSAKeyPairX509Codec byte[] spkBytes = derPublicKey.getEncoded(); DERValue derSPK = new DERValue(DER.BIT_STRING, new BitString(spkBytes)); - ArrayList spki = new ArrayList(2); + ArrayList<DERValue> spki = new ArrayList<DERValue>(2); spki.add(derAlgorithmID); spki.add(derSPK); DERValue derSPKI = new DERValue(DER.CONSTRUCTED | DER.SEQUENCE, spki); @@ -171,6 +173,7 @@ public class RSAKeyPairX509Codec /** * @throws InvalidParameterException ALWAYS. */ + @Override public byte[] encodePrivateKey(PrivateKey key) { throw new InvalidParameterException("Wrong format for private keys"); @@ -184,6 +187,7 @@ public class RSAKeyPairX509Codec * @throw InvalidParameterException if an exception occurs during the * unmarshalling process. */ + @Override public PublicKey decodePublicKey(byte[] input) { if (Configuration.DEBUG) @@ -245,6 +249,7 @@ public class RSAKeyPairX509Codec /** * @throws InvalidParameterException ALWAYS. */ + @Override public PrivateKey decodePrivateKey(byte[] input) { throw new InvalidParameterException("Wrong format for private keys"); diff --git a/gnu/java/security/pkcs/PKCS7SignedData.java b/gnu/java/security/pkcs/PKCS7SignedData.java index e479d2e8c..eccd69141 100644 --- a/gnu/java/security/pkcs/PKCS7SignedData.java +++ b/gnu/java/security/pkcs/PKCS7SignedData.java @@ -1,5 +1,5 @@ /* PKCS7SignedData.java -- reader/writer for PKCS#7 signedData objects - Copyright (C) 2004, 2005, 2006, 2010 Free Software Foundation, Inc. + Copyright (C) 2004, 2005, 2006, 2010, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -53,6 +53,8 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.lang.reflect.Method; +import java.lang.reflect.InvocationTargetException; import java.math.BigInteger; import java.security.cert.CRL; import java.security.cert.CRLException; @@ -84,12 +86,12 @@ public class PKCS7SignedData public static final OID PKCS7_SIGNED_DATA = new OID("1.2.840.113549.1.7.2"); private BigInteger version; - private Set digestAlgorithms; + private Set<DERValue> digestAlgorithms; private OID contentType; private byte[] content; private Certificate[] certificates; private CRL[] crls; - private Set signerInfos; + private Set<SignerInfo> signerInfos; public PKCS7SignedData(InputStream in) throws CRLException, CertificateException, IOException @@ -183,7 +185,7 @@ public class PKCS7SignedData if (Configuration.DEBUG) log.fine(" Version: " + version); - digestAlgorithms = new HashSet(); + digestAlgorithms = new HashSet<DERValue>(); val = ber.read(); if (!val.isConstructed()) throw new BEREncodingException("malformed DigestAlgorithmIdentifiers"); @@ -200,20 +202,17 @@ public class PKCS7SignedData log.fine(" AlgorithmIdentifier: " + val2); count += val2.getEncodedLength(); val2 = ber.read(); - if (val2.getTag() != BER.OBJECT_IDENTIFIER) + if (val2.getTag() != DER.OBJECT_IDENTIFIER) throw new BEREncodingException("malformed AlgorithmIdentifier"); if (Configuration.DEBUG) log.fine(" digestAlgorithmIdentifiers OID: " + val2.getValue()); - List algId = new ArrayList(2); - algId.add(val2.getValue()); + List<DERValue> algId = new ArrayList<DERValue>(2); + algId.add(val2); val2 = ber.read(); if (val2 != BER.END_OF_SEQUENCE) { count += val2.getEncodedLength(); - if (val2.getTag() == BER.NULL) - algId.add(null); - else - algId.add(val2.getEncoded()); + algId.add(val2); if (val2.isConstructed()) ber.skip(val2.getLength()); @@ -222,15 +221,15 @@ public class PKCS7SignedData val2 = ber.read(); } else - algId.add(null); + algId.add(new DERValue(DER.NULL, null)); if (Configuration.DEBUG) { log.fine(" digestAlgorithmIdentifiers params: "); - log.fine(Util.dumpString((byte[]) algId.get(1), + log.fine(Util.dumpString(algId.get(1).getEncoded(), " digestAlgorithmIdentifiers params: ")); } - digestAlgorithms.add(algId); + digestAlgorithms.add(new DERValue(DER.CONSTRUCTED | DER.SEQUENCE, algId)); } val = ber.read(); @@ -270,7 +269,7 @@ public class PKCS7SignedData log.fine(" ExtendedCertificatesAndCertificates: " + val); count = 0; val2 = ber.read(); - List certs = new LinkedList(); + List<Certificate> certs = new LinkedList<Certificate>(); while (val2 != BER.END_OF_SEQUENCE && (val.getLength() > 0 && val.getLength() > count)) { @@ -284,7 +283,7 @@ public class PKCS7SignedData if (BERValue.isIndefinite(val) || val.getLength() > count) val2 = ber.read(); } - certificates = (Certificate[]) certs.toArray(new Certificate[certs.size()]); + certificates = certs.toArray(new Certificate[certs.size()]); val = ber.read(); } @@ -296,7 +295,7 @@ public class PKCS7SignedData log.fine(" CertificateRevocationLists: " + val); count = 0; val2 = ber.read(); - List crls = new LinkedList(); + List<CRL> crls = new LinkedList<CRL>(); while (val2 != BER.END_OF_SEQUENCE && (val.getLength() > 0 && val.getLength() > count)) { @@ -309,11 +308,11 @@ public class PKCS7SignedData if (BERValue.isIndefinite(val) || val.getLength() > count) val2 = ber.read(); } - this.crls = (CRL[]) crls.toArray(new CRL[crls.size()]); + this.crls = crls.toArray(new CRL[crls.size()]); val = ber.read(); } - signerInfos = new HashSet(); + signerInfos = new HashSet<SignerInfo>(); if (!val.isConstructed()) throw new BEREncodingException("malformed SignerInfos"); if (Configuration.DEBUG) @@ -349,9 +348,9 @@ public class PKCS7SignedData * the data referenced by this <code>PKCS7SignedData</code> * instance. */ - public PKCS7SignedData(Set digestAlgorithms, PKCS7Data data, + public PKCS7SignedData(Set<DERValue> digestAlgorithms, PKCS7Data data, Certificate[] certificates, X509CRL[] crls, - Set signerInfos) + Set<SignerInfo> signerInfos) { super(); @@ -385,16 +384,35 @@ public class PKCS7SignedData return (content != null ? (byte[]) content.clone() : null); } - public Set getDigestAlgorithms() + public Set<DERValue> getDigestAlgorithms() { - // FIXME copy contents too, they are mutable!!! - return Collections.unmodifiableSet(digestAlgorithms); + Set<DERValue> daClone = new HashSet<DERValue>(digestAlgorithms.size()); + for (DERValue dv : digestAlgorithms) + { + Object clone = null; + Object obj = dv.getValue(); + if (obj != null && obj instanceof Cloneable) + { + try + { + Method m = obj.getClass().getDeclaredMethod("clone"); + m.setAccessible(true); + clone = m.invoke(obj); + } + catch (NoSuchMethodException e) { /* Impossible */ } + catch (IllegalAccessException e) { /* Ignored */ } + catch (InvocationTargetException e) { /* Ignored */ } + } + if (clone == null) clone = obj; + daClone.add(new DERValue(dv.getTag(), dv.getLength(), clone, dv.getEncoded())); + } + return Collections.unmodifiableSet(daClone); } - public Set getSignerInfos() + public Set<SignerInfo> getSignerInfos() { - Set copy = new HashSet(); - for (Iterator it = signerInfos.iterator(); it.hasNext(); ) + Set<SignerInfo> copy = new HashSet<SignerInfo>(); + for (Iterator<SignerInfo> it = signerInfos.iterator(); it.hasNext(); ) copy.add(it.next()); return Collections.unmodifiableSet(copy); } @@ -420,7 +438,7 @@ public class PKCS7SignedData DERValue derContentType = new DERValue(DER.OBJECT_IDENTIFIER, PKCS7Data.PKCS7_DATA); - ArrayList contentInfo = new ArrayList(2); + ArrayList<Object> contentInfo = new ArrayList<Object>(2); contentInfo.add(derContentType); if (content == null) contentInfo.add(new DERValue(DER.NULL, null)); @@ -453,9 +471,8 @@ public class PKCS7SignedData } baos.reset(); - for (Iterator it = signerInfos.iterator(); it.hasNext();) + for (SignerInfo signerInfo : signerInfos) { - SignerInfo signerInfo = (SignerInfo) it.next(); signerInfo.encode(baos); } baos.flush(); @@ -463,7 +480,7 @@ public class PKCS7SignedData DERValue derSignerInfos = new DERValue(DER.CONSTRUCTED | DER.SET, b3.length, b3, null); - ArrayList signedData = new ArrayList(6); + ArrayList<DERValue> signedData = new ArrayList<DERValue>(6); signedData.add(derVersion); signedData.add(derDigestAlgorithms); signedData.add(derContentInfo); @@ -475,7 +492,7 @@ public class PKCS7SignedData DERValue derSignedData = new DERValue(DER.CONSTRUCTED | DER.SEQUENCE, signedData); // now the outer contents - ArrayList outer = new ArrayList(3); + ArrayList<DERValue> outer = new ArrayList<DERValue>(3); outer.add(new DERValue(DER.OBJECT_IDENTIFIER, PKCS7_SIGNED_DATA)); outer.add(new DERValue(DER.CONTEXT | 0, null)); outer.add(derSignedData); diff --git a/gnu/java/security/pkcs/SignerInfo.java b/gnu/java/security/pkcs/SignerInfo.java index 07ce4d71b..155eaaefa 100644 --- a/gnu/java/security/pkcs/SignerInfo.java +++ b/gnu/java/security/pkcs/SignerInfo.java @@ -1,5 +1,5 @@ /* SignerInfo.java -- a SignerInfo object, from PKCS #7 - Copyright (C) 2004, 2005, 2010 Free Software Foundation, Inc. + Copyright (C) 2004, 2005, 2010. 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -144,7 +144,6 @@ public class SignerInfo if (Configuration.DEBUG) log.fine(" DigestAlgorithmIdentifier: " + val); - int count = 0; DERValue val2 = ber.read(); if (val2.getTag() != BER.OBJECT_IDENTIFIER) throw new BEREncodingException("malformed AlgorithmIdentifier"); @@ -205,7 +204,6 @@ public class SignerInfo throw new BEREncodingException("malformed DigestEncryptionAlgorithmIdentifier"); if (Configuration.DEBUG) log.fine(" DigestEncryptionAlgorithmIdentifier: " + val); - count = 0; val2 = ber.read(); if (val2.getTag() != BER.OBJECT_IDENTIFIER) throw new BEREncodingException("malformed AlgorithmIdentifier"); @@ -390,7 +388,7 @@ public class SignerInfo DERValue derDigestAlgorithmOID = new DERValue(DER.OBJECT_IDENTIFIER, digestAlgorithmId); - ArrayList digestAlgorithmIdentifier = new ArrayList(1); + ArrayList<DERValue> digestAlgorithmIdentifier = new ArrayList<DERValue>(1); digestAlgorithmIdentifier.add(derDigestAlgorithmOID); DERValue derDigestAlgorithmIdentifier = new DERValue(DER.CONSTRUCTED | DER.SEQUENCE, digestAlgorithmIdentifier); @@ -404,7 +402,7 @@ public class SignerInfo DERValue derDigestEncryptionAlgorithmOID = new DERValue(DER.OBJECT_IDENTIFIER, digestEncryptionAlgorithmId); - ArrayList digestEncryptionAlgorithmIdentifier = new ArrayList(1); + ArrayList<DERValue> digestEncryptionAlgorithmIdentifier = new ArrayList<DERValue>(1); digestEncryptionAlgorithmIdentifier.add(derDigestEncryptionAlgorithmOID); DERValue derDigestEncryptionAlgorithmIdentifier = new DERValue(DER.CONSTRUCTED | DER.SEQUENCE, digestEncryptionAlgorithmIdentifier); @@ -418,12 +416,14 @@ public class SignerInfo derUnauthenticatedAttributes = new DERValue(DER.CONSTRUCTED | DER.SET, unauthenticatedAttributes); - ArrayList signerInfo = new ArrayList(5); + ArrayList<DERValue> signerInfo = new ArrayList<DERValue>(7); signerInfo.add(derVersion); signerInfo.add(derIssuerAndSerialNumber); signerInfo.add(derDigestAlgorithmIdentifier); + signerInfo.add(derAuthenticatedAttributes); signerInfo.add(derDigestEncryptionAlgorithmIdentifier); signerInfo.add(derEncryptedDigest); + signerInfo.add(derUnauthenticatedAttributes); DERValue derSignerInfo = new DERValue(DER.CONSTRUCTED | DER.SEQUENCE, signerInfo); DERWriter.write(out, derSignerInfo); diff --git a/gnu/java/security/prng/BasePRNG.java b/gnu/java/security/prng/BasePRNG.java index eb5ada71c..35b6c441a 100644 --- a/gnu/java/security/prng/BasePRNG.java +++ b/gnu/java/security/prng/BasePRNG.java @@ -1,5 +1,5 @@ /* BasePRNG.java -- - Copyright (C) 2001, 2002, 2006 Free Software Foundation, Inc. + Copyright (C) 2001, 2002, 2006, 2014 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -72,12 +72,14 @@ public abstract class BasePRNG buffer = new byte[0]; } + @Override public String name() { return name; } - public void init(Map attributes) + @Override + public void init(Map<String,Object> attributes) { this.setup(attributes); @@ -85,6 +87,7 @@ public abstract class BasePRNG initialised = true; } + @Override public byte nextByte() throws IllegalStateException, LimitReachedException { if (! initialised) @@ -99,6 +102,7 @@ public abstract class BasePRNG nextBytes(out, 0, out.length); } + @Override public void nextBytes(byte[] out, int offset, int length) throws IllegalStateException, LimitReachedException { @@ -132,16 +136,19 @@ public abstract class BasePRNG } } + @Override public void addRandomByte(byte b) { throw new UnsupportedOperationException("random state is non-modifiable"); } + @Override public void addRandomBytes(byte[] buffer) { addRandomBytes(buffer, 0, buffer.length); } + @Override public void addRandomBytes(byte[] buffer, int offset, int length) { throw new UnsupportedOperationException("random state is non-modifiable"); @@ -163,6 +170,7 @@ public abstract class BasePRNG return buffer[ndx++]; } + @Override public Object clone() throws CloneNotSupportedException { BasePRNG result = (BasePRNG) super.clone(); @@ -172,7 +180,7 @@ public abstract class BasePRNG return result; } - public abstract void setup(Map attributes); + public abstract void setup(Map<String,Object> attributes); public abstract void fillBlock() throws LimitReachedException; } diff --git a/gnu/java/security/prng/IRandom.java b/gnu/java/security/prng/IRandom.java index eb1495dd8..418abaf33 100644 --- a/gnu/java/security/prng/IRandom.java +++ b/gnu/java/security/prng/IRandom.java @@ -1,5 +1,5 @@ /* IRandom.java -- - Copyright (C) 2001, 2002, 2003, 2006 Free Software Foundation, Inc. + Copyright (C) 2001, 2002, 2003, 2006, 2014 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -93,7 +93,7 @@ public interface IRandom * @exception IllegalArgumentException if at least one of the defined name/ * value pairs contains invalid data. */ - void init(Map attributes); + void init(Map<String,Object> attributes); /** * Returns the next 8 bits of random data generated from this instance. diff --git a/gnu/java/security/prng/LimitReachedException.java b/gnu/java/security/prng/LimitReachedException.java index 028c74553..97e7d6419 100644 --- a/gnu/java/security/prng/LimitReachedException.java +++ b/gnu/java/security/prng/LimitReachedException.java @@ -1,5 +1,5 @@ /* LimitReachedException.java -- - Copyright (C) 2001, 2002, 2006 Free Software Foundation, Inc. + Copyright (C) 2001, 2002, 2006, 2014 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -45,6 +45,8 @@ package gnu.java.security.prng; public class LimitReachedException extends Exception { + private static final long serialVersionUID = 6859108040075545065L; + public LimitReachedException() { super(); diff --git a/gnu/java/security/prng/MDGenerator.java b/gnu/java/security/prng/MDGenerator.java index b110486f4..66c1bd85a 100644 --- a/gnu/java/security/prng/MDGenerator.java +++ b/gnu/java/security/prng/MDGenerator.java @@ -1,5 +1,5 @@ /* MDGenerator.java -- - Copyright (C) 2001, 2002, 2006 Free Software Foundation, Inc. + Copyright (C) 2001, 2002, 2006, 2014 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -71,7 +71,8 @@ public class MDGenerator super(Registry.MD_PRNG); } - public void setup(Map attributes) + @Override + public void setup(Map<String,Object> attributes) { // find out which hash to use String underlyingMD = (String) attributes.get(MD_NAME); @@ -95,6 +96,7 @@ public class MDGenerator md.update(seed, 0, seed.length); } + @Override public void fillBlock() throws LimitReachedException { IMessageDigest mdc = (IMessageDigest) md.clone(); @@ -102,6 +104,7 @@ public class MDGenerator md.update(buffer, 0, buffer.length); } + @Override public void addRandomByte(final byte b) { if (md == null) @@ -109,6 +112,7 @@ public class MDGenerator md.update(b); } + @Override public void addRandomBytes(final byte[] buf, final int off, final int len) { if (md == null) @@ -116,6 +120,7 @@ public class MDGenerator md.update(buf, off, len); } + @Override public Object clone() throws CloneNotSupportedException { MDGenerator result = (MDGenerator) super.clone(); diff --git a/gnu/java/security/prng/PRNGFactory.java b/gnu/java/security/prng/PRNGFactory.java index b57d7c7bb..550cc1e95 100644 --- a/gnu/java/security/prng/PRNGFactory.java +++ b/gnu/java/security/prng/PRNGFactory.java @@ -1,5 +1,5 @@ /* PRNGFactory.java -- - Copyright (C) 2001, 2002, 2003, 2006 Free Software Foundation, Inc. + Copyright (C) 2001, 2002, 2003, 2006, 2014 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -83,9 +83,9 @@ public class PRNGFactory * @return a {@link Set} of pseudo-random number generator algorithm names * (Strings). */ - public static final Set getNames() + public static final Set<String> getNames() { - HashSet hs = new HashSet(); + HashSet<String> hs = new HashSet<String>(); hs.add(MD_PRNG); return Collections.unmodifiableSet(hs); } diff --git a/gnu/java/security/prng/RandomEvent.java b/gnu/java/security/prng/RandomEvent.java index fc4607a8a..eea21b576 100644 --- a/gnu/java/security/prng/RandomEvent.java +++ b/gnu/java/security/prng/RandomEvent.java @@ -1,5 +1,5 @@ /* RandomEvent.java -- an event with random data. - Copyright (C) 2004, 2006 Free Software Foundation, Inc. + Copyright (C) 2004, 2006, 2014 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -46,6 +46,8 @@ import java.util.EventObject; public class RandomEvent extends EventObject { + private static final long serialVersionUID = 2750214083590538430L; + private final byte sourceNumber; private final byte poolNumber; diff --git a/gnu/java/security/provider/CollectionCertStoreImpl.java b/gnu/java/security/provider/CollectionCertStoreImpl.java index 4bf3d5434..474aaf89e 100644 --- a/gnu/java/security/provider/CollectionCertStoreImpl.java +++ b/gnu/java/security/provider/CollectionCertStoreImpl.java @@ -1,5 +1,5 @@ /* CollectionCertStore.java -- Collection-based cert store. - Copyright (C) 2004 Free Software Foundation, Inc. + Copyright (C) 2004, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -57,7 +57,7 @@ public final class CollectionCertStoreImpl extends CertStoreSpi // Fields. // ------------------------------------------------------------------------- - private final Collection store; + private final Collection<?> store; // Constructors. // ------------------------------------------------------------------------- @@ -74,28 +74,30 @@ public final class CollectionCertStoreImpl extends CertStoreSpi // Instance methods. // ------------------------------------------------------------------------- - public Collection engineGetCertificates(CertSelector selector) + @Override + public Collection<? extends Certificate> engineGetCertificates(CertSelector selector) throws CertStoreException { - LinkedList result = new LinkedList(); - for (Iterator it = store.iterator(); it.hasNext(); ) + LinkedList<Certificate> result = new LinkedList<Certificate>(); + for (Iterator<?> it = store.iterator(); it.hasNext(); ) { Object o = it.next(); if ((o instanceof Certificate) && selector.match((Certificate) o)) - result.add(o); + result.add((Certificate) o); } return result; } - public Collection engineGetCRLs(CRLSelector selector) + @Override + public Collection<? extends CRL> engineGetCRLs(CRLSelector selector) throws CertStoreException { - LinkedList result = new LinkedList(); - for (Iterator it = store.iterator(); it.hasNext(); ) + LinkedList<CRL> result = new LinkedList<CRL>(); + for (Iterator<?> it = store.iterator(); it.hasNext(); ) { Object o = it.next(); if ((o instanceof CRL) && selector.match((CRL) o)) - result.add(o); + result.add((CRL) o); } return result; } diff --git a/gnu/java/security/provider/Gnu.java b/gnu/java/security/provider/Gnu.java index 62bb0a29e..1410d9cbf 100644 --- a/gnu/java/security/provider/Gnu.java +++ b/gnu/java/security/provider/Gnu.java @@ -1,5 +1,5 @@ /* Gnu.java --- Gnu provider main class - Copyright (C) 1999, 2002, 2003, 2005 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2003, 2005, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -45,6 +45,9 @@ import java.security.Provider; public final class Gnu extends Provider { + + private static final long serialVersionUID = -7055664012204311089L; + public Gnu() { super("GNU", 1.0, @@ -52,9 +55,9 @@ public final class Gnu + "Certificates and CRLs, PKIX certificate path validators, " + "Collection cert stores, Diffie-Hellman key agreement and " + "key pair generator"); - AccessController.doPrivileged (new PrivilegedAction() + AccessController.doPrivileged (new PrivilegedAction<Void>() { - public Object run() + public Void run() { // Note that all implementation class names are referenced by using // Class.getName(). That way when we staticly link the Gnu provider diff --git a/gnu/java/security/provider/PKIXCertPathValidatorImpl.java b/gnu/java/security/provider/PKIXCertPathValidatorImpl.java index e0d318777..7d6169175 100644 --- a/gnu/java/security/provider/PKIXCertPathValidatorImpl.java +++ b/gnu/java/security/provider/PKIXCertPathValidatorImpl.java @@ -1,5 +1,5 @@ /* PKIXCertPathValidatorImpl.java -- PKIX certificate path validator. - Copyright (C) 2004, 2005, 2006, 2010 Free Software Foundation, Inc. + Copyright (C) 2004, 2005, 2006, 2010, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -57,6 +57,7 @@ import java.security.InvalidAlgorithmParameterException; import java.security.InvalidKeyException; import java.security.PublicKey; import java.security.cert.CRL; +import java.security.cert.Certificate; import java.security.cert.CertPath; import java.security.cert.CertPathParameters; import java.security.cert.CertPathValidatorException; @@ -68,6 +69,8 @@ import java.security.cert.CertificateException; import java.security.cert.PKIXCertPathChecker; import java.security.cert.PKIXCertPathValidatorResult; import java.security.cert.PKIXParameters; +import java.security.cert.PolicyNode; +import java.security.cert.PolicyQualifierInfo; import java.security.cert.TrustAnchor; import java.security.cert.X509CRL; import java.security.cert.X509Certificate; @@ -126,7 +129,7 @@ public class PKIXCertPathValidatorImpl // Because this is the X.509 algorithm, we also check if all // cerificates are of type X509Certificate. PolicyNodeImpl rootNode = new PolicyNodeImpl(); - Set initPolicies = ((PKIXParameters) params).getInitialPolicies(); + Set<String> initPolicies = ((PKIXParameters) params).getInitialPolicies(); rootNode.setValidPolicy(ANY_POLICY); rootNode.setCritical(false); rootNode.setDepth(0); @@ -134,8 +137,8 @@ public class PKIXCertPathValidatorImpl rootNode.addAllExpectedPolicies(initPolicies); else rootNode.addExpectedPolicy(ANY_POLICY); - List checks = ((PKIXParameters) params).getCertPathCheckers(); - List l = path.getCertificates(); + List<PKIXCertPathChecker> checks = ((PKIXParameters) params).getCertPathCheckers(); + List<? extends Certificate> l = path.getCertificates(); if (l == null || l.size() == 0) throw new CertPathValidatorException(); X509Certificate[] p = null; @@ -152,7 +155,7 @@ public class PKIXCertPathValidatorImpl Date now = ((PKIXParameters) params).getDate(); if (now == null) now = new Date(); - LinkedList policyConstraints = new LinkedList(); + LinkedList<int[]> policyConstraints = new LinkedList<int[]>(); for (int i = p.length - 1; i >= 0; i--) { try @@ -163,12 +166,12 @@ public class PKIXCertPathValidatorImpl { throw new CertPathValidatorException(ce.toString()); } - Set uce = getCritExts(p[i]); - for (Iterator check = checks.iterator(); check.hasNext();) + Set<String> uce = getCritExts(p[i]); + for (PKIXCertPathChecker checker : checks) { try { - ((PKIXCertPathChecker) check.next()).check(p[i], uce); + checker.check(p[i], uce); } catch (Exception x) { @@ -259,14 +262,13 @@ public class PKIXCertPathValidatorImpl { throw new CertPathValidatorException("error selecting CRLs"); } - List certStores = ((PKIXParameters) params).getCertStores(); - List crls = new LinkedList(); - for (Iterator it = certStores.iterator(); it.hasNext();) + List<CertStore> certStores = ((PKIXParameters) params).getCertStores(); + List<CRL> crls = new LinkedList<CRL>(); + for (CertStore cs : certStores) { - CertStore cs = (CertStore) it.next(); try { - Collection c = cs.getCRLs(selector); + Collection<? extends CRL> c = cs.getCRLs(selector); crls.addAll(c); } catch (CertStoreException cse) @@ -276,9 +278,8 @@ public class PKIXCertPathValidatorImpl if (crls.isEmpty()) throw new CertPathValidatorException("no CRLs for issuer"); boolean certOk = false; - for (Iterator it = crls.iterator(); it.hasNext();) + for (CRL crl : crls) { - CRL crl = (CRL) it.next(); if (! (crl instanceof X509CRL)) continue; X509CRL xcrl = (X509CRL) crl; @@ -298,10 +299,9 @@ public class PKIXCertPathValidatorImpl // Now ensure that the first certificate in the chain was issued // by a trust anchor. Exception cause = null; - Set anchors = ((PKIXParameters) params).getTrustAnchors(); - for (Iterator i = anchors.iterator(); i.hasNext();) + Set<TrustAnchor> anchors = ((PKIXParameters) params).getTrustAnchors(); + for (TrustAnchor anchor : anchors) { - TrustAnchor anchor = (TrustAnchor) i.next(); X509Certificate anchorCert = null; PublicKey anchorKey = null; if (anchor.getTrustedCert() != null) @@ -335,14 +335,13 @@ public class PKIXCertPathValidatorImpl } else selector.addIssuerName(anchor.getCAName()); - List certStores = ((PKIXParameters) params).getCertStores(); - List crls = new LinkedList(); - for (Iterator it = certStores.iterator(); it.hasNext();) + List<CertStore> certStores = ((PKIXParameters) params).getCertStores(); + List<CRL> crls = new LinkedList<CRL>(); + for (CertStore cs : certStores) { - CertStore cs = (CertStore) it.next(); try { - Collection c = cs.getCRLs(selector); + Collection<? extends CRL> c = cs.getCRLs(selector); crls.addAll(c); } catch (CertStoreException cse) @@ -351,9 +350,8 @@ public class PKIXCertPathValidatorImpl } if (crls.isEmpty()) continue; - for (Iterator it = crls.iterator(); it.hasNext();) + for (CRL crl : crls) { - CRL crl = (CRL) it.next(); if (! (crl instanceof X509CRL)) continue; X509CRL xcrl = (X509CRL) crl; @@ -414,7 +412,7 @@ public class PKIXCertPathValidatorImpl */ private static boolean checkCRL(X509CRL crl, X509Certificate[] path, Date now, X509Certificate pubKeyCert, - PublicKey pubKey, List certStores) + PublicKey pubKey, List<CertStore> certStores) { Date nextUpdate = crl.getNextUpdate(); if (nextUpdate != null && nextUpdate.compareTo(now) < 0) @@ -461,10 +459,10 @@ public class PKIXCertPathValidatorImpl { X509CertSelectorImpl select = new X509CertSelectorImpl(); select.addSubjectName(crl.getIssuerDN()); - List certs = new LinkedList(); - for (Iterator it = certStores.iterator(); it.hasNext();) + List<Certificate> certs = new LinkedList<Certificate>(); + for (Iterator<CertStore> it = certStores.iterator(); it.hasNext();) { - CertStore cs = (CertStore) it.next(); + CertStore cs = it.next(); try { certs.addAll(cs.getCertificates(select)); @@ -473,7 +471,7 @@ public class PKIXCertPathValidatorImpl { } } - for (Iterator it = certs.iterator(); it.hasNext();) + for (Iterator<Certificate> it = certs.iterator(); it.hasNext();) { X509Certificate c = (X509Certificate) it.next(); for (int i = 0; i < path.length; i++) @@ -509,15 +507,15 @@ public class PKIXCertPathValidatorImpl return false; } - private static Set getCritExts(X509Certificate cert) + private static Set<String> getCritExts(X509Certificate cert) { - HashSet s = new HashSet(); + HashSet<String> s = new HashSet<String>(); if (cert instanceof GnuPKIExtension) { - Collection exts = ((GnuPKIExtension) cert).getExtensions(); - for (Iterator it = exts.iterator(); it.hasNext();) + Collection<Extension> exts = + ((GnuPKIExtension) cert).getExtensions(); + for (Extension ext : exts) { - Extension ext = (Extension) it.next(); if (ext.isCritical() && ! ext.isSupported()) s.add(ext.getOid().toString()); } @@ -582,16 +580,16 @@ public class PKIXCertPathValidatorImpl { if (Configuration.DEBUG) log.fine("updatePolicyTree depth == " + depth); - Set nodes = new HashSet(); - LinkedList stack = new LinkedList(); - Iterator current = null; + Set<PolicyNode> nodes = new HashSet<PolicyNode>(); + LinkedList<Iterator<? extends PolicyNode>> stack = new LinkedList<Iterator<? extends PolicyNode>>(); + Iterator<? extends PolicyNode> current = null; stack.addLast(Collections.singleton(root).iterator()); do { - current = (Iterator) stack.removeLast(); + current = stack.removeLast(); while (current.hasNext()) { - PolicyNodeImpl p = (PolicyNodeImpl) current.next(); + PolicyNode p = current.next(); if (Configuration.DEBUG) log.fine("visiting node == " + p); if (p.getDepth() == depth - 1) @@ -613,7 +611,6 @@ public class PKIXCertPathValidatorImpl Extension e = null; CertificatePolicies policies = null; - List qualifierInfos = null; if (cert instanceof GnuPKIExtension) { e = ((GnuPKIExtension) cert).getExtension(CertificatePolicies.ID); @@ -621,25 +618,24 @@ public class PKIXCertPathValidatorImpl policies = (CertificatePolicies) e.getValue(); } - List cp = null; + List<OID> cp = null; if (policies != null) cp = policies.getPolicies(); else - cp = Collections.EMPTY_LIST; + cp = Collections.emptyList(); boolean match = false; if (Configuration.DEBUG) { log.fine("nodes are == " + nodes); log.fine("cert policies are == " + cp); } - for (Iterator it = nodes.iterator(); it.hasNext();) + for (Iterator<PolicyNode> it = nodes.iterator(); it.hasNext();) { PolicyNodeImpl parent = (PolicyNodeImpl) it.next(); if (Configuration.DEBUG) log.fine("adding policies to " + parent); - for (Iterator it2 = cp.iterator(); it2.hasNext();) + for (OID policy : cp) { - OID policy = (OID) it2.next(); if (Configuration.DEBUG) log.fine("trying to add policy == " + policy); if (policy.toString().equals(ANY_POLICY) @@ -665,7 +661,8 @@ public class PKIXCertPathValidatorImpl } if (match && policies != null) { - List qualifiers = policies.getPolicyQualifierInfos(policy); + List<PolicyQualifierInfo> qualifiers = + policies.getPolicyQualifierInfos(policy); if (qualifiers != null) child.addAllPolicyQualifiers(qualifiers); } @@ -675,13 +672,12 @@ public class PKIXCertPathValidatorImpl throw new CertPathValidatorException("policy tree building failed"); } - private boolean checkExplicitPolicy(int depth, List explicitPolicies) + private boolean checkExplicitPolicy(int depth, List<int[]> explicitPolicies) { if (Configuration.DEBUG) log.fine("checkExplicitPolicy depth=" + depth); - for (Iterator it = explicitPolicies.iterator(); it.hasNext();) + for (int[] i : explicitPolicies) { - int[] i = (int[]) it.next(); int caDepth = i[0]; int limit = i[1]; if (Configuration.DEBUG) diff --git a/gnu/java/security/provider/X509CertificateFactory.java b/gnu/java/security/provider/X509CertificateFactory.java index 644033156..4fc13d238 100644 --- a/gnu/java/security/provider/X509CertificateFactory.java +++ b/gnu/java/security/provider/X509CertificateFactory.java @@ -1,5 +1,5 @@ /* X509CertificateFactory.java -- generates X.509 certificates. - Copyright (C) 2003 Free Software Foundation, Inc. + Copyright (C) 2003, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -76,6 +76,7 @@ public class X509CertificateFactory super(); } + @Override public Certificate engineGenerateCertificate(InputStream inStream) throws CertificateException { @@ -91,10 +92,11 @@ public class X509CertificateFactory } } - public Collection engineGenerateCertificates(InputStream inStream) + @Override + public Collection<? extends Certificate> engineGenerateCertificates(InputStream inStream) throws CertificateException { - LinkedList certs = new LinkedList(); + LinkedList<X509Certificate> certs = new LinkedList<X509Certificate>(); while (true) { try @@ -115,6 +117,7 @@ public class X509CertificateFactory return certs; } + @Override public CRL engineGenerateCRL(InputStream inStream) throws CRLException { try @@ -129,10 +132,11 @@ public class X509CertificateFactory } } - public Collection engineGenerateCRLs(InputStream inStream) + @Override + public Collection<? extends CRL> engineGenerateCRLs(InputStream inStream) throws CRLException { - LinkedList crls = new LinkedList(); + LinkedList<X509CRL> crls = new LinkedList<X509CRL>(); while (true) { try @@ -153,24 +157,28 @@ public class X509CertificateFactory return crls; } - public CertPath engineGenerateCertPath(List certs) + @Override + public CertPath engineGenerateCertPath(List<? extends Certificate> certs) { return new X509CertPath(certs); } + @Override public CertPath engineGenerateCertPath(InputStream in) throws CertificateEncodingException { return new X509CertPath(in); } + @Override public CertPath engineGenerateCertPath(InputStream in, String encoding) throws CertificateEncodingException { return new X509CertPath(in, encoding); } - public Iterator engineGetCertPathEncodings() + @Override + public Iterator<String> engineGetCertPathEncodings() { return X509CertPath.ENCODINGS.iterator(); } diff --git a/gnu/java/security/sig/BaseSignature.java b/gnu/java/security/sig/BaseSignature.java index ef4d87f26..09db44bf8 100644 --- a/gnu/java/security/sig/BaseSignature.java +++ b/gnu/java/security/sig/BaseSignature.java @@ -1,5 +1,5 @@ /* BaseSignature.java -- - Copyright (C) 2001, 2002, 2003, 2006 Free Software Foundation, Inc. + Copyright (C) 2001, 2002, 2003, 2006, 2014 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -94,12 +94,15 @@ public abstract class BaseSignature this.md = md; } + @Override public String name() { return schemeName + "-" + md.name(); } - public void setupVerify(Map attributes) throws IllegalArgumentException + @Override + public void setupVerify(Map<String,Object> attributes) + throws IllegalArgumentException { setup(attributes); // do we have a public key? @@ -108,7 +111,9 @@ public abstract class BaseSignature setupForVerification(key); } - public void setupSign(Map attributes) throws IllegalArgumentException + @Override + public void setupSign(Map<String,Object> attributes) + throws IllegalArgumentException { setup(attributes); // do we have a private key? @@ -117,6 +122,7 @@ public abstract class BaseSignature setupForSigning(key); } + @Override public void update(byte b) { if (md == null) @@ -125,6 +131,7 @@ public abstract class BaseSignature md.update(b); } + @Override public void update(byte[] b, int off, int len) { if (md == null) @@ -133,6 +140,7 @@ public abstract class BaseSignature md.update(b, off, len); } + @Override public Object sign() { if (md == null || privateKey == null) @@ -141,6 +149,7 @@ public abstract class BaseSignature return generateSignature(); } + @Override public boolean verify(Object sig) { if (md == null || publicKey == null) @@ -149,6 +158,7 @@ public abstract class BaseSignature return verifySignature(sig); } + @Override public abstract Object clone(); protected abstract void setupForVerification(PublicKey key) @@ -198,7 +208,7 @@ public abstract class BaseSignature getDefaultPRNG().nextBytes(buffer); } - private void setup(Map attributes) + private void setup(Map<String,Object> attributes) { init(); // do we have a Random or SecureRandom, or should we use our own? diff --git a/gnu/java/security/sig/ISignature.java b/gnu/java/security/sig/ISignature.java index be98f9a9b..0fa036618 100644 --- a/gnu/java/security/sig/ISignature.java +++ b/gnu/java/security/sig/ISignature.java @@ -1,5 +1,5 @@ /* ISignature.java -- - Copyright (C) 2001, 2002, 2003, 2006 Free Software Foundation, Inc. + Copyright (C) 2001, 2002, 2003, 2006, 2014 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -89,7 +89,8 @@ public interface ISignature * @see #SOURCE_OF_RANDOMNESS * @see #VERIFIER_KEY */ - void setupVerify(Map attributes) throws IllegalArgumentException; + void setupVerify(Map<String,Object> attributes) + throws IllegalArgumentException; /** * Initialises this instance for signature generation. @@ -100,7 +101,8 @@ public interface ISignature * @see #SOURCE_OF_RANDOMNESS * @see #SIGNER_KEY */ - void setupSign(Map attributes) throws IllegalArgumentException; + void setupSign(Map<String,Object> attributes) + throws IllegalArgumentException; /** * Digests one byte of a message for signing or verification purposes. diff --git a/gnu/java/security/sig/SignatureCodecFactory.java b/gnu/java/security/sig/SignatureCodecFactory.java index 0026ad164..7bf04ff40 100644 --- a/gnu/java/security/sig/SignatureCodecFactory.java +++ b/gnu/java/security/sig/SignatureCodecFactory.java @@ -1,5 +1,5 @@ /* SignatureCodecFactory.java -- Factory to instantiate Signature codecs - Copyright (C) 2006 Free Software Foundation, Inc. + Copyright (C) 2006, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -49,7 +49,6 @@ import gnu.java.security.util.FormatUtil; import java.util.Collections; import java.util.HashSet; -import java.util.Iterator; import java.util.Set; /** @@ -57,7 +56,7 @@ import java.util.Set; */ public class SignatureCodecFactory { - private static Set names; + private static Set<String> names; /** Trivial constructor to enforce Singleton pattern. */ private SignatureCodecFactory() @@ -156,17 +155,15 @@ public class SignatureCodecFactory * * @return a {@link Set} of the names of supported signature codec (Strings). */ - public static synchronized final Set getNames() + public static synchronized final Set<String> getNames() { if (names == null) { - HashSet hs = new HashSet(); + HashSet<String> hs = new HashSet<String>(); hs.add(Registry.DSS_SIG + "/" + Registry.RAW_ENCODING_SHORT_NAME); hs.add(Registry.DSS_SIG + "/" + Registry.X509_ENCODING_SORT_NAME); - Set hashNames = HashFactory.getNames(); - for (Iterator it = hashNames.iterator(); it.hasNext();) + for (String mdName : HashFactory.getNames()) { - String mdName = (String) it.next(); String name = Registry.RSA_PKCS1_V1_5_SIG + "-" + mdName; hs.add(name + "/" + Registry.RAW_ENCODING_SHORT_NAME); hs.add(name + "/" + Registry.X509_ENCODING_SORT_NAME); diff --git a/gnu/java/security/sig/SignatureFactory.java b/gnu/java/security/sig/SignatureFactory.java index 6cdaf6544..2ee5dd0a4 100644 --- a/gnu/java/security/sig/SignatureFactory.java +++ b/gnu/java/security/sig/SignatureFactory.java @@ -1,5 +1,5 @@ /* SignatureFactory.java -- - Copyright (C) 2001, 2002, 2003, 2006 Free Software Foundation, Inc. + Copyright (C) 2001, 2002, 2003, 2006, 2014 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -51,7 +51,7 @@ import java.util.Set; */ public class SignatureFactory { - private static Set names; + private static Set<String> names; /** Trivial constructor to enforce Singleton pattern. */ private SignatureFactory() @@ -87,11 +87,11 @@ public class SignatureFactory * * @return a {@link Set} of signature-with-appendix scheme names (Strings). */ - public static synchronized final Set getNames() + public static synchronized final Set<String> getNames() { if (names == null) { - HashSet hs = new HashSet(); + HashSet<String> hs = new HashSet<String>(); hs.add(Registry.DSS_SIG); hs.addAll(RSASignatureFactory.getNames()); names = Collections.unmodifiableSet(hs); diff --git a/gnu/java/security/sig/dss/DSSSignature.java b/gnu/java/security/sig/dss/DSSSignature.java index 024521ba4..5e098e337 100644 --- a/gnu/java/security/sig/dss/DSSSignature.java +++ b/gnu/java/security/sig/dss/DSSSignature.java @@ -1,5 +1,5 @@ /* DSSSignature.java -- - Copyright (C) 2001, 2002, 2003, 2006 Free Software Foundation, Inc. + Copyright (C) 2001, 2002, 2003, 2006, 2014 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -133,7 +133,7 @@ public class DSSSignature public static final BigInteger[] sign(final DSAPrivateKey k, final byte[] h) { final DSSSignature sig = new DSSSignature(); - final Map attributes = new HashMap(); + final Map<String,Object> attributes = new HashMap<String,Object>(); attributes.put(ISignature.SIGNER_KEY, k); sig.setupSign(attributes); return sig.computeRS(h); @@ -143,7 +143,7 @@ public class DSSSignature Random rnd) { final DSSSignature sig = new DSSSignature(); - final Map attributes = new HashMap(); + final Map<String,Object> attributes = new HashMap<String,Object>(); attributes.put(ISignature.SIGNER_KEY, k); if (rnd != null) attributes.put(ISignature.SOURCE_OF_RANDOMNESS, rnd); @@ -156,7 +156,7 @@ public class DSSSignature IRandom irnd) { final DSSSignature sig = new DSSSignature(); - final Map attributes = new HashMap(); + final Map<String,Object> attributes = new HashMap<String,Object>(); attributes.put(ISignature.SIGNER_KEY, k); if (irnd != null) attributes.put(ISignature.SOURCE_OF_RANDOMNESS, irnd); @@ -169,17 +169,19 @@ public class DSSSignature final BigInteger[] rs) { final DSSSignature sig = new DSSSignature(); - final Map attributes = new HashMap(); + final Map<String,Object> attributes = new HashMap<String,Object>(); attributes.put(ISignature.VERIFIER_KEY, k); sig.setupVerify(attributes); return sig.checkRS(rs, h); } + @Override public Object clone() { return new DSSSignature(this); } + @Override protected void setupForVerification(PublicKey k) throws IllegalArgumentException { @@ -189,6 +191,7 @@ public class DSSSignature this.publicKey = k; } + @Override protected void setupForSigning(PrivateKey k) throws IllegalArgumentException { if (! (k instanceof DSAPrivateKey)) @@ -197,12 +200,14 @@ public class DSSSignature this.privateKey = k; } + @Override protected Object generateSignature() throws IllegalStateException { final BigInteger[] rs = computeRS(md.digest()); return encodeSignature(rs[0], rs[1]); } + @Override protected boolean verifySignature(Object sig) throws IllegalStateException { final BigInteger[] rs = decodeSignature(sig); diff --git a/gnu/java/security/sig/dss/DSSSignatureX509Codec.java b/gnu/java/security/sig/dss/DSSSignatureX509Codec.java index d0a0188fb..f7aeda4f0 100644 --- a/gnu/java/security/sig/dss/DSSSignatureX509Codec.java +++ b/gnu/java/security/sig/dss/DSSSignatureX509Codec.java @@ -1,5 +1,5 @@ /* DSSSignatureX509Codec.java -- X.509 encoder/decoder for DSS signatures - Copyright (C) 2006 Free Software Foundation, Inc. + Copyright (C) 2006, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -130,7 +130,7 @@ public class DSSSignatureX509Codec DERValue derR = new DERValue(DER.INTEGER, rs[0]); DERValue derS = new DERValue(DER.INTEGER, rs[1]); - ArrayList dssSigValue = new ArrayList(2); + ArrayList<DERValue> dssSigValue = new ArrayList<DERValue>(2); dssSigValue.add(derR); dssSigValue.add(derS); DERValue derDssSigValue = new DERValue(DER.CONSTRUCTED | DER.SEQUENCE, diff --git a/gnu/java/security/sig/rsa/EMSA_PKCS1_V1_5.java b/gnu/java/security/sig/rsa/EMSA_PKCS1_V1_5.java index 3cddab4aa..fad0ac552 100644 --- a/gnu/java/security/sig/rsa/EMSA_PKCS1_V1_5.java +++ b/gnu/java/security/sig/rsa/EMSA_PKCS1_V1_5.java @@ -1,5 +1,5 @@ /* EMSA_PKCS1_V1_5.java -- - Copyright (C) 2003, 2006 Free Software Foundation, Inc. + Copyright (C) 2003, 2006, 2014 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -116,9 +116,6 @@ public class EMSA_PKCS1_V1_5 /** The underlying hash function to use with this instance. */ private IMessageDigest hash; - /** The output size of the hash function in octets. */ - private int hLen; // TODO: field not used!!! investigate - /** The DER part of DigestInfo not containing the hash value itself. */ private byte[] prefix; @@ -132,7 +129,6 @@ public class EMSA_PKCS1_V1_5 super(); this.hash = hash; - hLen = hash.hashSize(); final String name = hash.name(); if (name.equals(Registry.MD2_HASH)) prefix = MD2_PREFIX; diff --git a/gnu/java/security/sig/rsa/RSASignatureFactory.java b/gnu/java/security/sig/rsa/RSASignatureFactory.java index ba5121b46..8a49ddc01 100644 --- a/gnu/java/security/sig/rsa/RSASignatureFactory.java +++ b/gnu/java/security/sig/rsa/RSASignatureFactory.java @@ -1,5 +1,5 @@ /* RSASignatureFactory.java -- A Factory class to instantiate RSA Signatures - Copyright (C) 2006 Free Software Foundation, Inc. + Copyright (C) 2006, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -53,7 +53,7 @@ import gnu.java.security.sig.ISignature; */ public class RSASignatureFactory { - private static Set names; + private static Set<String> names; /** * Private constructor to enforce usage through Factory (class) methods. @@ -105,15 +105,15 @@ public class RSASignatureFactory * * @return a {@link Set} of RSA Signature algorithm names (Strings). */ - public static synchronized final Set getNames() + public static synchronized final Set<String> getNames() { if (names == null) { - Set hashNames = HashFactory.getNames(); - HashSet hs = new HashSet(); - for (Iterator it = hashNames.iterator(); it.hasNext();) + Set<String> hashNames = HashFactory.getNames(); + HashSet<String> hs = new HashSet<String>(); + for (Iterator<String> it = hashNames.iterator(); it.hasNext();) { - String mdName = (String) it.next(); + String mdName = it.next(); hs.add(Registry.RSA_PSS_SIG + "-" + mdName); } diff --git a/gnu/java/security/util/IntegerUtil.java b/gnu/java/security/util/IntegerUtil.java deleted file mode 100644 index 106dc4d66..000000000 --- a/gnu/java/security/util/IntegerUtil.java +++ /dev/null @@ -1,109 +0,0 @@ -/* IntegerUtil.java -- JDK 5 Integer methods with 1.4 API - Copyright (C) 2006 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package gnu.java.security.util; - -import java.util.LinkedHashMap; -import java.util.Map; - -/** - * Utility class which offers Integer related methods found in RI's version 5 - * but written with RI's 1.4 API. - */ -public abstract class IntegerUtil -{ - /** Maximum size of our cache of constructed Integers. */ - private static final int CACHE_SIZE = 100; - /** LRU (Least Recently Used) cache, of the last accessed 100 Integers. */ - private static final Map cache = new LinkedHashMap(CACHE_SIZE + 1, 0.75F, true) - { - public boolean removeEldestEntry(Map.Entry entry) - { - return size() > CACHE_SIZE; - } - }; - - /** Trivial private constructor to enforce Singleton usage. */ - private IntegerUtil() - { - super(); - } - - /** - * Similar to {@link Integer#valueOf(String)} except it caches the result in - * a local LRU cache of 100 elements, organized by access order. - * <p> - * This method MUST be used in the gnu.java.security and gnu.javax.crypto - * packages to ensure they would work with a version 1.4 only of the Java - * class library API. - * - * @param aString a string representation of an integer. - * @return the {@link Integer} object representing the designated string. - */ - public static final Integer valueOf(String aString) - { - Integer result; - synchronized (cache) - { - result = (Integer) cache.get(aString); - if (result == null) - { - result = Integer.valueOf(aString); - cache.put(aString, result); - } - } - return result; - } - - /** - * Simulates the <code>valueOf(int)</code> method found in {@link Integer} of - * the RI's version 1.5 using a local LRU cache of 100 elements, organized by - * access order. - * <p> - * This method MUST be used in the gnu.java.security and gnu.javax.crypto - * packages to ensure they would work with a version 1.4 only of the Java - * class library API. - * - * @param anInt a decimal integer. - * @return the {@link Integer} object representing the designated primitive. - */ - public static final Integer valueOf(int anInt) - { - return valueOf(Integer.toString(anInt, 10)); - } -} diff --git a/gnu/java/security/util/PRNG.java b/gnu/java/security/util/PRNG.java index 1bed04dcd..a7d3b4f63 100644 --- a/gnu/java/security/util/PRNG.java +++ b/gnu/java/security/util/PRNG.java @@ -1,5 +1,5 @@ /* PRNG.java -- A Utility methods for default source of randomness - Copyright (C) 2006 Free Software Foundation, Inc. + Copyright (C) 2006, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -72,16 +72,7 @@ public class PRNG IRandom delegate = new MDGenerator(); try { - HashMap map = new HashMap(); - // initialise it with a seed - long t = System.currentTimeMillis(); - byte[] seed = new byte[] { - (byte)(t >>> 56), (byte)(t >>> 48), - (byte)(t >>> 40), (byte)(t >>> 32), - (byte)(t >>> 24), (byte)(t >>> 16), - (byte)(t >>> 8), (byte) t }; - map.put(MDGenerator.SEEED, seed); - delegate.init(map); // default is to use SHA-1 hash + initialiseDelegate(delegate); } catch (Exception x) { @@ -121,15 +112,7 @@ public class PRNG { try { - HashMap map = new HashMap(); - long t = System.currentTimeMillis(); - byte[] seed = new byte[] { - (byte)(t >>> 56), (byte)(t >>> 48), - (byte)(t >>> 40), (byte)(t >>> 32), - (byte)(t >>> 24), (byte)(t >>> 16), - (byte)(t >>> 8), (byte) t }; - map.put(MDGenerator.SEEED, seed); - delegate.init(map); // default is to use SHA-1 hash + initialiseDelegate(delegate); delegate.nextBytes(buffer, offset, length); } catch (Exception y) @@ -138,4 +121,24 @@ public class PRNG } } } + + /** + * Initialise the delegate with a seed. + * + * @param the delegate to initialise. + */ + private static final void initialiseDelegate(IRandom delegate) + { + HashMap<String,Object> map = new HashMap<String,Object>(); + // initialise it with a seed + long t = System.currentTimeMillis(); + byte[] seed = new byte[] { + (byte)(t >>> 56), (byte)(t >>> 48), + (byte)(t >>> 40), (byte)(t >>> 32), + (byte)(t >>> 24), (byte)(t >>> 16), + (byte)(t >>> 8), (byte) t }; + map.put(MDGenerator.SEEED, seed); + delegate.init(map); // default is to use SHA-1 hash + } + } diff --git a/gnu/java/security/util/Sequence.java b/gnu/java/security/util/Sequence.java index 63086d2bd..8069ce891 100644 --- a/gnu/java/security/util/Sequence.java +++ b/gnu/java/security/util/Sequence.java @@ -1,5 +1,5 @@ /* Sequence.java -- a sequence of integers. - Copyright (C) 2004, 2006 Free Software Foundation, Inc. + Copyright (C) 2004, 2006, 2014 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -45,7 +45,7 @@ import java.util.LinkedList; * A monotonic sequence of integers in the finite field 2<sup>32</sup>. */ public final class Sequence - extends AbstractList + extends AbstractList<Integer> { private final Integer[] sequence; @@ -105,16 +105,17 @@ public final class Sequence } else { - LinkedList l = new LinkedList(); + LinkedList<Integer> l = new LinkedList<Integer>(); for (int i = start; i != end; i += span) l.add(Integer.valueOf(i)); l.add(Integer.valueOf(end)); - sequence = (Integer[]) l.toArray(new Integer[l.size()]); + sequence = l.toArray(new Integer[l.size()]); } } - public Object get(int index) + @Override + public Integer get(int index) { if (index < 0 || index >= size()) throw new IndexOutOfBoundsException("index=" + index + ", size=" + size()); diff --git a/gnu/java/security/util/SimpleList.java b/gnu/java/security/util/SimpleList.java index 15d54c988..2d3bd3525 100644 --- a/gnu/java/security/util/SimpleList.java +++ b/gnu/java/security/util/SimpleList.java @@ -1,5 +1,5 @@ /* SimpleList.java -- simple way to make tuples. - Copyright (C) 2004, 2006 Free Software Foundation, Inc. + Copyright (C) 2004, 2006, 2014 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -40,7 +40,6 @@ package gnu.java.security.util; import java.util.AbstractList; import java.util.Collection; -import java.util.Iterator; /** * A simple way to create immutable n-tuples. This class can be created with up @@ -48,7 +47,7 @@ import java.util.Iterator; * of arbitrary size. */ public final class SimpleList - extends AbstractList + extends AbstractList<Object> { private final Object[] elements; @@ -122,14 +121,14 @@ public final class SimpleList * natural order, the created n-tuple will have the order that the elements * are returned by the collection's iterator. * - * @param c The collection. + * @param coll The collection. */ - public SimpleList(Collection c) + public SimpleList(Collection<? extends Object> coll) { - elements = new Object[c.size()]; + elements = new Object[coll.size()]; int i = 0; - for (Iterator it = c.iterator(); it.hasNext() && i < elements.length;) - elements[i++] = it.next(); + for (Object o : coll) + elements[i++] = o; } public int size() 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() diff --git a/gnu/javax/crypto/cipher/IBlockCipher.java b/gnu/javax/crypto/cipher/IBlockCipher.java index 86f8b34e0..48cc6968c 100644 --- a/gnu/javax/crypto/cipher/IBlockCipher.java +++ b/gnu/javax/crypto/cipher/IBlockCipher.java @@ -1,5 +1,5 @@ /* IBlockCipher.java -- - Copyright (C) 2001, 2002, 2006 Free Software Foundation, Inc. + Copyright (C) 2001, 2002, 2006, 2014 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -113,7 +113,7 @@ public interface IBlockCipher * * @return an {@link Iterator} over the supported block sizes. */ - Iterator blockSizes(); + Iterator<Integer> blockSizes(); /** * Returns an {@link Iterator} over the supported key sizes. Each element @@ -121,7 +121,7 @@ public interface IBlockCipher * * @return an {@link Iterator} over the supported key sizes. */ - Iterator keySizes(); + Iterator<Integer> keySizes(); /** * Returns a clone of this instance. @@ -141,7 +141,8 @@ public interface IBlockCipher * @see #KEY_MATERIAL * @see #CIPHER_BLOCK_SIZE */ - void init(Map attributes) throws InvalidKeyException, IllegalStateException; + void init(Map<String,Object> attributes) + throws InvalidKeyException, IllegalStateException; /** * Returns the currently set block size for this instance. diff --git a/gnu/javax/crypto/jce/prng/FortunaImpl.java b/gnu/javax/crypto/jce/prng/FortunaImpl.java index d2073b98d..e9e334f0e 100644 --- a/gnu/javax/crypto/jce/prng/FortunaImpl.java +++ b/gnu/javax/crypto/jce/prng/FortunaImpl.java @@ -1,5 +1,5 @@ /* FortunaImpl.java -- Fortuna SecureRandom adapter. - Copyright (C) 2006 Free Software Foundation, Inc. + Copyright (C) 2006, 2014 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -64,7 +64,7 @@ public final class FortunaImpl { if (virgin) { - adaptee.init (Collections.singletonMap (Fortuna.SEED, seed)); + adaptee.init (Collections.singletonMap (Fortuna.SEED, (Object) seed)); virgin = false; } else diff --git a/gnu/javax/crypto/key/dh/DHKeyPairPKCS8Codec.java b/gnu/javax/crypto/key/dh/DHKeyPairPKCS8Codec.java index 8c03cbb00..27b74b996 100644 --- a/gnu/javax/crypto/key/dh/DHKeyPairPKCS8Codec.java +++ b/gnu/javax/crypto/key/dh/DHKeyPairPKCS8Codec.java @@ -1,5 +1,5 @@ /* DHKeyPairPKCS8Codec.java -- PKCS#8 encoder/decoder for DH keys - Copyright (C) 2006 Free Software Foundation, Inc. + Copyright (C) 2006, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -128,13 +128,13 @@ public class DHKeyPairPKCS8Codec q = BigInteger.ZERO; BigInteger x = pk.getX(); - ArrayList params = new ArrayList(3); + ArrayList<DERValue> params = new ArrayList<DERValue>(3); params.add(new DERValue(DER.INTEGER, p)); params.add(new DERValue(DER.INTEGER, g)); params.add(new DERValue(DER.INTEGER, q)); DERValue derParams = new DERValue(DER.CONSTRUCTED | DER.SEQUENCE, params); - ArrayList algorithmID = new ArrayList(2); + ArrayList<DERValue> algorithmID = new ArrayList<DERValue>(2); algorithmID.add(derOID); algorithmID.add(derParams); DERValue derAlgorithmID = new DERValue(DER.CONSTRUCTED | DER.SEQUENCE, @@ -142,7 +142,7 @@ public class DHKeyPairPKCS8Codec DERValue derPrivateKey = new DERValue(DER.OCTET_STRING, Util.trim(x)); - ArrayList pki = new ArrayList(3); + ArrayList<DERValue> pki = new ArrayList<DERValue>(3); pki.add(derVersion); pki.add(derAlgorithmID); pki.add(derPrivateKey); diff --git a/gnu/javax/crypto/key/dh/DHKeyPairX509Codec.java b/gnu/javax/crypto/key/dh/DHKeyPairX509Codec.java index 893716eef..7ed3666dd 100644 --- a/gnu/javax/crypto/key/dh/DHKeyPairX509Codec.java +++ b/gnu/javax/crypto/key/dh/DHKeyPairX509Codec.java @@ -1,5 +1,5 @@ /* DHKeyPairX509Codec.java -- X.509 DER encoder/decoder for DH keys - Copyright (C) 2006 Free Software Foundation, Inc. + Copyright (C) 2006, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -132,13 +132,13 @@ public class DHKeyPairX509Codec DERValue derG = new DERValue(DER.INTEGER, g); DERValue derQ = new DERValue(DER.INTEGER, q); - ArrayList params = new ArrayList(3); + ArrayList<DERValue> params = new ArrayList<DERValue>(3); params.add(derP); params.add(derG); params.add(derQ); DERValue derParams = new DERValue(DER.CONSTRUCTED | DER.SEQUENCE, params); - ArrayList algorithmID = new ArrayList(2); + ArrayList<DERValue> algorithmID = new ArrayList<DERValue>(2); algorithmID.add(derOID); algorithmID.add(derParams); DERValue derAlgorithmID = new DERValue(DER.CONSTRUCTED | DER.SEQUENCE, @@ -148,7 +148,7 @@ public class DHKeyPairX509Codec byte[] yBytes = derDHPublicKey.getEncoded(); DERValue derSPK = new DERValue(DER.BIT_STRING, new BitString(yBytes)); - ArrayList spki = new ArrayList(2); + ArrayList<DERValue> spki = new ArrayList<DERValue>(2); spki.add(derAlgorithmID); spki.add(derSPK); DERValue derSPKI = new DERValue(DER.CONSTRUCTED | DER.SEQUENCE, spki); diff --git a/gnu/javax/crypto/mac/IMac.java b/gnu/javax/crypto/mac/IMac.java index a9582564d..6081ef11f 100644 --- a/gnu/javax/crypto/mac/IMac.java +++ b/gnu/javax/crypto/mac/IMac.java @@ -1,5 +1,5 @@ /* IMac.java -- - Copyright (C) 2001, 2002, 2006 Free Software Foundation, Inc. + Copyright (C) 2001, 2002, 2006, 2014 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -129,7 +129,7 @@ public interface IMac * @exception IllegalStateException if the instance is already initialised. * @see #MAC_KEY_MATERIAL */ - void init(Map attributes) throws InvalidKeyException, IllegalStateException; + void init(Map<String,Object> attributes) throws InvalidKeyException, IllegalStateException; /** * Continues a <i>MAC</i> operation using the input byte. diff --git a/gnu/javax/crypto/mode/BaseMode.java b/gnu/javax/crypto/mode/BaseMode.java index 831dd9664..1f4feea22 100644 --- a/gnu/javax/crypto/mode/BaseMode.java +++ b/gnu/javax/crypto/mode/BaseMode.java @@ -1,5 +1,5 @@ /* BaseMode.java -- - Copyright (C) 2001, 2002, 2003, 2006 Free Software Foundation, Inc. + Copyright (C) 2001, 2002, 2003, 2006, 2014 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -91,6 +91,7 @@ public abstract class BaseMode state = -1; } + @Override public void update(byte[] in, int inOffset, byte[] out, int outOffset) throws IllegalStateException { @@ -110,6 +111,7 @@ public abstract class BaseMode } } + @Override public String name() { return new CPStringBuilder(name).append('(').append(cipher.name()).append(')') @@ -128,6 +130,7 @@ public abstract class BaseMode * @return the default value, in bytes, of the mode's block size. * @see ModeFactory */ + @Override public int defaultBlockSize() { return cipherBlockSize; @@ -139,6 +142,7 @@ public abstract class BaseMode * * @return the default value, in bytes, of the underlying cipher's key size. */ + @Override public int defaultKeySize() { return cipher.defaultKeySize(); @@ -155,9 +159,10 @@ public abstract class BaseMode * * @return an {@link Iterator} over the supported block sizes. */ - public Iterator blockSizes() + @Override + public Iterator<Integer> blockSizes() { - ArrayList al = new ArrayList(); + ArrayList<Integer> al = new ArrayList<Integer>(); al.add(Integer.valueOf(cipherBlockSize)); return Collections.unmodifiableList(al).iterator(); } @@ -169,12 +174,14 @@ public abstract class BaseMode * * @return an {@link Iterator} over the supported key sizes. */ - public Iterator keySizes() + @Override + public Iterator<Integer> keySizes() { return cipher.keySizes(); } - public void init(Map attributes) throws InvalidKeyException, + @Override + public void init(Map<String,Object> attributes) throws InvalidKeyException, IllegalStateException { synchronized (lock) @@ -208,6 +215,7 @@ public abstract class BaseMode } } + @Override public int currentBlockSize() { if (state == -1) @@ -215,6 +223,7 @@ public abstract class BaseMode return modeBlockSize; } + @Override public void reset() { synchronized (lock) @@ -226,6 +235,7 @@ public abstract class BaseMode } } + @Override public boolean selfTest() { int ks; @@ -240,6 +250,7 @@ public abstract class BaseMode return true; } + @Override public abstract Object clone(); /** The initialisation phase of the concrete mode implementation. */ @@ -248,8 +259,10 @@ public abstract class BaseMode /** The termination phase of the concrete mode implementation. */ public abstract void teardown(); + @Override public abstract void encryptBlock(byte[] in, int i, byte[] out, int o); + @Override public abstract void decryptBlock(byte[] in, int i, byte[] out, int o); private boolean testSymmetry(int ks, int bs) diff --git a/gnu/javax/crypto/mode/EAX.java b/gnu/javax/crypto/mode/EAX.java index b3e4a6a4e..910949e87 100644 --- a/gnu/javax/crypto/mode/EAX.java +++ b/gnu/javax/crypto/mode/EAX.java @@ -1,5 +1,5 @@ /* EAX.java -- - Copyright (C) 2004, 2006 Free Software Foundation, Inc. + Copyright (C) 2004, 2006, 2014 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -110,37 +110,44 @@ public class EAX init = false; } + @Override public Object clone() { return new EAX((IBlockCipher) cipher.clone(), cipherBlockSize); } + @Override public String name() { return Registry.EAX_MODE + "(" + cipher.name() + ")"; } + @Override public int defaultBlockSize() { return ctr.defaultBlockSize(); } + @Override public int defaultKeySize() { return ctr.defaultKeySize(); } - public Iterator blockSizes() + @Override + public Iterator<Integer> blockSizes() { return ctr.blockSizes(); } - public Iterator keySizes() + @Override + public Iterator<Integer> keySizes() { return ctr.keySizes(); } - public void init(Map attrib) throws InvalidKeyException + @Override + public void init(Map<String,Object> attrib) throws InvalidKeyException { byte[] nonce = (byte[]) attrib.get(IV); if (nonce == null) @@ -151,7 +158,7 @@ public class EAX Arrays.fill(t_n, (byte) 0); nonceOmac.reset(); - nonceOmac.init(Collections.singletonMap(MAC_KEY_MATERIAL, key)); + nonceOmac.init(Collections.singletonMap(MAC_KEY_MATERIAL, (Object) key)); nonceOmac.update(t_n, 0, t_n.length); nonceOmac.update(nonce, 0, nonce.length); byte[] N = nonceOmac.digest(); @@ -160,16 +167,16 @@ public class EAX nonceOmac.update(nonce, 0, nonce.length); t_n[t_n.length - 1] = 1; headerOmac.reset(); - headerOmac.init(Collections.singletonMap(MAC_KEY_MATERIAL, key)); + headerOmac.init(Collections.singletonMap(MAC_KEY_MATERIAL, (Object) key)); headerOmac.update(t_n, 0, t_n.length); t_n[t_n.length - 1] = 2; msgOmac.reset(); - msgOmac.init(Collections.singletonMap(MAC_KEY_MATERIAL, key)); + msgOmac.init(Collections.singletonMap(MAC_KEY_MATERIAL, (Object) key)); msgOmac.update(t_n, 0, t_n.length); Integer modeSize = (Integer) attrib.get(MODE_BLOCK_SIZE); if (modeSize == null) modeSize = Integer.valueOf(cipherBlockSize); - HashMap ctrAttr = new HashMap(); + HashMap<String,Object> ctrAttr = new HashMap<String,Object>(); ctrAttr.put(KEY_MATERIAL, key); ctrAttr.put(IV, N); ctrAttr.put(STATE, Integer.valueOf(ENCRYPTION)); @@ -196,11 +203,13 @@ public class EAX init = true; } + @Override public int currentBlockSize() { return ctr.currentBlockSize(); } + @Override public void encryptBlock(byte[] in, int inOff, byte[] out, int outOff) { if (! init) @@ -211,6 +220,7 @@ public class EAX msgOmac.update(out, outOff, ctr.currentBlockSize()); } + @Override public void decryptBlock(byte[] in, int inOff, byte[] out, int outOff) { if (! init) @@ -236,6 +246,7 @@ public class EAX } } + @Override public void reset() { nonceOmac.reset(); @@ -244,16 +255,19 @@ public class EAX ctr.reset(); } + @Override public boolean selfTest() { return true; // XXX } + @Override public int macSize() { return tagSize; } + @Override public byte[] digest() { byte[] tag = new byte[tagSize]; @@ -273,6 +287,7 @@ public class EAX reset(); } + @Override public void update(byte b) { if (! init) @@ -280,6 +295,7 @@ public class EAX headerOmac.update(b); } + @Override public void update(byte[] buf, int off, int len) { if (! init) diff --git a/gnu/javax/crypto/prng/Fortuna.java b/gnu/javax/crypto/prng/Fortuna.java index 8aec9ab7d..4d41cad55 100644 --- a/gnu/javax/crypto/prng/Fortuna.java +++ b/gnu/javax/crypto/prng/Fortuna.java @@ -1,5 +1,5 @@ /* Fortuna.java -- The Fortuna PRNG. - Copyright (C) 2004, 2006 Free Software Foundation, Inc. + Copyright (C) 2004, 2006, 2014 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -118,7 +118,8 @@ public class Fortuna buffer = new byte[256]; } - public void setup(Map attributes) + @Override + public void setup(Map<String,Object> attributes) { lastReseed = 0; reseedCount = 0; @@ -227,9 +228,9 @@ public class Fortuna counter = new byte[cipher.defaultBlockSize()]; buffer = new byte[cipher.defaultBlockSize()]; int keysize = 0; - for (Iterator it = cipher.keySizes(); it.hasNext();) + for (Iterator<Integer> it = cipher.keySizes(); it.hasNext();) { - int ks = ((Integer) it.next()).intValue(); + int ks = it.next().intValue(); if (ks > keysize) keysize = ks; if (keysize >= 32) @@ -238,6 +239,7 @@ public class Fortuna key = new byte[keysize]; } + @Override public byte nextByte() { byte[] b = new byte[1]; @@ -245,6 +247,7 @@ public class Fortuna return b[0]; } + @Override public void nextBytes(byte[] out, int offset, int length) { if (! seeded) @@ -275,11 +278,13 @@ public class Fortuna ndx = 0; } + @Override public void addRandomByte(byte b) { addRandomBytes(new byte[] { b }); } + @Override public void addRandomBytes(byte[] seed, int offset, int length) { hash.update(key); @@ -291,6 +296,7 @@ public class Fortuna seeded = true; } + @Override public void fillBlock() { if (! seeded) @@ -299,7 +305,8 @@ public class Fortuna incrementCounter(); } - public void setup(Map attributes) + @Override + public void setup(Map<String,Object> attributes) { seeded = false; Arrays.fill(key, (byte) 0); @@ -319,7 +326,7 @@ public class Fortuna try { cipher.reset(); - cipher.init(Collections.singletonMap(IBlockCipher.KEY_MATERIAL, key)); + cipher.init(Collections.singletonMap(IBlockCipher.KEY_MATERIAL, (Object) key)); } // We expect to never get an exception here. catch (InvalidKeyException ike) diff --git a/gnu/javax/net/ssl/Session.java b/gnu/javax/net/ssl/Session.java index 3acf9932d..bfa94c29a 100644 --- a/gnu/javax/net/ssl/Session.java +++ b/gnu/javax/net/ssl/Session.java @@ -1,5 +1,5 @@ /* SessionImpl.java -- concrete definition of SSLSession. - Copyright (C) 2006 Free Software Foundation, Inc. + Copyright (C) 2006, 2014 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -286,7 +286,7 @@ public abstract class Session implements SSLSession, Serializable /** * An SSL or TLS session ID. */ - public static final class ID implements Comparable, Serializable + public static final class ID implements Comparable<ID>, Serializable { // Fields. @@ -319,6 +319,7 @@ public abstract class Session implements SSLSession, Serializable return (byte[]) id.clone(); } + @Override public boolean equals(Object other) { if (!(other instanceof ID)) @@ -326,6 +327,7 @@ public abstract class Session implements SSLSession, Serializable return Arrays.equals(id, ((ID) other).id); } + @Override public int hashCode() { int code = 0; @@ -334,9 +336,10 @@ public abstract class Session implements SSLSession, Serializable return code; } - public int compareTo(Object other) + @Override + public int compareTo(ID other) { - byte[] id2 = ((ID) other).id; + byte[] id2 = other.id; if (id.length != id2.length) return (id.length < id2.length) ? -1 : 1; for (int i = 0; i < id.length; i++) @@ -349,6 +352,7 @@ public abstract class Session implements SSLSession, Serializable return 0; } + @Override public String toString() { CPStringBuilder str = new CPStringBuilder (3 * id.length + 1); diff --git a/gnu/javax/net/ssl/provider/AbstractHandshake.java b/gnu/javax/net/ssl/provider/AbstractHandshake.java index bf03ed77f..dbbd92962 100644 --- a/gnu/javax/net/ssl/provider/AbstractHandshake.java +++ b/gnu/javax/net/ssl/provider/AbstractHandshake.java @@ -1,5 +1,5 @@ /* AbstractHandshake.java -- abstract handshake handler. - Copyright (C) 2006 Free Software Foundation, Inc. + Copyright (C) 2006, 2014 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -588,7 +588,7 @@ Certificate.signature.sha_hash clientRandom.buffer().get(seed, serverRandom.length(), clientRandom.length()); prf = new SSLRandom(); - HashMap<String,byte[]> attr = new HashMap<String,byte[]>(2); + HashMap<String,Object> attr = new HashMap<String,Object>(2); attr.put(SSLRandom.SECRET, session.privateData.masterSecret); attr.put(SSLRandom.SEED, seed); prf.init(attr); @@ -606,7 +606,7 @@ Certificate.signature.sha_hash clientRandom.length()); prf = new TLSRandom(); - HashMap<String,byte[]> attr = new HashMap<String,byte[]>(2); + HashMap<String,Object> attr = new HashMap<String,Object>(2); attr.put(TLSRandom.SECRET, session.privateData.masterSecret); attr.put(TLSRandom.SEED, seed); prf.init(attr); @@ -650,7 +650,7 @@ Certificate.signature.sha_hash else { TLSRandom prf2 = new TLSRandom(); - HashMap<String,byte[]> attr = new HashMap<String,byte[]>(2); + HashMap<String,Object> attr = new HashMap<String,Object>(2); attr.put(TLSRandom.SECRET, keys[2]); byte[] seed = new byte[CLIENT_WRITE_KEY.length + clientRandom.length() + @@ -910,7 +910,7 @@ Certificate.signature.sha_hash MASTER_SECRET.length + clientRandom.length(), serverRandom.length()); TLSRandom prf = new TLSRandom(); - HashMap<String,byte[]> attr = new HashMap<String,byte[]>(2); + HashMap<String,Object> attr = new HashMap<String,Object>(2); attr.put(TLSRandom.SECRET, preMasterSecret); attr.put(TLSRandom.SEED, seed); prf.init(attr); diff --git a/gnu/javax/net/ssl/provider/SSLRandom.java b/gnu/javax/net/ssl/provider/SSLRandom.java index 0b28f1044..68da1bf52 100644 --- a/gnu/javax/net/ssl/provider/SSLRandom.java +++ b/gnu/javax/net/ssl/provider/SSLRandom.java @@ -1,5 +1,5 @@ /* SSLRandom.java -- SSLv3 pseudo-random function. - Copyright (C) 2006 Free Software Foundation, Inc. + Copyright (C) 2006, 2014 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -72,7 +72,8 @@ class SSLRandom implements IRandom // Instance methods. // ------------------------------------------------------------------------- - public void init(Map attrib) + @Override + public void init(Map<String,Object> attrib) { secret = (byte[]) attrib.get(SECRET); seed = (byte[]) attrib.get(SEED); @@ -90,11 +91,13 @@ class SSLRandom implements IRandom return "SSLRandom"; } + @Override public Object clone() { throw new UnsupportedOperationException(); } + @Override public byte nextByte() throws LimitReachedException { if (buffer == null) @@ -104,6 +107,7 @@ class SSLRandom implements IRandom return buffer[idx++]; } + @Override public void nextBytes(byte[] buf, int off, int len) throws LimitReachedException { @@ -131,14 +135,17 @@ class SSLRandom implements IRandom } // For future versions of GNU Crypto. No-ops. + @Override public void addRandomByte (byte b) { } + @Override public void addRandomBytes(byte[] buffer) { addRandomBytes(buffer, 0, buffer.length); } + @Override public void addRandomBytes (byte[] b, int i, int j) { } diff --git a/gnu/javax/net/ssl/provider/TLSRandom.java b/gnu/javax/net/ssl/provider/TLSRandom.java index ded632928..f438d7729 100644 --- a/gnu/javax/net/ssl/provider/TLSRandom.java +++ b/gnu/javax/net/ssl/provider/TLSRandom.java @@ -1,5 +1,5 @@ /* TLSRandom.java -- The TLS pseudo-random function. - Copyright (C) 2006 Free Software Foundation, Inc. + Copyright (C) 2006, 2014 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -62,8 +62,8 @@ class TLSRandom implements IRandom */ static final String SEED = "jessie.tls.prng.seed"; - private final IMac hmac_sha, hmac_md5; - private byte[] sha_a, md5_a; + private final IMac hmacSHA, hmacMD5; + private byte[] shaA, md5A; private byte[] seed; private final byte[] buffer; private int idx; @@ -74,8 +74,8 @@ class TLSRandom implements IRandom TLSRandom() { - hmac_sha = new TLSHMac(HashFactory.getInstance("SHA1")); - hmac_md5 = new TLSHMac(HashFactory.getInstance("MD5")); + hmacSHA = new TLSHMac(HashFactory.getInstance("SHA1")); + hmacMD5 = new TLSHMac(HashFactory.getInstance("MD5")); buffer = new byte[80]; // 80 == LCM of 16 and 20. idx = 0; init = false; @@ -84,6 +84,7 @@ class TLSRandom implements IRandom // Instance methods. // ------------------------------------------------------------------------- + @Override public Object clone() { try @@ -96,22 +97,22 @@ class TLSRandom implements IRandom } } - public void init(Map attributes) + public void init(Map<String,Object> attributes) { - HashMap sha_attr = new HashMap(); - HashMap md5_attr = new HashMap(); + HashMap<String,Object> shaAttr = new HashMap<String,Object>(); + HashMap<String,Object> md5Attr = new HashMap<String,Object>(); byte[] secret = (byte[]) attributes.get(SECRET); if (secret != null) { int l = (secret.length >>> 1) + (secret.length & 1); byte[] s1 = Util.trim(secret, 0, l); byte[] s2 = Util.trim(secret, secret.length - l, l); - md5_attr.put(IMac.MAC_KEY_MATERIAL, s1); - sha_attr.put(IMac.MAC_KEY_MATERIAL, s2); + md5Attr.put(IMac.MAC_KEY_MATERIAL, s1); + shaAttr.put(IMac.MAC_KEY_MATERIAL, s2); try { - hmac_md5.init(md5_attr); - hmac_sha.init(sha_attr); + hmacMD5.init(md5Attr); + hmacSHA.init(shaAttr); } catch (InvalidKeyException ike) { @@ -136,21 +137,23 @@ class TLSRandom implements IRandom // else re-use // A(0) is the seed, A(1) = HMAC_hash(secret, A(0)). - hmac_md5.update(seed, 0, seed.length); - md5_a = hmac_md5.digest(); - hmac_md5.reset(); - hmac_sha.update(seed, 0, seed.length); - sha_a = hmac_sha.digest(); - hmac_sha.reset(); + hmacMD5.update(seed, 0, seed.length); + md5A = hmacMD5.digest(); + hmacMD5.reset(); + hmacSHA.update(seed, 0, seed.length); + shaA = hmacSHA.digest(); + hmacSHA.reset(); fillBuffer(); init = true; } + @Override public String name() { return "TLSRandom"; } + @Override public byte nextByte() { if (!init) @@ -160,6 +163,7 @@ class TLSRandom implements IRandom return buffer[idx++]; } + @Override public void nextBytes(byte[] buf, int off, int len) { if (!init) @@ -183,14 +187,17 @@ class TLSRandom implements IRandom } // For future versions of GNU Crypto. No-ops. + @Override public void addRandomByte (byte b) { } + @Override public void addRandomBytes(byte[] buffer) { addRandomBytes(buffer, 0, buffer.length); } + @Override public void addRandomBytes (byte[] b, int i, int j) { } @@ -220,32 +227,32 @@ class TLSRandom implements IRandom */ private synchronized void fillBuffer() { - int len = hmac_md5.macSize(); + int len = hmacMD5.macSize(); for (int i = 0; i < buffer.length; i += len) { - hmac_md5.update(md5_a, 0, md5_a.length); - hmac_md5.update(seed, 0, seed.length); - byte[] b = hmac_md5.digest(); - hmac_md5.reset(); + hmacMD5.update(md5A, 0, md5A.length); + hmacMD5.update(seed, 0, seed.length); + byte[] b = hmacMD5.digest(); + hmacMD5.reset(); System.arraycopy(b, 0, buffer, i, len); - hmac_md5.update(md5_a, 0, md5_a.length); - md5_a = hmac_md5.digest(); - hmac_md5.reset(); + hmacMD5.update(md5A, 0, md5A.length); + md5A = hmacMD5.digest(); + hmacMD5.reset(); } - len = hmac_sha.macSize(); + len = hmacSHA.macSize(); for (int i = 0; i < buffer.length; i += len) { - hmac_sha.update(sha_a, 0, sha_a.length); - hmac_sha.update(seed, 0, seed.length); - byte[] b = hmac_sha.digest(); - hmac_sha.reset(); + hmacSHA.update(shaA, 0, shaA.length); + hmacSHA.update(seed, 0, seed.length); + byte[] b = hmacSHA.digest(); + hmacSHA.reset(); for (int j = 0; j < len; j++) { buffer[j + i] ^= b[j]; } - hmac_sha.update(sha_a, 0, sha_a.length); - sha_a = hmac_sha.digest(); - hmac_sha.reset(); + hmacSHA.update(shaA, 0, shaA.length); + shaA = hmacSHA.digest(); + hmacSHA.reset(); } idx = 0; } diff --git a/gnu/javax/net/ssl/provider/Util.java b/gnu/javax/net/ssl/provider/Util.java index a2004b7aa..a79a2cc8b 100644 --- a/gnu/javax/net/ssl/provider/Util.java +++ b/gnu/javax/net/ssl/provider/Util.java @@ -1,5 +1,5 @@ /* Util.java -- Miscellaneous utility methods. - Copyright (C) 2006 Free Software Foundation, Inc. + Copyright (C) 2006, 2014 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -419,14 +419,14 @@ public final class Util * each element of <i>array</i> with <i>args</i>. The return type * of the array will be an array of <i>returnType</i>. */ - static Object[] transform(Object[] array, Class returnType, - String method, Object[] args) + static <T> T[] transform(Object[] array, Class<T> returnType, + String method, Object[] args) throws InvocationTargetException, NoSuchMethodException, IllegalAccessException { if (args == null) args = new Object[0]; - Object[] result = (Object[]) Array.newInstance(returnType, array.length); + T[] result = (T[]) Array.newInstance(returnType, array.length); Class[] argsClasses = new Class[args.length]; for (int i = 0; i < args.length; i++) { @@ -444,7 +444,7 @@ public final class Util Object o = objMethod.invoke(array[i], args); if (!returnType.isAssignableFrom(o.getClass())) throw new ClassCastException(); - result[i] = o; + result[i] = returnType.cast(o); } return result; } diff --git a/gnu/javax/net/ssl/provider/X509KeyManagerFactory.java b/gnu/javax/net/ssl/provider/X509KeyManagerFactory.java index a63cb2cbe..44fb37e1f 100644 --- a/gnu/javax/net/ssl/provider/X509KeyManagerFactory.java +++ b/gnu/javax/net/ssl/provider/X509KeyManagerFactory.java @@ -1,5 +1,5 @@ /* X509KeyManagerFactory.java -- X.509 key manager factory. - Copyright (C) 2006 Free Software Foundation, Inc. + Copyright (C) 2006, 2014 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -75,6 +75,7 @@ import javax.net.ssl.KeyManagerFactorySpi; import javax.net.ssl.ManagerFactoryParameters; import javax.net.ssl.SSLEngine; import javax.net.ssl.X509ExtendedKeyManager; + import gnu.javax.net.ssl.NullManagerParameters; import gnu.javax.net.ssl.PrivateCredentials; @@ -113,9 +114,13 @@ public class X509KeyManagerFactory extends KeyManagerFactorySpi protected void engineInit(ManagerFactoryParameters params) throws InvalidAlgorithmParameterException { + Map<String, X509Certificate[]> certMap; + Map<String, PrivateKey> keyMap; + if (params instanceof NullManagerParameters) { - current = new Manager(Collections.EMPTY_MAP, Collections.EMPTY_MAP); + certMap = Collections.emptyMap(); + keyMap = Collections.emptyMap(); } else if (params instanceof PrivateCredentials) { @@ -124,10 +129,8 @@ public class X509KeyManagerFactory extends KeyManagerFactorySpi List<PrivateKey> keys = ((PrivateCredentials) params).getPrivateKeys(); int i = 0; - HashMap<String, X509Certificate[]> certMap - = new HashMap<String, X509Certificate[]>(); - HashMap<String, PrivateKey> keyMap - = new HashMap<String, PrivateKey>(); + certMap = new HashMap<String, X509Certificate[]>(); + keyMap = new HashMap<String, PrivateKey>(); Iterator<X509Certificate[]> c = chains.iterator(); Iterator<PrivateKey> k = keys.iterator(); while (c.hasNext() && k.hasNext()) @@ -136,12 +139,12 @@ public class X509KeyManagerFactory extends KeyManagerFactorySpi keyMap.put(String.valueOf(i), k.next()); i++; } - current = new Manager(keyMap, certMap); } else { throw new InvalidAlgorithmParameterException(); } + current = new Manager(keyMap, certMap); } protected void engineInit(KeyStore store, char[] passwd) @@ -175,11 +178,11 @@ public class X509KeyManagerFactory extends KeyManagerFactorySpi HashMap<String, PrivateKey> p = new HashMap<String, PrivateKey>(); HashMap<String, X509Certificate[]> c = new HashMap<String, X509Certificate[]>(); - Enumeration aliases = store.aliases(); + Enumeration<String> aliases = store.aliases(); UnrecoverableKeyException exception = null; while (aliases.hasMoreElements()) { - String alias = (String) aliases.nextElement(); + String alias = aliases.nextElement(); if (!store.isKeyEntry(alias)) { continue; @@ -316,9 +319,9 @@ public class X509KeyManagerFactory extends KeyManagerFactorySpi private String[] getAliases(String keyType, Principal[] issuers) { LinkedList<String> l = new LinkedList<String>(); - for (Iterator i = privateKeys.keySet().iterator(); i.hasNext(); ) + for (Iterator<String> i = privateKeys.keySet().iterator(); i.hasNext(); ) { - String alias = (String) i.next(); + String alias = i.next(); X509Certificate[] chain = getCertificateChain(alias); if (chain.length == 0) continue; diff --git a/gnu/javax/net/ssl/provider/X509TrustManagerFactory.java b/gnu/javax/net/ssl/provider/X509TrustManagerFactory.java index ddd2f9c8b..eab53ac43 100644 --- a/gnu/javax/net/ssl/provider/X509TrustManagerFactory.java +++ b/gnu/javax/net/ssl/provider/X509TrustManagerFactory.java @@ -1,5 +1,5 @@ /* X509TrustManagerFactory.java -- X.509 trust manager factory. - Copyright (C) 2006 Free Software Foundation, Inc. + Copyright (C) 2006, 2014 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -183,10 +183,10 @@ public class X509TrustManagerFactory extends TrustManagerFactorySpi } LinkedList<X509Certificate> l = new LinkedList<X509Certificate>(); - Enumeration aliases = store.aliases(); + Enumeration<String> aliases = store.aliases(); while (aliases.hasMoreElements()) { - String alias = (String) aliases.nextElement(); + String alias = aliases.nextElement(); if (!store.isCertificateEntry(alias)) continue; Certificate c = store.getCertificate(alias); diff --git a/gnu/javax/security/auth/callback/AWTCallbackHandler.java b/gnu/javax/security/auth/callback/AWTCallbackHandler.java index f241157ee..5aad0335d 100644 --- a/gnu/javax/security/auth/callback/AWTCallbackHandler.java +++ b/gnu/javax/security/auth/callback/AWTCallbackHandler.java @@ -1,5 +1,5 @@ /* AWTCallbackHandler.java -- - Copyright (C) 2004, 2006 Free Software Foundation, Inc. + Copyright (C) 2004, 2006, 2014 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -77,10 +77,8 @@ public class AWTCallbackHandler extends AbstractCallbackHandler protected String actionCommand; private static final String ACTION_CANCEL = "CANCEL"; - private static final String ACTION_NO = "NO"; private static final String ACTION_NONE = "NONE"; private static final String ACTION_OK = "OK"; - private static final String ACTION_YES = "YES"; // Constructor. // ------------------------------------------------------------------------- @@ -126,7 +124,7 @@ public class AWTCallbackHandler extends AbstractCallbackHandler buttons.add(ok); dialog.add(buttons, BorderLayout.SOUTH); dialog.pack(); - dialog.show(); + dialog.setVisible(true); try { wait(); } catch (InterruptedException ie) { } if (actionCommand.equals(ACTION_OK)) @@ -217,7 +215,7 @@ public class AWTCallbackHandler extends AbstractCallbackHandler buttons.add(b); } dialog.pack(); - dialog.show(); + dialog.setVisible(true); try { wait(); } catch (InterruptedException ie) { } for (int i = 0; i < choices.length; i++) @@ -307,7 +305,7 @@ public class AWTCallbackHandler extends AbstractCallbackHandler buttons.add(cancel); dialog.add(buttons); dialog.pack(); - dialog.show(); + dialog.setVisible(true); try { wait(); } catch (InterruptedException ie) { } if (actionCommand.equals(ACTION_OK)) @@ -344,7 +342,7 @@ public class AWTCallbackHandler extends AbstractCallbackHandler buttons.add(cancel); dialog.add(buttons); dialog.pack(); - dialog.show(); + dialog.setVisible(true); try { wait(); } catch (InterruptedException ie) { } if (actionCommand.equals(ACTION_OK)) @@ -381,7 +379,7 @@ public class AWTCallbackHandler extends AbstractCallbackHandler buttons.add(cancel); dialog.add(buttons, BorderLayout.SOUTH); dialog.pack(); - dialog.show(); + dialog.setVisible(true); try { wait(); } catch (InterruptedException ie) { } if (actionCommand.equals(ACTION_OK)) @@ -420,7 +418,7 @@ public class AWTCallbackHandler extends AbstractCallbackHandler dialog.add(label); dialog.add(buttons); dialog.pack(); - dialog.show(); + dialog.setVisible(true); try { wait(); } catch (InterruptedException ie) { } dialog.dispose(); diff --git a/gnu/javax/security/auth/callback/ConsoleCallbackHandler.java b/gnu/javax/security/auth/callback/ConsoleCallbackHandler.java index 4c24ab808..bb25ca049 100644 --- a/gnu/javax/security/auth/callback/ConsoleCallbackHandler.java +++ b/gnu/javax/security/auth/callback/ConsoleCallbackHandler.java @@ -1,5 +1,5 @@ /* ConsoleCallbackHandler.java -- - Copyright (C) 2005, 2006 Free Software Foundation, Inc. + Copyright (C) 2005, 2006, 2014 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -124,7 +124,7 @@ public class ConsoleCallbackHandler extends AbstractCallbackHandler } else { - TreeSet indices = new TreeSet(); + TreeSet<Integer> indices = new TreeSet<Integer>(); StringTokenizer tok = new StringTokenizer(reply, ","); String[] replies = new String[tok.countTokens()]; int idx = 0; @@ -146,7 +146,7 @@ public class ConsoleCallbackHandler extends AbstractCallbackHandler { int[] ii = new int[indices.size()]; int i = 0; - for (Iterator it = indices.iterator(); it.hasNext(); ) + for (Iterator<Integer> it = indices.iterator(); it.hasNext(); ) ii[i++] = ((Integer) it.next()).intValue(); c.setSelectedIndexes(ii); } diff --git a/gnu/javax/security/auth/callback/GnuCallbacks.java b/gnu/javax/security/auth/callback/GnuCallbacks.java index 9fd72f926..810452010 100644 --- a/gnu/javax/security/auth/callback/GnuCallbacks.java +++ b/gnu/javax/security/auth/callback/GnuCallbacks.java @@ -1,5 +1,5 @@ /* GnuCallbacks.java -- Provider for callback implementations. - Copyright (C) 2004, 2006 Free Software Foundation, Inc. + Copyright (C) 2004, 2006, 2014 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -44,13 +44,16 @@ import java.security.Provider; public final class GnuCallbacks extends Provider { + + private static final long serialVersionUID = -5978562213558760614L; + public GnuCallbacks() { super("GNU-CALLBACKS", 2.1, "Implementations of various callback handlers."); - AccessController.doPrivileged(new PrivilegedAction() + AccessController.doPrivileged(new PrivilegedAction<Void>() { - public Object run() + public Void run() { put("CallbackHandler.Default", DefaultCallbackHandler.class.getName()); put("CallbackHandler.Console", ConsoleCallbackHandler.class.getName()); diff --git a/gnu/javax/security/auth/login/ConfigFileParser.java b/gnu/javax/security/auth/login/ConfigFileParser.java index bebd036f9..e86e4a8c6 100644 --- a/gnu/javax/security/auth/login/ConfigFileParser.java +++ b/gnu/javax/security/auth/login/ConfigFileParser.java @@ -1,5 +1,5 @@ /* ConfigFileParser.java -- JAAS Login Configuration default syntax parser - Copyright (C) 2006, 2010 Free Software Foundation, Inc. + Copyright (C) 2006, 2010, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -95,7 +95,8 @@ public final class ConfigFileParser Logger.getLogger(ConfigFileParser.class.getName()) : null; private ConfigFileTokenizer cft; - private final Map map = new HashMap(); + private final Map<String,List<AppConfigurationEntry>> map = + new HashMap<String,List<AppConfigurationEntry>>(); // default 0-arguments constructor @@ -106,7 +107,7 @@ public final class ConfigFileParser * encountered, for that application name in the just parsed configuration * file. */ - public Map getLoginModulesMap() + public Map<String,List<AppConfigurationEntry>> getLoginModulesMap() { return map; } @@ -159,7 +160,7 @@ public final class ConfigFileParser if (cft.nextToken() != '{') abort("Missing '{' after APP_NAME_OR_OTHER"); - List lmis = new ArrayList(); + List<AppConfigurationEntry> lmis = new ArrayList<AppConfigurationEntry>(); while (parseACE(lmis)) { /* do nothing */ @@ -173,10 +174,10 @@ public final class ConfigFileParser if (c != ';') abort("Was expecting ';' but found " + (char) c); - List listOfACEs = (List) map.get(appName); + List<AppConfigurationEntry> listOfACEs = map.get(appName); if (listOfACEs == null) { - listOfACEs = new ArrayList(); + listOfACEs = new ArrayList<AppConfigurationEntry>(); map.put(appName, listOfACEs); } listOfACEs.addAll(lmis); @@ -188,7 +189,8 @@ public final class ConfigFileParser * Returns <code>false</code> otherwise. * @throws IOException if an exception occurs while parsing the input. */ - private boolean parseACE(List listOfACEs) throws IOException + private boolean parseACE(List<AppConfigurationEntry> listOfACEs) + throws IOException { int c = cft.nextToken(); if (c != ConfigFileTokenizer.TT_WORD) @@ -219,7 +221,7 @@ public final class ConfigFileParser else abort("Unknown Flag: " + flag); - Map options = new HashMap(); + Map<String,String> options = new HashMap<String,String>(); String paramName, paramValue; c = cft.nextToken(); while (c != ';') diff --git a/gnu/javax/security/auth/login/GnuConfiguration.java b/gnu/javax/security/auth/login/GnuConfiguration.java index 6afe1cd19..b7c3b5a44 100644 --- a/gnu/javax/security/auth/login/GnuConfiguration.java +++ b/gnu/javax/security/auth/login/GnuConfiguration.java @@ -1,5 +1,5 @@ /* GnuConfiguration.java -- GNU Classpath implementation of JAAS Configuration - Copyright (C) 2006, 2010 Free Software Foundation, Inc. + Copyright (C) 2006, 2010, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -47,7 +47,6 @@ import java.net.MalformedURLException; import java.net.URL; import java.security.Security; import java.util.HashMap; -import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.logging.Logger; @@ -136,7 +135,7 @@ public final class GnuConfiguration extends Configuration * this map is a {@link List} of {@link AppConfigurationEntry}s for that * application name. */ - private Map loginModulesMap; + private Map<String,List<AppConfigurationEntry>> loginModulesMap; /** Our reference to our default syntax parser. */ private ConfigFileParser cp; @@ -148,7 +147,7 @@ public final class GnuConfiguration extends Configuration { super(); - loginModulesMap = new HashMap(); + loginModulesMap = new HashMap<String,List<AppConfigurationEntry>>(); cp = new ConfigFileParser(); init(); } @@ -173,13 +172,13 @@ public final class GnuConfiguration extends Configuration if (appName.length() == 0) return null; - List loginModules = (List) loginModulesMap.get(appName); + List<AppConfigurationEntry> loginModules = loginModulesMap.get(appName); if (loginModules == null || loginModules.size() == 0) return null; if (gnu.java.security.Configuration.DEBUG) log.fine(appName + " -> " + loginModules.size() + " entry(ies)"); - return (AppConfigurationEntry[]) loginModules.toArray(new AppConfigurationEntry[0]); + return loginModules.toArray(new AppConfigurationEntry[loginModules.size()]); } /** @@ -241,7 +240,7 @@ public final class GnuConfiguration extends Configuration * <i>java.security.auth.login.config.url.N</i>. * * @return <code>true</code> if it succeeds, and <code>false</code> - * otherwsie. + * otherwise. */ private boolean processSecurityProperties() { @@ -386,23 +385,23 @@ public final class GnuConfiguration extends Configuration private void parseConfig(InputStream configStream) throws IOException { cp.parse(new InputStreamReader(configStream, "UTF-8")); - Map loginModulesMap = cp.getLoginModulesMap(); + Map<String,List<AppConfigurationEntry>> loginModulesMap = cp.getLoginModulesMap(); mergeLoginModules(loginModulesMap); } - private void mergeLoginModules(Map otherLoginModules) + private void mergeLoginModules(Map<String,List<AppConfigurationEntry>> otherLoginModules) { if (otherLoginModules == null || otherLoginModules.size() < 1) return; - for (Iterator it = otherLoginModules.keySet().iterator(); it.hasNext();) + for (Map.Entry<String,List<AppConfigurationEntry>> entry : otherLoginModules.entrySet()) { - String appName = (String) it.next(); - List thatListOfACEs = (List) otherLoginModules.get(appName); + String appName = entry.getKey(); + List<AppConfigurationEntry> thatListOfACEs = entry.getValue(); if (thatListOfACEs == null || thatListOfACEs.size() < 1) continue; - List thisListsOfACEs = (List) loginModulesMap.get(appName); + List<AppConfigurationEntry> thisListsOfACEs = loginModulesMap.get(appName); if (thisListsOfACEs == null) loginModulesMap.put(appName, thatListOfACEs); else diff --git a/java/security/AccessControlContext.java b/java/security/AccessControlContext.java index fd964751c..726a6f6e6 100644 --- a/java/security/AccessControlContext.java +++ b/java/security/AccessControlContext.java @@ -1,5 +1,5 @@ /* AccessControlContext.java --- Access Control Context Class - Copyright (C) 1999, 2004 Free Software Foundation, Inc. + Copyright (C) 1999, 2004, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -67,11 +67,11 @@ public final class AccessControlContext */ public AccessControlContext(ProtectionDomain[] context) { - HashSet domains = new HashSet (context.length); + HashSet<ProtectionDomain> domains = + new HashSet<ProtectionDomain>(context.length); for (int i = 0; i < context.length; i++) domains.add (context[i]); - protectionDomains = (ProtectionDomain[]) - domains.toArray (new ProtectionDomain[domains.size()]); + protectionDomains = domains.toArray (new ProtectionDomain[domains.size()]); combiner = null; } diff --git a/java/security/AllPermission.java b/java/security/AllPermission.java index 6adcd8c9c..0a0a5f2ce 100644 --- a/java/security/AllPermission.java +++ b/java/security/AllPermission.java @@ -1,5 +1,5 @@ /* AllPermission.java -- Permission to do anything - Copyright (C) 1998, 2001, 2002, 2004, 2005 Free Software Foundation, Inc. + Copyright (C) 1998, 2001, 2002, 2004, 2005, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -163,6 +163,7 @@ public final class AllPermission extends Permission * @throws IllegalArgumentException if perm is not an AllPermission * @throws SecurityException if the collection is read-only */ + @Override public void add(Permission perm) { if (isReadOnly()) @@ -178,6 +179,7 @@ public final class AllPermission extends Permission * @param perm the permission to check * @return true if this collection contains an AllPermission */ + @Override public boolean implies(Permission perm) { return all_allowed; @@ -188,11 +190,12 @@ public final class AllPermission extends Permission * * @return the elements in the collection */ - public Enumeration elements() + @Override + public Enumeration<Permission> elements() { return all_allowed - ? Collections.enumeration(Collections.singleton(new AllPermission())) - : EmptyEnumeration.getInstance(); + ? Collections.enumeration(Collections.singleton((Permission) new AllPermission())) + : new EmptyEnumeration<Permission>(); } } // class AllPermissionCollection } // class AllPermission diff --git a/java/security/BasicPermission.java b/java/security/BasicPermission.java index 6296cffea..3bd0bd8f3 100644 --- a/java/security/BasicPermission.java +++ b/java/security/BasicPermission.java @@ -1,5 +1,5 @@ /* BasicPermission.java -- implements a simple named permission - Copyright (C) 1998, 1999, 2002, 2003, 2004, 2005, 2006 + Copyright (C) 1998, 1999, 2002, 2003, 2004, 2005, 2006, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -128,6 +128,7 @@ public abstract class BasicPermission extends Permission * @param perm the <code>Permission</code> object to test against * @return true if the specified permission is implied */ + @Override public boolean implies(Permission perm) { if (! getClass().isInstance(perm)) @@ -155,6 +156,7 @@ public abstract class BasicPermission extends Permission * @param obj the <code>Object</code> to test for equality * @return true if obj is semantically equal to this */ + @Override public boolean equals(Object obj) { return getClass().isInstance(obj) @@ -168,6 +170,7 @@ public abstract class BasicPermission extends Permission * * @return a hash value for this object */ + @Override public int hashCode() { return getName().hashCode(); @@ -217,7 +220,7 @@ public abstract class BasicPermission extends Permission * * @serial a hash mapping name to permissions, all of type permClass */ - private final Hashtable permissions = new Hashtable(); + private final Hashtable<String,Permission> permissions = new Hashtable<String,Permission>(); /** * If "*" is in the collection. @@ -231,14 +234,14 @@ public abstract class BasicPermission extends Permission * * @serial the limiting subclass of this collection */ - private final Class permClass; + private final Class<? extends BasicPermission> permClass; /** * Construct a collection over the given runtime class. * * @param c the class */ - BasicPermissionCollection(Class c) + BasicPermissionCollection(Class<? extends BasicPermission> c) { permClass = c; } @@ -251,6 +254,7 @@ public abstract class BasicPermission extends Permission * @throws IllegalArgumentException if perm is not the correct type * @throws SecurityException if the collection is read-only */ + @Override public void add(Permission perm) { if (isReadOnly()) @@ -270,6 +274,7 @@ public abstract class BasicPermission extends Permission * @param permission the permission to check * @return true if it is implied by this */ + @Override public boolean implies(Permission permission) { if (! permClass.isInstance(permission)) @@ -300,7 +305,8 @@ public abstract class BasicPermission extends Permission * * @return an enumeration of the collection contents */ - public Enumeration elements() + @Override + public Enumeration<Permission> elements() { return permissions.elements(); } diff --git a/java/security/CodeSource.java b/java/security/CodeSource.java index dd353eda0..6f98a00cd 100644 --- a/java/security/CodeSource.java +++ b/java/security/CodeSource.java @@ -1,5 +1,5 @@ /* CodeSource.java -- Code location and certifcates - Copyright (C) 1998, 2002, 2004 Free Software Foundation, Inc. + Copyright (C) 1998, 2002, 2004, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -82,7 +82,7 @@ public class CodeSource implements Serializable private final URL location; /** The set of certificates for this code base. */ - private transient HashSet certs; + private transient HashSet<Certificate> certs; /** * This creates a new instance of <code>CodeSource</code> that loads code @@ -96,7 +96,7 @@ public class CodeSource implements Serializable { this.location = location; if (certs != null) - this.certs = new HashSet(Arrays.asList(certs)); + this.certs = new HashSet<Certificate>(Arrays.asList(certs)); } /** @@ -104,6 +104,7 @@ public class CodeSource implements Serializable * * @return a hash value for this object */ + @Override public int hashCode() { return (location == null ? 0 : location.hashCode()) @@ -118,6 +119,7 @@ public class CodeSource implements Serializable * @param obj the <code>Object</code> to test against * @return true if the specified object is equal to this one */ + @Override public boolean equals(Object obj) { if (! (obj instanceof CodeSource)) @@ -259,6 +261,7 @@ public class CodeSource implements Serializable * * @return a <code>String</code> for this object */ + @Override public String toString() { CPStringBuilder sb = new CPStringBuilder("(").append(location); @@ -266,7 +269,7 @@ public class CodeSource implements Serializable sb.append(" <no certificates>"); else { - Iterator iter = certs.iterator(); + Iterator<Certificate> iter = certs.iterator(); for (int i = certs.size(); --i >= 0; ) sb.append(' ').append(iter.next()); } @@ -288,7 +291,7 @@ public class CodeSource implements Serializable { s.defaultReadObject(); int count = s.readInt(); - certs = new HashSet(); + certs = new HashSet<Certificate>(); while (--count >= 0) { String type = (String) s.readObject(); @@ -327,10 +330,10 @@ public class CodeSource implements Serializable { int count = certs.size(); s.writeInt(count); - Iterator iter = certs.iterator(); + Iterator<Certificate> iter = certs.iterator(); while (--count >= 0) { - Certificate c = (Certificate) iter.next(); + Certificate c = iter.next(); s.writeObject(c.getType()); byte[] encoded; try diff --git a/java/security/DummySignature.java b/java/security/DummySignature.java index b74885c99..2720dd47a 100644 --- a/java/security/DummySignature.java +++ b/java/security/DummySignature.java @@ -1,5 +1,5 @@ /* DummySignature.java - Signature wrapper for SignatureSpi. - Copyright (C) 1999, 2002 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -47,6 +47,7 @@ final class DummySignature extends Signature this.sigSpi = sigSpi; } + @Override public Object clone() throws CloneNotSupportedException { Signature result = new DummySignature @@ -55,45 +56,53 @@ final class DummySignature extends Signature return result; } + @Override protected void engineInitVerify(PublicKey publicKey) throws InvalidKeyException { sigSpi.engineInitVerify(publicKey); } + @Override protected void engineInitSign(PrivateKey privateKey) throws InvalidKeyException { sigSpi.engineInitSign(privateKey); } + @Override protected void engineUpdate(byte b) throws SignatureException { sigSpi.engineUpdate(b); } + @Override protected void engineUpdate(byte[]b, int off, int len) throws SignatureException { sigSpi.engineUpdate(b, off, len); } + @Override protected byte[] engineSign() throws SignatureException { return sigSpi.engineSign(); } + @Override protected boolean engineVerify(byte[]sigBytes) throws SignatureException { return sigSpi.engineVerify(sigBytes); } + @Override protected void engineSetParameter(String param, Object value) throws InvalidParameterException { sigSpi.engineSetParameter(param, value); } + @Override protected Object engineGetParameter(String param) throws InvalidParameterException { diff --git a/java/security/Identity.java b/java/security/Identity.java index 83ec4c8e1..d3f48e887 100644 --- a/java/security/Identity.java +++ b/java/security/Identity.java @@ -1,5 +1,5 @@ /* Identity.java --- Identity Class - Copyright (C) 1999, 2003, Free Software Foundation, Inc. + Copyright (C) 1999, 2003, 2014, Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -71,7 +71,7 @@ public abstract class Identity implements Principal, Serializable private IdentityScope scope; private PublicKey publicKey; private String info; - private Vector certificates; + private Vector<Certificate> certificates; /** Constructor for serialization only. */ protected Identity() @@ -202,7 +202,7 @@ public abstract class Identity implements Principal, Serializable // Check public key of this certificate against the first one in the vector if (certificates.size() > 0) { - if (((Certificate) certificates.firstElement()).getPublicKey() != publicKey) + if (certificates.firstElement().getPublicKey() != publicKey) throw new KeyManagementException("Public key does not match"); } certificates.addElement(certificate); @@ -238,7 +238,7 @@ public abstract class Identity implements Principal, Serializable Certificate[] certs = new Certificate[certificates.size()]; int max = certificates.size(); for (int i = 0; i < max; i++) - certs[i] = (Certificate) certificates.elementAt(i); + certs[i] = certificates.elementAt(i); return certs; } diff --git a/java/security/IntersectingDomainCombiner.java b/java/security/IntersectingDomainCombiner.java index 2bfcfb442..9a40ce75e 100644 --- a/java/security/IntersectingDomainCombiner.java +++ b/java/security/IntersectingDomainCombiner.java @@ -1,5 +1,5 @@ /* IntersectingDomainCombiner.java -- - Copyright (C) 2004 Free Software Foundation, Inc. + Copyright (C) 2004, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -65,7 +65,7 @@ final class IntersectingDomainCombiner implements DomainCombiner public ProtectionDomain[] combine (ProtectionDomain[] currentDomains, ProtectionDomain[] assignedDomains) { - HashSet newDomains = new HashSet (); + HashSet<ProtectionDomain> newDomains = new HashSet<ProtectionDomain>(); for (int i = 0; i < currentDomains.length; i++) { if (currentDomains[i] == null) @@ -76,7 +76,6 @@ final class IntersectingDomainCombiner implements DomainCombiner newDomains.add (currentDomains[i]); } } - return (ProtectionDomain[]) - newDomains.toArray(new ProtectionDomain[newDomains.size()]); + return newDomains.toArray(new ProtectionDomain[newDomains.size()]); } } diff --git a/java/security/KeyPairGenerator.java b/java/security/KeyPairGenerator.java index 5e6bb1a3c..19724da6f 100644 --- a/java/security/KeyPairGenerator.java +++ b/java/security/KeyPairGenerator.java @@ -1,5 +1,5 @@ /* KeyPairGenerator.java --- Key Pair Generator Class - Copyright (C) 1999, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2003, 2004, 2005, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -236,6 +236,7 @@ public abstract class KeyPairGenerator extends KeyPairGeneratorSpi * the {@link SecureRandom} to use. * @since 1.2 */ + @Override public void initialize(int keysize, SecureRandom random) { } @@ -269,6 +270,7 @@ public abstract class KeyPairGenerator extends KeyPairGeneratorSpi * if the designated specifications are invalid. * @since 1.2 */ + @Override public void initialize(AlgorithmParameterSpec params, SecureRandom random) throws InvalidAlgorithmParameterException { diff --git a/java/security/Permissions.java b/java/security/Permissions.java index d814064e0..40087ba02 100644 --- a/java/security/Permissions.java +++ b/java/security/Permissions.java @@ -1,5 +1,5 @@ /* Permissions.java -- a collection of permission collections - Copyright (C) 1998, 2001, 2002, 2004, 2005 Free Software Foundation, Inc. + Copyright (C) 1998, 2001, 2002, 2004, 2005, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -78,7 +78,8 @@ public final class Permissions extends PermissionCollection * * @serial maps Class to PermissionCollection */ - final Hashtable perms = new Hashtable(); + final Hashtable<Class<?>,PermissionCollection> perms = + new Hashtable<Class<?>,PermissionCollection>(); /** * This method initializes a new instance of <code>Permissions</code>. @@ -99,6 +100,7 @@ public final class Permissions extends PermissionCollection * @param perm the <code>Permission</code> to add * @throws SecurityException if this collection is marked as read only */ + @Override public void add(Permission perm) { if (isReadOnly()) @@ -114,8 +116,7 @@ public final class Permissions extends PermissionCollection } else { - PermissionCollection pc - = (PermissionCollection) perms.get(perm.getClass()); + PermissionCollection pc = perms.get(perm.getClass()); if (pc == null) { pc = perm.newPermissionCollection(); @@ -134,12 +135,12 @@ public final class Permissions extends PermissionCollection * @param perm the <code>Permission</code> to test * @return true if the specified permission is implied by this */ + @Override public boolean implies(Permission perm) { if (allPermission != null) return true; - PermissionCollection pc - = (PermissionCollection) perms.get(perm.getClass()); + PermissionCollection pc = perms.get(perm.getClass()); return pc == null ? false : pc.implies(perm); } @@ -150,41 +151,41 @@ public final class Permissions extends PermissionCollection * * @return an <code>Enumeration</code> of this collection's elements */ + @Override public Enumeration<Permission> elements() { - return new Enumeration() + return new Enumeration<Permission>() { - Enumeration main_enum = perms.elements(); - Enumeration sub_enum; + Enumeration<PermissionCollection> mainEnum = perms.elements(); + Enumeration<Permission> subEnum; public boolean hasMoreElements() { - if (sub_enum == null) + if (subEnum == null) { - if (main_enum == null) + if (mainEnum == null) return false; - if (! main_enum.hasMoreElements()) + if (! mainEnum.hasMoreElements()) { - main_enum = null; + mainEnum = null; return false; } - PermissionCollection pc = - (PermissionCollection) main_enum.nextElement(); - sub_enum = pc.elements(); + PermissionCollection pc = mainEnum.nextElement(); + subEnum = pc.elements(); } - if (! sub_enum.hasMoreElements()) + if (! subEnum.hasMoreElements()) { - sub_enum = null; + subEnum = null; return hasMoreElements(); } return true; } - public Object nextElement() + public Permission nextElement() { if (! hasMoreElements()) throw new NoSuchElementException(); - return sub_enum.nextElement(); + return subEnum.nextElement(); } }; } @@ -207,7 +208,8 @@ public final class Permissions extends PermissionCollection * * @serial the stored permissions, both as key and value */ - private final Hashtable perms = new Hashtable(); + private final Hashtable<Permission,Permission> perms = + new Hashtable<Permission,Permission>(); /** * Add a permission. We don't need to check for read-only, as this @@ -216,6 +218,7 @@ public final class Permissions extends PermissionCollection * * @param perm the permission to add */ + @Override public void add(Permission perm) { perms.put(perm, perm); @@ -228,13 +231,14 @@ public final class Permissions extends PermissionCollection * @return true if it is implied */ // FIXME: Should this method be synchronized? + @Override public boolean implies(Permission perm) { - Enumeration elements = elements(); + Enumeration<Permission> elements = elements(); while (elements.hasMoreElements()) { - Permission p = (Permission)elements.nextElement(); + Permission p = elements.nextElement(); if (p.implies(perm)) return true; } @@ -246,7 +250,8 @@ public final class Permissions extends PermissionCollection * * @return the elements */ - public Enumeration elements() + @Override + public Enumeration<Permission> elements() { return perms.elements(); } diff --git a/java/security/Policy.java b/java/security/Policy.java index 118626ea1..930315bfd 100644 --- a/java/security/Policy.java +++ b/java/security/Policy.java @@ -1,5 +1,5 @@ /* Policy.java --- Policy Manager Class - Copyright (C) 1999, 2003, 2004 Free Software Foundation, Inc. + Copyright (C) 1999, 2003, 2004, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -92,7 +92,7 @@ public abstract class Policy private static Policy currentPolicy; /** Map of ProtectionDomains to PermissionCollections for this instance. */ - private Map pd2pc = null; + private Map<ProtectionDomain,PermissionCollection> pd2pc = null; /** Constructs a new <code>Policy</code> object. */ public Policy() @@ -140,7 +140,8 @@ public abstract class Policy private static void setup(final Policy policy) { if (policy.pd2pc == null) - policy.pd2pc = Collections.synchronizedMap(new LinkedHashMap()); + policy.pd2pc = + Collections.synchronizedMap(new LinkedHashMap<ProtectionDomain,PermissionCollection>()); ProtectionDomain pd = policy.getClass().getProtectionDomain(); if (pd.getCodeSource() != null) @@ -232,12 +233,12 @@ public abstract class Policy if (pd2pc == null) setup(this); - PermissionCollection result = (PermissionCollection) pd2pc.get(domain); + PermissionCollection result = pd2pc.get(domain); if (result != null) { Permissions realResult = new Permissions(); - for (Enumeration e = result.elements(); e.hasMoreElements(); ) - realResult.add((Permission) e.nextElement()); + for (Enumeration<Permission> e = result.elements(); e.hasMoreElements(); ) + realResult.add(e.nextElement()); return realResult; } @@ -248,8 +249,8 @@ public abstract class Policy PermissionCollection pc = domain.getPermissions(); if (pc != null) - for (Enumeration e = pc.elements(); e.hasMoreElements(); ) - result.add((Permission) e.nextElement()); + for (Enumeration<Permission> e = pc.elements(); e.hasMoreElements(); ) + result.add(e.nextElement()); return result; } diff --git a/java/security/SecureRandom.java b/java/security/SecureRandom.java index abf4ff308..649966fee 100644 --- a/java/security/SecureRandom.java +++ b/java/security/SecureRandom.java @@ -1,5 +1,5 @@ /* SecureRandom.java --- Secure Random class implementation - Copyright (C) 1999, 2001, 2002, 2003, 2005, 2006 + Copyright (C) 1999, 2001, 2002, 2003, 2005, 2006, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -38,22 +38,14 @@ exception statement from your version. */ package java.security; -import gnu.classpath.SystemProperties; import gnu.java.lang.CPStringBuilder; import gnu.java.security.Engine; -import gnu.java.security.action.GetSecurityPropertyAction; import gnu.java.security.jce.prng.SecureRandomAdapter; import gnu.java.security.jce.prng.Sha160RandomSpi; -import java.io.IOException; -import java.io.InputStream; import java.lang.reflect.InvocationTargetException; -import java.net.MalformedURLException; -import java.net.URL; import java.util.Enumeration; import java.util.Random; -import java.util.logging.Level; -import java.util.logging.Logger; /** * An interface to a cryptographically secure pseudo-random number @@ -110,7 +102,7 @@ public class SecureRandom extends Random String classname = null; int i; - Enumeration e; + Enumeration<?> e; for (i = 0; i < p.length; i++) { e = p[i].propertyNames(); diff --git a/java/security/Security.java b/java/security/Security.java index 6cd98b0fb..6b20a7cb6 100644 --- a/java/security/Security.java +++ b/java/security/Security.java @@ -1,5 +1,5 @@ /* Security.java --- Java base security class implementation - Copyright (C) 1999, 2001, 2002, 2003, 2004, 2005, 2006 + Copyright (C) 1999, 2001, 2002, 2003, 2004, 2005, 2006, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -48,10 +48,8 @@ import java.io.IOException; import java.io.InputStream; import java.net.URL; import java.util.Collections; -import java.util.Enumeration; import java.util.HashMap; import java.util.HashSet; -import java.util.Iterator; import java.util.LinkedHashSet; import java.util.Map; import java.util.Properties; @@ -68,7 +66,7 @@ public final class Security { private static final String ALG_ALIAS = "Alg.Alias."; - private static Vector providers = new Vector(); + private static Vector<Provider> providers = new Vector<Provider>(); private static Properties secprops = new Properties(); static @@ -139,7 +137,7 @@ public final class Security try { ClassLoader sys = ClassLoader.getSystemClassLoader(); - providers.addElement(Class.forName(name, true, sys).newInstance()); + providers.addElement((Provider) Class.forName(name, true, sys).newInstance()); } catch (ClassNotFoundException x) { @@ -191,13 +189,10 @@ public final class Security return null; String property = String.valueOf(propName) + "." + String.valueOf(algName); - Provider p; - for (Iterator i = providers.iterator(); i.hasNext(); ) + for (Provider p : providers) { - p = (Provider) i.next(); - for (Iterator j = p.keySet().iterator(); j.hasNext(); ) + for (String key : p.stringPropertyNames()) { - String key = (String) j.next(); if (key.equalsIgnoreCase(property)) return p.getProperty(key); } @@ -235,7 +230,7 @@ public final class Security int max = providers.size (); for (int i = 0; i < max; i++) { - if (((Provider) providers.elementAt(i)).getName().equals(provider.getName())) + if (providers.elementAt(i).getName().equals(provider.getName())) return -1; } @@ -291,7 +286,7 @@ public final class Security int max = providers.size (); for (int i = 0; i < max; i++) { - if (((Provider) providers.elementAt(i)).getName().equals(name)) + if (providers.elementAt(i).getName().equals(name)) { providers.remove(i); break; @@ -337,7 +332,7 @@ public final class Security int max = providers.size (); for (int i = 0; i < max; i++) { - p = (Provider) providers.elementAt(i); + p = providers.elementAt(i); if (p.getName().equals(name)) return p; } @@ -422,9 +417,9 @@ public final class Security Provider[] providers = getProviders(); int ndx; for (int i = 0; i < providers.length; i++) - for (Enumeration e = providers[i].propertyNames(); e.hasMoreElements(); ) + for (String s : providers[i].stringPropertyNames()) { - String service = ((String) e.nextElement()).trim(); + String service = s.trim(); if (service.toUpperCase().startsWith(serviceName)) { service = service.substring(serviceName.length()).trim(); @@ -490,7 +485,7 @@ public final class Security if (filter == null || filter.length() == 0) return getProviders(); - HashMap map = new HashMap(1); + HashMap<String,String> map = new HashMap<String,String>(1); int i = filter.indexOf(':'); if (i == -1) // <service>.<algorithm> map.put(filter, ""); @@ -505,7 +500,7 @@ public final class Security * set of <i>selection</i> criteria. * * <p>The <i>selection</i> criteria are defined in a {@link Map} where each - * element specifies a <i>selection</i> querry. The <i>Keys</i> in this + * element specifies a <i>selection</i> query. The <i>Keys</i> in this * {@link Map} must be in one of the two following forms:</p> * * <ul> @@ -531,7 +526,7 @@ public final class Security * </ul> * * @param filter - * a {@link Map} of <i>selection querries</i>. + * a {@link Map} of <i>selection queries</i>. * @return all currently installed {@link Provider}s which satisfy ALL the * <i>selection</i> criteria defined in <code>filter</code>. * Returns ALL installed {@link Provider}s if <code>filter</code> @@ -549,68 +544,67 @@ public final class Security if (filter == null) return getProviders(); - Set<String> querries = filter.keySet(); - if (querries == null || querries.isEmpty()) + Set<String> queries = filter.keySet(); + if (queries == null || queries.isEmpty()) return getProviders(); - LinkedHashSet result = new LinkedHashSet(providers); // assume all + LinkedHashSet<Provider> result = new LinkedHashSet<Provider>(providers); // assume all int dot, ws; - String querry, service, algorithm, attribute, value; - LinkedHashSet serviceProviders = new LinkedHashSet(); // preserve insertion order - for (Iterator i = querries.iterator(); i.hasNext(); ) + String service, algorithm, attribute, value; + LinkedHashSet<Provider> serviceProviders = new LinkedHashSet<Provider>(); // preserve insertion order + for (String query : queries) { - querry = (String) i.next(); - if (querry == null) // all providers + if (query == null) // all providers continue; - querry = querry.trim(); - if (querry.length() == 0) // all providers + query = query.trim(); + if (query.length() == 0) // all providers continue; - dot = querry.indexOf('.'); + dot = query.indexOf('.'); if (dot == -1) // syntax error throw new InvalidParameterException( - "missing dot in '" + String.valueOf(querry)+"'"); + "missing dot in '" + String.valueOf(query)+"'"); - value = filter.get(querry); - // deconstruct querry into [service, algorithm, attribute] + value = filter.get(query); + // deconstruct query into [service, algorithm, attribute] if (value == null || value.trim().length() == 0) // <service>.<algorithm> { value = null; attribute = null; - service = querry.substring(0, dot).trim(); - algorithm = querry.substring(dot+1).trim(); + service = query.substring(0, dot).trim(); + algorithm = query.substring(dot+1).trim(); } else // <service>.<algorithm> <attribute> { - ws = querry.indexOf(' '); + ws = query.indexOf(' '); if (ws == -1) throw new InvalidParameterException( "value (" + String.valueOf(value) + - ") is not empty, but querry (" + String.valueOf(querry) + + ") is not empty, but query (" + String.valueOf(query) + ") is missing at least one space character"); value = value.trim(); - attribute = querry.substring(ws+1).trim(); + attribute = query.substring(ws+1).trim(); // was the dot in the attribute? if (attribute.indexOf('.') != -1) throw new InvalidParameterException( "attribute_name (" + String.valueOf(attribute) + - ") in querry (" + String.valueOf(querry) + ") contains a dot"); + ") in query (" + String.valueOf(query) + ") contains a dot"); - querry = querry.substring(0, ws).trim(); - service = querry.substring(0, dot).trim(); - algorithm = querry.substring(dot+1).trim(); + query = query.substring(0, ws).trim(); + service = query.substring(0, dot).trim(); + algorithm = query.substring(dot+1).trim(); } // service and algorithm must not be empty if (service.length() == 0) throw new InvalidParameterException( - "<crypto_service> in querry (" + String.valueOf(querry) + + "<crypto_service> in query (" + String.valueOf(query) + ") is empty"); if (algorithm.length() == 0) throw new InvalidParameterException( - "<algorithm_or_type> in querry (" + String.valueOf(querry) + + "<algorithm_or_type> in query (" + String.valueOf(query) + ") is empty"); selectProviders(service, algorithm, attribute, value, result, serviceProviders); @@ -622,17 +616,16 @@ public final class Security if (result.isEmpty()) return null; - return (Provider[]) result.toArray(new Provider[result.size()]); + return result.toArray(new Provider[result.size()]); } private static void selectProviders(String svc, String algo, String attr, - String val, LinkedHashSet providerSet, - LinkedHashSet result) + String val, LinkedHashSet<Provider> providerSet, + LinkedHashSet<Provider> result) { result.clear(); // ensure we start with an empty result set - for (Iterator i = providerSet.iterator(); i.hasNext(); ) + for (Provider p : providerSet) { - Provider p = (Provider) i.next(); if (provides(p, svc, algo, attr, val)) result.add(p); } @@ -641,9 +634,7 @@ public final class Security private static boolean provides(Provider p, String svc, String algo, String attr, String val) { - Iterator it; String serviceDotAlgorithm = null; - String key = null; String realVal; boolean found = false; // if <svc>.<algo> <attr> is in the set then so is <svc>.<algo> @@ -651,9 +642,8 @@ public final class Security outer: for (int r = 0; r < 3; r++) // guard against circularity { serviceDotAlgorithm = (svc+"."+String.valueOf(algo)).trim(); - for (it = p.keySet().iterator(); it.hasNext(); ) + for (String key : p.stringPropertyNames()) { - key = (String) it.next(); if (key.equalsIgnoreCase(serviceDotAlgorithm)) // eureka { found = true; @@ -679,9 +669,8 @@ public final class Security // <service>.<algorithm> <attribute>; find the key entry that match String realAttr; int limit = serviceDotAlgorithm.length() + 1; - for (it = p.keySet().iterator(); it.hasNext(); ) + for (String key : p.stringPropertyNames()) { - key = (String) it.next(); if (key.length() <= limit) continue; diff --git a/java/security/SignatureSpi.java b/java/security/SignatureSpi.java index 1ed078c0b..11ce551a0 100644 --- a/java/security/SignatureSpi.java +++ b/java/security/SignatureSpi.java @@ -1,5 +1,5 @@ /* SignatureSpi.java --- Signature Service Provider Interface - Copyright (C) 1999, 2003, Free Software Foundation, Inc. + Copyright (C) 1999, 2003, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -309,6 +309,7 @@ public abstract class SignatureSpi * @throws CloneNotSupportedException * if the implementation does not support cloning. */ + @Override public Object clone() throws CloneNotSupportedException { return super.clone(); diff --git a/java/security/UnresolvedPermission.java b/java/security/UnresolvedPermission.java index 449454aaf..d7af92211 100644 --- a/java/security/UnresolvedPermission.java +++ b/java/security/UnresolvedPermission.java @@ -1,5 +1,5 @@ /* UnresolvedPermission.java -- Placeholder for unresolved permissions - Copyright (C) 1998, 2001, 2002, 2004, 2005 Free Software Foundation, Inc. + Copyright (C) 1998, 2001, 2002, 2004, 2005, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -128,6 +128,7 @@ public final class UnresolvedPermission extends Permission * @param perm the <code>Permission</code> object to test * @return false; until a permission is resolved, it implies nothing */ + @Override public boolean implies(Permission perm) { return false; @@ -149,6 +150,7 @@ public final class UnresolvedPermission extends Permission * @param obj the <code>Object</code> to test for equality * @return true if the specified object is equal to this one */ + @Override public boolean equals(Object obj) { if (! (obj instanceof UnresolvedPermission)) @@ -164,6 +166,7 @@ public final class UnresolvedPermission extends Permission * * @return A hash value */ + @Override public int hashCode() { return name.hashCode(); @@ -175,6 +178,7 @@ public final class UnresolvedPermission extends Permission * * @return the action list */ + @Override public String getActions() { return actions; @@ -186,6 +190,7 @@ public final class UnresolvedPermission extends Permission * * @return <code>String</code> representation of this object */ + @Override public String toString() { return "(unresolved " + type + ' ' + name + ' ' + actions + ')'; @@ -197,6 +202,7 @@ public final class UnresolvedPermission extends Permission * * @return a new <code>PermissionCollection</code> */ + @Override public PermissionCollection newPermissionCollection() { return new UnresolvedPermissionCollection(); @@ -264,7 +270,8 @@ class UnresolvedPermissionCollection extends PermissionCollection * @serial map of typename to a Vector of permissions (you'd think Sun * would document this better!) */ - final Hashtable permissions = new Hashtable(); + final Hashtable<String,Vector<Permission>> permissions = + new Hashtable<String,Vector<Permission>>(); /** * Add a permission. @@ -273,6 +280,7 @@ class UnresolvedPermissionCollection extends PermissionCollection * @throws IllegalArgumentException if perm is not an UnresolvedPermission * @throws SecurityException if the collection is read-only */ + @Override public void add(Permission perm) { if (isReadOnly()) @@ -280,10 +288,10 @@ class UnresolvedPermissionCollection extends PermissionCollection if (! (perm instanceof UnresolvedPermission)) throw new IllegalArgumentException(); UnresolvedPermission up = (UnresolvedPermission) perm; - Vector v = (Vector) permissions.get(up.type); + Vector<Permission> v = permissions.get(up.type); if (v == null) { - v = new Vector(); + v = new Vector<Permission>(); permissions.put(up.type, v); } v.add(up); @@ -295,6 +303,7 @@ class UnresolvedPermissionCollection extends PermissionCollection * @param perm the permission to check * @return false; unresolved permissions imply nothing */ + @Override public boolean implies(Permission perm) { return false; @@ -305,40 +314,41 @@ class UnresolvedPermissionCollection extends PermissionCollection * * @return the elements */ - public Enumeration elements() + @Override + public Enumeration<Permission> elements() { - return new Enumeration() + return new Enumeration<Permission>() { - Enumeration main_enum = permissions.elements(); - Enumeration sub_enum; + Enumeration<Vector<Permission>> mainEnum = permissions.elements(); + Enumeration<Permission> subEnum; public boolean hasMoreElements() { - if (sub_enum == null) + if (subEnum == null) { - if (main_enum == null) + if (mainEnum == null) return false; - if (! main_enum.hasMoreElements()) + if (! mainEnum.hasMoreElements()) { - main_enum = null; + mainEnum = null; return false; } - Vector v = (Vector) main_enum.nextElement(); - sub_enum = v.elements(); + Vector<Permission> v = mainEnum.nextElement(); + subEnum = v.elements(); } - if (! sub_enum.hasMoreElements()) + if (! subEnum.hasMoreElements()) { - sub_enum = null; + subEnum = null; return hasMoreElements(); } return true; } - public Object nextElement() + public Permission nextElement() { if (! hasMoreElements()) throw new NoSuchElementException(); - return sub_enum.nextElement(); + return subEnum.nextElement(); } }; } diff --git a/java/security/cert/CertPath.java b/java/security/cert/CertPath.java index 7211647a4..5c9a12ab9 100644 --- a/java/security/cert/CertPath.java +++ b/java/security/cert/CertPath.java @@ -1,5 +1,5 @@ /* CertPath.java -- a sequence of certificates - Copyright (C) 2002, 2005 Free Software Foundation, Inc. + Copyright (C) 2002, 2005, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -195,7 +195,7 @@ public abstract class CertPath implements Serializable public String toString() { - List l = getCertificates(); + List<? extends Certificate> l = getCertificates(); int size = l.size(); int i = 0; CPStringBuilder result = new CPStringBuilder(type); diff --git a/java/security/cert/CertPathValidator.java b/java/security/cert/CertPathValidator.java index 8bd7b58e8..ec02a7585 100644 --- a/java/security/cert/CertPathValidator.java +++ b/java/security/cert/CertPathValidator.java @@ -1,5 +1,5 @@ /* CertPathValidator -- validates certificate paths. - Copyright (C) 2003, 2004 Free Software Foundation, Inc. + Copyright (C) 2003, 2004, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -39,15 +39,14 @@ exception statement from your version. */ package java.security.cert; import gnu.java.lang.CPStringBuilder; - import gnu.java.security.Engine; +import gnu.java.security.action.GetSecurityPropertyAction; import java.lang.reflect.InvocationTargetException; import java.security.AccessController; import java.security.InvalidAlgorithmParameterException; import java.security.NoSuchAlgorithmException; import java.security.NoSuchProviderException; -import java.security.PrivilegedAction; import java.security.Provider; import java.security.Security; @@ -112,18 +111,9 @@ public class CertPathValidator { * @return The default validator type. */ public static synchronized String getDefaultType() { - String type = (String) AccessController.doPrivileged( - new PrivilegedAction() - { - public Object run() - { - return Security.getProperty("certpathvalidator.type"); - } - } + return AccessController.doPrivileged( + new GetSecurityPropertyAction("certpathvalidator.type", "PKIX") ); - if (type == null) - type = "PKIX"; - return type; } /** diff --git a/java/security/cert/CertStore.java b/java/security/cert/CertStore.java index 630e96762..d4435c1a0 100644 --- a/java/security/cert/CertStore.java +++ b/java/security/cert/CertStore.java @@ -1,5 +1,5 @@ /* CertStore -- stores and retrieves certificates. - Copyright (C) 2003, 2004 Free Software Foundation, Inc. + Copyright (C) 2003, 2004, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -41,12 +41,12 @@ package java.security.cert; import gnu.java.lang.CPStringBuilder; import gnu.java.security.Engine; +import gnu.java.security.action.GetSecurityPropertyAction; import java.lang.reflect.InvocationTargetException; import java.security.InvalidAlgorithmParameterException; import java.security.NoSuchAlgorithmException; import java.security.NoSuchProviderException; -import java.security.PrivilegedAction; import java.security.Provider; import java.security.Security; import java.util.Collection; @@ -112,17 +112,9 @@ public class CertStore */ public static final synchronized String getDefaultType() { - String type = null; - type = (String) java.security.AccessController.doPrivileged( - new PrivilegedAction() { - public Object run() { - return Security.getProperty("certstore.type"); - } - } + return java.security.AccessController.doPrivileged( + new GetSecurityPropertyAction("certstore.type", "LDAP") ); - if (type == null) - type = "LDAP"; - return type; } /** diff --git a/java/security/cert/CollectionCertStoreParameters.java b/java/security/cert/CollectionCertStoreParameters.java index 389874854..6edaf7677 100644 --- a/java/security/cert/CollectionCertStoreParameters.java +++ b/java/security/cert/CollectionCertStoreParameters.java @@ -1,5 +1,5 @@ /* CollectionCertStoreParameters -- collection-based cert store parameters - Copyright (C) 2003 Free Software Foundation, Inc. + Copyright (C) 2003, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -60,7 +60,7 @@ public class CollectionCertStoreParameters implements CertStoreParameters // ------------------------------------------------------------------------ /** The underlying collection. */ - private final Collection collection; + private final Collection<?> collection; // Constructors. // ------------------------------------------------------------------------ @@ -92,9 +92,10 @@ public class CollectionCertStoreParameters implements CertStoreParameters // Instance methods. // ------------------------------------------------------------------------ + @Override public Object clone() { - return new CollectionCertStoreParameters(new ArrayList(collection)); + return new CollectionCertStoreParameters(new ArrayList<Object>(collection)); } /** diff --git a/java/security/cert/PKIXParameters.java b/java/security/cert/PKIXParameters.java index bbb75571f..1778d6127 100644 --- a/java/security/cert/PKIXParameters.java +++ b/java/security/cert/PKIXParameters.java @@ -1,5 +1,5 @@ /* PKIXParameters.java -- parameters for the PKIX cert path algorithm - Copyright (C) 2003 Free Software Foundation, Inc. + Copyright (C) 2003, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -65,16 +65,16 @@ public class PKIXParameters implements CertPathParameters // ------------------------------------------------------------------------ /** The trusted certificates. */ - private final Set trustAnchors; + private final Set<TrustAnchor> trustAnchors; /** The set of initial policy identifiers. */ - private final Set initPolicies; + private final Set<String> initPolicies; /** The list of certificate stores. */ - private final List certStores; + private final List<CertStore> certStores; /** The list of path checkers. */ - private final List pathCheckers; + private final List<PKIXCertPathChecker> pathCheckers; /** The revocation enabled flag. */ private boolean revocationEnabled; @@ -120,9 +120,9 @@ public class PKIXParameters implements CertPathParameters throws KeyStoreException, InvalidAlgorithmParameterException { this(); - for (Enumeration e = keystore.aliases(); e.hasMoreElements(); ) + for (Enumeration<String> e = keystore.aliases(); e.hasMoreElements(); ) { - String alias = (String) e.nextElement(); + String alias = e.nextElement(); if (!keystore.isCertificateEntry(alias)) continue; Certificate cert = keystore.getCertificate(alias); @@ -157,10 +157,10 @@ public class PKIXParameters implements CertPathParameters */ private PKIXParameters() { - trustAnchors = new HashSet(); - initPolicies = new HashSet(); - certStores = new LinkedList(); - pathCheckers = new LinkedList(); + trustAnchors = new HashSet<TrustAnchor>(); + initPolicies = new HashSet<String>(); + certStores = new LinkedList<CertStore>(); + pathCheckers = new LinkedList<PKIXCertPathChecker>(); revocationEnabled = true; exPolicyRequired = false; policyMappingInhibited = false; @@ -223,9 +223,9 @@ public class PKIXParameters implements CertPathParameters if (trustAnchors.isEmpty()) throw new InvalidAlgorithmParameterException("no trust anchors"); this.trustAnchors.clear(); - for (Iterator i = trustAnchors.iterator(); i.hasNext(); ) + for (Iterator<TrustAnchor> i = trustAnchors.iterator(); i.hasNext(); ) { - this.trustAnchors.add((TrustAnchor) i.next()); + this.trustAnchors.add(i.next()); } } @@ -255,9 +255,9 @@ public class PKIXParameters implements CertPathParameters this.initPolicies.clear(); if (initPolicies == null) return; - for (Iterator i = initPolicies.iterator(); i.hasNext(); ) + for (String ip : initPolicies) { - this.initPolicies.add((String) i.next()); + this.initPolicies.add(ip); } } @@ -294,9 +294,9 @@ public class PKIXParameters implements CertPathParameters this.certStores.clear(); if (certStores == null) return; - for (Iterator i = certStores.iterator(); i.hasNext(); ) + for (Iterator<CertStore> i = certStores.iterator(); i.hasNext(); ) { - this.certStores.add((CertStore) i.next()); + this.certStores.add(i.next()); } } @@ -465,9 +465,9 @@ public class PKIXParameters implements CertPathParameters this.pathCheckers.clear(); if (pathCheckers == null) return; - for (Iterator i = pathCheckers.iterator(); i.hasNext(); ) + for (Iterator<PKIXCertPathChecker> i = pathCheckers.iterator(); i.hasNext(); ) { - this.pathCheckers.add((PKIXCertPathChecker) i.next()); + this.pathCheckers.add(i.next()); } } diff --git a/java/security/cert/X509CRLSelector.java b/java/security/cert/X509CRLSelector.java index d412a1ae3..1ac5c640b 100644 --- a/java/security/cert/X509CRLSelector.java +++ b/java/security/cert/X509CRLSelector.java @@ -1,5 +1,5 @@ /* X509CRLSelector.java -- selects X.509 CRLs by criteria. - Copyright (C) 2004 Free Software Foundation, Inc. + Copyright (C) 2004, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -80,7 +80,7 @@ public class X509CRLSelector implements CRLSelector, Cloneable private static final String CRL_NUMBER_ID = "2.5.29.20"; - private List issuerNames; + private List<X500Principal> issuerNames; private BigInteger maxCrlNumber; private BigInteger minCrlNumber; private Date date; @@ -121,7 +121,7 @@ public class X509CRLSelector implements CRLSelector, Cloneable throw ioe; } if (issuerNames == null) - issuerNames = new LinkedList(); + issuerNames = new LinkedList<X500Principal>(); issuerNames.add(p); } @@ -146,7 +146,7 @@ public class X509CRLSelector implements CRLSelector, Cloneable throw ioe; } if (issuerNames == null) - issuerNames = new LinkedList(); + issuerNames = new LinkedList<X500Principal>(); issuerNames.add(p); } @@ -166,12 +166,12 @@ public class X509CRLSelector implements CRLSelector, Cloneable issuerNames = null; return; } - List l = new ArrayList(names.size()); - for (Iterator it = names.iterator(); it.hasNext(); ) + List<X500Principal> l = new ArrayList<X500Principal>(names.size()); + for (Iterator<?> it = names.iterator(); it.hasNext(); ) { Object o = it.next(); if (o instanceof X500Principal) - l.add(o); + l.add((X500Principal) o); else if (o instanceof String) { try @@ -222,14 +222,19 @@ public class X509CRLSelector implements CRLSelector, Cloneable /** * Returns the set of issuer names that are matched by this selector, * or <code>null</code> if this criteria is not set. The returned - * collection is not modifiable. + * collection is not modifiable and is a deep copy of the original. * * @return The set of issuer names. */ public Collection<Object> getIssuerNames() { if (issuerNames != null) - return Collections.unmodifiableList(issuerNames); + { + List<Object> iNames = new ArrayList<Object>(); + for (X500Principal principal : issuerNames) + iNames.add(principal.getName()); + return Collections.unmodifiableList(iNames); + } else return null; } diff --git a/java/security/cert/X509CertSelector.java b/java/security/cert/X509CertSelector.java index 8c1230afb..ef8123bf7 100644 --- a/java/security/cert/X509CertSelector.java +++ b/java/security/cert/X509CertSelector.java @@ -1,5 +1,5 @@ /* X509CertSelector.java -- selects X.509 certificates by criteria. - Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc. + Copyright (C) 2004, 2005, 2006, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -646,7 +646,7 @@ public class X509CertSelector implements CertSelector, Cloneable } if (keyPurposeSet != null) { - List kp = null; + List<String> kp = null; try { kp = cert.getExtendedKeyUsage(); @@ -657,7 +657,7 @@ public class X509CertSelector implements CertSelector, Cloneable } if (kp == null) return false; - for (Iterator it = keyPurposeSet.iterator(); it.hasNext(); ) + for (Iterator<String> it = keyPurposeSet.iterator(); it.hasNext(); ) { if (!kp.contains(it.next())) return false; @@ -846,14 +846,20 @@ public class X509CertSelector implements CertSelector, Cloneable return; } Set<String> s = new HashSet<String>(); - for (Iterator it = keyPurposeSet.iterator(); it.hasNext(); ) + for (Iterator<String> it = keyPurposeSet.iterator(); it.hasNext(); ) { - Object o = it.next(); - if (!(o instanceof String)) - throw new IOException("not a string: " + o); + String o = null; + try + { + o = it.next(); + } + catch (ClassCastException ce) + { + throw new IOException("not a string: " + o, ce); + } try { - OID oid = new OID((String) o); + OID oid = new OID(o); int[] comp = oid.getIDs(); if (!checkOid(comp)) throw new IOException("malformed OID: " + o); diff --git a/java/util/Properties.java b/java/util/Properties.java index b0f436f42..9ca60a831 100644 --- a/java/util/Properties.java +++ b/java/util/Properties.java @@ -1,5 +1,5 @@ /* Properties.java -- a set of persistent properties - Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. + Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -439,12 +439,12 @@ label = Name:\\u0020</pre> writer.println("#" + header); writer.println ("#" + Calendar.getInstance ().getTime ()); - Iterator iter = entrySet ().iterator (); + Iterator<Map.Entry<Object,Object>> iter = entrySet().iterator(); int i = size (); CPStringBuilder s = new CPStringBuilder (); // Reuse the same buffer. while (--i >= 0) { - Map.Entry entry = (Map.Entry) iter.next (); + Map.Entry<Object,Object> entry = iter.next (); formatForOutput ((String) entry.getKey (), s, true); s.append ('='); formatForOutput ((String) entry.getValue (), s, false); @@ -516,7 +516,7 @@ label = Name:\\u0020</pre> // for that. This prevents modifications from ruining the enumeration, // as well as ignoring duplicates. Properties prop = this; - Set s = new HashSet(); + Set<Object> s = new HashSet<Object>(); // Eliminate tail recursion. do { @@ -528,6 +528,42 @@ label = Name:\\u0020</pre> } /** + * <p> + * Returns the set of keys in this property list, including keys + * from the default properties which are distinct from those in the + * main property list. Only entries where both the key and its value + * are {@code String} objects are returned; any other entries are + * omitted. + * </p> + * <p> + * The returned set is not backed by this object, so any modifications + * to it will <emph>not</emph> be reflected in this object. + * </p> + * + * @return all keys from the main and default property lists which are + * {@code} String objects. + * @since 1.6 + */ + public Set<String> stringPropertyNames() + { + Properties prop = this; + Set<String> s = new HashSet<String>(); + do + { + for (Map.Entry<Object,Object> entry : entrySet()) + { + Object key = entry.getKey(); + if (key instanceof String && + entry.getValue() instanceof String) + s.add((String) key); + } + prop = prop.defaults; + } + while (prop != null); + return s; + } + + /** * Prints the key/value pairs to the given print stream. This is * mainly useful for debugging purposes. * diff --git a/javax/naming/directory/BasicAttribute.java b/javax/naming/directory/BasicAttribute.java index 65b44169e..df18a1b6c 100644 --- a/javax/naming/directory/BasicAttribute.java +++ b/javax/naming/directory/BasicAttribute.java @@ -1,5 +1,5 @@ /* BasicAttribute.java -- - Copyright (C) 2000, 2001, 2004, 2006 Free Software Foundation, Inc. + Copyright (C) 2000, 2001, 2004, 2006, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -94,6 +94,7 @@ public class BasicAttribute implements Attribute values.add (value); } + @Override public void add (int index, Object val) { if (! ordered && contains (val)) @@ -101,6 +102,7 @@ public class BasicAttribute implements Attribute values.add (index, val); } + @Override public boolean add (Object val) { if (! ordered && contains (val)) @@ -108,11 +110,13 @@ public class BasicAttribute implements Attribute return values.add (val); } + @Override public void clear () { values.clear (); } + @Override public Object clone () { BasicAttribute c = new BasicAttribute (); @@ -122,6 +126,7 @@ public class BasicAttribute implements Attribute return c; } + @Override public boolean contains (Object val) { for (int i = 0; i < values.size (); ++i) @@ -133,6 +138,7 @@ public class BasicAttribute implements Attribute return false; } + @Override public boolean equals (Object obj) { if (! (obj instanceof BasicAttribute)) @@ -167,7 +173,8 @@ public class BasicAttribute implements Attribute return true; } - + + @Override public Object get () throws NamingException { @@ -176,35 +183,41 @@ public class BasicAttribute implements Attribute return get (0); } + @Override public Object get (int index) throws NamingException { return values.get (index); } + @Override public NamingEnumeration<?> getAll () throws NamingException { return new BasicAttributeEnumeration (); } + @Override public DirContext getAttributeDefinition () throws OperationNotSupportedException, NamingException { throw new OperationNotSupportedException (); } + @Override public DirContext getAttributeSyntaxDefinition () throws OperationNotSupportedException, NamingException { throw new OperationNotSupportedException (); } + @Override public String getID () { return attrID; } + @Override public int hashCode () { int val = attrID.hashCode (); @@ -228,16 +241,19 @@ public class BasicAttribute implements Attribute return val; } + @Override public boolean isOrdered () { return ordered; } + @Override public Object remove (int index) { return values.remove (index); } + @Override public boolean remove (Object val) { for (int i = 0; i < values.size (); ++i) @@ -252,6 +268,7 @@ public class BasicAttribute implements Attribute return false; } + @Override public Object set (int index, Object val) { if (! ordered && contains (val)) @@ -259,11 +276,13 @@ public class BasicAttribute implements Attribute return values.set (index, val); } + @Override public int size () { return values.size (); } + @Override public String toString () { String r = attrID; @@ -321,7 +340,7 @@ public class BasicAttribute implements Attribute } // Used when enumerating this attribute. - private class BasicAttributeEnumeration implements NamingEnumeration + private class BasicAttributeEnumeration implements NamingEnumeration<Object> { int where = 0; @@ -329,25 +348,30 @@ public class BasicAttribute implements Attribute { } + @Override public void close () throws NamingException { } + @Override public boolean hasMore () throws NamingException { return hasMoreElements (); } + @Override public Object next () throws NamingException { return nextElement (); } + @Override public boolean hasMoreElements () { return where < values.size (); } + @Override public Object nextElement () throws NoSuchElementException { if (where == values.size ()) diff --git a/javax/security/auth/AuthPermission.java b/javax/security/auth/AuthPermission.java index 176ed9fb4..36ae8f9e9 100644 --- a/javax/security/auth/AuthPermission.java +++ b/javax/security/auth/AuthPermission.java @@ -1,5 +1,5 @@ /* AuthPermission.java -- permissions related to authentication. - Copyright (C) 2004 Free Software Foundation, Inc. + Copyright (C) 2004, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -122,6 +122,8 @@ import java.security.BasicPermission; public final class AuthPermission extends BasicPermission { + private static final long serialVersionUID = 5806031445061587174L; + /** * Creates a new authentication permission for the given target name. * diff --git a/javax/security/auth/DestroyFailedException.java b/javax/security/auth/DestroyFailedException.java index 98de82bd4..16d1c7241 100644 --- a/javax/security/auth/DestroyFailedException.java +++ b/javax/security/auth/DestroyFailedException.java @@ -1,5 +1,5 @@ /* DestroyFailedException.java -- signals an object could not be destroyed. - Copyright (C) 2004 Free Software Foundation, Inc. + Copyright (C) 2004, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -47,6 +47,8 @@ package javax.security.auth; public class DestroyFailedException extends Exception { + private static final long serialVersionUID = -7790152857282749162L; + /** * Creates a new DestroyFailedException with no detail message. */ diff --git a/javax/security/auth/PrivateCredentialPermission.java b/javax/security/auth/PrivateCredentialPermission.java index 1982eef3d..7c5f02090 100644 --- a/javax/security/auth/PrivateCredentialPermission.java +++ b/javax/security/auth/PrivateCredentialPermission.java @@ -1,5 +1,5 @@ /* PrivateCredentialPermission.java -- permissions governing private credentials. - Copyright (C) 2004 Free Software Foundation, Inc. + Copyright (C) 2004, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -83,7 +83,7 @@ public final class PrivateCredentialPermission extends Permission * @serial The principals, a set of CredOwner objects (an undocumented * inner class of this class). */ - private final Set principals; + private final Set<CredOwner> principals; /** * @serial Who knows? @@ -109,7 +109,7 @@ public final class PrivateCredentialPermission extends Permission throw new IllegalArgumentException("actions must be \"read\""); } StringTokenizer st = new StringTokenizer (name, " \"'"); - principals = new HashSet(); + principals = new HashSet<CredOwner>(); if (st.countTokens() < 3 || (st.countTokens() & 1) == 0) { throw new IllegalArgumentException ("badly formed credential name"); @@ -142,19 +142,19 @@ public final class PrivateCredentialPermission extends Permission } final String[][] principals = getPrincipals(); - final String[][] that_principals = that.getPrincipals(); - if (that_principals == null) + final String[][] thatPrincipals = that.getPrincipals(); + if (thatPrincipals == null) { return false; } - if (that_principals.length != principals.length) + if (thatPrincipals.length != principals.length) { return false; } for (int i = 0; i < principals.length; i++) { - if (!principals[i][0].equals (that_principals[i][0]) || - !principals[i][1].equals (that_principals[i][1])) + if (!principals[i][0].equals (thatPrincipals[i][0]) || + !principals[i][1].equals (thatPrincipals[i][1])) { return false; } @@ -196,10 +196,10 @@ public final class PrivateCredentialPermission extends Permission public String[][] getPrincipals() { String[][] ret = new String[principals.size()][]; - Iterator it = principals.iterator(); + Iterator<CredOwner> it = principals.iterator(); for (int i = 0; i < principals.size() && it.hasNext(); i++) { - CredOwner co = (CredOwner) it.next(); + CredOwner co = it.next(); ret[i] = new String[] { co.getPrincipalClass(), co.getPrincipalName() }; } return ret; @@ -241,18 +241,18 @@ public final class PrivateCredentialPermission extends Permission return false; } String[][] principals = getPrincipals(); - String[][] that_principals = that.getPrincipals(); - if (that_principals == null) + String[][] thatPrincipals = that.getPrincipals(); + if (thatPrincipals == null) { return false; } for (int i = 0; i < principals.length; i++) { - for (int j = 0; j < that_principals.length; j++) + for (int j = 0; j < thatPrincipals.length; j++) { - if (principals[i][0].equals (that_principals[j][0]) && + if (principals[i][0].equals (thatPrincipals[j][0]) && (principals[i][1].equals ("*") || - principals[i][1].equals (that_principals[j][1]))) + principals[i][1].equals (thatPrincipals[j][1]))) { return true; } @@ -280,6 +280,8 @@ public final class PrivateCredentialPermission extends Permission private static class CredOwner implements Serializable { + private static final long serialVersionUID = -5607449830436408266L; + // Fields. // ----------------------------------------------------------------------- diff --git a/javax/security/auth/RefreshFailedException.java b/javax/security/auth/RefreshFailedException.java index 6b8f94dcd..8409dd16a 100644 --- a/javax/security/auth/RefreshFailedException.java +++ b/javax/security/auth/RefreshFailedException.java @@ -1,5 +1,5 @@ /* RefreshFailedException.java -- signals a failed refresh. - Copyright (C) 2004 Free Software Foundation, Inc. + Copyright (C) 2004, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -44,6 +44,8 @@ package javax.security.auth; public class RefreshFailedException extends Exception { + private static final long serialVersionUID = 5058444488565265840L; + /** * Create a new RefreshFailedException with no detail message. */ diff --git a/javax/security/auth/Subject.java b/javax/security/auth/Subject.java index e9b0804a5..a5f7a37d0 100644 --- a/javax/security/auth/Subject.java +++ b/javax/security/auth/Subject.java @@ -1,5 +1,5 @@ /* Subject.java -- a single entity in the system. - Copyright (C) 2004, 2005 Free Software Foundation, Inc. + Copyright (C) 2004, 2005, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -70,24 +70,24 @@ public final class Subject implements Serializable * @serial The set of principals. The type of this field is SecureSet, a * private inner class. */ - private final Set principals; + private final Set<Principal> principals; /** * @serial The read-only flag. */ private boolean readOnly; - private final transient SecureSet pubCred; - private final transient SecureSet privCred; + private final transient SecureSet<Object> pubCred; + private final transient SecureSet<Object> privCred; // Constructors. // ------------------------------------------------------------------------- public Subject() { - principals = new SecureSet (this, SecureSet.PRINCIPALS); - pubCred = new SecureSet (this, SecureSet.PUBLIC_CREDENTIALS); - privCred = new SecureSet (this, SecureSet.PRIVATE_CREDENTIALS); + principals = new SecureSet<Principal> (this, SecureSet.PRINCIPALS); + pubCred = new SecureSet<Object> (this, SecureSet.PUBLIC_CREDENTIALS); + privCred = new SecureSet<Object> (this, SecureSet.PRIVATE_CREDENTIALS); readOnly = false; } @@ -99,9 +99,9 @@ public final class Subject implements Serializable { throw new NullPointerException(); } - this.principals = new SecureSet (this, SecureSet.PRINCIPALS, principals); - this.pubCred = new SecureSet (this, SecureSet.PUBLIC_CREDENTIALS, pubCred); - this.privCred = new SecureSet (this, SecureSet.PRIVATE_CREDENTIALS, privCred); + this.principals = new SecureSet<Principal> (this, SecureSet.PRINCIPALS, principals); + this.pubCred = new SecureSet<Object> (this, SecureSet.PUBLIC_CREDENTIALS, pubCred); + this.privCred = new SecureSet<Object> (this, SecureSet.PRIVATE_CREDENTIALS, privCred); this.readOnly = readOnly; } @@ -150,7 +150,7 @@ public final class Subject implements Serializable * @throws SecurityException If the caller is not allowed to run under a * different identity (<code>"doAs"</code> target of {@link AuthPermission}. */ - public static Object doAs (final Subject subject, final PrivilegedAction action) + public static <T> T doAs (final Subject subject, final PrivilegedAction<T> action) { final SecurityManager sm = System.getSecurityManager(); if (sm != null) @@ -176,8 +176,8 @@ public final class Subject implements Serializable * different identity (<code>"doAs"</code> target of {@link AuthPermission}. * @throws PrivilegedActionException If the action throws an exception. */ - public static Object doAs (final Subject subject, - final PrivilegedExceptionAction action) + public static <T> T doAs (final Subject subject, + final PrivilegedExceptionAction<T> action) throws PrivilegedActionException { final SecurityManager sm = System.getSecurityManager(); @@ -205,9 +205,9 @@ public final class Subject implements Serializable * different identity (<code>"doAsPrivileged"</code> target of {@link * AuthPermission}. */ - public static Object doAsPrivileged (final Subject subject, - final PrivilegedAction action, - final AccessControlContext acc) + public static <T> T doAsPrivileged (final Subject subject, + final PrivilegedAction<T> action, + final AccessControlContext acc) { final SecurityManager sm = System.getSecurityManager(); if (sm != null) @@ -234,9 +234,9 @@ public final class Subject implements Serializable * {@link AuthPermission}. * @throws PrivilegedActionException If the action throws an exception. */ - public static Object doAsPrivileged (final Subject subject, - final PrivilegedExceptionAction action, - AccessControlContext acc) + public static <T> T doAsPrivileged (final Subject subject, + final PrivilegedExceptionAction<T> action, + AccessControlContext acc) throws PrivilegedActionException { final SecurityManager sm = System.getSecurityManager(); @@ -253,7 +253,7 @@ public final class Subject implements Serializable // Instance methods. // ------------------------------------------------------------------------- - + @Override public boolean equals (Object o) { if (!(o instanceof Subject)) @@ -273,13 +273,13 @@ public final class Subject implements Serializable public <T extends Principal> Set<T> getPrincipals(Class<T> clazz) { - HashSet result = new HashSet (principals.size()); - for (Iterator it = principals.iterator(); it.hasNext(); ) + HashSet<T> result = new HashSet<T> (principals.size()); + for (Iterator<Principal> it = principals.iterator(); it.hasNext(); ) { - Object o = it.next(); + Principal o = it.next(); if (o != null && clazz.isAssignableFrom (o.getClass())) { - result.add(o); + result.add(clazz.cast(o)); } } return Collections.unmodifiableSet (result); @@ -292,13 +292,13 @@ public final class Subject implements Serializable public <T> Set<T> getPrivateCredentials (Class<T> clazz) { - HashSet result = new HashSet (privCred.size()); - for (Iterator it = privCred.iterator(); it.hasNext(); ) + HashSet<T> result = new HashSet<T> (privCred.size()); + for (Iterator<Object> it = privCred.iterator(); it.hasNext(); ) { Object o = it.next(); if (o != null && clazz.isAssignableFrom (o.getClass())) { - result.add(o); + result.add(clazz.cast(o)); } } return Collections.unmodifiableSet (result); @@ -311,18 +311,19 @@ public final class Subject implements Serializable public <T> Set<T> getPublicCredentials (Class<T> clazz) { - HashSet result = new HashSet (pubCred.size()); - for (Iterator it = pubCred.iterator(); it.hasNext(); ) + HashSet<T> result = new HashSet<T> (pubCred.size()); + for (Iterator<Object> it = pubCred.iterator(); it.hasNext(); ) { Object o = it.next(); if (o != null && clazz.isAssignableFrom (o.getClass())) { - result.add(o); + result.add(clazz.cast(o)); } } return Collections.unmodifiableSet (result); } + @Override public int hashCode() { return principals.hashCode() + privCred.hashCode() + pubCred.hashCode(); @@ -355,6 +356,7 @@ public final class Subject implements Serializable readOnly = true; } + @Override public String toString() { return Subject.class.getName() + " [ principals=" + principals + @@ -368,7 +370,7 @@ public final class Subject implements Serializable /** * An undocumented inner class that is used for sets in the parent class. */ - private static class SecureSet extends AbstractSet implements Serializable + private static class SecureSet<E> extends AbstractSet<E> implements Serializable { // Fields. // ----------------------------------------------------------------------- @@ -380,25 +382,24 @@ public final class Subject implements Serializable static final int PRIVATE_CREDENTIALS = 2; private final Subject subject; - private final LinkedList elements; + private final LinkedList<E> elements; private final transient int type; // Constructors. // ----------------------------------------------------------------------- - SecureSet (final Subject subject, final int type, final Collection inElements) + SecureSet (final Subject subject, final int type, final Collection<? extends E> inElements) { this (subject, type); - for (Iterator it = inElements.iterator(); it.hasNext(); ) + for (E e : inElements) { - Object o = it.next(); - if (type == PRINCIPALS && !(o instanceof Principal)) + if (type == PRINCIPALS && !(e instanceof Principal)) { - throw new IllegalArgumentException(o+" is not a Principal"); + throw new IllegalArgumentException(e+" is not a Principal"); } - if (!this.elements.contains (o)) + if (!this.elements.contains (e)) { - this.elements.add (o); + this.elements.add (e); } } } @@ -407,23 +408,26 @@ public final class Subject implements Serializable { this.subject = subject; this.type = type; - this.elements = new LinkedList(); + this.elements = new LinkedList<E>(); } // Instance methods. // ----------------------------------------------------------------------- + @Override public synchronized int size() { return elements.size(); } - public Iterator iterator() + @Override + public Iterator<E> iterator() { return elements.iterator(); } - public synchronized boolean add(Object element) + @Override + public synchronized boolean add(E element) { if (subject.isReadOnly()) { @@ -468,7 +472,8 @@ public final class Subject implements Serializable return elements.add (element); } - + + @Override public synchronized boolean remove (final Object element) { if (subject.isReadOnly()) @@ -510,12 +515,14 @@ public final class Subject implements Serializable return elements.remove(element); } + @Override public synchronized boolean contains (final Object element) { return elements.contains (element); } - public boolean removeAll (final Collection c) + @Override + public boolean removeAll (final Collection<?> c) { if (subject.isReadOnly()) { @@ -524,7 +531,8 @@ public final class Subject implements Serializable return super.removeAll (c); } - public boolean retainAll (final Collection c) + @Override + public boolean retainAll (final Collection<?> c) { if (subject.isReadOnly()) { @@ -533,6 +541,7 @@ public final class Subject implements Serializable return super.retainAll (c); } + @Override public void clear() { if (subject.isReadOnly()) diff --git a/javax/security/auth/SubjectDomainCombiner.java b/javax/security/auth/SubjectDomainCombiner.java index 927e7479d..a50e54b12 100644 --- a/javax/security/auth/SubjectDomainCombiner.java +++ b/javax/security/auth/SubjectDomainCombiner.java @@ -1,5 +1,5 @@ /* SubjectDomainCombiner.java -- domain combiner for Subjects. - Copyright (C) 2004, 2005 Free Software Foundation, Inc. + Copyright (C) 2004, 2005, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -66,10 +66,10 @@ public class SubjectDomainCombiner implements DomainCombiner public ProtectionDomain[] combine (final ProtectionDomain[] current, final ProtectionDomain[] assigned) { - LinkedList domains = new LinkedList(); + LinkedList<ProtectionDomain> domains = new LinkedList<ProtectionDomain>(); Principal[] principals = null; if (subject != null) - principals = (Principal[]) subject.getPrincipals().toArray (new Principal[0]); + principals = subject.getPrincipals().toArray (new Principal[0]); if (current != null) { for (int i = 0; i < current.length; i++) @@ -87,7 +87,7 @@ public class SubjectDomainCombiner implements DomainCombiner domains.add (assigned[i]); } } - return (ProtectionDomain[]) domains.toArray (new ProtectionDomain[domains.size()]); + return domains.toArray (new ProtectionDomain[domains.size()]); } public Subject getSubject() diff --git a/javax/security/auth/callback/ChoiceCallback.java b/javax/security/auth/callback/ChoiceCallback.java index 30bddd559..0ea2b526b 100644 --- a/javax/security/auth/callback/ChoiceCallback.java +++ b/javax/security/auth/callback/ChoiceCallback.java @@ -1,5 +1,5 @@ /* ChoiceCallback.java -- callback for a choice of values. - Copyright (C) 2003, Free Software Foundation, Inc. + Copyright (C) 2003, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -54,6 +54,8 @@ public class ChoiceCallback implements Callback, Serializable // Constants and variables // ------------------------------------------------------------------------- + private static final long serialVersionUID = -3975664071579892167L; + /** * @serial * @since 1.4 diff --git a/javax/security/auth/callback/ConfirmationCallback.java b/javax/security/auth/callback/ConfirmationCallback.java index 8f89bf5fa..fccc87236 100644 --- a/javax/security/auth/callback/ConfirmationCallback.java +++ b/javax/security/auth/callback/ConfirmationCallback.java @@ -1,5 +1,5 @@ /* ConfirmationCallback.java -- callback for confirmations. - Copyright (C) 2003, Free Software Foundation, Inc. + Copyright (C) 2003, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -54,6 +54,8 @@ public class ConfirmationCallback implements Callback, Serializable // Constants and variables // ------------------------------------------------------------------------- + private static final long serialVersionUID = -9095656433782481624L; + /** * <p>Unspecified option type.</p> * diff --git a/javax/security/auth/callback/LanguageCallback.java b/javax/security/auth/callback/LanguageCallback.java index e0190e6cc..d76b592c2 100644 --- a/javax/security/auth/callback/LanguageCallback.java +++ b/javax/security/auth/callback/LanguageCallback.java @@ -1,5 +1,5 @@ /* LanguageCallback.java -- callback for language choices. - Copyright (C) 2003, Free Software Foundation, Inc. + Copyright (C) 2003, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -54,6 +54,8 @@ public class LanguageCallback implements Callback, Serializable // Constants and variables // ------------------------------------------------------------------------- + private static final long serialVersionUID = 2019050433478903213L; + /** * @serial * @since 1.4 diff --git a/javax/security/auth/callback/NameCallback.java b/javax/security/auth/callback/NameCallback.java index 4b8bf1c69..6909e7310 100644 --- a/javax/security/auth/callback/NameCallback.java +++ b/javax/security/auth/callback/NameCallback.java @@ -1,5 +1,5 @@ /* NameCallback.java -- callback for user names. - Copyright (C) 2003, Free Software Foundation, Inc. + Copyright (C) 2003, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -53,6 +53,8 @@ public class NameCallback implements Callback, Serializable // Constants and variables // ------------------------------------------------------------------------- + private static final long serialVersionUID = 3770938795909392253L; + /** * @serial * @since 1.4 diff --git a/javax/security/auth/callback/PasswordCallback.java b/javax/security/auth/callback/PasswordCallback.java index 6309aacba..025cd6f03 100644 --- a/javax/security/auth/callback/PasswordCallback.java +++ b/javax/security/auth/callback/PasswordCallback.java @@ -1,5 +1,5 @@ /* PasswordCallback.java -- callback for passwords. - Copyright (C) 2003, Free Software Foundation, Inc. + Copyright (C) 2003, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -53,6 +53,8 @@ public class PasswordCallback implements Callback, Serializable // Constants and variables // ------------------------------------------------------------------------- + private static final long serialVersionUID = 2267422647454909926L; + /** * @serial * @since 1.4 diff --git a/javax/security/auth/callback/TextInputCallback.java b/javax/security/auth/callback/TextInputCallback.java index 1fe071327..b05b1d08c 100644 --- a/javax/security/auth/callback/TextInputCallback.java +++ b/javax/security/auth/callback/TextInputCallback.java @@ -1,5 +1,5 @@ /* TextInputCallback.java -- callbacks for user input. - Copyright (C) 2003, Free Software Foundation, Inc. + Copyright (C) 2003, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -53,6 +53,8 @@ public class TextInputCallback implements Callback, Serializable // Constants and variables // ------------------------------------------------------------------------- + private static final long serialVersionUID = -8064222478852811804L; + /** * @serial * @since 1.4 diff --git a/javax/security/auth/callback/TextOutputCallback.java b/javax/security/auth/callback/TextOutputCallback.java index 0ab3a040f..26223668c 100644 --- a/javax/security/auth/callback/TextOutputCallback.java +++ b/javax/security/auth/callback/TextOutputCallback.java @@ -1,5 +1,5 @@ /* TextOutputCallback.java -- callback for text output. - Copyright (C) 2003 Free Software Foundation, Inc. + Copyright (C) 2003, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -54,6 +54,8 @@ public class TextOutputCallback implements Callback, Serializable // Constants and variables // ------------------------------------------------------------------------- + private static final long serialVersionUID = 1689502495511663102L; + /** Information message */ public static final int INFORMATION = 0; diff --git a/javax/security/auth/callback/UnsupportedCallbackException.java b/javax/security/auth/callback/UnsupportedCallbackException.java index f5308b9ea..9b698d270 100644 --- a/javax/security/auth/callback/UnsupportedCallbackException.java +++ b/javax/security/auth/callback/UnsupportedCallbackException.java @@ -1,5 +1,5 @@ /* UnsupportedCallbackException.java -- signals an unsupported callback type. - Copyright (C) 2003, Free Software Foundation, Inc. + Copyright (C) 2003, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -49,6 +49,8 @@ public class UnsupportedCallbackException extends Exception // Constants and variables // ------------------------------------------------------------------------- + private static final long serialVersionUID = -6873556327655666839L; + /** @serial */ private Callback callback; diff --git a/javax/security/auth/kerberos/DelegationPermission.java b/javax/security/auth/kerberos/DelegationPermission.java index 42bb9c73c..c2aa969fc 100644 --- a/javax/security/auth/kerberos/DelegationPermission.java +++ b/javax/security/auth/kerberos/DelegationPermission.java @@ -1,5 +1,5 @@ /* DelegationPermission.java -- kerberos delegation permission - Copyright (C) 2006 Free Software Foundation, Inc. + Copyright (C) 2006, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -50,8 +50,7 @@ import java.util.Vector; public final class DelegationPermission extends BasicPermission { - // FIXME: Enable this when serialization works. - // private static final long serialVersionUID = 883133252142523922L; + private static final long serialVersionUID = 883133252142523922L; /** * Create a new instance with the given name. @@ -91,19 +90,22 @@ public final class DelegationPermission throw new IllegalArgumentException("invalid syntax for principals"); } + @Override public boolean implies(Permission perm) { return equals(perm); } + @Override public PermissionCollection newPermissionCollection() { // FIXME: don't know how to serialize here. I suspect this // class has to have a particular name, etc ... return new PermissionCollection() { - private Vector permissions = new Vector(); + private Vector<Permission> permissions = new Vector<Permission>(); + @Override public void add(Permission perm) { if (isReadOnly()) @@ -113,21 +115,23 @@ public final class DelegationPermission permissions.add(perm); } + @Override public boolean implies(Permission perm) { if (! (perm instanceof DelegationPermission)) return false; - Enumeration e = elements(); + Enumeration<Permission> e = elements(); while (e.hasMoreElements()) { - DelegationPermission dp = (DelegationPermission) e.nextElement(); + Permission dp = e.nextElement(); if (dp.implies(perm)) return true; } return false; } - public Enumeration elements() + @Override + public Enumeration<Permission> elements() { return permissions.elements(); } diff --git a/javax/security/auth/kerberos/KerberosPrincipal.java b/javax/security/auth/kerberos/KerberosPrincipal.java index 4ba767226..46da0fa1c 100644 --- a/javax/security/auth/kerberos/KerberosPrincipal.java +++ b/javax/security/auth/kerberos/KerberosPrincipal.java @@ -1,5 +1,5 @@ /* KerberosPrincipal.java -- a kerberos principal - Copyright (C) 2006 Free Software Foundation, Inc. + Copyright (C) 2006, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -55,7 +55,7 @@ public final class KerberosPrincipal implements Serializable, Principal { // Uncomment when serialization is correct. - // private static final long serialVersionUID = -7374788026156829911L; + private static final long serialVersionUID = -7374788026156829911L; /** * Constant from the RFC: "Just the name of the principal as in DCE, or diff --git a/javax/security/auth/kerberos/KerberosTicket.java b/javax/security/auth/kerberos/KerberosTicket.java index ff70b9f4e..66227fd20 100644 --- a/javax/security/auth/kerberos/KerberosTicket.java +++ b/javax/security/auth/kerberos/KerberosTicket.java @@ -1,5 +1,5 @@ /* KerberosTicket.java -- a kerberos ticket - Copyright (C) 2006 Free Software Foundation, Inc. + Copyright (C) 2006, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -73,7 +73,7 @@ public class KerberosTicket private static final int INITIAL = 9; private static final int NUM_FLAGS = 12; - private byte[] asn1Encoding; + @SuppressWarnings("unusedPrivate") private byte[] asn1Encoding; private KeyImpl sessionKey; private boolean[] flags; private Date authTime; diff --git a/javax/security/auth/kerberos/KeyImpl.java b/javax/security/auth/kerberos/KeyImpl.java index a7cf3d212..d8027c07e 100644 --- a/javax/security/auth/kerberos/KeyImpl.java +++ b/javax/security/auth/kerberos/KeyImpl.java @@ -49,7 +49,7 @@ import javax.crypto.SecretKey; final class KeyImpl implements Serializable, SecretKey { // Enable this when serialization works. - // private static final long serialVersionUID = -7889313790214321193L; + private static final long serialVersionUID = -7889313790214321193L; public String algorithm; public int type; diff --git a/javax/security/auth/kerberos/ServicePermission.java b/javax/security/auth/kerberos/ServicePermission.java index 4412ea459..ba015246e 100644 --- a/javax/security/auth/kerberos/ServicePermission.java +++ b/javax/security/auth/kerberos/ServicePermission.java @@ -1,5 +1,5 @@ /* ServicePermission.java -- kerberos service permission - Copyright (C) 2006 Free Software Foundation, Inc. + Copyright (C) 2006, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -54,8 +54,7 @@ import java.util.Vector; public final class ServicePermission extends Permission { - // FIXME: Enable this when serialization works. - // private static final long serialVersionUID = -1227585031618624935L; + private static final long serialVersionUID = -1227585031618624935L; private static final int INITIATE = 1; private static final int ACCEPT = 2; @@ -82,6 +81,7 @@ public final class ServicePermission parseActions(action); } + @Override public boolean implies(Permission perm) { if (! (perm instanceof ServicePermission)) @@ -92,6 +92,7 @@ public final class ServicePermission return getName().equals(sp.getName()); } + @Override public boolean equals(Object obj) { if (! (obj instanceof ServicePermission)) @@ -100,6 +101,7 @@ public final class ServicePermission return flags == sp.flags && getName().equals(sp.getName()); } + @Override public int hashCode() { return getName().hashCode() + flags; @@ -108,6 +110,7 @@ public final class ServicePermission /** * Return a string representing the actions. */ + @Override public String getActions() { if (flags == (INITIATE | ACCEPT)) @@ -119,12 +122,14 @@ public final class ServicePermission return ""; } + @Override public PermissionCollection newPermissionCollection() { return new PermissionCollection() { - private Vector permissions = new Vector(); + private Vector<Permission> permissions = new Vector<Permission>(); + @Override public void add(Permission perm) { if (isReadOnly()) @@ -134,21 +139,23 @@ public final class ServicePermission permissions.add(perm); } + @Override public boolean implies(Permission perm) { if (! (perm instanceof ServicePermission)) return false; - Enumeration e = elements(); + Enumeration<Permission> e = elements(); while (e.hasMoreElements()) { - ServicePermission sp = (ServicePermission) e.nextElement(); + Permission sp = e.nextElement(); if (sp.implies(perm)) return true; } return false; } - public Enumeration elements() + @Override + public Enumeration<Permission> elements() { return permissions.elements(); } diff --git a/javax/security/auth/login/AppConfigurationEntry.java b/javax/security/auth/login/AppConfigurationEntry.java index 044c9105b..fd4d09210 100644 --- a/javax/security/auth/login/AppConfigurationEntry.java +++ b/javax/security/auth/login/AppConfigurationEntry.java @@ -1,5 +1,5 @@ /* AppConfigurationEntry.java - Copyright (C) 2004, 2006 Free Software Foundation, Inc. + Copyright (C) 2004, 2006, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -49,7 +49,7 @@ public class AppConfigurationEntry private final String loginModuleName; private final LoginModuleControlFlag controlFlag; - private final Map options; + private final Map<String,?> options; // Constructor. // ------------------------------------------------------------------------- @@ -72,7 +72,7 @@ public class AppConfigurationEntry this.loginModuleName = loginModuleName; this.controlFlag = controlFlag; - this.options = Collections.unmodifiableMap (new HashMap (options)); + this.options = Collections.unmodifiableMap (new HashMap<String,Object>(options)); } // Instance methods. diff --git a/javax/security/auth/login/Configuration.java b/javax/security/auth/login/Configuration.java index fe56f8a59..bbaef065d 100644 --- a/javax/security/auth/login/Configuration.java +++ b/javax/security/auth/login/Configuration.java @@ -1,5 +1,5 @@ /* Configuration.java - Copyright (C) 2004, 2006 Free Software Foundation, Inc. + Copyright (C) 2004, 2006, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -96,10 +96,10 @@ public abstract class Configuration { if (config == null) { - String conf = (String) AccessController.doPrivileged - (new PrivilegedAction() + String conf = AccessController.doPrivileged + (new PrivilegedAction<String>() { - public Object run() + public String run() { return Security.getProperty ("login.configuration.provider"); } diff --git a/javax/security/auth/login/LoginContext.java b/javax/security/auth/login/LoginContext.java index b2e4b97b6..39d8702c9 100644 --- a/javax/security/auth/login/LoginContext.java +++ b/javax/security/auth/login/LoginContext.java @@ -1,5 +1,5 @@ /* LoginContext.java - Copyright (C) 2004, 2006 Free Software Foundation, Inc. + Copyright (C) 2004, 2006, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -59,7 +59,7 @@ public class LoginContext private final Subject subject; private final AppConfigurationEntry[] entries; private final LoginModule[] modules; - private final Map sharedState; + private final Map<String,?> sharedState; public LoginContext (final String name) throws LoginException { @@ -104,7 +104,7 @@ public class LoginContext + name); this.entries = entries; modules = new LoginModule[entries.length]; - sharedState = new HashMap(); + sharedState = new HashMap<String,Object>(); for (int i = 0; i < entries.length; i++) modules[i] = lookupModule (entries[i], subject, sharedState); } @@ -195,7 +195,7 @@ public class LoginContext { GetSecurityPropertyAction act = new GetSecurityPropertyAction ("auth.login.defaultCallbackHandler"); - String classname = (String) AccessController.doPrivileged (act); + String classname = AccessController.doPrivileged (act); if (classname != null) { try @@ -223,7 +223,7 @@ public class LoginContext } private LoginModule lookupModule (AppConfigurationEntry entry, - Subject subject, Map sharedState) + Subject subject, Map<String,?> sharedState) throws LoginException { LoginModule module = null; @@ -231,7 +231,7 @@ public class LoginContext try { ClassLoader cl = Thread.currentThread().getContextClassLoader(); - Class c = Class.forName(entry.getLoginModuleName(), true, cl); + Class<?> c = Class.forName(entry.getLoginModuleName(), true, cl); module = (LoginModule) c.newInstance(); } catch (ClassNotFoundException cnfe) diff --git a/javax/security/auth/x500/X500Principal.java b/javax/security/auth/x500/X500Principal.java index 0a1e8c665..79c3336e1 100644 --- a/javax/security/auth/x500/X500Principal.java +++ b/javax/security/auth/x500/X500Principal.java @@ -1,5 +1,5 @@ /* X500Principal.java -- X.500 principal. - Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc. + Copyright (C) 2003, 2004, 2005, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -89,9 +89,8 @@ public final class X500Principal implements Principal, Serializable private static final OID DC = new OID("0.9.2342.19200300.100.1.25"); private static final OID UID = new OID("0.9.2342.19200300.100.1.1"); - private transient List components; - private transient Map currentRdn; - private transient boolean fixed; + private transient List<Map<OID,String>> components; + private transient Map<OID,String> currentRdn; private transient byte[] encoded; // Constructors. @@ -99,8 +98,8 @@ public final class X500Principal implements Principal, Serializable private X500Principal() { - components = new LinkedList(); - currentRdn = new LinkedHashMap(); + components = new LinkedList<Map<OID,String>>(); + currentRdn = new LinkedHashMap<OID,String>(); components.add (currentRdn); } @@ -147,12 +146,11 @@ public final class X500Principal implements Principal, Serializable int result = size(); 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(); // We don't bother looking at the value of the entry. - result = result * 31 + ((OID) e.getKey()).hashCode(); + result = result * 31 + e.getKey().hashCode(); } } return result; @@ -166,12 +164,11 @@ public final class X500Principal implements Principal, Serializable 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 = ((X500Principal) o).getComponent (oid, i); if (v2 == null) return false; @@ -203,14 +200,14 @@ public final class X500Principal implements Principal, Serializable if (! (rfc2253 || rfc1779 || canon)) throw new IllegalArgumentException ("unsupported format " + format); 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)) @@ -278,22 +275,20 @@ public final class X500Principal implements Principal, Serializable { if (rdn >= size()) return null; - return (String) ((Map) components.get (rdn)).get (oid); + return components.get(rdn).get(oid); } private void encodeDer() { - 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)); @@ -484,7 +479,7 @@ public final class X500Principal implements Principal, Serializable private void newRelativeDistinguishedName() { - currentRdn = new LinkedHashMap(); + currentRdn = new LinkedHashMap<OID,String>(); components.add(currentRdn); } diff --git a/javax/security/cert/CertificateEncodingException.java b/javax/security/cert/CertificateEncodingException.java index 47aedcf05..fa1440707 100644 --- a/javax/security/cert/CertificateEncodingException.java +++ b/javax/security/cert/CertificateEncodingException.java @@ -1,5 +1,5 @@ /* CertificateEncodingException.java -- certificate encoding exception. - Copyright (C) 2004 Free Software Foundation, Inc. + Copyright (C) 2004, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -48,6 +48,8 @@ package javax.security.cert; public class CertificateEncodingException extends CertificateException { + private static final long serialVersionUID = 6219492851589449162L; + public CertificateEncodingException() { super(); diff --git a/javax/security/cert/CertificateException.java b/javax/security/cert/CertificateException.java index 270cc926f..d00ab80d7 100644 --- a/javax/security/cert/CertificateException.java +++ b/javax/security/cert/CertificateException.java @@ -1,5 +1,5 @@ /* CertificateException.java -- certificate exception. - Copyright (C) 2004 Free Software Foundation, Inc. + Copyright (C) 2004, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -48,6 +48,8 @@ package javax.security.cert; public class CertificateException extends Exception { + private static final long serialVersionUID = 3192535253797119798L; + public CertificateException() { super(); diff --git a/javax/security/cert/CertificateExpiredException.java b/javax/security/cert/CertificateExpiredException.java index 3a8c0515e..1c4e68b96 100644 --- a/javax/security/cert/CertificateExpiredException.java +++ b/javax/security/cert/CertificateExpiredException.java @@ -1,5 +1,5 @@ /* CertificateExpiredException.java -- certificate expired exception. - Copyright (C) 2004 Free Software Foundation, Inc. + Copyright (C) 2004, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -48,6 +48,8 @@ package javax.security.cert; public class CertificateExpiredException extends CertificateException { + private static final long serialVersionUID = 9071001339691533771L; + public CertificateExpiredException() { super(); diff --git a/javax/security/cert/CertificateNotYetValidException.java b/javax/security/cert/CertificateNotYetValidException.java index 22a7c4a22..4142bb0e2 100644 --- a/javax/security/cert/CertificateNotYetValidException.java +++ b/javax/security/cert/CertificateNotYetValidException.java @@ -1,5 +1,5 @@ /* CertificateNotYetValidException.java -- certificate not yet valid exception. - Copyright (C) 2004 Free Software Foundation, Inc. + Copyright (C) 2004, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -48,6 +48,8 @@ package javax.security.cert; public class CertificateNotYetValidException extends CertificateException { + private static final long serialVersionUID = 4355919900041064702L; + public CertificateNotYetValidException() { super(); diff --git a/javax/security/cert/CertificateParsingException.java b/javax/security/cert/CertificateParsingException.java index f359f8d7a..dccf44329 100644 --- a/javax/security/cert/CertificateParsingException.java +++ b/javax/security/cert/CertificateParsingException.java @@ -1,5 +1,5 @@ /* CertificateParsingException.java -- certificate parsing exception. - Copyright (C) 2004 Free Software Foundation, Inc. + Copyright (C) 2004, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -47,6 +47,8 @@ package javax.security.cert; public class CertificateParsingException extends CertificateException { + private static final long serialVersionUID = -7989222416793322029L; + public CertificateParsingException() { super(); diff --git a/javax/security/sasl/AuthenticationException.java b/javax/security/sasl/AuthenticationException.java index 0f674645d..6e00a722c 100644 --- a/javax/security/sasl/AuthenticationException.java +++ b/javax/security/sasl/AuthenticationException.java @@ -1,5 +1,5 @@ /* AuthenticationException.java -- - Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc. + Copyright (C) 2003, 2004, 2005, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -55,6 +55,8 @@ package javax.security.sasl; public class AuthenticationException extends SaslException { + private static final long serialVersionUID = -3579708765071815007L; + // Constants and variables // ------------------------------------------------------------------------- diff --git a/javax/security/sasl/RealmCallback.java b/javax/security/sasl/RealmCallback.java index 7cb36433f..7112d7c40 100644 --- a/javax/security/sasl/RealmCallback.java +++ b/javax/security/sasl/RealmCallback.java @@ -1,5 +1,5 @@ /* RealmCallback.java -- - Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc. + Copyright (C) 2003, 2004, 2005, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -49,6 +49,8 @@ import javax.security.auth.callback.TextInputCallback; public class RealmCallback extends TextInputCallback { + private static final long serialVersionUID = -4342673378785456908L; + /** * Constructs a <code>RealmCallback</code> with a prompt. * diff --git a/javax/security/sasl/RealmChoiceCallback.java b/javax/security/sasl/RealmChoiceCallback.java index 7068a504b..896be4722 100644 --- a/javax/security/sasl/RealmChoiceCallback.java +++ b/javax/security/sasl/RealmChoiceCallback.java @@ -1,5 +1,5 @@ /* RealmChoiceCallback.java -- - Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc. + Copyright (C) 2003, 2004, 2005, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -49,6 +49,8 @@ import javax.security.auth.callback.ChoiceCallback; public class RealmChoiceCallback extends ChoiceCallback { + private static final long serialVersionUID = -8588141348846281332L; + /** * Constructs a <code>RealmChoiceCallback</code> with a prompt, a list of * choices and a default choice. diff --git a/javax/security/sasl/Sasl.java b/javax/security/sasl/Sasl.java index 475be09e0..e77bdb86b 100644 --- a/javax/security/sasl/Sasl.java +++ b/javax/security/sasl/Sasl.java @@ -1,5 +1,5 @@ /* Sasl.java -- - Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc. + Copyright (C) 2003, 2004, 2005, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -457,10 +457,9 @@ public class Sasl */ public static Enumeration<SaslClientFactory> getSaslClientFactories() { - Vector result = new Vector(); - HashSet names = new HashSet(); + Vector<SaslClientFactory> result = new Vector<SaslClientFactory>(); + HashSet<String> names = new HashSet<String>(); Provider[] providers = Security.getProviders(); - Iterator it; if (providers != null) { Provider p; @@ -468,7 +467,7 @@ public class Sasl for (int i = 0; i < providers.length; i++) { p = providers[i]; - for (it = p.keySet().iterator(); it.hasNext(); ) + for (Iterator<Object> it = p.keySet().iterator(); it.hasNext(); ) { key = (String) it.next(); // add key's binding (a) it is a class of a client factory, @@ -483,9 +482,9 @@ public class Sasl } // we have the factory class names in names; instantiate and enumerate String c; - for (it = names.iterator(); it.hasNext(); ) + for (Iterator<String> it = names.iterator(); it.hasNext(); ) { - c = (String) it.next(); + c = it.next(); try { SaslClientFactory f = (SaslClientFactory) Class.forName(c).newInstance(); @@ -650,10 +649,9 @@ public class Sasl */ public static Enumeration<SaslServerFactory> getSaslServerFactories() { - Vector result = new Vector(); - HashSet names = new HashSet(); + Vector<SaslServerFactory> result = new Vector<SaslServerFactory>(); + HashSet<String> names = new HashSet<String>(); Provider[] providers = Security.getProviders(); - Iterator it; if (providers != null) { Provider p; @@ -661,7 +659,7 @@ public class Sasl for (int i = 0; i < providers.length; i++) { p = providers[i]; - for (it = p.keySet().iterator(); it.hasNext(); ) + for (Iterator<Object> it = p.keySet().iterator(); it.hasNext(); ) { key = (String) it.next(); // add key's binding (a) it is a class of a server factory, @@ -675,10 +673,8 @@ public class Sasl } } // we have the factory class names in names; instantiate and enumerate - String c; - for (it = names.iterator(); it.hasNext(); ) + for (String c : names) { - c = (String) it.next(); try { SaslServerFactory f = (SaslServerFactory) Class.forName(c).newInstance(); diff --git a/tools/gnu/classpath/tools/jarsigner/SFHelper.java b/tools/gnu/classpath/tools/jarsigner/SFHelper.java index 9e4882f0e..59ad14315 100644 --- a/tools/gnu/classpath/tools/jarsigner/SFHelper.java +++ b/tools/gnu/classpath/tools/jarsigner/SFHelper.java @@ -1,5 +1,5 @@ /* SFHelper -- A .SF file helper - Copyright (C) 2006, 2007 Free Software Foundation, Inc. + Copyright (C) 2006, 2007, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -229,7 +229,7 @@ public class SFHelper else throw new SecurityException(Messages.getString("SFHelper.6")); //$NON-NLS-1$ - Map signatureAttributes = new HashMap(); + Map<String,Object> signatureAttributes = new HashMap<String,Object>(); signatureAttributes.put(ISignature.SIGNER_KEY, signerKey); signatureAlgorithm.setupSign(signatureAttributes); signatureAlgorithm.update(sfBytes, 0, sfBytes.length); |