Package com.helger.phase4.crypto
Class AS4CryptParams
java.lang.Object
com.helger.phase4.crypto.AS4CryptParams
- All Implemented Interfaces:
com.helger.commons.lang.ICloneable<AS4CryptParams>
@NotThreadSafe
public class AS4CryptParams
extends Object
implements com.helger.commons.lang.ICloneable<AS4CryptParams>
AS4 encrypt/decrypt parameters
- Since:
- 0.9.0
- Author:
- Philip Helger, Gregor Scholtysik
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final booleanstatic final ECryptoKeyEncryptionAlgorithmstatic final ECryptoKeyIdentifierTypestatic final Stringstatic final ICryptoSessionKeyProvider -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor using defaultsetKeyIdentifierType(ECryptoKeyIdentifierType),setKeyEncAlgorithm(ECryptoKeyEncryptionAlgorithm),setMGFAlgorithm(String)andsetDigestAlgorithm(String) -
Method Summary
Modifier and TypeMethodDescriptionvoidcloneTo(AS4CryptParams aTarget) static AS4CryptParamsfinal ECryptoAlgorithmCryptfinal StringgetAlias()final X509CertificategetClone()final Stringfinal ECryptoKeyIdentifierTypefinal Stringfinal ProviderNote: this is currently not used by WSS4Jfinal ProviderNote: this is currently not used by WSS4Jfinal IWSSecEncryptCustomizerfinal booleanhasAlias()final booleanfinal booleanbooleanisCryptEnabled(Consumer<String> aWarningConsumer) final booleanfinal AS4CryptParamssetAlgorithmCrypt(ECryptoAlgorithmCrypt eAlgorithmCrypt) A encryption algorithm can be set.final AS4CryptParamsfinal AS4CryptParamssetCertificate(X509Certificate aCert) Set the X509 certificate be used.final AS4CryptParamssetDigestAlgorithm(String sDigestAlgorithm) Set the digest algorithm to use with the RSA-OAEP key transport algorithm.final AS4CryptParamssetEncryptSymmetricSessionKey(boolean b) Enable or disable the inclusion of the symmetric session key into the transmission or not.final AS4CryptParamssetFromPMode(PModeLegSecurity aSecurity) This method callssetAlgorithmCrypt(ECryptoAlgorithmCrypt)based on the PMode parameters.final AS4CryptParamssetKeyEncAlgorithm(ECryptoKeyEncryptionAlgorithm eKeyEncAlgorithm) final AS4CryptParamssetKeyIdentifierType(ECryptoKeyIdentifierType eKeyIdentifierType) Set the key identifier type to use.final AS4CryptParamssetMGFAlgorithm(String sMGFAlgorithm) Set the mask generation function (MGF) algorithm to use with the RSA-OAEP key transport algorithm.final AS4CryptParamssetSecurityProvider(Provider aSecurityProvider) Set the security provider to be used for encryption and decryption.final AS4CryptParamssetSecurityProviderDecrypt(Provider aSecurityProviderDecrypt) Set the security provider to be used for decryption (not for encryption).
Note: this is currently not used by WSS4Jfinal AS4CryptParamssetSecurityProviderEncrypt(Provider aSecurityProviderEncrypt) Set the security provider to be used for encryption (not for decryption).
Note: this is currently not used by WSS4Jfinal AS4CryptParamssetSessionKeyProvider(ICryptoSessionKeyProvider aSessionKeyProvider) Set the session key provider to be used for encryption.final AS4CryptParamstoString()
-
Field Details
-
DEFAULT_KEY_IDENTIFIER_TYPE
-
DEFAULT_KEY_ENCRYPTION_ALGORITHM
-
DEFAULT_MGF_ALGORITHM
- See Also:
-
DEFAULT_DIGEST_ALGORITHM
- See Also:
-
DEFAULT_SESSION_KEY_PROVIDER
-
DEFAULT_ENCRYPT_SYMMETRIC_SESSION_KEY
public static final boolean DEFAULT_ENCRYPT_SYMMETRIC_SESSION_KEY- See Also:
-
-
Constructor Details
-
AS4CryptParams
public AS4CryptParams()Default constructor using defaultsetKeyIdentifierType(ECryptoKeyIdentifierType),setKeyEncAlgorithm(ECryptoKeyEncryptionAlgorithm),setMGFAlgorithm(String)andsetDigestAlgorithm(String)
-
-
Method Details
-
isCryptEnabled
-
getKeyIdentifierType
- Returns:
- The key identifier type. May not be
null. - Since:
- 0.11.0
-
setKeyIdentifierType
@Nonnull public final AS4CryptParams setKeyIdentifierType(@Nonnull ECryptoKeyIdentifierType eKeyIdentifierType) Set the key identifier type to use. That defines how the information about the signing certificate is transmitted.- Parameters:
eKeyIdentifierType- The key identifier type to use. May not benull.- Returns:
- this for chaining
- Since:
- 0.11.0
-
getAlgorithmCrypt
- Returns:
- The encryption algorithm to use. May be
null.
-
setAlgorithmCrypt
@Nonnull public final AS4CryptParams setAlgorithmCrypt(@Nullable ECryptoAlgorithmCrypt eAlgorithmCrypt) A encryption algorithm can be set.
MANDATORY if you want to use encryption.- Parameters:
eAlgorithmCrypt- the encryption algorithm that should be set- Returns:
- this for chaining
-
getKeyEncAlgorithm
-
setKeyEncAlgorithm
@Nonnull public final AS4CryptParams setKeyEncAlgorithm(@Nonnull ECryptoKeyEncryptionAlgorithm eKeyEncAlgorithm) -
getMGFAlgorithm
- Returns:
- The mask generation function (MGF) algorithm to use with the
RSA-OAEP key transport algorithm. The default is
DEFAULT_MGF_ALGORITHM
-
setMGFAlgorithm
Set the mask generation function (MGF) algorithm to use with the RSA-OAEP key transport algorithm.- Parameters:
sMGFAlgorithm- The MFG algorithm to use. May neither benullnor empty.- Returns:
- this for chaining
-
getDigestAlgorithm
- Returns:
- The digest algorithm to use with the RSA-OAEP key transport
algorithm. The default is
DEFAULT_DIGEST_ALGORITHM
-
setDigestAlgorithm
Set the digest algorithm to use with the RSA-OAEP key transport algorithm.- Parameters:
sDigestAlgorithm- The digest algorithm to use. May neither benullnor empty.- Returns:
- this for chaining
-
getCertificate
- Returns:
- The currently set X509 certificate. May be
null.
-
hasCertificate
public final boolean hasCertificate()- Returns:
trueif an X509 certificate is present,falseif not.
-
setCertificate
Set the X509 certificate be used. The provided certificate is not checked for validity. If it is expired only a warning is logged but the certificate will still be used.- Parameters:
aCert- The certificate to be used. May benull.- Returns:
- this for chaining
-
getAlias
-
hasAlias
public final boolean hasAlias() -
setAlias
-
getSessionKeyProvider
- Returns:
- The session key provider to be used. Never
null. - Since:
- 2.1.2
-
setSessionKeyProvider
@Nonnull public final AS4CryptParams setSessionKeyProvider(@Nonnull ICryptoSessionKeyProvider aSessionKeyProvider) Set the session key provider to be used for encryption. The provided provider must never return anullkey.- Parameters:
aSessionKeyProvider- The session key provider to be used. May not benull.- Returns:
- this for chaining
- Since:
- 2.1.2
-
getSecurityProviderEncrypt
Note: this is currently not used by WSS4J- Returns:
- The security provider to be used for encryption (not for
decryption). May be
null. - Since:
- 2.4.0
-
setSecurityProviderEncrypt
@Nonnull public final AS4CryptParams setSecurityProviderEncrypt(@Nullable Provider aSecurityProviderEncrypt) Set the security provider to be used for encryption (not for decryption).
Note: this is currently not used by WSS4J- Parameters:
aSecurityProviderEncrypt- The security provider to be used. May benull.- Returns:
- this for chaining
- Since:
- 2.4.0
-
getSecurityProviderDecrypt
Note: this is currently not used by WSS4J- Returns:
- The security provider to be used for decryption (not for
encryption). May be
null. - Since:
- 2.4.0
-
setSecurityProviderDecrypt
@Nonnull public final AS4CryptParams setSecurityProviderDecrypt(@Nullable Provider aSecurityProviderDecrypt) Set the security provider to be used for decryption (not for encryption).
Note: this is currently not used by WSS4J- Parameters:
aSecurityProviderDecrypt- The security provider to be used. May benull.- Returns:
- this for chaining
- Since:
- 2.4.0
-
setSecurityProvider
Set the security provider to be used for encryption and decryption.- Parameters:
aSecurityProvider- The security provider to be used. May benull.- Returns:
- this for chaining
- Since:
- 2.1.4
-
isEncryptSymmetricSessionKey
public final boolean isEncryptSymmetricSessionKey()- Returns:
trueif the symmetric session key should be part of the transmission orfalseif not. Default isDEFAULT_ENCRYPT_SYMMETRIC_SESSION_KEY- Since:
- 2.1.4
-
setEncryptSymmetricSessionKey
Enable or disable the inclusion of the symmetric session key into the transmission or not.- Parameters:
b-trueto enabled,falseto disable it.- Returns:
- this for chaining
- Since:
- 2.1.4
-
getWSSecEncryptCustomizer
-
hasWSSecEncryptCustomizer
public final boolean hasWSSecEncryptCustomizer() -
setWSSecEncryptCustomizer
-
setFromPMode
This method callssetAlgorithmCrypt(ECryptoAlgorithmCrypt)based on the PMode parameters. If the PMode parameter isnullthe value will be set tonull.- Parameters:
aSecurity- The PMode security stuff to use. May benull.- Returns:
- this for chaining
- See Also:
-
cloneTo
-
getClone
- Specified by:
getClonein interfacecom.helger.commons.lang.ICloneable<AS4CryptParams>
-
toString
-
createDefault
- Returns:
- A non-
nulldefault instance. - See Also:
-