Package convex.core.crypto
Class PFXTools
java.lang.Object
convex.core.crypto.PFXTools
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Certificate
createSelfSignedCertificate(AKeyPair kpToSign)
static KeyStore
createStore(File keyFile, String passPhrase)
Creates a new PKCS12 Key store.static AKeyPair
getKeyPair(KeyStore ks, String alias, String passPhrase)
static KeyStore
Loads an existing PKCS12 Key store.static KeyStore
Adds a key to a key storestatic KeyStore
Saves a PKCS12 Key store to disk.
-
Field Details
-
KEYSTORE_TYPE
- See Also:
- Constant Field Values
-
CERTIFICATE_ALGORITHM
- See Also:
- Constant Field Values
-
-
Constructor Details
-
PFXTools
public PFXTools()
-
-
Method Details
-
createStore
public static KeyStore createStore(File keyFile, String passPhrase) throws KeyStoreException, IOException, NoSuchAlgorithmException, CertificateExceptionCreates a new PKCS12 Key store.- Parameters:
keyFile
- File to use for key storepassPhrase
- Passphrase for key store- Returns:
- New KeyStore instance
- Throws:
KeyStoreException
IOException
NoSuchAlgorithmException
CertificateException
-
loadStore
public static KeyStore loadStore(File keyFile, String passPhrase) throws IOException, GeneralSecurityExceptionLoads an existing PKCS12 Key store. Passphrase optional, may be blank or null.- Parameters:
keyFile
- File for existing KeyStorepassPhrase
- Passphrase for KeyStore. May be blank or null.- Returns:
- KeyStore instance
- Throws:
IOException
- If an IO error occursGeneralSecurityException
- If a security error occurs
-
saveStore
public static KeyStore saveStore(KeyStore ks, File keyFile, String passPhrase) throws GeneralSecurityException, IOExceptionSaves a PKCS12 Key store to disk. Passphrase optional, may be blank or null.- Parameters:
ks
- KeyStore to savekeyFile
- Target KeyStore filepassPhrase
- Passphrase for KeyStore. May be blank or null.- Returns:
- KeyStore instance
- Throws:
IOException
- If an IO error occurs accessing the KeystoreGeneralSecurityException
- if a security exception occurs
-
createSelfSignedCertificate
public static Certificate createSelfSignedCertificate(AKeyPair kpToSign) throws GeneralSecurityException- Parameters:
kpToSign
- Key Pair- Returns:
- New Certificate
- Throws:
GeneralSecurityException
- if a security exception occurs
-
saveKey
public static KeyStore saveKey(KeyStore ks, AKeyPair kp, String passPhrase) throws IOException, GeneralSecurityExceptionAdds a key to a key store- Parameters:
ks
- Keystorekp
- Key pairpassPhrase
- Passphrase for key- Returns:
- Updated KeyStore
- Throws:
IOException
- If an IO error occurs accessing the KeystoreGeneralSecurityException
- if a security exception occurs
-
getKeyPair
public static AKeyPair getKeyPair(KeyStore ks, String alias, String passPhrase) throws UnrecoverableKeyException, KeyStoreException, NoSuchAlgorithmException
-