Package com.logicaldoc.sign
Class KeystoreUtil
java.lang.Object
com.logicaldoc.sign.KeystoreUtil
Helper class to handle java keystore and certificates
- Since:
- 7.7.2
- Author:
- Marco Meschieri - LogicalDOC
-
Constructor Summary
ConstructorDescriptionKeystoreUtil
(File keyStoreFile, String keyStorePassword, String organizationAlias) -
Method Summary
Modifier and TypeMethodDescriptionvoid
createNewKeystore
(String dn, int validity) void
exportOrganizationPrivateKeyAndCertificate
(File keyFile, File certFile) void
exportPrivateKeyAndCertificate
(String alias, String password, File keyFile, File certFile) Exports private key and public certificateextractCertExpiration
(String alias) extractCertName
(String alias) void
generateUserCertificate
(String userAlias, String userFullName, String userPassword, int validity) getPrivateKey
(String alias, String password) void
importCertificatePrivateKeyPair
(String alias, File certFile, File keyFile) void
removeAlias
(String alias)
-
Constructor Details
-
KeystoreUtil
-
-
Method Details
-
extractCertExpiration
public Date extractCertExpiration(String alias) throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException -
extractCertName
public String extractCertName(String alias) throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException -
removeAlias
- Throws:
IOException
-
createNewKeystore
- Throws:
IOException
-
generateUserCertificate
public void generateUserCertificate(String userAlias, String userFullName, String userPassword, int validity) throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException, InvalidNameException -
importCertificatePrivateKeyPair
public void importCertificatePrivateKeyPair(String alias, File certFile, File keyFile) throws IOException - Throws:
IOException
-
getPrivateKey
- Throws:
IOException
-
exportPrivateKeyAndCertificate
public void exportPrivateKeyAndCertificate(String alias, String password, File keyFile, File certFile) throws IOException Exports private key and public certificate- Parameters:
alias
- alias of the certificate in the keystorepassword
- the password to open the keystorekeyFile
- The key file to export(in PKCS12 format)certFile
- The optional public certificate file- Throws:
IOException
- cannot access the certificate inside the keystore
-
exportOrganizationPrivateKeyAndCertificate
public void exportOrganizationPrivateKeyAndCertificate(File keyFile, File certFile) throws IOException - Throws:
IOException
-
getKeyStoreFile
-
getKeyStorePassword
-