@ThreadSafe public abstract class AbstractCertificateFactory extends AbstractDynamicComponent implements IKeyStoreCertificateFactory, IAliasedCertificateFactory
KeyStore object. The only method to be implemented is
IKeyStoreCertificateFactory.reinitKeyStore() which is responsible for setting the keystore. The
protected method setKeyStore(KeyStore) may be used to work
around the default behaviour and provide an arbitrary implementation.| Modifier and Type | Field and Description |
|---|---|
static String |
ATTR_PASSWORD |
static String |
ATTR_TYPE
Key store type; since 4.0.0
|
static com.helger.security.keystore.EKeyStoreType |
DEFAULT_KEY_STORE_TYPE |
m_aRWLock| Constructor and Description |
|---|
AbstractCertificateFactory() |
| 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) |
protected void |
debugLog(Supplier<String> aSupplier) |
boolean |
equals(Object o) |
String |
getAlias(Partnership aPartnership,
ECertificatePartnershipType ePartnershipType) |
X509Certificate |
getCertificate(IBaseMessage aMsg,
ECertificatePartnershipType ePartnershipType)
Get the certificate of the specified type for the partnership defined in
the provided message
|
X509Certificate |
getCertificate(String sAlias) |
com.helger.commons.collection.impl.ICommonsOrderedMap<String,X509Certificate> |
getCertificates() |
KeyStore |
getKeyStore() |
String |
getKeyStoreType() |
char[] |
getPassword() |
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 void |
initEmptyKeyStore()
This method is responsible to create a new empty keystore based on the
configured type.
|
protected X509Certificate |
internalGetCertificate(String sAlias,
ECertificatePartnershipType ePartnershipType) |
boolean |
isDebugLogEnabled() |
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 |
setDebugLogEnaled(boolean bDebugLog) |
protected void |
setKeyStore(KeyStore aKeyStore)
Internal method to set the
KeyStore used internally. |
void |
setKeyStoreType(com.helger.security.keystore.IKeyStoreType aKeyStoreType) |
void |
setKeyStoreType(String sKeyStoreType) |
void |
setPassword(String sPassword) |
attrs, getAttributeAsIntRequired, getAttributeAsStringRequired, getName, getSession, toStringclone, finalize, getClass, notify, notifyAll, wait, wait, waitreinitKeyStoregetCertificateOrNullattrs, getName, getSessionpublic static final com.helger.security.keystore.EKeyStoreType DEFAULT_KEY_STORE_TYPE
public static final String ATTR_TYPE
public static final String ATTR_PASSWORD
public final boolean isDebugLogEnabled()
public final void setDebugLogEnaled(boolean bDebugLog)
public final void setKeyStoreType(@Nullable com.helger.security.keystore.IKeyStoreType aKeyStoreType)
@Nullable public char[] getPassword()
@Nonnull @OverrideOnDemand protected KeyStore createNewKeyStore(@Nonnull com.helger.security.keystore.EKeyStoreType eKeyStoreType) throws GeneralSecurityException
GeneralSecurityExceptionpublic void initDynamicComponent(@Nonnull IAS2Session aSession, @Nullable com.helger.commons.collection.attr.IStringMap aOptions) throws AS2Exception
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!AS2Exception - If an error occurs while initializing the componentAS2InvalidParameterException - If a required parameter is null in the parameters MapIAS2Session@Nonnull public KeyStore getKeyStore()
getKeyStore in interface IKeyStoreCertificateFactoryprotected final void setKeyStore(@Nonnull KeyStore aKeyStore)
KeyStore used internally.aKeyStore - The key store to use. May not be null.protected void initEmptyKeyStore()
throws AS2Exception
AS2Exception - In case of errorgetKeyStoreType(),
createNewKeyStore(EKeyStoreType),
setKeyStore(KeyStore)@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 AS2Exception
AS2Exception@Nonnull protected X509Certificate internalGetCertificate(@Nullable String sAlias, @Nullable ECertificatePartnershipType ePartnershipType) throws AS2Exception
AS2Exception@Nonnull public X509Certificate getCertificate(@Nullable String sAlias) throws AS2Exception
getCertificate in interface IAliasedCertificateFactoryAS2Exception@Nonnull public X509Certificate getCertificate(@Nonnull IBaseMessage aMsg, @Nonnull ECertificatePartnershipType ePartnershipType) throws AS2Exception
ICertificateFactorygetCertificate in interface ICertificateFactoryaMsg - Message to get the partnership from. May not be null.ePartnershipType - Sender or receiver?null-AS2Exception - In case of errorAS2CertificateNotFoundException - If no certificate is present@Nonnull @ReturnsMutableCopy public com.helger.commons.collection.impl.ICommonsOrderedMap<String,X509Certificate> getCertificates() throws AS2Exception
getCertificates in interface IAliasedCertificateFactoryAS2Exception@OverrideOnDemand
protected void onChange()
throws AS2Exception
AS2Exception - In case saving fails.@Nonnull public PrivateKey getPrivateKey(@Nullable X509Certificate aCert) throws AS2Exception
getPrivateKey in interface ICertificateFactoryAS2Exceptionpublic void addCertificate(@Nonnull @Nonempty String sAlias, @Nonnull X509Certificate aCert, boolean bOverwrite) throws AS2Exception
addCertificate in interface IAliasedCertificateFactoryAS2Exceptionpublic void addPrivateKey(@Nonnull @Nonempty String sAlias, @Nonnull Key aKey, @Nonnull String sPassword) throws AS2Exception
addPrivateKey in interface IAliasedCertificateFactoryAS2Exceptionpublic void clearCertificates()
throws AS2Exception
clearCertificates in interface IAliasedCertificateFactoryAS2Exceptionpublic void removeCertificate(@Nonnull X509Certificate aCert) throws AS2Exception
removeCertificate in interface IAliasedCertificateFactoryAS2Exceptionpublic void removeCertificate(@Nullable String sAlias) throws AS2Exception
removeCertificate in interface IAliasedCertificateFactoryAS2Exceptionpublic void load(@Nonnull @WillClose InputStream aIS, @Nonnull char[] aPassword) throws AS2Exception
AS2Exceptionpublic void save(@Nonnull @WillClose OutputStream aOS, @Nonnull char[] aPassword) throws AS2Exception
AS2Exceptionpublic boolean equals(Object o)
equals in class AbstractDynamicComponentpublic int hashCode()
hashCode in class AbstractDynamicComponentCopyright © 2013–2022 Philip Helger. All rights reserved.