All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.bouncycastle.jcajce.BCLoadStoreParameter Maven / Gradle / Ivy

Go to download

The FIPS 140-3 Bouncy Castle Crypto package is a Java implementation of cryptographic algorithms certified to FIPS 140-3 level 1. This jar contains JCE provider and low-level API for the BC-FJA version 2.0.0, FIPS Certificate #4743. Please see certificate for certified platform details.

There is a newer version: 2.0.0
Show newest version
package org.bouncycastle.jcajce;

import java.io.InputStream;
import java.io.OutputStream;
import java.security.KeyStore;

public class BCLoadStoreParameter
    implements KeyStore.LoadStoreParameter
{
    private final InputStream in;
    private final OutputStream out;
    private final KeyStore.ProtectionParameter protectionParameter;

    /**
     * Base constructor for
     *
     * @param out
     * @param password
     */
    public BCLoadStoreParameter(OutputStream out, char[] password)
    {
        this(out, new KeyStore.PasswordProtection(password));
    }

    public BCLoadStoreParameter(InputStream in, char[] password)
    {
        this(in, new KeyStore.PasswordProtection(password));
    }

    public BCLoadStoreParameter(InputStream in, KeyStore.ProtectionParameter protectionParameter)
    {
        this(in, null, protectionParameter);
    }

    public BCLoadStoreParameter(OutputStream out, KeyStore.ProtectionParameter protectionParameter)
    {
        this(null, out, protectionParameter);
    }

    BCLoadStoreParameter(InputStream in, OutputStream out, KeyStore.ProtectionParameter protectionParameter)
    {
        this.in = in;
        this.out = out;
        this.protectionParameter = protectionParameter;
    }

    public KeyStore.ProtectionParameter getProtectionParameter()
    {
        return protectionParameter;
    }

    public OutputStream getOutputStream()
    {
        if (out == null)
        {
            throw new UnsupportedOperationException("parameter not configured for storage - no OutputStream");
        }

        return out;
    }

    public InputStream getInputStream()
    {
        if (out != null)
        {
            throw new UnsupportedOperationException("parameter configured for storage OutputStream present");
        }

        return in;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy