|
IP*Works! SSL V6 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--ipworksssl.Certmgr
The CertMgr bean is used to manage the digital certificates installed on a system.
The bean methods, such as ListCertificateStores or ListStoreCertificates ,
are used to list certificate stores and certificates. The corresponding lists are returned
via the StoreList and CertList events. Encoded certificates are
provided through the events. By supplying
the encoded certificate to the CertEncoded property of another instance of the
bean, you can get information about the certificate through the corresponding
properties (described below).
The CertSubject , CertSerialNumber , and CertIssuer properties
identify the certificate. CertSubject is also used in conjunction with
the CertStore property to search for certificates. Please refer to the
description of these properties for details.
The CertEffectiveDate and CertExpirationDate show the time boundaries
of the certificate.
CertPublicKey , CertPublicKeyAlgorithm , and CertPublicKeyLength , CertVersion provide information about the certificate keys and the
certificate format (version).
The CertUsageFlags specifies the intended usage of the certificate. The CertUsage property provides a text description of these flags.
| Field Summary | |
static int |
sstMachine
|
static int |
sstPEMKey
|
static int |
sstPFXBlob
|
static int |
sstPFXFile
|
static int |
sstUser
|
| Constructor Summary | |
Certmgr()
|
|
| Method Summary | |
void |
addCertmgrEventListener(CertmgrEventListener l)
|
java.lang.String |
config(java.lang.String configurationString)
Sets or retrieves a beanconfiguration setting. |
void |
createCertificate(java.lang.String certSubject,
int serialNumber)
Creates a new self-signed certificate in the current store. |
void |
createKey(java.lang.String keyName)
Creates a new keyset associated with the provided name. |
void |
deleteCertificate()
Deletes the currently selected certificate from the store. |
void |
deleteKey(java.lang.String keyName)
Deletes the keyset associated with the provided name. |
void |
exportCertificate(java.lang.String PFXFile,
java.lang.String password)
Saves the current certificate to a PFX file. |
java.lang.String |
generateCSR(java.lang.String certSubject,
java.lang.String keyName)
Generates a new CSR to be sent to a signing authority. |
java.lang.String |
getCertEffectiveDate()
A date before which the certificate is not valid. |
byte[] |
getCertEncoded()
The contents of the certificate (PEM/base64 encoded). |
java.lang.String |
getCertExpirationDate()
A date after which the certificate is not valid. |
java.lang.String |
getCertIssuer()
The issuer of the certificate. |
java.lang.String |
getCertPrivateKey()
The private key of the certificate (if available). |
java.lang.String |
getCertPrivateKeyContainer()
The name of the private key container for the certificate (if available). |
java.lang.String |
getCertPublicKey()
The public key of the certificate. |
java.lang.String |
getCertPublicKeyAlgorithm()
Textual description of the public key algorithm of the certificate. |
int |
getCertPublicKeyLength()
The length of the certificate public key (in bits). |
java.lang.String |
getCertSerialNumber()
The serial number of the certificate encoded as a string. |
java.lang.String |
getCertSignatureAlgorithm()
Textual description of the signature algorithm of the certificate. |
byte[] |
getCertStore()
The certificate store to search for certificates. |
java.lang.String |
getCertStorePassword()
The password for the certificate store (if any). |
int |
getCertStoreType()
The type of certificate store for CertStore . |
java.lang.String |
getCertSubject()
The subject of the certificate. |
java.lang.String |
getCertThumbprintMD5()
MD5 hash of the certificate. |
java.lang.String |
getCertThumbprintSHA1()
SHA1 hash of the certificate. |
java.lang.String |
getCertUsage()
Textual description of CertUsageFlags . |
int |
getCertUsageFlags()
Flags that show intended use for the certificate. |
java.lang.String |
getCertVersion()
The certificate's version number. |
void |
importCertificate(java.lang.String PFXFile,
java.lang.String password,
java.lang.String subject)
Imports a certificate from a PFX file into the current certificate store. |
void |
importSignedCSR(byte[] signedCSR,
java.lang.String keyName)
Imports a signed CSR. |
boolean |
isCertPrivateKeyAvailable()
Shows whether a private key is available for the selected certificate. |
void |
issueCertificate(java.lang.String certSubject,
int serialNumber)
Creates a new certificate in the current store, signed by the selected certificate. |
java.lang.String |
listCertificateStores()
Lists certificate stores. |
java.lang.String |
listKeys()
List keysets in a CSP. |
java.lang.String |
listMachineStores()
List machine certificate stores. |
java.lang.String |
listStoreCertificates()
List certificates in a store. |
void |
readCertificate(java.lang.String fileName)
Loads a certificate from a file. |
void |
removeCertmgrEventListener(CertmgrEventListener l)
|
void |
reset()
Resets all certificate properties to their default values. |
void |
saveCertificate(java.lang.String fileName)
Saves the current certificate to a file. |
void |
setCertEncoded(byte[] certEncoded)
The contents of the certificate (PEM/base64 encoded). |
void |
setCertStore(byte[] certStore)
The certificate store to search for certificates. |
void |
setCertStorePassword(java.lang.String certStorePassword)
The password for the certificate store (if any). |
void |
setCertStoreType(int certStoreType)
The type of certificate store for CertStore . |
void |
setCertSubject(java.lang.String certSubject)
The subject of the certificate. |
java.lang.String |
showCertificateChain()
Show certificate chain. |
java.lang.String |
signCSR(byte[] CSR,
int serialNumber)
Creates a signed certificate from a CSR. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final int sstUser
public static final int sstMachine
public static final int sstPFXFile
public static final int sstPFXBlob
public static final int sstPEMKey
| Constructor Detail |
public Certmgr()
| Method Detail |
public java.lang.String getCertEffectiveDate()
The following is an example of an encoded date illustrating the format: 23-Jan-2000 15:00:00.
public byte[] getCertEncoded()
When CertEncoded is set to a valid certificate, CertSubject and other certificate properties are updated to reflect the subject
and other attributes of the certificate.
This property is also used to find a digital id (i.e. certificate
and private key pair) in the current store. In this case, a search
is initiated in the current CertStore for the private key of the
certificate. If the key is found, CertSubject is updated to reflect
the full subject of the selected certificate and CertPrivateKeyAvailable returns True.
public void setCertEncoded(byte[] certEncoded)
throws IPWorksSSLException
When CertEncoded is set to a valid certificate, CertSubject and other certificate properties are updated to reflect the subject
and other attributes of the certificate.
This property is also used to find a digital id (i.e. certificate
and private key pair) in the current store. In this case, a search
is initiated in the current CertStore for the private key of the
certificate. If the key is found, CertSubject is updated to reflect
the full subject of the selected certificate and CertPrivateKeyAvailable returns True.
IPWorksSSLExceptionpublic java.lang.String getCertExpirationDate()
The following is an example of an encoded date illustrating the format: 23-Jan-2001 15:00:00.
public java.lang.String getCertIssuer()
The property contains a string representation of the distinguished name of the issuing authority for the certificate.
public java.lang.String getCertPrivateKey()
The key is provided as a series of hex-encoded bytes.
Note that the private key may be available, but not exportable.
In this case, CertPrivateKey return an empty string.
public boolean isCertPrivateKeyAvailable()
If CertPrivateKeyAvailable is True, the certificate may be used
for authentication purposes (e.g. server authentication).
public java.lang.String getCertPrivateKeyContainer()
This functionality is available only in Windows platforms.
public java.lang.String getCertPublicKey()
The key is provided as a series of hex-encoded bytes.
public java.lang.String getCertPublicKeyAlgorithm()
The property contains either the name of the algorithm (such as "RSA" or "RSA_DH"), or an object id (OID) string representing the algorithm.
public int getCertPublicKeyLength()
Common values are 512, 1024, and 2048.
public java.lang.String getCertSerialNumber()
The number is encoded as a series of hexadecimal digits, each two of them representing a byte of the serial number.
public java.lang.String getCertSignatureAlgorithm()
The property contains either the name of the algorithm (such as "RSA" or "RSA_MD5RSA"), or an object id (OID) string representing the algorithm.
public byte[] getCertStore()
The CertStoreType property specifies the type of the
certificate store specified by CertStore . If the store
is password protected, specify the password in CertStorePassword .
CertStore is used in conjunction with the CertSubject property to select a certificate. If CertStore has a value and CertSubject or CertEncoded is set, a search for a certificate is initiated. Please refer to the CertSubject property for details.
Designations of certificate stores are platform-dependent.
The following are designations of the most common User and Machine certificate stores in Windows:
In Java, the certificate store normally is a file containing certificates and optional private keys.
When the certificate store type is PFXFile, this property must be set to the name of the file. When the type is PFXBlob, the property must be set to the binary contents of a PFX file (i.e. PKCS12 certificate store).
If the provider is OpenSSL, the certificate store is a file containing a certificate and a private key. This property must be set to the name of the file.
public void setCertStore(byte[] certStore)
throws IPWorksSSLException
The CertStoreType property specifies the type of the
certificate store specified by CertStore . If the store
is password protected, specify the password in CertStorePassword .
CertStore is used in conjunction with the CertSubject property to select a certificate. If CertStore has a value and CertSubject or CertEncoded is set, a search for a certificate is initiated. Please refer to the CertSubject property for details.
Designations of certificate stores are platform-dependent.
The following are designations of the most common User and Machine certificate stores in Windows:
In Java, the certificate store normally is a file containing certificates and optional private keys.
When the certificate store type is PFXFile, this property must be set to the name of the file. When the type is PFXBlob, the property must be set to the binary contents of a PFX file (i.e. PKCS12 certificate store).
If the provider is OpenSSL, the certificate store is a file containing a certificate and a private key. This property must be set to the name of the file.
IPWorksSSLExceptionpublic java.lang.String getCertStorePassword()
If the certificate store is of a type that requires a password, the value of this property is used to open the certificate store.
public void setCertStorePassword(java.lang.String certStorePassword)
throws IPWorksSSLException
If the certificate store is of a type that requires a password, the value of this property is used to open the certificate store.
IPWorksSSLExceptionpublic int getCertStoreType()
CertStore .
This property can take one of the following values:
public void setCertStoreType(int certStoreType)
throws IPWorksSSLException
CertStore .
This property can take one of the following values:
IPWorksSSLExceptionpublic java.lang.String getCertSubject()
When this property is set, a search is performed in the current certificate store certificate with matching subject.
If an exact match is not found, the store is searched for subjects containing the value of the property.
When setting the property to a partial subject, CN= should be omitted. For example, the following code would find the certificate with subject CN=Test Certificate, OU=People, C=US
Example (Searching with partial subject)
Control.CertSubject = "Test"
If a match is not found, the property is set to an empty string, and no certificate is selected.
The special value "*" picks a random certificate in the certificate store.
If a matching certificate is found, the CertSubject property
is set to the full subject of the matching certificate.
public void setCertSubject(java.lang.String certSubject)
throws IPWorksSSLException
When this property is set, a search is performed in the current certificate store certificate with matching subject.
If an exact match is not found, the store is searched for subjects containing the value of the property.
When setting the property to a partial subject, CN= should be omitted. For example, the following code would find the certificate with subject CN=Test Certificate, OU=People, C=US
Example (Searching with partial subject)
Control.CertSubject = "Test"
If a match is not found, the property is set to an empty string, and no certificate is selected.
The special value "*" picks a random certificate in the certificate store.
If a matching certificate is found, the CertSubject property
is set to the full subject of the matching certificate.
IPWorksSSLExceptionpublic java.lang.String getCertThumbprintMD5()
If the hash does not exist, it is computed using the CryptHashCertificate function.
public java.lang.String getCertThumbprintSHA1()
If the hash does not exist, it is computed using the CryptHashCertificate function.
public java.lang.String getCertUsage()
CertUsageFlags .
The value will of one or more of the following strings, separated by commas:
If the provider is OpenSSL the value is a comma separated list of X509 certificate extension names.
public int getCertUsageFlags()
The value of CertUsageFlags is a combination of the following
flags:
CertUsage property for a text representation
of CertUsageFlags .
This functionality is currently not available when the provider is OpenSSL.
public java.lang.String getCertVersion()
The possible values are the strings "V1", "V2", and "V3".
public java.lang.String config(java.lang.String configurationString)
throws IPWorksSSLException
Config is a generic method available in every bean.
It is used to set and retrieveconfiguration settingsfor the
bean.
Configuration settings are similar in functionality to properties,
but they are rarely used. In order to avoid "polluting" the property
namespace of the bean, access to these internal properties is provided through the Config method.
To set a configuration setting named PROPERTY , you must call Config("PROPERTY=VALUE") , where VALUE is the value of the setting expressed as a string. For boolean values, use the strings "True", "False", "0", "1", "Yes", or "No" (case does not matter).
To read (query) the value of a configuration setting, you must call Config("PROPERTY") . The value will be returned as a string.
IPWorksSSLException
public void createCertificate(java.lang.String certSubject,
int serialNumber)
throws IPWorksSSLException
CertSubject specifies the subject of the new certificate. A new keyset (public/private key pair) is generated and associated with the new certificate.
SerialNumber specifies the certificate serial number. All certificates signed by the same issuer must have different (unique) serial numbers.
The time validity of the new certificate is determined by theCertValidityTimeconfiguration setting, and the key size by theCertKeyLengthconfiguration setting.
NOTE: This functionality is only available in Windows.
IPWorksSSLException
public void createKey(java.lang.String keyName)
throws IPWorksSSLException
CreateKey will create a new keyset (public/private key pair)
within the Cryptographic Service Provider (CSP) used by the
bean. The CSP can be set using theCSPconfiguration setting.
NOTE: This functionality is only available in Windows.
IPWorksSSLException
public void deleteCertificate()
throws IPWorksSSLException
If the certificate cannot be deleted, an error is returned.
This functionality is currently not available when the provider is OpenSSL.
IPWorksSSLException
public void deleteKey(java.lang.String keyName)
throws IPWorksSSLException
DeleteKey will delete the keyset (public/private key pair)
associated with KeyName from the Cryptographic Service
Provider (CSP). The CSP can be set using theCSPconfiguration setting.
NOTE: This functionality is only available in Windows.
IPWorksSSLException
public void exportCertificate(java.lang.String PFXFile,
java.lang.String password)
throws IPWorksSSLException
The current certificate and its private key are saved to the file specified by PFXFile in PKCS12 format. The file contents are protected by Password . If the provider is OpenSSL, the current certificate and its private key are saved to the file specified by PFXFile in PEM format. The private key is encrypted using the Password .
IPWorksSSLException
public java.lang.String generateCSR(java.lang.String certSubject,
java.lang.String keyName)
throws IPWorksSSLException
CertSubject specifies the subject of the Certificate Signing Request (CSR). KeyName specifies the name of the keyset (public/private key pair) to be used. If the keyset does not already exist in the Cryptographic Service Provider (CSP), the bean will automatically generate one. To set the CSP, use theCSPconfiguration setting.
NOTE: it is important to remember the name of the keyset that is used when creating a CSR, as keyset must be later reassociated with the certificate after the trust authority has signed the CSR.
NOTE: This functionality is only available in Windows.
IPWorksSSLException
public void importCertificate(java.lang.String PFXFile,
java.lang.String password,
java.lang.String subject)
throws IPWorksSSLException
The certificate specified by Subject and its private key are loaded from the PKCS12 file specified by PFXFile . If the file is password-protected Password is used to open it.
Subject is optional. If empty, the first certificate in the store is loaded instead of the matching certificate.
If the provider is OpenSSL, the current version just loads the first certificate and its private key. Subject is ignored.
IPWorksSSLException
public void importSignedCSR(byte[] signedCSR,
java.lang.String keyName)
throws IPWorksSSLException
SignedCSR specifies a certificate that has been signed by a trust authority. KeyName is the name of the keyset (public/private key pair) that was used to create the original Certificate Signing Request (CSR).
NOTE: This functionality is only available in Windows.
IPWorksSSLException
public void issueCertificate(java.lang.String certSubject,
int serialNumber)
throws IPWorksSSLException
CertSubject specifies the subject of the new certificate. A new keyset (public/private key pair) is generated and associated with the new certificate.
SerialNumber specifies the certificate serial number. All certificates signed by the same issuer must have different (unique) serial numbers.
The certificate specified by CertSubject ( CertEncoded ) will be
used as the issuing certificate.
If no certificate has been selected in the current CertStore prior
to calling this method, or if the selected certificate does not have an
associated private key, the method throws an IPWorksException
raises an IPWorksException exception
.
The time validity of the new certificate is determined by theCertValidityTimeconfiguration setting, and the key size by theCertKeyLengthconfiguration setting.
NOTE: This functionality is only available in Windows.
IPWorksSSLException
public java.lang.String listCertificateStores()
throws IPWorksSSLException
Lists the system certificate stores for the current user account.
The results are provided through the StoreList event.
The same information is also returned upon method completion as a set of lines, one per certificate store name.
NOTE: This functionality is only available in Windows.
IPWorksSSLException
public java.lang.String listKeys()
throws IPWorksSSLException
Lists the keys (public/private key pairs) in a Cryptographic
Service Provider. The results are provided through the KeyList event.
The same information is also returned upon method completion as a set of lines, one per key, with each line containing the following information separated by Tab characters: KeyContainer , KeyType , AlgId , KeyLen .
NOTE: This functionality is only available in Windows.
IPWorksSSLException
public java.lang.String listMachineStores()
throws IPWorksSSLException
Same as the ListCertificateStores method, but lists certificate
stores in the machine account (under HKEY_LOCAL_MACHINE in the registry).
NOTE: This functionality is only available in Windows.
IPWorksSSLException
public java.lang.String listStoreCertificates()
throws IPWorksSSLException
Lists the certificates in a store. The results are provided
through the CertList event.
The same information is also returned upon method completion as a set of lines, one per certificate, with each line containing the following information separated by Tab characters: CertSubject , CertIssuer , CertSerialNumber , HasPrivateKey (as "1" or "0").
This functionality is currently not available when the provider is OpenSSL.
IPWorksSSLException
public void readCertificate(java.lang.String fileName)
throws IPWorksSSLException
The file contents can be encoded in base64 (PEM) or ASN (DER) format.
Setting this property to a filename is equivalent to assigning
the file contents to CertEncoded .
IPWorksSSLException
public void reset()
throws IPWorksSSLException
If a certificate and private key is selected and.or a certificate store is opened, both are released upon calling this method.
IPWorksSSLException
public void saveCertificate(java.lang.String fileName)
throws IPWorksSSLException
The certificate is saved in base64 (PEM) format to the file specified by FileName . If the file exists, it is overwritten.
IPWorksSSLException
public java.lang.String showCertificateChain()
throws IPWorksSSLException
Shows the certificate chain for the certificate. The results are provided
through the CertChain event.
The same information is also returned upon method completion as a set of lines, one per key, with each line containing the following information separated by Tab characters: CertSubject , CertIssuer , CertSerialNumber , TrustStatus , TrustInfo .
NOTE: This functionality is only available in Windows.
IPWorksSSLException
public java.lang.String signCSR(byte[] CSR,
int serialNumber)
throws IPWorksSSLException
CSR specifies the Certificate Signing Request to be signed.
SerialNumber specifies the certificate serial number. All certificates signed by the same issuer must have different (unique) serial numbers.
The time validity of the new certificate is determined by theCertValidityTimeconfiguration setting, and the key size by theCertKeyLengthconfiguration setting.
NOTE: This functionality is only available in Windows.
IPWorksSSLException
public void addCertmgrEventListener(CertmgrEventListener l)
throws java.util.TooManyListenersException
java.util.TooManyListenersExceptionpublic void removeCertmgrEventListener(CertmgrEventListener l)
|
IP*Works! SSL V6 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||