1 package org.bouncycastle.jcajce; 2 3 import java.io.OutputStream; 4 import java.security.KeyStore; 5 import java.security.KeyStore.LoadStoreParameter; 6 import java.security.KeyStore.ProtectionParameter; 7 8 /** 9 * LoadStoreParameter to allow for additional config with PKCS12 files. 10 * <p> 11 * Note: if you want a straight DER encoding of a PKCS#12 file you should use this. 12 * </p> 13 */ 14 public class PKCS12StoreParameter 15 implements LoadStoreParameter 16 { 17 private final OutputStream out; 18 private final ProtectionParameter protectionParameter; 19 private final boolean forDEREncoding; 20 PKCS12StoreParameter(OutputStream out, char[] password)21 public PKCS12StoreParameter(OutputStream out, char[] password) 22 { 23 this(out, password, false); 24 } 25 PKCS12StoreParameter(OutputStream out, ProtectionParameter protectionParameter)26 public PKCS12StoreParameter(OutputStream out, ProtectionParameter protectionParameter) 27 { 28 this(out, protectionParameter, false); 29 } 30 PKCS12StoreParameter(OutputStream out, char[] password, boolean forDEREncoding)31 public PKCS12StoreParameter(OutputStream out, char[] password, boolean forDEREncoding) 32 { 33 this(out, new KeyStore.PasswordProtection(password), forDEREncoding); 34 } 35 PKCS12StoreParameter(OutputStream out, ProtectionParameter protectionParameter, boolean forDEREncoding)36 public PKCS12StoreParameter(OutputStream out, ProtectionParameter protectionParameter, boolean forDEREncoding) 37 { 38 this.out = out; 39 this.protectionParameter = protectionParameter; 40 this.forDEREncoding = forDEREncoding; 41 } 42 getOutputStream()43 public OutputStream getOutputStream() 44 { 45 return out; 46 } 47 getProtectionParameter()48 public ProtectionParameter getProtectionParameter() 49 { 50 return protectionParameter; 51 } 52 53 /** 54 * Return whether the KeyStore used with this parameter should be DER encoded on saving. 55 * 56 * @return true for straight DER encoding, false otherwise, 57 */ isForDEREncoding()58 public boolean isForDEREncoding() 59 { 60 return forDEREncoding; 61 } 62 } 63