Methods Summary |
---|
public org.bouncycastle.mail.smime.SMIMESignedGenerator | createGenerator()Creates an SMIMESignedGenerator . Includes a signer private key and certificate,
and a pool of certs and cerls (if any) to go with the signature.
// create the generator for creating an smime/signed message
SMIMESignedGenerator generator = new SMIMESignedGenerator();
// add a signer to the generator - this specifies we are using SHA1
// the encryption algorithm used is taken from the key
generator.addSigner(this.privateKey, this.certificate, SMIMESignedGenerator.DIGEST_SHA1);
// add our pool of certs and cerls (if any) to go with the signature
generator.addCertificatesAndCRLs(this.certStore);
return generator;
|
private static java.lang.String | extractAttribute(java.lang.String DistinguishedName, java.lang.String attributeName)
int i = DistinguishedName.indexOf(attributeName);
if (i < 0) {
return null;
}
i += attributeName.length();
int j = DistinguishedName.indexOf(",", i);
if (j - 1 <= 0) {
return null;
}
return DistinguishedName.substring(i, j).trim();
|
public javax.mail.internet.MimeMultipart | generate(javax.mail.internet.MimeMessage message)Generates a signed MimeMultipart from a MimeMessage.
// create the generator for creating an smime/signed MimeMultipart
SMIMESignedGenerator generator = createGenerator();
// do it
return generator.generate(message, "BC");
|
public javax.mail.internet.MimeMultipart | generate(javax.mail.internet.MimeBodyPart content)Generates a signed MimeMultipart from a MimeBodyPart.
// create the generator for creating an smime/signed MimeMultipart
SMIMESignedGenerator generator = createGenerator();
// do it
return generator.generate(content, "BC");
|
public java.security.cert.CertStore | getCertStore()Getter for property certStore.
return this.certStore;
|
public java.security.cert.X509Certificate | getCertificate()Getter for property certificate.
return this.certificate;
|
public 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.
return KeyStore.getDefaultType();
|
public java.security.PrivateKey | getPrivateKey()Getter for property privateKey.
return this.privateKey;
|
public static java.lang.String | getSignerAddress(java.security.cert.X509Certificate certificate)Extracts the signer email address (EMAILADDRESS=) from an X509Certificate distinguished name.
return extractAttribute(certificate.getSubjectDN().toString(), "EMAILADDRESS=");
|
public java.lang.String | getSignerAddress()Getter for property signerAddress.
return getSignerAddress(getCertificate());
|
public static java.lang.String | getSignerCN(java.security.cert.X509Certificate certificate)Extracts the signer common name (CN=) from an X509Certificate distinguished name.
return extractAttribute(certificate.getSubjectDN().toString(), "CN=");
|
public java.lang.String | getSignerCN()Getter for property signerCN.
return getSignerCN(getCertificate());
|
public static java.lang.String | getSignerDistinguishedName(java.security.cert.X509Certificate certificate)Extracts the signer distinguished name (DN) from an X509Certificate .
return certificate.getSubjectDN().toString();
|
public java.lang.String | getSignerDistinguishedName()Getter for property signerDistinguishedName.
return getSignerDistinguishedName(getCertificate());
|