|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--iaik.me.x509.X509Certificate
This class is used to parse X509 certificates. The certificate can be parsed with
X509Certificate x509 = new X509Certificate(SysUtil.openFileInputStream(file));
Constructor Summary | |
X509Certificate(byte[] data)
Creates a X509 certificate where the certificate info is stored in a byte array. |
|
X509Certificate(InputStream in)
Creates a X509 certificate from a given inputstream. |
Method Summary | |
static X509Certificate[] |
arrangeCertificateChain(PublicKey pubKey,
Vector v)
|
static X509Certificate[] |
arrangeCertificateChain(PublicKey pubKey,
X509Certificate[] certs)
|
void |
checkValidity()
This method checks the validity of the certificate. |
void |
checkValidity(Date date)
This method checks the validity of the Certificate. |
boolean |
equals(Object obj)
Compares two certificate objects. |
Enumeration |
extensions()
Returns an enumeration of the certificate's extensions. Enumeration e = x509.extensions(); while (e.hasMoreElements()) { System.out.println((X509Extension)e.nextElement()); } |
byte[] |
getEncoded()
getNotBefore() |
X509Extension |
getExtension(String oid)
This method returns a specific certificate Extension. |
Name |
getIssuerDN()
Returns the certificate's issuer name. |
Date |
getNotAfter()
Returns the certificate's ending of validity. |
Date |
getNotBefore()
Returns the certificate's beginning of validity. |
PublicKey |
getPublicKey()
Returns the public key of the X509 certificate. |
BigInteger |
getSerialNumber()
Returns the serialnumber of the X509 certificate. |
String |
getSigAlgOID()
Returns the signature algorithm ID. |
Name |
getSubjectDN()
Returns the certificate's subject. |
int |
getVersion()
Returns the version number of the X509 Certificate. |
int |
hashCode()
Returns a specific hash value from the X509Certificate object. |
String |
toString()
This method shows information from the certificate including: version, serial number, signature algorithm, subject, issuer, valid from - to, the publickey representation and an enumeration of the extensions. |
void |
verify()
This method verifies a self signed certificate. |
void |
verify(PublicKey publicKey)
This method used a public key to verify the certificate. |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public X509Certificate(InputStream in) throws IOException
in
- the inputstreamIOException
- if an error with the stream occurs.public X509Certificate(byte[] data) throws IOException
data
- the bytearrayIOException
- if an error during decoding occursMethod Detail |
public int getVersion()
public BigInteger getSerialNumber()
public String getSigAlgOID()
public PublicKey getPublicKey()
public Name getSubjectDN()
public Name getIssuerDN()
public Date getNotBefore()
public Date getNotAfter()
public Enumeration extensions()
Enumeration e = x509.extensions(); while (e.hasMoreElements()) { System.out.println((X509Extension)e.nextElement()); }
public X509Extension getExtension(String oid)
X509Certificate x509 = new X509Certificate(SysUtil.openFileInputStream(file));
X509Extension ex1= x509.getExtension(X509Extension.OID_KEY_USAGE);
For details how to retrieve values from the extension object see:@link X509Extensionoid
- Object Identifier of the Extensionpublic byte[] getEncoded()
public void verify() throws CryptoException
CryptoException
- if the publickey does not correspond to the privatepublic void verify(PublicKey publicKey) throws CryptoException
the
- publickeyCryptoException
- public void checkValidity() throws CryptoException
The validity can be checked with this:
try { x509.checkValidity(); System.out.println("Certificate Valid!); } catch (CryptoException e) { System.out.println("Certificate not Valid!"); }
CryptoException
- public void checkValidity(Date date) throws CryptoException
checkValidity()
If the certificate is not valid yet or if it's validity is over a CryptoException
is thrown.
The validity can be checked with this:
Date date = new Date(123123); // insert the desired Date here try { x509.checkValidity(date); System.out.println("Certificate Valid!); } catch (CryptoException e) { System.out.println("Certificate not Valid!"); }
date
- the dateCryptoException
- if thepublic String toString()
toString
in class Object
String
object containing all the before mentionend informationpublic int hashCode()
hashCode
in class Object
public boolean equals(Object obj)
equals
in class Object
public static X509Certificate[] arrangeCertificateChain(PublicKey pubKey, X509Certificate[] certs) throws CryptoException
public static X509Certificate[] arrangeCertificateChain(PublicKey pubKey, Vector v) throws CryptoException
|
This Javadoc may contain text parts from IETF Internet Standard specifications, see copyright note) and RSA Data Security Public-Key Cryptography Standards (see copyright note). | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |