public class CertificateUtils
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
(package private) static java.lang.String |
CERT_BEG
certificate encoding start mark
|
(package private) static java.lang.String |
CERT_BROKEN
certificate encoding start mark
|
(package private) static java.lang.String |
CERT_END
certificate encoding end mark
|
static int |
CERT_INVALID_BROKEN
Indicates the PEM data is not valid.
|
static int |
CERT_INVALID_CA_NOT_SIGNED_BY_CA
Indicates the certificate is CA and not signed by a CA certificate.
|
static int |
CERT_INVALID_CORRUPTED1
Indicates the certificate is corrupted.
|
static int |
CERT_INVALID_CORRUPTED2
Indicates the certificate is corrupted.
|
static int |
CERT_INVALID_CORRUPTED3
Indicates the certificate is corrupted.
|
static int |
CERT_INVALID_CORRUPTED4
Indicates the certificate is corrupted.
|
static int |
CERT_INVALID_CORRUPTED5
Indicates the certificate is corrupted.
|
static int |
CERT_INVALID_EXPIRED
Indicates the certificate is expired.
|
static int |
CERT_INVALID_NOT_YET_VALID
Indicates the certificate is not yet valid.
|
static int |
CERT_INVALID_PEER_NOT_SIGNED_BY_CA
Indicates the certificate is Peer and not signed by a CA certificate.
|
static int |
CERT_INVALID_PEER_SELF_SIGNED
Indicates the certificate is Peer and self-signed.
|
static int |
CERT_INVALID_SIGNER_NOT_FOUND
Indicates the signer certificate was not found.
|
static java.lang.String |
CERT_ISSUER
Key to identify map with Issuer properties.
|
static java.lang.String |
CERT_OWNER
Key to identify map with Owner properties.
|
static java.lang.String |
CERT_SERIAL_NUMBER
Key to identify certificate Serial Number.
|
static int |
CERT_VALID
Indicates the certificate is valid.
|
static java.lang.String |
CERT_VALIDITY_NOT_AFTER
Key to identify Validity Not After property.
|
static java.lang.String |
CERT_VALIDITY_NOT_BEFORE
Key to identify Validity Not Before property.
|
(package private) static int |
SPLIT_CHUNK
certificate encoding I/O chunk (as in *.PEM files)
|
Constructor and Description |
---|
CertificateUtils() |
Modifier and Type | Method and Description |
---|---|
static boolean |
compareNames(java.lang.String dn1,
java.lang.String dn2)
Compare the two given Distinctive Names and check if they are identical.
|
static java.util.Map<java.lang.String,java.lang.String> |
getCertificateDNProperties(CertDef cd,
boolean owner)
Get a map of the owner or issuer Distinctive Name properties.
|
static java.lang.String |
getCertificateDNProperty(CertDef cd,
java.lang.String prop,
boolean owner)
Get the value of the specified property, from the Distinctive Name entry
associated with the owner or issuer.
|
static java.util.Map<java.lang.String,java.lang.Object> |
getCertificateProperties(CertDef cd)
Loads the X509 certificate from the specified definition and returns
a map with properties for:
CERT_OWNER - this property will keep a Map of Distinctive
Name properties for the owner
CERT_ISSUER - this property will keep a Map of Distinctive
Name properties for the issuer
CERT_VALIDITY_NOT_BEFORE - the date from which this
certificate starts to be valid. |
static java.lang.String |
getValiditityMessage(int state)
Get a string describing the given certificate state.
|
static boolean |
isSelfSigned(CertDef cert)
Check if the given certificate is self-signed.
|
static boolean |
isSelfSigned(java.security.cert.X509Certificate x509)
Check if the given certificate is self-signed (issuer and owner DN are
equal).
|
(package private) static java.security.cert.X509Certificate |
loadCertificate(java.lang.String[] PEM)
Parse the given PEM certificate representation and return its X509
instance.
|
public static final java.lang.String CERT_OWNER
public static final java.lang.String CERT_ISSUER
public static final java.lang.String CERT_VALIDITY_NOT_BEFORE
public static final java.lang.String CERT_VALIDITY_NOT_AFTER
public static final java.lang.String CERT_SERIAL_NUMBER
public static final int CERT_VALID
public static final int CERT_INVALID_BROKEN
public static final int CERT_INVALID_NOT_YET_VALID
public static final int CERT_INVALID_EXPIRED
public static final int CERT_INVALID_PEER_SELF_SIGNED
public static final int CERT_INVALID_PEER_NOT_SIGNED_BY_CA
public static final int CERT_INVALID_SIGNER_NOT_FOUND
public static final int CERT_INVALID_CA_NOT_SIGNED_BY_CA
public static final int CERT_INVALID_CORRUPTED1
public static final int CERT_INVALID_CORRUPTED2
public static final int CERT_INVALID_CORRUPTED3
public static final int CERT_INVALID_CORRUPTED4
public static final int CERT_INVALID_CORRUPTED5
static final java.lang.String CERT_BROKEN
static final java.lang.String CERT_BEG
static final java.lang.String CERT_END
static final int SPLIT_CHUNK
public static boolean isSelfSigned(CertDef cert)
cert
- The certificate which should be checked.true
if this certificate is self-signedpublic static boolean isSelfSigned(java.security.cert.X509Certificate x509)
x509
- The certificate which should be checked.true
if this certificate is self-signedpublic static boolean compareNames(java.lang.String dn1, java.lang.String dn2)
dn1
- First Distinctive Namedn2
- Second Distinctive Nametrue
if the two Distinctive Names are identical.public static java.lang.String getValiditityMessage(int state)
state
- The state to be described.public static java.util.Map<java.lang.String,java.lang.Object> getCertificateProperties(CertDef cd)
CERT_OWNER
- this property will keep a Map of Distinctive
Name properties for the owner
CERT_ISSUER
- this property will keep a Map of Distinctive
Name properties for the issuer
CERT_VALIDITY_NOT_BEFORE
- the date from which this
certificate starts to be valid.
CERT_VALIDITY_NOT_AFTER
- the date from which this
certificate's validity period ends.
cd
- The certificate definition from which the info will be
extracted.null
if the
certificate PEM data could not be loaded.public static java.util.Map<java.lang.String,java.lang.String> getCertificateDNProperties(CertDef cd, boolean owner)
cd
- The certificate definition from which the info will be
extracted.owner
- true
if the owner property should be retrieved;
false
for the issuer property.null
if the
certificate PEM data could not be loaded.public static java.lang.String getCertificateDNProperty(CertDef cd, java.lang.String prop, boolean owner)
cd
- The certificate definition from which the info will be
extracted.owner
- true
if the owner property should be retrieved;
false
for the issuer property.static java.security.cert.X509Certificate loadCertificate(java.lang.String[] PEM)
PEM
- The PEM representation of this certificate.null
if
the certificate could not be instantiated.