Methods Summary |
---|
static java.lang.String | getInfo(TLV cert)Returns description of given certificate (subject, issuer, serial
number and validity).
try {
TLV sn = cert.child.child.skipOptional(0xa0);
TLV issuer = sn.next.next;
TLV subject = issuer.next.next;
String result;
result =
// "Subject"
Resource.getString(
ResourceConstants.JSR177_CERTIFICATE_SUBJECT) +
": " + RFC2253Name.NameToString(subject);
result +=
"\n\n" +
// "Issuer"
Resource.getString(
ResourceConstants.JSR177_CERTIFICATE_ISSUER) +
": " + RFC2253Name.NameToString(issuer);
String s;
try {
s = "" + sn.getInteger();
} catch (TLVException e) {
s = "0x" + Utils.hexNumber(sn.data, sn.valueOffset, sn.length);
}
result +=
"\n\n" +
// "Serial number"
Resource.getString(ResourceConstants.JSR177_CERTIFICATE_SN) +
": " + s;
return
result + "\n\n" +
// "Valid from"
Resource.getString(
ResourceConstants.JSR177_CERTIFICATE_VALIDFROM) +
" " +
Utils.calendarToString(getValidity(cert, true)) +
" " +
// "through"
Resource.getString(
ResourceConstants.JSR177_CERTIFICATE_VALIDTILL) +
" " +
Utils.calendarToString(getValidity(cert, false));
} catch (TLVException tlve) { // ignored
} catch (IllegalArgumentException iae) { // ignored
} catch (NullPointerException npe) { // ignored
}
return null;
|
TLV | getIssuer()Returns issuer name for this certificate which can be used
only for comparison.
return cert.child.child.skipOptional(0xa0).next.next;
|
TLV | getIssuerAndSerialNumber()Returns new IssuerAndSerialNumber TLV object which can be used
as element of new data structure.
TLV t = TLV.createSequence();
t.setChild(getIssuer().copy()).
setNext(getSerialNumber().copy());
return t;
|
TLV | getKeyAlgorithmID()Returns key algorithm identifier for this certificate which can
be used as element of new data structure.
return getSubject().next.child.copy();
|
TLV | getSerialNumber()Returns serial number of this certificate. The result can be used
only for comparison, not for the construction of new DER
structure.
return cert.child.child.skipOptional(0xa0);
|
TLV | getSubject()Returns subject name for this certificate which can be used
only for comparison.
return getIssuer().next.next;
|
static java.util.Calendar | getValidity(TLV cert, boolean notBefore)Returns notBefore or notAfter date for the given certificate.
try {
TLV t = cert.child.child.skipOptional(0xa0).next.next.next.child;
if (! notBefore) {
t = t.next;
}
return t.getTime();
} catch (NullPointerException npe) {
throw new TLVException("Invalid certificate");
}
|
boolean | isExpired()Verifies if this certificate is expired.
Calendar c = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
try {
return c.before(getValidity(cert, true)) ||
c.after(getValidity(cert, false));
} catch (TLVException e) {
return true;
}
|
boolean | isIssuedBy(com.sun.satsa.pki.Certificate next)Verifies if this certificate was issued by subject of the
specified certificate. Returns false for self-signed certificates.
TLV issuer = getIssuer();
return (requestId != null) &&
Utils.byteMatch(requestId, next.id) &&
(! RFC2253Name.compare(issuer, getSubject())) &&
RFC2253Name.compare(issuer, next.getSubject());
|