|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.james.security.KeyHolder
public class KeyHolder
Loads a KeyStore
in memory and keeps it ready for the
cryptographic activity.
It has the role of being a simpler intermediate to the crypto libraries. Uses specifically the Legion of the Bouncy Castle libraries, particularly for the SMIME activity.
Constructor Summary | |
---|---|
KeyHolder(java.lang.String keyStoreFileName,
java.lang.String keyStorePassword,
java.lang.String keyAlias,
java.lang.String keyAliasPassword,
java.lang.String keyStoreType)
Creates a new instance of KeyHolder using KeyStore related parameters. |
Method Summary | |
---|---|
org.bouncycastle.mail.smime.SMIMESignedGenerator |
createGenerator()
Creates an SMIMESignedGenerator . |
javax.mail.internet.MimeMultipart |
generate(javax.mail.internet.MimeBodyPart content)
Generates a signed MimeMultipart from a MimeBodyPart. |
javax.mail.internet.MimeMultipart |
generate(javax.mail.internet.MimeMessage message)
Generates a signed MimeMultipart from a MimeMessage. |
java.security.cert.X509Certificate |
getCertificate()
Getter for property certificate. |
java.security.cert.CertStore |
getCertStore()
Getter for property certStore. |
static java.lang.String |
getDefaultType()
Returns the default keystore type as specified in the Java security properties file, or the string "jks" (acronym for "Java keystore") if no such property exists. |
java.security.PrivateKey |
getPrivateKey()
Getter for property privateKey. |
java.lang.String |
getSignerAddress()
Getter for property signerAddress. |
static java.lang.String |
getSignerAddress(java.security.cert.X509Certificate certificate)
Extracts the signer email address (EMAILADDRESS=) from an X509Certificate distinguished name. |
java.lang.String |
getSignerCN()
Getter for property signerCN. |
static java.lang.String |
getSignerCN(java.security.cert.X509Certificate certificate)
Extracts the signer common name (CN=) from an X509Certificate distinguished name. |
java.lang.String |
getSignerDistinguishedName()
Getter for property signerDistinguishedName. |
static java.lang.String |
getSignerDistinguishedName(java.security.cert.X509Certificate certificate)
Extracts the signer distinguished name (DN) from an X509Certificate . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public KeyHolder(java.lang.String keyStoreFileName, java.lang.String keyStorePassword, java.lang.String keyAlias, java.lang.String keyAliasPassword, java.lang.String keyStoreType) throws java.security.KeyStoreException, java.io.FileNotFoundException, java.io.IOException, java.security.NoSuchAlgorithmException, java.security.InvalidAlgorithmParameterException, java.security.cert.CertificateException, java.security.UnrecoverableKeyException, java.security.NoSuchProviderException
KeyHolder
using KeyStore
related parameters.
keyStoreFileName
- The (absolute) file name of the .keystore file to load the keystore from.keyStorePassword
- The (optional) password used to check the integrity of the keystore.
If given, it is used to check the integrity of the keystore data,
otherwise, if null, the integrity of the keystore is not checked.keyAlias
- The alias name of the key.
If missing (is null) and if there is only one key in the keystore, will default to it.keyAliasPassword
- The password of the alias for recovering the key.
If missing (is null) will default to keyStorePassword. At least one of the passwords must be provided.keyStoreType
- The type of keystore.
If missing (is null) will default to the keystore type as specified in the Java security properties file,
or the string "jks" (acronym for "Java keystore") if no such property exists.
java.security.KeyStoreException
- Thrown when the keyAlias is specified and not found,
or is not specified and either no alias is found or more than one is found.
java.io.FileNotFoundException
java.io.IOException
java.security.NoSuchAlgorithmException
java.security.InvalidAlgorithmParameterException
java.security.cert.CertificateException
java.security.UnrecoverableKeyException
java.security.NoSuchProviderException
KeyStore.getDefaultType()
,
KeyStore.getInstance(String)
,
KeyStore.load(java.io.InputStream, char[])
,
KeyStore.getKey(java.lang.String, char[])
,
KeyStore.getCertificate(java.lang.String)
Method Detail |
---|
public static java.lang.String getDefaultType()
KeyStore.getDefaultType()
.public java.security.PrivateKey getPrivateKey()
public java.security.cert.X509Certificate getCertificate()
public java.security.cert.CertStore getCertStore()
public org.bouncycastle.mail.smime.SMIMESignedGenerator createGenerator() throws java.security.cert.CertStoreException, org.bouncycastle.mail.smime.SMIMEException
SMIMESignedGenerator
. Includes a signer private key and certificate,
and a pool of certs and cerls (if any) to go with the signature.
java.security.cert.CertStoreException
org.bouncycastle.mail.smime.SMIMEException
public javax.mail.internet.MimeMultipart generate(javax.mail.internet.MimeMessage message) throws java.security.cert.CertStoreException, java.security.NoSuchAlgorithmException, java.security.NoSuchProviderException, org.bouncycastle.mail.smime.SMIMEException
message
- The message to sign.
MimeMultipart
.
java.security.cert.CertStoreException
java.security.NoSuchAlgorithmException
java.security.NoSuchProviderException
org.bouncycastle.mail.smime.SMIMEException
public javax.mail.internet.MimeMultipart generate(javax.mail.internet.MimeBodyPart content) throws java.security.cert.CertStoreException, java.security.NoSuchAlgorithmException, java.security.NoSuchProviderException, org.bouncycastle.mail.smime.SMIMEException
content
- The content to sign.
MimeMultipart
.
java.security.cert.CertStoreException
java.security.NoSuchAlgorithmException
java.security.NoSuchProviderException
org.bouncycastle.mail.smime.SMIMEException
public static java.lang.String getSignerDistinguishedName(java.security.cert.X509Certificate certificate)
X509Certificate
.
certificate
- The certificate to extract the information from.
public static java.lang.String getSignerCN(java.security.cert.X509Certificate certificate)
X509Certificate
distinguished name.
certificate
- The certificate to extract the information from.
getSignerDistinguishedName(X509Certificate)
public static java.lang.String getSignerAddress(java.security.cert.X509Certificate certificate)
X509Certificate
distinguished name.
certificate
- The certificate to extract the information from.
getSignerDistinguishedName(X509Certificate)
public java.lang.String getSignerDistinguishedName()
getSignerDistinguishedName(X509Certificate)
public java.lang.String getSignerCN()
getSignerCN(X509Certificate)
public java.lang.String getSignerAddress()
getSignerAddress(X509Certificate)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |