Methods Summary |
---|
public void | checkValidity()
if (notBefore == -1) {
// retrieve and cache the value of validity period
notBefore = tbsCert.getValidity().getNotBefore().getTime();
notAfter = tbsCert.getValidity().getNotAfter().getTime();
}
long time = System.currentTimeMillis();
if (time < notBefore) {
throw new CertificateNotYetValidException();
}
if (time > notAfter) {
throw new CertificateExpiredException();
}
|
public void | checkValidity(java.util.Date date)
if (notBefore == -1) {
// retrieve and cache the value of validity period
notBefore = tbsCert.getValidity().getNotBefore().getTime();
notAfter = tbsCert.getValidity().getNotAfter().getTime();
}
long time = date.getTime();
if (time < notBefore) {
// BEGIN android-changed
throw new CertificateNotYetValidException("current time: " + date
+ ", validation time: " + new Date(notBefore));
// END android-changed
}
if (time > notAfter) {
// BEGIN android-changed
throw new CertificateExpiredException("current time: " + date
+ ", expiration time: " + new Date(notAfter));
// END android-changed
}
|
private void | fastVerify(java.security.PublicKey key)Implements a faster RSA verification method that delegates to OpenSSL
native code. In all other aspects it behaves just like the ordinary
{@link verify} method.
if (!(key instanceof RSAPublicKey)) {
throw new InvalidKeyException(Messages.getString("security.15C1"));
}
RSAPublicKey rsaKey = (RSAPublicKey) key;
String algorithm = getSigAlgName();
int i = algorithm.indexOf("with");
algorithm = algorithm.substring(i + 4) + "-" + algorithm.substring(0, i);
if (tbsCertificate == null) {
tbsCertificate = tbsCert.getEncoded();
}
byte[] sig = certificate.getSignatureValue();
if (!OpenSSLSocketImpl.verifySignature(tbsCertificate, sig, algorithm, rsaKey)) {
throw new SignatureException(Messages.getString("security.15C")); //$NON-NLS-1$
}
|
public int | getBasicConstraints()
if (extensions == null) {
return Integer.MAX_VALUE;
}
return extensions.valueOfBasicConstrains();
|
public java.util.Set | getCriticalExtensionOIDs()
if (extensions == null) {
return null;
}
// retrieve the info from the cached extensions object
return extensions.getCriticalExtensions();
|
public byte[] | getEncoded()
if (encoding == null) {
encoding = certificate.getEncoded();
}
byte[] result = new byte[encoding.length];
System.arraycopy(encoding, 0, result, 0, encoding.length);
return result;
|
public java.util.List | getExtendedKeyUsage()
if (extensions == null) {
return null;
}
try {
return extensions.valueOfExtendedKeyUsage();
} catch (IOException e) {
throw new CertificateParsingException(e);
}
|
public byte[] | getExtensionValue(java.lang.String oid)
if (extensions == null) {
return null;
}
// retrieve the info from the cached extensions object
Extension ext = extensions.getExtensionByOID(oid);
return (ext == null) ? null : ext.getRawExtnValue();
|
public java.util.Collection | getIssuerAlternativeNames()
if (extensions == null) {
return null;
}
try {
// Retrieve the extension value from the cached extensions object
// This extension is not checked for correctness during
// certificate generation, so now it can throw exception
return extensions.valueOfIssuerAlternativeName();
} catch (IOException e) {
throw new CertificateParsingException(e);
}
|
public java.security.Principal | getIssuerDN()
if (issuer == null) {
// retrieve the issuer's principal
issuer = tbsCert.getIssuer().getX500Principal();
}
return issuer;
|
public boolean[] | getIssuerUniqueID()
return tbsCert.getIssuerUniqueID();
|
public javax.security.auth.x500.X500Principal | getIssuerX500Principal()
if (issuer == null) {
// retrieve the issuer's principal
issuer = tbsCert.getIssuer().getX500Principal();
}
return issuer;
|
public boolean[] | getKeyUsage()
if (extensions == null) {
return null;
}
return extensions.valueOfKeyUsage();
|
public java.util.Set | getNonCriticalExtensionOIDs()
if (extensions == null) {
return null;
}
// retrieve the info from the cached extensions object
return extensions.getNonCriticalExtensions();
|
public java.util.Date | getNotAfter()
if (notBefore == -1) {
// the value was not retrieved from the certificate, do it:
notBefore = tbsCert.getValidity().getNotBefore().getTime();
notAfter = tbsCert.getValidity().getNotAfter().getTime();
}
return new Date(notAfter);
|
public java.util.Date | getNotBefore()
if (notBefore == -1) {
// the value was not retrieved from the certificate, do it:
notBefore = tbsCert.getValidity().getNotBefore().getTime();
notAfter = tbsCert.getValidity().getNotAfter().getTime();
}
return new Date(notBefore);
|
public java.security.PublicKey | getPublicKey()
if (publicKey == null) {
// retrieve the public key from SubjectPublicKeyInfo
// substructure of X.509 certificate
publicKey = tbsCert.getSubjectPublicKeyInfo().getPublicKey();
}
return publicKey;
|
public java.math.BigInteger | getSerialNumber()
if (serialNumber == null) {
serialNumber = tbsCert.getSerialNumber();
}
return serialNumber;
|
public java.lang.String | getSigAlgName()
if (sigAlgOID == null) {
// if info was not retrieved (and cached), do it:
sigAlgOID = tbsCert.getSignature().getAlgorithm();
// retrieve the name of the signing algorithm
sigAlgName = AlgNameMapper.map2AlgName(sigAlgOID);
if (sigAlgName == null) {
// if could not be found, use OID as a name
sigAlgName = sigAlgOID;
}
}
return sigAlgName;
|
public java.lang.String | getSigAlgOID()
if (sigAlgOID == null) {
// if info was not retrieved (and cached), do it:
sigAlgOID = tbsCert.getSignature().getAlgorithm();
// retrieve the name of the signing algorithm
sigAlgName = AlgNameMapper.map2AlgName(sigAlgOID);
if (sigAlgName == null) {
// if could not be found, use OID as a name
sigAlgName = sigAlgOID;
}
}
return sigAlgOID;
|
public byte[] | getSigAlgParams()
if (nullSigAlgParams) {
return null;
}
if (sigAlgParams == null) {
sigAlgParams = tbsCert.getSignature().getParameters();
if (sigAlgParams == null) {
nullSigAlgParams = true;
return null;
}
}
return sigAlgParams;
|
public byte[] | getSignature()
if (signature == null) {
// retrieve the value of the signature
signature = certificate.getSignatureValue();
}
byte[] result = new byte[signature.length];
System.arraycopy(signature, 0, result, 0, signature.length);
return result;
|
public java.util.Collection | getSubjectAlternativeNames()
if (extensions == null) {
return null;
}
try {
// Retrieve the extension value from the cached extensions object
// This extension is not checked for correctness during
// certificate generation, so now it can throw exception
return extensions.valueOfSubjectAlternativeName();
} catch (IOException e) {
throw new CertificateParsingException(e);
}
|
public java.security.Principal | getSubjectDN()
if (subject == null) {
// retrieve the subject's principal
subject = tbsCert.getSubject().getX500Principal();
}
return subject;
|
public boolean[] | getSubjectUniqueID()
return tbsCert.getSubjectUniqueID();
|
public javax.security.auth.x500.X500Principal | getSubjectX500Principal()
if (subject == null) {
// retrieve the subject's principal
subject = tbsCert.getSubject().getX500Principal();
}
return subject;
|
public byte[] | getTBSCertificate()
if (tbsCertificate == null) {
// retrieve the encoded form of the TBSCertificate structure
tbsCertificate = tbsCert.getEncoded();
}
byte[] result = new byte[tbsCertificate.length];
System.arraycopy(tbsCertificate, 0, result, 0, tbsCertificate.length);
return result;
|
public int | getVersion()
return tbsCert.getVersion() + 1;
|
public boolean | hasUnsupportedCriticalExtension()
if (extensions == null) {
return false;
}
// retrieve the info from the cached extensions object
return extensions.hasUnsupportedCritical();
|
public java.lang.String | toString()
return certificate.toString();
|
public void | verify(java.security.PublicKey key)Verifies the signature of the certificate.
// BEGIN android-added
if (getSigAlgName().endsWith("withRSA")) {
fastVerify(key);
return;
}
// END android-added
Signature signature = Signature.getInstance(getSigAlgName());
signature.initVerify(key);
// retrieve the encoding of the TBSCertificate structure
if (tbsCertificate == null) {
tbsCertificate = tbsCert.getEncoded();
}
// compute and verify the signature
signature.update(tbsCertificate, 0, tbsCertificate.length);
if (!signature.verify(certificate.getSignatureValue())) {
throw new SignatureException(Messages.getString("security.15C")); //$NON-NLS-1$
}
|
public void | verify(java.security.PublicKey key, java.lang.String sigProvider)Verifies the signature of the certificate.
// BEGIN android-added
if (getSigAlgName().endsWith("withRSA")) {
fastVerify(key);
return;
}
// END android-added
Signature signature =
Signature.getInstance(getSigAlgName(), sigProvider);
signature.initVerify(key);
// retrieve the encoding of the TBSCertificate structure
if (tbsCertificate == null) {
tbsCertificate = tbsCert.getEncoded();
}
// compute and verify the signature
signature.update(tbsCertificate, 0, tbsCertificate.length);
if (!signature.verify(certificate.getSignatureValue())) {
throw new SignatureException(Messages.getString("security.15C")); //$NON-NLS-1$
}
|