summaryrefslogtreecommitdiff
path: root/java/security/cert
diff options
context:
space:
mode:
Diffstat (limited to 'java/security/cert')
-rw-r--r--java/security/cert/CRL.java3
-rw-r--r--java/security/cert/CertPath.java5
-rw-r--r--java/security/cert/CertPathBuilderException.java66
-rw-r--r--java/security/cert/CertPathValidatorException.java64
-rw-r--r--java/security/cert/CertStoreException.java66
-rw-r--r--java/security/cert/CertStoreSpi.java3
-rw-r--r--java/security/cert/Certificate.java5
-rw-r--r--java/security/cert/CertificateFactorySpi.java6
-rw-r--r--java/security/cert/CollectionCertStoreParameters.java1
-rw-r--r--java/security/cert/LDAPCertStoreParameters.java4
-rw-r--r--java/security/cert/PKIXBuilderParameters.java3
-rw-r--r--java/security/cert/PKIXCertPathBuilderResult.java4
-rw-r--r--java/security/cert/PKIXCertPathChecker.java3
-rw-r--r--java/security/cert/PKIXCertPathValidatorResult.java4
-rw-r--r--java/security/cert/PKIXParameters.java2
-rw-r--r--java/security/cert/PolicyQualifierInfo.java7
-rw-r--r--java/security/cert/TrustAnchor.java23
-rw-r--r--java/security/cert/X509CRL.java5
-rw-r--r--java/security/cert/X509CRLEntry.java5
-rw-r--r--java/security/cert/X509CRLSelector.java10
-rw-r--r--java/security/cert/X509CertSelector.java105
-rw-r--r--java/security/cert/X509Certificate.java7
22 files changed, 133 insertions, 268 deletions
diff --git a/java/security/cert/CRL.java b/java/security/cert/CRL.java
index 1eaa70fa9..618aa4566 100644
--- a/java/security/cert/CRL.java
+++ b/java/security/cert/CRL.java
@@ -1,5 +1,5 @@
/* CRL.java --- Certificate Revocation List
- Copyright (C) 1999 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2014 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -81,6 +81,7 @@ public abstract class CRL
@return a string representing the CRL.
*/
+ @Override
public abstract String toString();
/**
diff --git a/java/security/cert/CertPath.java b/java/security/cert/CertPath.java
index 5c9a12ab9..221c267d6 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, 2014 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2005, 2014, 2015 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -173,6 +173,7 @@ public abstract class CertPath implements Serializable
* @param o the object to compare to
* @return true if the two are equal
*/
+ @Override
public boolean equals(Object o)
{
if (! (o instanceof CertPath))
@@ -188,11 +189,13 @@ public abstract class CertPath implements Serializable
*
* @return the hashcode
*/
+ @Override
public int hashCode()
{
return 31 * type.hashCode() + getCertificates().hashCode();
}
+ @Override
public String toString()
{
List<? extends Certificate> l = getCertificates();
diff --git a/java/security/cert/CertPathBuilderException.java b/java/security/cert/CertPathBuilderException.java
index 985151010..5906dae93 100644
--- a/java/security/cert/CertPathBuilderException.java
+++ b/java/security/cert/CertPathBuilderException.java
@@ -1,6 +1,6 @@
/* CertPathBuilderException.java -- wraps an exception during certificate
path building
- Copyright (C) 2002, 2005 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2005, 2015 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -39,8 +39,6 @@ exception statement from your version. */
package java.security.cert;
-import java.io.PrintStream;
-import java.io.PrintWriter;
import java.security.GeneralSecurityException;
/**
@@ -84,7 +82,7 @@ public class CertPathBuilderException extends GeneralSecurityException
*/
public CertPathBuilderException(Throwable cause)
{
- this(cause == null ? null : cause.toString(), cause);
+ super(cause);
}
/**
@@ -95,65 +93,7 @@ public class CertPathBuilderException extends GeneralSecurityException
*/
public CertPathBuilderException(String msg, Throwable cause)
{
- super(msg);
- initCause(cause);
- }
-
- /**
- * Get the detail message.
- *
- * @return the detail message
- */
- public String getMessage()
- {
- return super.getMessage();
- }
-
- /**
- * Get the cause, null if unknown.
- *
- * @return the cause
- */
- public Throwable getCause()
- {
- return super.getCause();
+ super(msg, cause);
}
- /**
- * Convert this to a string, including its cause.
- *
- * @return the string conversion
- */
- public String toString()
- {
- return super.toString();
- }
-
- /**
- * Print the stack trace to <code>System.err</code>.
- */
- public void printStackTrace()
- {
- super.printStackTrace();
- }
-
- /**
- * Print the stack trace to a stream.
- *
- * @param stream the stream
- */
- public void printStackTrace(PrintStream stream)
- {
- super.printStackTrace(stream);
- }
-
- /**
- * Print the stack trace to a stream.
- *
- * @param stream the stream
- */
- public void printStackTrace(PrintWriter stream)
- {
- super.printStackTrace(stream);
- }
}
diff --git a/java/security/cert/CertPathValidatorException.java b/java/security/cert/CertPathValidatorException.java
index f3195be29..23f19b081 100644
--- a/java/security/cert/CertPathValidatorException.java
+++ b/java/security/cert/CertPathValidatorException.java
@@ -1,6 +1,6 @@
/* CertPathValidatorException.java -- wraps an exception during validation
of a CertPath
- Copyright (C) 2002, 2005 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2005, 2014 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -39,8 +39,6 @@ exception statement from your version. */
package java.security.cert;
-import java.io.PrintStream;
-import java.io.PrintWriter;
import java.security.GeneralSecurityException;
/**
@@ -135,8 +133,7 @@ public class CertPathValidatorException extends GeneralSecurityException
public CertPathValidatorException(String msg, Throwable cause,
CertPath certPath, int index)
{
- super(msg);
- initCause(cause);
+ super(msg, cause);
if (index < -1 || (certPath != null
&& index >= certPath.getCertificates().size()))
throw new IndexOutOfBoundsException();
@@ -147,16 +144,6 @@ public class CertPathValidatorException extends GeneralSecurityException
}
/**
- * Get the detail message.
- *
- * @return the detail message
- */
- public String getMessage()
- {
- return super.getMessage();
- }
-
- /**
* Get the certificate path that had the failure, or null.
*
* @return the culprit path
@@ -176,51 +163,4 @@ public class CertPathValidatorException extends GeneralSecurityException
return index;
}
- /**
- * Get the cause, null if unknown.
- *
- * @return the cause
- */
- public Throwable getCause()
- {
- return super.getCause();
- }
-
- /**
- * Convert this to a string, including its cause.
- *
- * @return the string conversion
- */
- public String toString()
- {
- return super.toString();
- }
-
- /**
- * Print the stack trace to <code>System.err</code>.
- */
- public void printStackTrace()
- {
- super.printStackTrace();
- }
-
- /**
- * Print the stack trace to a stream.
- *
- * @param stream the stream
- */
- public void printStackTrace(PrintStream stream)
- {
- super.printStackTrace(stream);
- }
-
- /**
- * Print the stack trace to a stream.
- *
- * @param stream the stream
- */
- public void printStackTrace(PrintWriter stream)
- {
- super.printStackTrace(stream);
- }
}
diff --git a/java/security/cert/CertStoreException.java b/java/security/cert/CertStoreException.java
index a4d8b7a46..c243bb42c 100644
--- a/java/security/cert/CertStoreException.java
+++ b/java/security/cert/CertStoreException.java
@@ -1,5 +1,5 @@
/* CertStoreException.java -- wraps an exception during certificate storage
- Copyright (C) 2002, 2005 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2005, 2014, 2015 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,8 +38,6 @@ exception statement from your version. */
package java.security.cert;
-import java.io.PrintStream;
-import java.io.PrintWriter;
import java.security.GeneralSecurityException;
/**
@@ -84,7 +82,7 @@ public class CertStoreException extends GeneralSecurityException
*/
public CertStoreException(Throwable cause)
{
- this(cause == null ? null : cause.toString(), cause);
+ super(cause);
}
/**
@@ -95,65 +93,7 @@ public class CertStoreException extends GeneralSecurityException
*/
public CertStoreException(String msg, Throwable cause)
{
- super(msg);
- initCause(cause);
- }
-
- /**
- * Get the detail message.
- *
- * @return the detail message
- */
- public String getMessage()
- {
- return super.getMessage();
- }
-
- /**
- * Get the cause, null if unknown.
- *
- * @return the cause
- */
- public Throwable getCause()
- {
- return super.getCause();
+ super(msg, cause);
}
- /**
- * Convert this to a string, including its cause.
- *
- * @return the string conversion
- */
- public String toString()
- {
- return super.toString();
- }
-
- /**
- * Print the stack trace to <code>System.err</code>.
- */
- public void printStackTrace()
- {
- super.printStackTrace();
- }
-
- /**
- * Print the stack trace to a stream.
- *
- * @param stream the stream
- */
- public void printStackTrace(PrintStream stream)
- {
- super.printStackTrace(stream);
- }
-
- /**
- * Print the stack trace to a stream.
- *
- * @param stream the stream
- */
- public void printStackTrace(PrintWriter stream)
- {
- super.printStackTrace(stream);
- }
}
diff --git a/java/security/cert/CertStoreSpi.java b/java/security/cert/CertStoreSpi.java
index a47978a22..85de3ae5b 100644
--- a/java/security/cert/CertStoreSpi.java
+++ b/java/security/cert/CertStoreSpi.java
@@ -1,5 +1,5 @@
/* CertStoreSpi -- certificate store service provider interface.
- Copyright (C) 2003 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2014 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -69,6 +69,7 @@ public abstract class CertStoreSpi
* @throws InvalidAlgorithmParameterException If the specified
* parameters are inappropriate for this class.
*/
+ @SuppressWarnings("unused")
public CertStoreSpi(CertStoreParameters params)
throws InvalidAlgorithmParameterException
{
diff --git a/java/security/cert/Certificate.java b/java/security/cert/Certificate.java
index be1713cbf..b9abe8e65 100644
--- a/java/security/cert/Certificate.java
+++ b/java/security/cert/Certificate.java
@@ -1,5 +1,5 @@
/* Certificate.java --- Certificate 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.
@@ -107,6 +107,7 @@ public abstract class Certificate implements Serializable
@return true if equal, false otherwise
*/
+ @Override
public boolean equals(Object other)
{
if( other instanceof Certificate ) {
@@ -136,6 +137,7 @@ public abstract class Certificate implements Serializable
@return A hash code of this class
*/
+ @Override
public int hashCode()
{
return super.hashCode();
@@ -198,6 +200,7 @@ public abstract class Certificate implements Serializable
@return a string representing the Certificate.
*/
+ @Override
public abstract String toString();
diff --git a/java/security/cert/CertificateFactorySpi.java b/java/security/cert/CertificateFactorySpi.java
index 2c9ca5d38..2b5bb529c 100644
--- a/java/security/cert/CertificateFactorySpi.java
+++ b/java/security/cert/CertificateFactorySpi.java
@@ -1,5 +1,5 @@
/* CertificateFactorySpi.java --- Certificate Factory 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.
@@ -172,6 +172,7 @@ public abstract class CertificateFactorySpi
* @throws CertificateException If an error occurs decoding the
* CertPath.
*/
+ @SuppressWarnings({"unused","static-method"})
public CertPath engineGenerateCertPath(InputStream inStream)
throws CertificateException
{
@@ -188,6 +189,7 @@ public abstract class CertificateFactorySpi
* @throws CertificateException If an error occurs decoding the
* CertPath.
*/
+ @SuppressWarnings({"unused","static-method"})
public CertPath engineGenerateCertPath(InputStream inStream, String encoding)
throws CertificateException
{
@@ -204,6 +206,7 @@ public abstract class CertificateFactorySpi
* @throws CertificateException If an error occurs generating the
* CertPath.
*/
+ @SuppressWarnings({"unused","static-method"})
public CertPath engineGenerateCertPath(List<? extends Certificate> certificates)
throws CertificateException
{
@@ -217,6 +220,7 @@ public abstract class CertificateFactorySpi
*
* @return The Iterator of supported encodings.
*/
+ @SuppressWarnings("static-method")
public Iterator<String> engineGetCertPathEncodings()
{
throw new UnsupportedOperationException("not implemented");
diff --git a/java/security/cert/CollectionCertStoreParameters.java b/java/security/cert/CollectionCertStoreParameters.java
index 6edaf7677..ace8eccbc 100644
--- a/java/security/cert/CollectionCertStoreParameters.java
+++ b/java/security/cert/CollectionCertStoreParameters.java
@@ -115,6 +115,7 @@ public class CollectionCertStoreParameters implements CertStoreParameters
*
* @return The string representation of these parameters.
*/
+ @Override
public String toString()
{
return "CollectionCertStoreParameters: [ collection: "
diff --git a/java/security/cert/LDAPCertStoreParameters.java b/java/security/cert/LDAPCertStoreParameters.java
index f2dff764a..615b80853 100644
--- a/java/security/cert/LDAPCertStoreParameters.java
+++ b/java/security/cert/LDAPCertStoreParameters.java
@@ -1,5 +1,5 @@
/* LDAPCertStoreParameters.java -- LDAP CertStore parameters.
- Copyright (C) 2003 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2015 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -102,6 +102,7 @@ public class LDAPCertStoreParameters implements CertStoreParameters
// Instance methods.
// ------------------------------------------------------------------------
+ @Override
public Object clone()
{
return new LDAPCertStoreParameters(serverName, port);
@@ -132,6 +133,7 @@ public class LDAPCertStoreParameters implements CertStoreParameters
*
* @return The string representation of these parameters.
*/
+ @Override
public String toString()
{
return "LDAPCertStoreParameters: [ serverName: " + serverName
diff --git a/java/security/cert/PKIXBuilderParameters.java b/java/security/cert/PKIXBuilderParameters.java
index 3a29b5218..47f8484df 100644
--- a/java/security/cert/PKIXBuilderParameters.java
+++ b/java/security/cert/PKIXBuilderParameters.java
@@ -1,5 +1,5 @@
/* PKIXBuilderParameters.java -- parameters for PKIX cert path builders
- Copyright (C) 2003 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2014 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -140,6 +140,7 @@ public class PKIXBuilderParameters extends PKIXParameters
this.maxPathLength = maxPathLength;
}
+ @Override
public String toString()
{
CPStringBuilder buf = new CPStringBuilder(super.toString());
diff --git a/java/security/cert/PKIXCertPathBuilderResult.java b/java/security/cert/PKIXCertPathBuilderResult.java
index 52984b543..779983339 100644
--- a/java/security/cert/PKIXCertPathBuilderResult.java
+++ b/java/security/cert/PKIXCertPathBuilderResult.java
@@ -1,5 +1,5 @@
/* PKIXCertPathBuilderResult.java -- PKIX cert path bulider result
- Copyright (C) 2003 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2014 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -90,11 +90,13 @@ public class PKIXCertPathBuilderResult extends PKIXCertPathValidatorResult
*
* @return The certificate path that was built.
*/
+ @Override
public CertPath getCertPath()
{
return certPath;
}
+ @Override
public String toString()
{
CPStringBuilder buf = new CPStringBuilder(super.toString());
diff --git a/java/security/cert/PKIXCertPathChecker.java b/java/security/cert/PKIXCertPathChecker.java
index 0bedf401a..b33117f84 100644
--- a/java/security/cert/PKIXCertPathChecker.java
+++ b/java/security/cert/PKIXCertPathChecker.java
@@ -1,5 +1,5 @@
/* PKIXCertPathChecker.java -- checks X.509 certificate paths.
- Copyright (C) 2003 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2015 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -76,6 +76,7 @@ public abstract class PKIXCertPathChecker implements Cloneable
// Cloneable interface.
// ------------------------------------------------------------------------
+ @Override
public Object clone()
{
try
diff --git a/java/security/cert/PKIXCertPathValidatorResult.java b/java/security/cert/PKIXCertPathValidatorResult.java
index 17b5c86f8..2b1f05edb 100644
--- a/java/security/cert/PKIXCertPathValidatorResult.java
+++ b/java/security/cert/PKIXCertPathValidatorResult.java
@@ -1,5 +1,5 @@
/* PKIXCertPathValidatorResult.java -- PKIX cert path builder result
- Copyright (C) 2003 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2015 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -123,6 +123,7 @@ public class PKIXCertPathValidatorResult implements CertPathValidatorResult
*
* @return The copy.
*/
+ @Override
public Object clone()
{
return new PKIXCertPathValidatorResult(trustAnchor, policyTree,
@@ -134,6 +135,7 @@ public class PKIXCertPathValidatorResult implements CertPathValidatorResult
*
* @return A printable string representation of this result.
*/
+ @Override
public String toString()
{
return "[ Trust Anchor=" + trustAnchor + "; Policy Tree="
diff --git a/java/security/cert/PKIXParameters.java b/java/security/cert/PKIXParameters.java
index 1778d6127..33ba297b6 100644
--- a/java/security/cert/PKIXParameters.java
+++ b/java/security/cert/PKIXParameters.java
@@ -521,6 +521,7 @@ public class PKIXParameters implements CertPathParameters
*
* @return The copy.
*/
+ @Override
public Object clone()
{
return new PKIXParameters(this);
@@ -531,6 +532,7 @@ public class PKIXParameters implements CertPathParameters
*
* @return A printable representation of these parameters.
*/
+ @Override
public String toString() {
return "[ Trust Anchors: " + trustAnchors + "; Initial Policy OIDs="
+ (initPolicies != null ? initPolicies.toString() : "any")
diff --git a/java/security/cert/PolicyQualifierInfo.java b/java/security/cert/PolicyQualifierInfo.java
index b53faa935..07530d3b3 100644
--- a/java/security/cert/PolicyQualifierInfo.java
+++ b/java/security/cert/PolicyQualifierInfo.java
@@ -1,5 +1,5 @@
/* PolicyQualifierInfo.java -- policy qualifier info object.
- Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2004, 2014 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -102,7 +102,7 @@ PolicyQualifierId ::= OBJECT IDENTIFIER
{
if (encoded == null)
throw new IOException("null bytes");
- this.encoded = (byte[]) encoded.clone();
+ this.encoded = encoded.clone();
DERReader in = new DERReader(new ByteArrayInputStream(this.encoded));
DERValue qualInfo = in.read();
if (!qualInfo.isConstructed())
@@ -139,7 +139,7 @@ PolicyQualifierId ::= OBJECT IDENTIFIER
*/
public final byte[] getEncoded()
{
- return (byte[]) encoded.clone();
+ return encoded.clone();
}
/**
@@ -161,6 +161,7 @@ PolicyQualifierId ::= OBJECT IDENTIFIER
*
* @return The string representation.
*/
+ @Override
public String toString()
{
return "PolicyQualifierInfo { policyQualifierId ::= " + oid
diff --git a/java/security/cert/TrustAnchor.java b/java/security/cert/TrustAnchor.java
index 2110ed518..f0537d2ef 100644
--- a/java/security/cert/TrustAnchor.java
+++ b/java/security/cert/TrustAnchor.java
@@ -1,5 +1,5 @@
/* TrustAnchor.java -- an ultimately-trusted certificate.
- Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2004, 2014, 2015 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -40,6 +40,7 @@ package java.security.cert;
import gnu.java.security.x509.X500DistinguishedName;
+import java.io.IOException;
import java.security.PublicKey;
/**
@@ -87,7 +88,7 @@ public class TrustAnchor
caName = null;
caKey = null;
if (nameConstraints != null)
- this.nameConstraints = (byte[]) nameConstraints.clone();
+ this.nameConstraints = nameConstraints.clone();
else
this.nameConstraints = null;
}
@@ -102,6 +103,10 @@ public class TrustAnchor
* @params caName The CA's distinguished name.
* @params caKey The CA's public key.
* @params nameConstraints The encoded nameConstraints.
+ * @throws NullPointerException if the specified CA name or key is
+ * {@code null}.
+ * @throws IllegalArgumentException if the CA name is of zero length or
+ * incorrectly formatted, or the name constraints can't be decoded.
*/
public TrustAnchor(String caName, PublicKey caKey, byte[] nameConstraints)
{
@@ -110,10 +115,17 @@ public class TrustAnchor
if (caName.length() == 0)
throw new IllegalArgumentException();
trustedCert = null;
- this.caName = new X500DistinguishedName(caName);
+ try
+ {
+ this.caName = new X500DistinguishedName(caName);
+ }
+ catch (IOException ex)
+ {
+ throw new IllegalArgumentException("Couldn't parse name", ex);
+ }
this.caKey = caKey;
if (nameConstraints != null)
- this.nameConstraints = (byte[]) nameConstraints.clone();
+ this.nameConstraints = nameConstraints.clone();
else
this.nameConstraints = null;
}
@@ -167,7 +179,7 @@ public class TrustAnchor
{
if (nameConstraints == null)
return null;
- return (byte[]) nameConstraints.clone();
+ return nameConstraints.clone();
}
/**
@@ -175,6 +187,7 @@ public class TrustAnchor
*
* @return The printable representation.
*/
+ @Override
public String toString()
{
if (trustedCert == null)
diff --git a/java/security/cert/X509CRL.java b/java/security/cert/X509CRL.java
index 895ba33e7..3e4a4e96b 100644
--- a/java/security/cert/X509CRL.java
+++ b/java/security/cert/X509CRL.java
@@ -1,5 +1,5 @@
/* X509CRL.java --- X.509 Certificate Revocation List
- Copyright (C) 1999, 2004 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2004, 2014, 2015 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -119,6 +119,7 @@ public abstract class X509CRL extends CRL implements X509Extension
@return true if equal, false otherwise
*/
+ @Override
public boolean equals(Object other)
{
if( other instanceof X509CRL ) {
@@ -148,6 +149,7 @@ public abstract class X509CRL extends CRL implements X509Extension
@return A hash code of this class
*/
+ @Override
public int hashCode()
{
return super.hashCode();
@@ -390,6 +392,7 @@ public abstract class X509CRL extends CRL implements X509Extension
* @return The issuer's X.500 distinguished name.
* @since JDK 1.4
*/
+ @SuppressWarnings("static-method")
public X500Principal getIssuerX500Principal()
{
throw new UnsupportedOperationException();
diff --git a/java/security/cert/X509CRLEntry.java b/java/security/cert/X509CRLEntry.java
index ac5ef4714..d8f00187f 100644
--- a/java/security/cert/X509CRLEntry.java
+++ b/java/security/cert/X509CRLEntry.java
@@ -1,5 +1,5 @@
/* X509CRLEntry.java --- X.509 Certificate Revocation List Entry
- Copyright (C) 1999 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2015 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -89,6 +89,7 @@ public abstract class X509CRLEntry implements X509Extension
@return true if equal, false otherwise
*/
+ @Override
public boolean equals(Object other)
{
if( other instanceof X509CRLEntry ) {
@@ -118,6 +119,7 @@ public abstract class X509CRLEntry implements X509Extension
@return A hash code of this class
*/
+ @Override
public int hashCode()
{
return super.hashCode();
@@ -164,6 +166,7 @@ public abstract class X509CRLEntry implements X509Extension
@return a string representing this X509CRLEntry.
*/
+ @Override
public abstract String toString();
}
diff --git a/java/security/cert/X509CRLSelector.java b/java/security/cert/X509CRLSelector.java
index 1ac5c640b..81817da1d 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, 2014 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2014, 2015 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -72,7 +72,7 @@ import javax.security.auth.x500.X500Principal;
* @author Casey Marshall (csm@gnu.org)
* @since 1.4
*/
-public class X509CRLSelector implements CRLSelector, Cloneable
+public class X509CRLSelector implements CRLSelector
{
// Fields.
@@ -235,8 +235,7 @@ public class X509CRLSelector implements CRLSelector, Cloneable
iNames.add(principal.getName());
return Collections.unmodifiableList(iNames);
}
- else
- return null;
+ return null;
}
/**
@@ -339,6 +338,7 @@ public class X509CRLSelector implements CRLSelector, Cloneable
*
* @return The string.
*/
+ @Override
public String toString()
{
CPStringBuilder str = new CPStringBuilder(X509CRLSelector.class.getName());
@@ -367,6 +367,7 @@ public class X509CRLSelector implements CRLSelector, Cloneable
* @param _crl The CRL being checked.
* @return True if the CRL matches, false otherwise.
*/
+ @Override
public boolean match(CRL _crl)
{
if (!(_crl instanceof X509CRL))
@@ -433,6 +434,7 @@ public class X509CRLSelector implements CRLSelector, Cloneable
*
* @return The copy.
*/
+ @Override
public Object clone()
{
try
diff --git a/java/security/cert/X509CertSelector.java b/java/security/cert/X509CertSelector.java
index ef8123bf7..ccdb3344d 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, 2014 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2005, 2006, 2014, 2015 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -47,7 +47,6 @@ import gnu.java.security.x509.ext.Extension;
import gnu.java.security.x509.ext.GeneralName;
import gnu.java.security.x509.ext.GeneralSubtree;
import gnu.java.security.x509.ext.NameConstraints;
-import gnu.java.security.x509.ext.GeneralName.Kind;
import java.io.IOException;
import java.math.BigInteger;
@@ -87,7 +86,7 @@ import javax.security.auth.x500.X500Principal;
* @author Casey Marshall (csm@gnu.org)
* @since 1.4
*/
-public class X509CertSelector implements CertSelector, Cloneable
+public class X509CertSelector implements CertSelector
{
// Constants and fields.
@@ -107,7 +106,7 @@ public class X509CertSelector implements CertSelector, Cloneable
{
byte[] nameBytes = null;
GeneralName.Kind kind = GeneralName.Kind.forTag(id);
- switch (Kind.forTag(id))
+ switch (kind)
{
case dNSName:
case rfc822Name:
@@ -133,6 +132,7 @@ public class X509CertSelector implements CertSelector, Cloneable
case ediPartyName:
case x400Address:
case otherName:
+ default:
throw new IOException("cannot decode string representation of "
+ kind);
}
@@ -259,6 +259,7 @@ public class X509CertSelector implements CertSelector, Cloneable
altNames.add(generalName);
}
+ @Override
public Object clone()
{
try
@@ -281,9 +282,8 @@ public class X509CertSelector implements CertSelector, Cloneable
public byte[] getAuthorityKeyIdentifier()
{
if (authKeyId != null)
- return (byte[]) authKeyId.clone();
- else
- return null;
+ return authKeyId.clone();
+ return null;
}
/**
@@ -317,8 +317,7 @@ public class X509CertSelector implements CertSelector, Cloneable
{
if (certValid != null)
return (Date) certValid.clone();
- else
- return null;
+ return null;
}
/**
@@ -332,8 +331,7 @@ public class X509CertSelector implements CertSelector, Cloneable
{
if (keyPurposeSet != null)
return Collections.unmodifiableSet(keyPurposeSet);
- else
- return null;
+ return null;
}
/**
@@ -346,8 +344,7 @@ public class X509CertSelector implements CertSelector, Cloneable
{
if (issuer != null)
return issuer.getEncoded();
- else
- return null;
+ return null;
}
/**
@@ -360,8 +357,7 @@ public class X509CertSelector implements CertSelector, Cloneable
{
if (issuer != null)
return issuer.getName();
- else
- return null;
+ return null;
}
/**
@@ -373,9 +369,8 @@ public class X509CertSelector implements CertSelector, Cloneable
public boolean[] getKeyUsage()
{
if (keyUsage != null)
- return (boolean[]) keyUsage.clone();
- else
- return null;
+ return keyUsage.clone();
+ return null;
}
/**
@@ -400,9 +395,8 @@ public class X509CertSelector implements CertSelector, Cloneable
public byte[] getNameConstraints()
{
if (nameConstraints != null)
- return (byte[]) nameConstraints.clone();
- else
- return null;
+ return nameConstraints.clone();
+ return null;
}
public Collection<List<?>> getPathToNames()
@@ -413,7 +407,7 @@ public class X509CertSelector implements CertSelector, Cloneable
for (GeneralName name : pathToNames)
{
List<Object> n = new ArrayList<Object>(2);
- n.add(name.kind().tag());
+ n.add(Integer.valueOf(name.kind().tag()));
n.add(name.name());
names.add(n);
}
@@ -456,6 +450,7 @@ public class X509CertSelector implements CertSelector, Cloneable
*
* @return Null.
*/
+ @SuppressWarnings("static-method")
public Date getPrivateKeyValid()
{
return null;
@@ -489,7 +484,7 @@ public class X509CertSelector implements CertSelector, Cloneable
for (GeneralName name : altNames)
{
List<Object> n = new ArrayList<Object>(2);
- n.add(name.kind().tag());
+ n.add(Integer.valueOf(name.kind().tag()));
n.add(name.name());
names.add(n);
}
@@ -508,8 +503,7 @@ public class X509CertSelector implements CertSelector, Cloneable
{
if (subject != null)
return subject.getEncoded();
- else
- return null;
+ return null;
}
/**
@@ -522,8 +516,7 @@ public class X509CertSelector implements CertSelector, Cloneable
{
if (subject != null)
return subject.getName();
- else
- return null;
+ return null;
}
/**
@@ -536,9 +529,8 @@ public class X509CertSelector implements CertSelector, Cloneable
public byte[] getSubjectKeyIdentifier()
{
if (subjectKeyId != null)
- return (byte[]) subjectKeyId.clone();
- else
- return null;
+ return subjectKeyId.clone();
+ return null;
}
/**
@@ -571,17 +563,18 @@ public class X509CertSelector implements CertSelector, Cloneable
* @param certificate The certificate to check.
* @return true if the certificate matches all criteria.
*/
+ @Override
public boolean match(Certificate certificate)
{
if (!(certificate instanceof X509Certificate))
return false;
- X509Certificate cert = (X509Certificate) certificate;
- if (this.cert != null)
+ X509Certificate other = (X509Certificate) certificate;
+ if (cert != null)
{
try
{
- byte[] e1 = this.cert.getEncoded();
- byte[] e2 = cert.getEncoded();
+ byte[] e1 = cert.getEncoded();
+ byte[] e2 = other.getEncoded();
if (!Arrays.equals(e1, e2))
return false;
}
@@ -592,14 +585,14 @@ public class X509CertSelector implements CertSelector, Cloneable
}
if (serialNo != null)
{
- if (!serialNo.equals(cert.getSerialNumber()))
+ if (!serialNo.equals(other.getSerialNumber()))
return false;
}
if (certValid != null)
{
try
{
- cert.checkValidity(certValid);
+ other.checkValidity(certValid);
}
catch (CertificateException ce)
{
@@ -608,40 +601,40 @@ public class X509CertSelector implements CertSelector, Cloneable
}
if (issuer != null)
{
- if (!issuer.equals(cert.getIssuerX500Principal()))
+ if (!issuer.equals(other.getIssuerX500Principal()))
return false;
}
if (subject != null)
{
- if (!subject.equals(cert.getSubjectX500Principal()))
+ if (!subject.equals(other.getSubjectX500Principal()))
return false;
}
if (sigId != null)
{
- if (!sigId.toString().equals(cert.getSigAlgOID()))
+ if (!sigId.toString().equals(other.getSigAlgOID()))
return false;
}
if (subjectKeyId != null)
{
- byte[] b = cert.getExtensionValue(SUBJECT_KEY_ID);
+ byte[] b = other.getExtensionValue(SUBJECT_KEY_ID);
if (!Arrays.equals(b, subjectKeyId))
return false;
}
if (authKeyId != null)
{
- byte[] b = cert.getExtensionValue(AUTH_KEY_ID);
+ byte[] b = other.getExtensionValue(AUTH_KEY_ID);
if (!Arrays.equals(b, authKeyId))
return false;
}
if (keyUsage != null)
{
- boolean[] b = cert.getKeyUsage();
+ boolean[] b = other.getKeyUsage();
if (!Arrays.equals(b, keyUsage))
return false;
}
if (basicConstraints >= 0)
{
- if (cert.getBasicConstraints() != basicConstraints)
+ if (other.getBasicConstraints() != basicConstraints)
return false;
}
if (keyPurposeSet != null)
@@ -649,7 +642,7 @@ public class X509CertSelector implements CertSelector, Cloneable
List<String> kp = null;
try
{
- kp = cert.getExtendedKeyUsage();
+ kp = other.getExtendedKeyUsage();
}
catch (CertificateParsingException cpe)
{
@@ -668,7 +661,7 @@ public class X509CertSelector implements CertSelector, Cloneable
Collection<List<?>> an = null;
try
{
- an = cert.getSubjectAlternativeNames();
+ an = other.getSubjectAlternativeNames();
}
catch (CertificateParsingException cpe)
{
@@ -709,7 +702,7 @@ public class X509CertSelector implements CertSelector, Cloneable
}
if (nameConstraints != null)
{
- byte[] nc = cert.getExtensionValue(NAME_CONSTRAINTS_ID);
+ byte[] nc = other.getExtensionValue(NAME_CONSTRAINTS_ID);
if (!Arrays.equals(nameConstraints, nc))
return false;
}
@@ -717,15 +710,15 @@ public class X509CertSelector implements CertSelector, Cloneable
if (policy != null)
{
CertificatePolicies policies = null;
- if (cert instanceof GnuPKIExtension)
+ if (other instanceof GnuPKIExtension)
{
policies = (CertificatePolicies)
- ((GnuPKIExtension) cert).getExtension(CertificatePolicies.ID).getValue();
+ ((GnuPKIExtension) other).getExtension(CertificatePolicies.ID).getValue();
}
else
{
byte[] policiesDer =
- cert.getExtensionValue(CertificatePolicies.ID.toString());
+ other.getExtensionValue(CertificatePolicies.ID.toString());
try
{
policies = new CertificatePolicies(policiesDer);
@@ -745,16 +738,16 @@ public class X509CertSelector implements CertSelector, Cloneable
if (pathToNames != null)
{
NameConstraints nc = null;
- if (cert instanceof GnuPKIExtension)
+ if (other instanceof GnuPKIExtension)
{
Extension e =
- ((GnuPKIExtension) cert).getExtension(NameConstraints.ID);
+ ((GnuPKIExtension) other).getExtension(NameConstraints.ID);
if (e != null)
nc = (NameConstraints) e.getValue();
}
else
{
- byte[] b = cert.getExtensionValue(NameConstraints.ID.toString());
+ byte[] b = other.getExtensionValue(NameConstraints.ID.toString());
if (b != null)
{
try
@@ -957,6 +950,7 @@ public class X509CertSelector implements CertSelector, Cloneable
* @throws IOException If the argument is not a valid DER-encoded
* name constraints.
*/
+ @SuppressWarnings("unused")
public void setNameConstraints(byte[] nameConstraints)
throws IOException
{
@@ -965,7 +959,7 @@ public class X509CertSelector implements CertSelector, Cloneable
// But we just compare raw byte arrays.
this.nameConstraints = nameConstraints != null
- ? (byte[]) nameConstraints.clone() : null;
+ ? nameConstraints.clone() : null;
}
/**
@@ -1056,6 +1050,7 @@ public class X509CertSelector implements CertSelector, Cloneable
*
* @param UNUSED Is silently ignored.
*/
+ @SuppressWarnings("unused")
public void setPrivateKeyValid(Date UNUSED)
{
}
@@ -1216,8 +1211,7 @@ public class X509CertSelector implements CertSelector, Cloneable
try
{
KeyFactory enc = KeyFactory.getInstance("X.509");
- subjectKeySpec = (X509EncodedKeySpec)
- enc.getKeySpec(key, X509EncodedKeySpec.class);
+ subjectKeySpec = enc.getKeySpec(key, X509EncodedKeySpec.class);
}
catch (Exception x)
{
@@ -1256,6 +1250,7 @@ public class X509CertSelector implements CertSelector, Cloneable
this.sigId = null;
}
+ @Override
public String toString()
{
CPStringBuilder str = new CPStringBuilder(X509CertSelector.class.getName());
diff --git a/java/security/cert/X509Certificate.java b/java/security/cert/X509Certificate.java
index ab9e1be37..62a1e01eb 100644
--- a/java/security/cert/X509Certificate.java
+++ b/java/security/cert/X509Certificate.java
@@ -1,5 +1,5 @@
/* X509Certificate.java --- X.509 Certificate class
- Copyright (C) 1999,2003, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2003, 2006, 2015 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -488,6 +488,7 @@ public abstract class X509Certificate
* @throws CertificateParsingException If this extension cannot be
* parsed from its encoded form.
*/
+ @SuppressWarnings({"unused","static-method"})
public java.util.List<String> getExtendedKeyUsage()
throws CertificateParsingException
{
@@ -532,6 +533,7 @@ public abstract class X509Certificate
* be parsed.
* @since JDK 1.4
*/
+ @SuppressWarnings({"unused","static-method"})
public java.util.Collection<List<?>> getSubjectAlternativeNames()
throws CertificateParsingException
{
@@ -559,6 +561,7 @@ public abstract class X509Certificate
* be parsed.
* @since JDK 1.4
*/
+ @SuppressWarnings({"unused","static-method"})
public java.util.Collection<List<?>> getIssuerAlternativeNames()
throws CertificateParsingException
{
@@ -571,6 +574,7 @@ public abstract class X509Certificate
* @return The subject's X.500 distinguished name.
* @since JDK 1.4
*/
+ @SuppressWarnings("static-method")
public javax.security.auth.x500.X500Principal getSubjectX500Principal()
{
throw new UnsupportedOperationException();
@@ -582,6 +586,7 @@ public abstract class X509Certificate
* @return The issuer's X.500 distinguished name.
* @since JDK 1.4
*/
+ @SuppressWarnings("static-method")
public javax.security.auth.x500.X500Principal getIssuerX500Principal()
{
throw new UnsupportedOperationException();