Search in sources :

Example 6 with ProtectionParameter

use of java.security.KeyStore.ProtectionParameter in project XobotOS by xamarin.

the class JDKPKCS12KeyStore method engineStore.

public void engineStore(LoadStoreParameter param) throws IOException, NoSuchAlgorithmException, CertificateException {
    if (param == null) {
        throw new IllegalArgumentException("'param' arg cannot be null");
    }
    if (!(param instanceof JDKPKCS12StoreParameter)) {
        throw new IllegalArgumentException("No support for 'param' of type " + param.getClass().getName());
    }
    JDKPKCS12StoreParameter bcParam = (JDKPKCS12StoreParameter) param;
    char[] password;
    ProtectionParameter protParam = param.getProtectionParameter();
    if (protParam == null) {
        password = null;
    } else if (protParam instanceof KeyStore.PasswordProtection) {
        password = ((KeyStore.PasswordProtection) protParam).getPassword();
    } else {
        throw new IllegalArgumentException("No support for protection parameter of type " + protParam.getClass().getName());
    }
    doStore(bcParam.getOutputStream(), password, bcParam.isUseDEREncoding());
}
Also used : KeyStore(java.security.KeyStore) BCKeyStore(org.bouncycastle.jce.interfaces.BCKeyStore) ProtectionParameter(java.security.KeyStore.ProtectionParameter)

Aggregations

KeyStore (java.security.KeyStore)6 ProtectionParameter (java.security.KeyStore.ProtectionParameter)6 Entry (java.security.KeyStore.Entry)2 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)2 BCKeyStore (org.bouncycastle.jce.interfaces.BCKeyStore)2 EncryptionException (com.evolveum.midpoint.prism.crypto.EncryptionException)1 Protector (com.evolveum.midpoint.prism.crypto.Protector)1 ProtectorImpl (com.evolveum.midpoint.prism.crypto.ProtectorImpl)1 File (java.io.File)1 IOException (java.io.IOException)1 LoadStoreParameter (java.security.KeyStore.LoadStoreParameter)1 PrivateKeyEntry (java.security.KeyStore.PrivateKeyEntry)1 SecretKeyEntry (java.security.KeyStore.SecretKeyEntry)1 TrustedCertificateEntry (java.security.KeyStore.TrustedCertificateEntry)1 KeyStoreException (java.security.KeyStoreException)1 PrivateKey (java.security.PrivateKey)1 Provider (java.security.Provider)1 UnrecoverableEntryException (java.security.UnrecoverableEntryException)1 CertificateException (java.security.cert.CertificateException)1 X509Certificate (java.security.cert.X509Certificate)1