public class CertificateUtils extends Object
| Constructor and Description |
|---|
CertificateUtils()
Default constructor.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
addCertificate(String certificateFile)
Add a new certificate to include.
|
boolean |
createCertificate(String cn,
String c,
String l,
String o,
String ou,
String st,
int validityDays,
String exportFile,
String exportPassword,
boolean selfsign,
boolean generateSingle)
Create a PKCS12 certificate file based on the supplied parameters.
|
boolean |
createCertificationRequest(String cn,
String c,
String l,
String o,
String ou,
String st,
int validityDays,
String requestFile,
String keyFile,
String exportPassword)
Create certificate request and key files based on the supplied parameters.
|
boolean |
createIdentity(Vector<String> certFiles,
String keyFile,
String p12File,
String exportPassword,
boolean usePKCS8)
Creates an PKCS12 identity file from a key a list of certificates.
|
void |
externalCall(String[] commandArray,
VirtualSessionManager vsm)
Utility function that calls an external command.
|
void |
initCAFromFiles(String certFile,
String keyFile)
Method to initialize the CA certificates to use when generating
certificates.
|
void |
initCAFromP12(String caFile,
String caPassword)
Method to initialize the CA certificates to use when generating
certificates.
|
void |
setStrength(int newStrength)
Set the cipher strength to use.
|
void |
setUseDSA(boolean useDSA)
Set whether DSA cipher should be used or not.
|
boolean |
signCertificationRequest(String requestFile,
String keyFile,
String certFile,
String exportPassword)
Create certificate (X509) file and key files based on the supplied
parameters.
|
public void setUseDSA(boolean useDSA)
useDSA - true means to use DSApublic void setStrength(int newStrength)
newStrength - -
allowed values 1024 and 512, default is 1024public boolean addCertificate(String certificateFile)
certificateFile - -
name of the file holding the certificate.public void initCAFromP12(String caFile, String caPassword) throws KeyStoreException, NoSuchAlgorithmException, CertificateException, FileNotFoundException, IOException, UnrecoverableKeyException, InvalidKeyException, NoSuchProviderException, SignatureException
caFile - name of file that contains the PKCS#10 filecaPassword - password to load the PKCS#10 fileKeyStoreExceptionNoSuchAlgorithmExceptionCertificateExceptionFileNotFoundExceptionIOExceptionUnrecoverableKeyExceptionInvalidKeyExceptionNoSuchProviderExceptionSignatureExceptionpublic void initCAFromFiles(String certFile, String keyFile) throws KeyStoreException, NoSuchAlgorithmException, CertificateException, FileNotFoundException, IOException, UnrecoverableKeyException, InvalidKeyException, InvalidKeySpecException, NoSuchProviderException, SignatureException
certFile - file containing BER encoded X509 certificatekeyFile - file containing PKCS#8 encoded keyKeyStoreExceptionNoSuchAlgorithmExceptionCertificateExceptionFileNotFoundExceptionIOExceptionUnrecoverableKeyExceptionInvalidKeyExceptionNoSuchProviderExceptionSignatureExceptionInvalidKeySpecExceptionpublic void externalCall(String[] commandArray, VirtualSessionManager vsm) throws IOException
commandArray - -
the array describing what command to execute.IOExceptionpublic boolean createCertificate(String cn, String c, String l, String o, String ou, String st, int validityDays, String exportFile, String exportPassword, boolean selfsign, boolean generateSingle) throws IOException, InvalidKeyException, SecurityException, SignatureException, NoSuchAlgorithmException, org.bouncycastle.crypto.DataLengthException, org.bouncycastle.crypto.CryptoException, KeyStoreException, NoSuchProviderException, CertificateException, InvalidKeySpecException
cn - Common Namec - Countryl - Localityo - Organisationou - Organisation Unitst - StatevalidityDays - default one yearexportFile - output fileexportPassword - password to secure file withselfsign - certificate self signed?IOExceptionInvalidKeyExceptionSecurityExceptionSignatureExceptionNoSuchAlgorithmExceptionorg.bouncycastle.crypto.DataLengthExceptionorg.bouncycastle.crypto.CryptoExceptionKeyStoreExceptionNoSuchProviderExceptionCertificateExceptionInvalidKeySpecExceptionpublic boolean createIdentity(Vector<String> certFiles, String keyFile, String p12File, String exportPassword, boolean usePKCS8) throws FileNotFoundException, IOException, NoSuchAlgorithmException, InvalidKeySpecException, UnrecoverableKeyException, CertificateException, KeyStoreException, InvalidKeyException, NoSuchProviderException, SignatureException, Exception
certFiles - an ordered list of certificate fileskeyFile - a PKCS8 or PKCS12 encoded file holding the identity keyp12File - the output fileusePKCS8 - the key file format to use (throws exception if mismatch with
actual file)FileNotFoundExceptionIOExceptionNoSuchAlgorithmExceptionInvalidKeySpecExceptionUnrecoverableKeyExceptionCertificateExceptionKeyStoreExceptionInvalidKeyExceptionNoSuchProviderExceptionSignatureExceptionExceptionpublic boolean createCertificationRequest(String cn, String c, String l, String o, String ou, String st, int validityDays, String requestFile, String keyFile, String exportPassword) throws IOException, InvalidKeyException, SecurityException, SignatureException, NoSuchAlgorithmException, org.bouncycastle.crypto.DataLengthException, org.bouncycastle.crypto.CryptoException, KeyStoreException, NoSuchProviderException, CertificateException, InvalidKeySpecException
cn - Common Namec - Countryl - Localityo - Organisationou - Organisation Unitst - StatevalidityDays - default one yearrequestFile - output PKCS10 request filekeyFile - output PKCS8 key fileexportPassword - password to secure file withIOExceptionInvalidKeyExceptionSecurityExceptionSignatureExceptionNoSuchAlgorithmExceptionorg.bouncycastle.crypto.DataLengthExceptionorg.bouncycastle.crypto.CryptoExceptionKeyStoreExceptionNoSuchProviderExceptionCertificateExceptionInvalidKeySpecExceptionpublic boolean signCertificationRequest(String requestFile, String keyFile, String certFile, String exportPassword) throws IOException, InvalidKeyException, SecurityException, SignatureException, NoSuchAlgorithmException, org.bouncycastle.crypto.DataLengthException, org.bouncycastle.crypto.CryptoException, KeyStoreException, NoSuchProviderException, CertificateException, InvalidKeySpecException
requestFile - input PKCS10 request filekeyFile - in PKCS8 key filecertfile - output X509 certificate fileexportPassword - password to secure file withIOExceptionInvalidKeyExceptionSecurityExceptionSignatureExceptionNoSuchAlgorithmExceptionorg.bouncycastle.crypto.DataLengthExceptionorg.bouncycastle.crypto.CryptoExceptionKeyStoreExceptionNoSuchProviderExceptionCertificateExceptionInvalidKeySpecExceptionPhantom® and NetPhantom® are registered trademarks of Nexum Technologies SARL.
© Copyright Nexum Technologies SARL, 2013. All rights reserved.