Package org.mozilla.jss.pkcs11
Class PK11Cert
- java.lang.Object
-
- java.security.cert.Certificate
-
- java.security.cert.X509Certificate
-
- org.mozilla.jss.pkcs11.PK11Cert
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.AutoCloseable
,java.security.cert.X509Extension
,InternalCertificate
,TokenCertificate
,X509Certificate
- Direct Known Subclasses:
PK11InternalCert
public class PK11Cert extends java.security.cert.X509Certificate implements InternalCertificate, TokenCertificate, java.lang.AutoCloseable
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
PK11Cert.StringPrincipal
A class that implements Principal with a String.
-
Field Summary
Fields Modifier and Type Field Description protected org.mozilla.jss.pkcs11.CertProxy
certProxy
static int
EMAIL
static int
GOVT_APPROVED_CA
static int
INVISIBLE_CA
static org.slf4j.Logger
logger
protected java.lang.String
nickname
static int
NS_TRUSTED_CA
static int
OBJECT_SIGNING
static int
SEND_WARN
static int
SSL
protected TokenProxy
tokenProxy
static int
TRUSTED_CA
static int
TRUSTED_CLIENT_CA
static int
TRUSTED_PEER
static int
USER
static int
VALID_CA
static int
VALID_PEER
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
checkValidity()
void
checkValidity(java.util.Date date)
void
close()
static int
decodeTrustFlags(java.lang.String flags)
static java.lang.String
encodeTrustFlags(int flags)
boolean
equals(java.lang.Object other)
void
finalize()
int
getBasicConstraints()
java.util.Set<java.lang.String>
getCriticalExtensionOIDs()
int
getEmailTrust()
Get the email (S/MIME) trust flags for this certificate.byte[]
getEncoded()
byte[]
getExtensionValue(java.lang.String oid)
java.security.Principal
getIssuerDN()
protected java.lang.String
getIssuerDNString()
boolean[]
getIssuerUniqueID()
boolean[]
getKeyUsage()
java.lang.String
getNickname()
java.util.Set<java.lang.String>
getNonCriticalExtensionOIDs()
java.util.Date
getNotAfter()
java.util.Date
getNotBefore()
int
getObjectSigningTrust()
Get the object signing trust flags for this certificate.CryptoToken
getOwningToken()
Returns the CryptoToken that owns this certificate.java.security.PublicKey
getPublicKey()
java.math.BigInteger
getSerialNumber()
protected byte[]
getSerialNumberByteArray()
java.lang.String
getSigAlgName()
java.lang.String
getSigAlgOID()
byte[]
getSigAlgParams()
byte[]
getSignature()
int
getSSLTrust()
Get the SSL trust flags for this certificate.java.security.Principal
getSubjectDN()
protected java.lang.String
getSubjectDNString()
boolean[]
getSubjectUniqueID()
byte[]
getTBSCertificate()
protected int
getTrust(int type)
Gets the trust flags for this cert.java.lang.String
getTrustFlags()
byte[]
getUniqueID()
Returns the unique ID of this key.int
getVersion()
int
hashCode()
boolean
hasUnsupportedCriticalExtension()
static boolean
isTrustFlagEnabled(int flag, int flags)
void
setEmailTrust(int trust)
Set the email (S/MIME) trust flags for this certificate.void
setObjectSigningTrust(int trust)
Set the object signing trust flags for this certificate.void
setSSLTrust(int trust)
Set the SSL trust flags for this certificate.protected void
setTrust(int type, int trust)
Sets the trust flags for this cert.void
setTrustFlags(java.lang.String trustFlags)
java.lang.String
toString()
void
verify(java.security.PublicKey key)
void
verify(java.security.PublicKey key, java.lang.String sigProvider)
-
-
-
Field Detail
-
logger
public static org.slf4j.Logger logger
-
VALID_PEER
public static final int VALID_PEER
- See Also:
- Constant Field Values
-
TRUSTED_PEER
public static final int TRUSTED_PEER
- See Also:
- Constant Field Values
-
SEND_WARN
public static final int SEND_WARN
- See Also:
- Constant Field Values
-
VALID_CA
public static final int VALID_CA
- See Also:
- Constant Field Values
-
TRUSTED_CA
public static final int TRUSTED_CA
- See Also:
- Constant Field Values
-
NS_TRUSTED_CA
public static final int NS_TRUSTED_CA
- See Also:
- Constant Field Values
-
USER
public static final int USER
- See Also:
- Constant Field Values
-
TRUSTED_CLIENT_CA
public static final int TRUSTED_CLIENT_CA
- See Also:
- Constant Field Values
-
INVISIBLE_CA
public static final int INVISIBLE_CA
- See Also:
- Constant Field Values
-
GOVT_APPROVED_CA
public static final int GOVT_APPROVED_CA
- See Also:
- Constant Field Values
-
SSL
public static final int SSL
- See Also:
- Constant Field Values
-
EMAIL
public static final int EMAIL
- See Also:
- Constant Field Values
-
OBJECT_SIGNING
public static final int OBJECT_SIGNING
- See Also:
- Constant Field Values
-
certProxy
protected org.mozilla.jss.pkcs11.CertProxy certProxy
-
tokenProxy
protected TokenProxy tokenProxy
-
nickname
protected java.lang.String nickname
-
-
Method Detail
-
isTrustFlagEnabled
public static boolean isTrustFlagEnabled(int flag, int flags)
-
encodeTrustFlags
public static java.lang.String encodeTrustFlags(int flags)
-
decodeTrustFlags
public static int decodeTrustFlags(java.lang.String flags) throws java.lang.Exception
- Throws:
java.lang.Exception
-
getEncoded
public byte[] getEncoded() throws java.security.cert.CertificateEncodingException
- Specified by:
getEncoded
in interfaceX509Certificate
- Specified by:
getEncoded
in classjava.security.cert.Certificate
- Returns:
- The DER encoding of this certificate.
- Throws:
java.security.cert.CertificateEncodingException
- If an error occurred.
-
getNickname
public java.lang.String getNickname()
- Specified by:
getNickname
in interfaceX509Certificate
- Returns:
- The nickname of this certificate (could be null).
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.security.cert.Certificate
-
equals
public boolean equals(java.lang.Object other)
- Overrides:
equals
in classjava.security.cert.Certificate
-
getSubjectDN
public java.security.Principal getSubjectDN()
- Specified by:
getSubjectDN
in interfaceX509Certificate
- Specified by:
getSubjectDN
in classjava.security.cert.X509Certificate
- Returns:
- The RFC 1485 ASCII encoding of the Subject Name.
-
getIssuerDN
public java.security.Principal getIssuerDN()
- Specified by:
getIssuerDN
in interfaceX509Certificate
- Specified by:
getIssuerDN
in classjava.security.cert.X509Certificate
- Returns:
- The RFC 1485 ASCII encoding of the issuer's Subject Name.
-
getSerialNumber
public java.math.BigInteger getSerialNumber()
- Specified by:
getSerialNumber
in interfaceX509Certificate
- Specified by:
getSerialNumber
in classjava.security.cert.X509Certificate
- Returns:
- The serial number of this certificate.
-
getSerialNumberByteArray
protected byte[] getSerialNumberByteArray()
-
getSubjectDNString
protected java.lang.String getSubjectDNString()
-
getIssuerDNString
protected java.lang.String getIssuerDNString()
-
getPublicKey
public java.security.PublicKey getPublicKey()
- Specified by:
getPublicKey
in interfaceX509Certificate
- Specified by:
getPublicKey
in classjava.security.cert.Certificate
- Returns:
- The Public Key from this certificate.
-
getVersion
public int getVersion()
- Specified by:
getVersion
in interfaceX509Certificate
- Specified by:
getVersion
in classjava.security.cert.X509Certificate
- Returns:
- the version number of this X.509 certificate. 0 means v1, 1 means v2, 2 means v3.
-
getBasicConstraints
public int getBasicConstraints()
- Specified by:
getBasicConstraints
in classjava.security.cert.X509Certificate
-
getKeyUsage
public boolean[] getKeyUsage()
- Specified by:
getKeyUsage
in classjava.security.cert.X509Certificate
-
getSubjectUniqueID
public boolean[] getSubjectUniqueID()
- Specified by:
getSubjectUniqueID
in classjava.security.cert.X509Certificate
-
getIssuerUniqueID
public boolean[] getIssuerUniqueID()
- Specified by:
getIssuerUniqueID
in classjava.security.cert.X509Certificate
-
getSigAlgParams
public byte[] getSigAlgParams()
- Specified by:
getSigAlgParams
in classjava.security.cert.X509Certificate
-
getSigAlgName
public java.lang.String getSigAlgName()
- Specified by:
getSigAlgName
in classjava.security.cert.X509Certificate
-
getSigAlgOID
public java.lang.String getSigAlgOID()
- Specified by:
getSigAlgOID
in classjava.security.cert.X509Certificate
-
getSignature
public byte[] getSignature()
- Specified by:
getSignature
in classjava.security.cert.X509Certificate
-
getTBSCertificate
public byte[] getTBSCertificate() throws java.security.cert.CertificateEncodingException
- Specified by:
getTBSCertificate
in classjava.security.cert.X509Certificate
- Throws:
java.security.cert.CertificateEncodingException
-
getNotAfter
public java.util.Date getNotAfter()
- Specified by:
getNotAfter
in classjava.security.cert.X509Certificate
-
getNotBefore
public java.util.Date getNotBefore()
- Specified by:
getNotBefore
in classjava.security.cert.X509Certificate
-
checkValidity
public void checkValidity() throws java.security.cert.CertificateExpiredException, java.security.cert.CertificateNotYetValidException
- Specified by:
checkValidity
in classjava.security.cert.X509Certificate
- Throws:
java.security.cert.CertificateExpiredException
java.security.cert.CertificateNotYetValidException
-
checkValidity
public void checkValidity(java.util.Date date) throws java.security.cert.CertificateExpiredException, java.security.cert.CertificateNotYetValidException
- Specified by:
checkValidity
in classjava.security.cert.X509Certificate
- Throws:
java.security.cert.CertificateExpiredException
java.security.cert.CertificateNotYetValidException
-
toString
public java.lang.String toString()
- Specified by:
toString
in classjava.security.cert.Certificate
-
verify
public void verify(java.security.PublicKey key) throws java.security.cert.CertificateException, java.security.NoSuchAlgorithmException, java.security.InvalidKeyException, java.security.NoSuchProviderException, java.security.SignatureException
- Specified by:
verify
in classjava.security.cert.Certificate
- Throws:
java.security.cert.CertificateException
java.security.NoSuchAlgorithmException
java.security.InvalidKeyException
java.security.NoSuchProviderException
java.security.SignatureException
-
verify
public void verify(java.security.PublicKey key, java.lang.String sigProvider) throws java.security.cert.CertificateException, java.security.NoSuchAlgorithmException, java.security.InvalidKeyException, java.security.NoSuchProviderException, java.security.SignatureException
- Specified by:
verify
in classjava.security.cert.Certificate
- Throws:
java.security.cert.CertificateException
java.security.NoSuchAlgorithmException
java.security.InvalidKeyException
java.security.NoSuchProviderException
java.security.SignatureException
-
getExtensionValue
public byte[] getExtensionValue(java.lang.String oid)
- Specified by:
getExtensionValue
in interfacejava.security.cert.X509Extension
-
getCriticalExtensionOIDs
public java.util.Set<java.lang.String> getCriticalExtensionOIDs()
- Specified by:
getCriticalExtensionOIDs
in interfacejava.security.cert.X509Extension
-
getNonCriticalExtensionOIDs
public java.util.Set<java.lang.String> getNonCriticalExtensionOIDs()
- Specified by:
getNonCriticalExtensionOIDs
in interfacejava.security.cert.X509Extension
-
hasUnsupportedCriticalExtension
public boolean hasUnsupportedCriticalExtension()
- Specified by:
hasUnsupportedCriticalExtension
in interfacejava.security.cert.X509Extension
-
finalize
public void finalize() throws java.lang.Throwable
- Overrides:
finalize
in classjava.lang.Object
- Throws:
java.lang.Throwable
-
close
public void close() throws java.lang.Exception
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Throws:
java.lang.Exception
-
getUniqueID
public byte[] getUniqueID()
Description copied from interface:TokenCertificate
Returns the unique ID of this key. Unique IDs can be used to match certificates to keys.- Specified by:
getUniqueID
in interfaceTokenCertificate
- See Also:
PrivateKey.getUniqueID()
-
getOwningToken
public CryptoToken getOwningToken()
Description copied from interface:TokenCertificate
Returns the CryptoToken that owns this certificate. Cryptographic operations with this key may only be performed on the token that owns the key.- Specified by:
getOwningToken
in interfaceTokenCertificate
-
setTrust
protected void setTrust(int type, int trust)
Sets the trust flags for this cert.- Parameters:
type
- SSL, EMAIL, or OBJECT_SIGNING.trust
- The trust flags for this type of trust.
-
getTrust
protected int getTrust(int type)
Gets the trust flags for this cert.- Parameters:
type
- SSL, EMAIL, or OBJECT_SIGNING.- Returns:
- The trust flags for this type of trust.
-
setSSLTrust
public void setSSLTrust(int trust)
Set the SSL trust flags for this certificate.- Specified by:
setSSLTrust
in interfaceInternalCertificate
- Parameters:
trust
- A bitwise OR of the trust flags VALID_PEER, VALID_CA, TRUSTED_CA, USER, and TRUSTED_CLIENT_CA.
-
setEmailTrust
public void setEmailTrust(int trust)
Set the email (S/MIME) trust flags for this certificate.- Specified by:
setEmailTrust
in interfaceInternalCertificate
- Parameters:
trust
- A bitwise OR of the trust flags VALID_PEER, VALID_CA, TRUSTED_CA, USER, and TRUSTED_CLIENT_CA.
-
setObjectSigningTrust
public void setObjectSigningTrust(int trust)
Set the object signing trust flags for this certificate.- Specified by:
setObjectSigningTrust
in interfaceInternalCertificate
- Parameters:
trust
- A bitwise OR of the trust flags VALID_PEER, VALID_CA, TRUSTED_CA, USER, and TRUSTED_CLIENT_CA.
-
getSSLTrust
public int getSSLTrust()
Get the SSL trust flags for this certificate.- Specified by:
getSSLTrust
in interfaceInternalCertificate
- Returns:
- A bitwise OR of the trust flags VALID_PEER, VALID_CA, TRUSTED_CA, USER, and TRUSTED_CLIENT_CA.
-
getEmailTrust
public int getEmailTrust()
Get the email (S/MIME) trust flags for this certificate.- Specified by:
getEmailTrust
in interfaceInternalCertificate
- Returns:
- A bitwise OR of the trust flags VALID_PEER, VALID_CA, TRUSTED_CA, USER, and TRUSTED_CLIENT_CA.
-
getObjectSigningTrust
public int getObjectSigningTrust()
Get the object signing trust flags for this certificate.- Specified by:
getObjectSigningTrust
in interfaceInternalCertificate
- Returns:
- A bitwise OR of the trust flags VALID_PEER, VALID_CA, TRUSTED_CA, USER, and TRUSTED_CLIENT_CA.
-
getTrustFlags
public java.lang.String getTrustFlags()
-
setTrustFlags
public void setTrustFlags(java.lang.String trustFlags) throws java.lang.Exception
- Throws:
java.lang.Exception
-
-