org.kde.koala
Class KSSLCertificate

java.lang.Object
  extended by org.kde.koala.KSSLCertificate
All Implemented Interfaces:
org.kde.qt.QtSupport

public class KSSLCertificate
extends java.lang.Object
implements org.kde.qt.QtSupport

KDE X.509 Certificate This class represents an X.509 (SSL) certificate. Note: this object is VERY HEAVY TO COPY. Please try to use reference or pointer whenever possible

Author:
George Staikos
See Also:
KSSL

Field Summary
static int Any
           
static int ErrorReadingRoot
           
static int Expired
           
static int InvalidCA
           
static int InvalidHost
           
static int InvalidPurpose
           
static int Irrelevant
           
static int NoCARoot
           
static int None
           
static int NoSSL
           
static int Ok
           
static int PathLengthExceeded
           
static int PrivateKeyFailed
           
static int Rejected
           
static int Revoked
           
static int SelfSigned
           
static int SelfSignedChain
           
static int SignatureFailed
           
static int SMIMEEncrypt
           
static int SMIMESign
           
static int SSLClient
           
static int SSLServer
           
static int Unknown
          A CA certificate can be validated as Irrelevant when it was not used to sign any other relevant certificate.
static int Untrusted
           
 
Constructor Summary
  KSSLCertificate()
           
protected KSSLCertificate(java.lang.Class dummy)
           
  KSSLCertificate(KSSLCertificate x)
          Copy constructor.
 
Method Summary
 KSSLCertChain chain()
          Get a reference to the certificate chain.
 void dispose()
          Delete the wrapped C++ instance ahead of finalize()
protected  void finalize()
          Deletes the wrapped C++ instance
static KSSLCertificate fromString(java.lang.String cert)
          Create an X.509 certificate from a base64 encoded string.
 void getEmails(java.lang.String[] to)
          FIXME: document
 java.lang.String getIssuer()
          Get the issuer of the certificate (X.509 map).
 java.lang.String getKDEKey()
          KDEKey is a concatenation "Subject (MD5)", mostly needed for SMIME.
 java.lang.String getKeyType()
          Get the key type (RSA, DSA, etc).
 java.lang.String getMD5Digest()
          Get the MD5 digest of the certificate.
static java.lang.String getMD5DigestFromKDEKey(java.lang.String k)
          Aegypten semantics force us to search by MD5Digest only.
 java.lang.String getMD5DigestText()
          Get the MD5 digest of the certificate.
 java.lang.String getNotAfter()
          Get the date that the certificate is valid until.
 java.lang.String getNotBefore()
          Get the date that the certificate becomes valid on.
 java.lang.String getPublicKeyText()
          Get the public key.
 java.util.Calendar getQDTNotAfter()
          Get the date that the certificate is valid until.
 java.util.Calendar getQDTNotBefore()
          Get the date that the certificate becomes valid on.
 java.lang.String getSerialNumber()
          Get the serial number of the certificate.
 java.lang.String getSignatureText()
          Get the signature.
 java.lang.String getSubject()
          Get the subject of the certificate (X.509 map).
 boolean isDisposed()
          Has the wrapped C++ instance been deleted?
 boolean isSigner()
          Check if this is a signer certificate.
 boolean isValid()
          Check if this is a valid certificate.
 boolean isValid(int p)
          Check if this is a valid certificate.
protected  int processError(int ec)
           
 KSSLCertificate replicate()
          Explicitly make a copy of this certificate.
 int revalidate()
          Check if this is a valid certificate.
 int revalidate(int p)
          Check if this is a valid certificate.
 boolean setCert(java.lang.StringBuffer cert)
          Re-set the certificate from a base64 string.
 java.util.ArrayList subjAltNames()
          The alternate subject name.
 byte[] toDer()
          Convert the certificate to DER (ASN.1) format.
 byte[] toNetscape()
          Convert the certificate to Netscape format.
 byte[] toPem()
          Convert the certificate to PEM (base64) format.
 java.lang.String toString()
          Convert this certificate to a string.
 java.lang.String toText()
          Convert the certificate to OpenSSL plain text format.
 int validate()
          Check if this is a valid certificate.
 int validate(int p)
          Check if this is a valid certificate.
static java.lang.String verifyText(int x)
          Obtain the localized message that corresponds to a validation result.
 KSSLX509V3 x509V3Extensions()
          Access the X.509v3 parameters.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

Unknown

public static final int Unknown
A CA certificate can be validated as Irrelevant when it was not used to sign any other relevant certificate.

See Also:
Constant Field Values

Ok

public static final int Ok
See Also:
Constant Field Values

NoCARoot

public static final int NoCARoot
See Also:
Constant Field Values

InvalidPurpose

public static final int InvalidPurpose
See Also:
Constant Field Values

PathLengthExceeded

public static final int PathLengthExceeded
See Also:
Constant Field Values

InvalidCA

public static final int InvalidCA
See Also:
Constant Field Values

Expired

public static final int Expired
See Also:
Constant Field Values

SelfSigned

public static final int SelfSigned
See Also:
Constant Field Values

ErrorReadingRoot

public static final int ErrorReadingRoot
See Also:
Constant Field Values

NoSSL

public static final int NoSSL
See Also:
Constant Field Values

Revoked

public static final int Revoked
See Also:
Constant Field Values

Untrusted

public static final int Untrusted
See Also:
Constant Field Values

SignatureFailed

public static final int SignatureFailed
See Also:
Constant Field Values

Rejected

public static final int Rejected
See Also:
Constant Field Values

PrivateKeyFailed

public static final int PrivateKeyFailed
See Also:
Constant Field Values

InvalidHost

public static final int InvalidHost
See Also:
Constant Field Values

Irrelevant

public static final int Irrelevant
See Also:
Constant Field Values

SelfSignedChain

public static final int SelfSignedChain
See Also:
Constant Field Values

None

public static final int None
See Also:
Constant Field Values

SSLServer

public static final int SSLServer
See Also:
Constant Field Values

SSLClient

public static final int SSLClient
See Also:
Constant Field Values

SMIMESign

public static final int SMIMESign
See Also:
Constant Field Values

SMIMEEncrypt

public static final int SMIMEEncrypt
See Also:
Constant Field Values

Any

public static final int Any
See Also:
Constant Field Values
Constructor Detail

KSSLCertificate

protected KSSLCertificate(java.lang.Class dummy)

KSSLCertificate

public KSSLCertificate(KSSLCertificate x)
Copy constructor. Beware, this is very expensive.

Parameters:
x - the object to copy from

KSSLCertificate

public KSSLCertificate()
Method Detail

toString

public java.lang.String toString()
Convert this certificate to a string.

Overrides:
toString in class java.lang.Object
Returns:
the certificate in base64 format

getSubject

public java.lang.String getSubject()
Get the subject of the certificate (X.509 map).

Returns:
the subject

getIssuer

public java.lang.String getIssuer()
Get the issuer of the certificate (X.509 map).

Returns:
the issuer

getNotBefore

public java.lang.String getNotBefore()
Get the date that the certificate becomes valid on.

Returns:
the date as a string, localised

getNotAfter

public java.lang.String getNotAfter()
Get the date that the certificate is valid until.

Returns:
the date as a string, localised

getQDTNotBefore

public java.util.Calendar getQDTNotBefore()
Get the date that the certificate becomes valid on.

Returns:
the date

getQDTNotAfter

public java.util.Calendar getQDTNotAfter()
Get the date that the certificate is valid until.

Returns:
the date

toDer

public byte[] toDer()
Convert the certificate to DER (ASN.1) format.

Returns:
the binary data of the DER encoding

toPem

public byte[] toPem()
Convert the certificate to PEM (base64) format.

Returns:
the binary data of the PEM encoding

toNetscape

public byte[] toNetscape()
Convert the certificate to Netscape format.

Returns:
the binary data of the Netscape encoding

toText

public java.lang.String toText()
Convert the certificate to OpenSSL plain text format.

Returns:
the OpenSSL text encoding

getSerialNumber

public java.lang.String getSerialNumber()
Get the serial number of the certificate.

Returns:
the serial number as a string

getKeyType

public java.lang.String getKeyType()
Get the key type (RSA, DSA, etc).

Returns:
the key type as a string

getPublicKeyText

public java.lang.String getPublicKeyText()
Get the public key.

Returns:
the public key as a hexidecimal string

getMD5DigestText

public java.lang.String getMD5DigestText()
Get the MD5 digest of the certificate. Result is padded with : to separate bytes - it's a text version!

Returns:
the MD5 digest in a hexidecimal string

getMD5Digest

public java.lang.String getMD5Digest()
Get the MD5 digest of the certificate.

Returns:
the MD5 digest in a hexidecimal string

getSignatureText

public java.lang.String getSignatureText()
Get the signature.

Returns:
the signature in text format

isValid

public boolean isValid()
Check if this is a valid certificate. Will use cached data.

Returns:
true if it is valid

isValid

public boolean isValid(int p)
Check if this is a valid certificate. Will use cached data.

Parameters:
p - the purpose to validate for
Returns:
true if it is valid

subjAltNames

public java.util.ArrayList subjAltNames()
The alternate subject name.

Returns:
string list with subjectAltName

validate

public int validate()
Check if this is a valid certificate. Will use cached data.

Returns:
the result of the validation

validate

public int validate(int p)
Check if this is a valid certificate. Will use cached data.

Parameters:
p - the purpose to validate for
Returns:
the result of the validation

revalidate

public int revalidate()
Check if this is a valid certificate. Will NOT use cached data.

Returns:
the result of the validation

revalidate

public int revalidate(int p)
Check if this is a valid certificate. Will NOT use cached data.

Parameters:
p - the purpose to validate for
Returns:
the result of the validation

chain

public KSSLCertChain chain()
Get a reference to the certificate chain.

Returns:
reference to the chain

replicate

public KSSLCertificate replicate()
Explicitly make a copy of this certificate.

Returns:
a copy of the certificate

setCert

public boolean setCert(java.lang.StringBuffer cert)
Re-set the certificate from a base64 string.

Parameters:
cert - the certificate to set to
Returns:
true on success

x509V3Extensions

public KSSLX509V3 x509V3Extensions()
Access the X.509v3 parameters.

Returns:
reference to the extension object
See Also:
KSSLX509V3

isSigner

public boolean isSigner()
Check if this is a signer certificate.

Returns:
true if this is a signer certificate

getEmails

public void getEmails(java.lang.String[] to)
FIXME: document


getKDEKey

public java.lang.String getKDEKey()
KDEKey is a concatenation "Subject (MD5)", mostly needed for SMIME. The result of getKDEKey might change and should not be used for persistant storage.


fromString

public static KSSLCertificate fromString(java.lang.String cert)
Create an X.509 certificate from a base64 encoded string.

Parameters:
cert - the certificate in base64 form
Returns:
the X.509 certificate, or NULL

verifyText

public static java.lang.String verifyText(int x)
Obtain the localized message that corresponds to a validation result.

Parameters:
x - the code to look up
Returns:
the message text corresponding to the validation code

getMD5DigestFromKDEKey

public static java.lang.String getMD5DigestFromKDEKey(java.lang.String k)
Aegypten semantics force us to search by MD5Digest only.


processError

protected int processError(int ec)

finalize

protected void finalize()
                 throws java.lang.InternalError
Deletes the wrapped C++ instance

Overrides:
finalize in class java.lang.Object
Throws:
java.lang.InternalError

dispose

public void dispose()
Delete the wrapped C++ instance ahead of finalize()


isDisposed

public boolean isDisposed()
Has the wrapped C++ instance been deleted?