Search in sources :

Example 1 with PKCS12StoreParameter

use of org.bouncycastle.jcajce.provider.config.PKCS12StoreParameter in project robovm by robovm.

the class PKCS12KeyStoreSpi 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 PKCS12StoreParameter || param instanceof JDKPKCS12StoreParameter)) {
        throw new IllegalArgumentException("No support for 'param' of type " + param.getClass().getName());
    }
    PKCS12StoreParameter bcParam;
    if (param instanceof PKCS12StoreParameter) {
        bcParam = (PKCS12StoreParameter) param;
    } else {
        bcParam = new PKCS12StoreParameter(((JDKPKCS12StoreParameter) param).getOutputStream(), param.getProtectionParameter(), ((JDKPKCS12StoreParameter) param).isUseDEREncoding());
    }
    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.isForDEREncoding());
}
Also used : PKCS12StoreParameter(org.bouncycastle.jcajce.provider.config.PKCS12StoreParameter) JDKPKCS12StoreParameter(org.bouncycastle.jce.provider.JDKPKCS12StoreParameter) JDKPKCS12StoreParameter(org.bouncycastle.jce.provider.JDKPKCS12StoreParameter) KeyStore(java.security.KeyStore) BCKeyStore(org.bouncycastle.jce.interfaces.BCKeyStore) ProtectionParameter(java.security.KeyStore.ProtectionParameter)

Aggregations

KeyStore (java.security.KeyStore)1 ProtectionParameter (java.security.KeyStore.ProtectionParameter)1 PKCS12StoreParameter (org.bouncycastle.jcajce.provider.config.PKCS12StoreParameter)1 BCKeyStore (org.bouncycastle.jce.interfaces.BCKeyStore)1 JDKPKCS12StoreParameter (org.bouncycastle.jce.provider.JDKPKCS12StoreParameter)1