// 
// Decompiled by Procyon v0.6.0
// 

package org.bouncycastle.jcajce;

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

public class BCLoadStoreParameter implements KeyStore.LoadStoreParameter
{
    private final InputStream in;
    private final OutputStream out;
    private final KeyStore.ProtectionParameter protectionParameter;
    
    public BCLoadStoreParameter(final OutputStream outputStream, final char[] password) {
        this(outputStream, new KeyStore.PasswordProtection(password));
    }
    
    public BCLoadStoreParameter(final InputStream inputStream, final char[] password) {
        this(inputStream, new KeyStore.PasswordProtection(password));
    }
    
    public BCLoadStoreParameter(final InputStream inputStream, final KeyStore.ProtectionParameter protectionParameter) {
        this(inputStream, null, protectionParameter);
    }
    
    public BCLoadStoreParameter(final OutputStream outputStream, final KeyStore.ProtectionParameter protectionParameter) {
        this(null, outputStream, protectionParameter);
    }
    
    BCLoadStoreParameter(final InputStream in, final OutputStream out, final KeyStore.ProtectionParameter protectionParameter) {
        this.in = in;
        this.out = out;
        this.protectionParameter = protectionParameter;
    }
    
    @Override
    public KeyStore.ProtectionParameter getProtectionParameter() {
        return this.protectionParameter;
    }
    
    public OutputStream getOutputStream() {
        if (this.out == null) {
            throw new UnsupportedOperationException("parameter not configured for storage - no OutputStream");
        }
        return this.out;
    }
    
    public InputStream getInputStream() {
        if (this.out != null) {
            throw new UnsupportedOperationException("parameter configured for storage OutputStream present");
        }
        return this.in;
    }
}
