public class CertificateFactory extends AbstractCertificateFactory implements IAliasedCertificateFactory, IKeyStoreCertificateFactory, IStorableCertificateFactory
| Modifier and Type | Field and Description |
|---|---|
static String |
ATTR_FILENAME |
static String |
ATTR_PASSWORD |
static String |
ATTR_SAVE_CHANGES_TO_FILE |
static String |
ATTR_TYPE
Key store type; since 4.0.0
|
static com.helger.security.keystore.EKeyStoreType |
DEFAULT_KEY_STORE_TYPE |
m_aRWLockDEFAULT_SAVE_CHANGES_TO_FILE| Constructor and Description |
|---|
CertificateFactory() |
| Modifier and Type | Method and Description |
|---|---|
void |
addCertificate(String sAlias,
X509Certificate aCert,
boolean bOverwrite) |
void |
addPrivateKey(String sAlias,
Key aKey,
String sPassword) |
void |
clearCertificates() |
protected KeyStore |
createNewKeyStore(com.helger.security.keystore.EKeyStoreType eKeyStoreType) |
boolean |
equals(Object o) |
String |
getAlias(Partnership aPartnership,
ECertificatePartnershipType ePartnershipType) |
X509Certificate |
getCertificate(String sAlias) |
com.helger.commons.collection.impl.ICommonsOrderedMap<String,Certificate> |
getCertificates() |
String |
getFilename() |
KeyStore |
getKeyStore() |
char[] |
getPassword() |
PrivateKey |
getPrivateKey(IMessageMDN aMDN,
X509Certificate aCert) |
PrivateKey |
getPrivateKey(IMessage aMsg,
X509Certificate aCert) |
PrivateKey |
getPrivateKey(X509Certificate aCert) |
protected String |
getUnifiedAlias(String sAlias)
Overridable method to perform unifications on aliases, e.g. for lower
casing when using Oracle JDKs PKCS12 implementation.
|
int |
hashCode() |
void |
initDynamicComponent(IAS2Session aSession,
com.helger.commons.collection.attr.IStringMap aOptions)
After creating a Component object, this method should be called to set any
parameters used by the component.
|
protected X509Certificate |
internalGetCertificate(String sAlias,
ECertificatePartnershipType ePartnershipType) |
boolean |
isSaveChangesToFile() |
void |
load(InputStream aIS,
char[] aPassword) |
protected void |
onChange()
Custom callback method that is invoked if something changes in the key
store.
|
void |
removeCertificate(String sAlias) |
void |
removeCertificate(X509Certificate aCert) |
void |
save(OutputStream aOS,
char[] aPassword) |
void |
setFilename(String sFilename) |
void |
setPassword(char[] aPassword) |
void |
setSaveChangesToFile(boolean bSaveChangesToFile)
Change the behavior if all changes should trigger a saving to the original
file.
|
getCertificate, getCertificate, getCertificateOrNull, getCertificateOrNullattrs, getAttributeAsIntRequired, getAttributeAsStringRequired, getName, getSession, toStringclone, finalize, getClass, notify, notifyAll, wait, wait, waitload, load, save, savegetCertificate, getCertificate, getCertificateOrNull, getCertificateOrNullattrs, getName, getSessionpublic static final com.helger.security.keystore.EKeyStoreType DEFAULT_KEY_STORE_TYPE
public static final String ATTR_TYPE
public static final String ATTR_FILENAME
public static final String ATTR_PASSWORD
public static final String ATTR_SAVE_CHANGES_TO_FILE
@Nonnull @OverrideOnDemand protected KeyStore createNewKeyStore(@Nonnull com.helger.security.keystore.EKeyStoreType eKeyStoreType) throws Exception
Exceptionpublic void initDynamicComponent(@Nonnull IAS2Session aSession, @Nullable com.helger.commons.collection.attr.IStringMap aOptions) throws OpenAS2Exception
IDynamicComponentinitDynamicComponent in interface IDynamicComponentinitDynamicComponent in class AbstractDynamicComponentaSession - the component uses this object to access other componentsaOptions - configuration values for the component. All parameters will be
stored as attributes of this component. All attributes existing
before this method is called will be removed!OpenAS2Exception - If an error occurs while initializing the componentInvalidParameterException - If a required parameter is null in the parameters MapIAS2Session@Nullable @OverrideOnDemand protected String getUnifiedAlias(@Nullable String sAlias)
sAlias - Source alias. May be null.null if the source was null.@Nonnull public String getAlias(@Nonnull Partnership aPartnership, @Nonnull ECertificatePartnershipType ePartnershipType) throws OpenAS2Exception
getAlias in class AbstractCertificateFactoryOpenAS2Exception@Nonnull protected X509Certificate internalGetCertificate(@Nullable String sAlias, @Nullable ECertificatePartnershipType ePartnershipType) throws OpenAS2Exception
internalGetCertificate in class AbstractCertificateFactoryOpenAS2Exception@Nonnull public X509Certificate getCertificate(@Nullable String sAlias) throws OpenAS2Exception
getCertificate in interface IAliasedCertificateFactoryOpenAS2Exception@Nonnull @ReturnsMutableCopy public com.helger.commons.collection.impl.ICommonsOrderedMap<String,Certificate> getCertificates() throws OpenAS2Exception
getCertificates in interface IAliasedCertificateFactoryOpenAS2Exceptionpublic void setFilename(@Nullable String sFilename)
setFilename in interface IStorableCertificateFactory@Nonnull public String getFilename() throws InvalidParameterException
getFilename in interface IStorableCertificateFactoryInvalidParameterException@Nonnull public KeyStore getKeyStore()
getKeyStore in interface IKeyStoreCertificateFactorypublic void setPassword(@Nonnull char[] aPassword)
setPassword in interface IStorableCertificateFactory@Nonnull public char[] getPassword() throws InvalidParameterException
getPassword in interface IStorableCertificateFactoryInvalidParameterExceptionpublic void setSaveChangesToFile(boolean bSaveChangesToFile)
IStorableCertificateFactoryIStorableCertificateFactory.DEFAULT_SAVE_CHANGES_TO_FILE.setSaveChangesToFile in interface IStorableCertificateFactorybSaveChangesToFile - true to enable auto-saving, false to disable
it.public boolean isSaveChangesToFile()
isSaveChangesToFile in interface IStorableCertificateFactorytrue if changes to the key store should be persisted
back to the original file, false if not. The default
value is IStorableCertificateFactory.DEFAULT_SAVE_CHANGES_TO_FILE.@OverrideOnDemand
protected void onChange()
throws OpenAS2Exception
OpenAS2Exception - In case saving fails.isSaveChangesToFile(),
setSaveChangesToFile(boolean)@Nonnull public PrivateKey getPrivateKey(@Nullable X509Certificate aCert) throws OpenAS2Exception
OpenAS2Exception@Nonnull public PrivateKey getPrivateKey(@Nullable IMessage aMsg, @Nullable X509Certificate aCert) throws OpenAS2Exception
getPrivateKey in interface ICertificateFactoryOpenAS2Exception@Nonnull public PrivateKey getPrivateKey(@Nullable IMessageMDN aMDN, @Nullable X509Certificate aCert) throws OpenAS2Exception
getPrivateKey in interface ICertificateFactoryOpenAS2Exceptionpublic void addCertificate(@Nonnull @Nonempty String sAlias, @Nonnull X509Certificate aCert, boolean bOverwrite) throws OpenAS2Exception
addCertificate in interface IAliasedCertificateFactoryOpenAS2Exceptionpublic void addPrivateKey(@Nonnull @Nonempty String sAlias, @Nonnull Key aKey, @Nonnull String sPassword) throws OpenAS2Exception
addPrivateKey in interface IAliasedCertificateFactoryOpenAS2Exceptionpublic void clearCertificates()
throws OpenAS2Exception
clearCertificates in interface IAliasedCertificateFactoryOpenAS2Exceptionpublic void load(@Nonnull @WillClose InputStream aIS, @Nonnull char[] aPassword) throws OpenAS2Exception
load in interface IStorableCertificateFactoryOpenAS2Exceptionpublic void removeCertificate(@Nonnull X509Certificate aCert) throws OpenAS2Exception
removeCertificate in interface IAliasedCertificateFactoryOpenAS2Exceptionpublic void removeCertificate(@Nullable String sAlias) throws OpenAS2Exception
removeCertificate in interface IAliasedCertificateFactoryOpenAS2Exceptionpublic void save(@Nonnull @WillClose OutputStream aOS, @Nonnull char[] aPassword) throws OpenAS2Exception
save in interface IStorableCertificateFactoryOpenAS2Exceptionpublic boolean equals(Object o)
equals in class AbstractDynamicComponentpublic int hashCode()
hashCode in class AbstractDynamicComponentCopyright © 2013–2019 Philip Helger. All rights reserved.