Package com.helger.phase4.crypto
Class AS4CryptParams
java.lang.Object
com.helger.phase4.crypto.AS4CryptParams
- All Implemented Interfaces:
com.helger.base.clone.ICloneable<AS4CryptParams>
@NotThreadSafe
public class AS4CryptParams
extends Object
implements com.helger.base.clone.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(@NonNull AS4CryptParams aTarget) static @NonNull AS4CryptParamsfinal @Nullable ECryptoAlgorithmCryptfinal @Nullable StringgetAlias()final @Nullable X509Certificate@NonNull AS4CryptParamsgetClone()final @NonNull @Nonempty Stringfinal @Nullable ECryptoKeyAgreementMethodfinal @Nullable ECryptoKeyDerivationMethodfinal @NonNull ECryptoKeyEncryptionAlgorithmfinal @NonNull ECryptoKeyIdentifierTypefinal @Nullable ECryptoKeyWrapAlgorithmfinal @NonNull @Nonempty Stringfinal @Nullable ProviderNote: this is currently not used by WSS4Jfinal @Nullable ProviderNote: this is currently not used by WSS4Jfinal @NonNull ICryptoSessionKeyProviderfinal @Nullable IWSSecEncryptCustomizerfinal booleanhasAlias()final booleanfinal booleanfinal booleanbooleanisCryptEnabled(@Nullable Consumer<String> aWarningConsumer) final booleanfinal @NonNull AS4CryptParamssetAlgorithmCrypt(@Nullable ECryptoAlgorithmCrypt eAlgorithmCrypt) A encryption algorithm can be set.final @NonNull AS4CryptParamsfinal @NonNull AS4CryptParamssetCertificate(@Nullable X509Certificate aCert) Set the X509 certificate be used.final @NonNull AS4CryptParamssetDigestAlgorithm(@NonNull @Nonempty String sDigestAlgorithm) Set the digest algorithm to use with the RSA-OAEP key transport algorithm.final @NonNull AS4CryptParamsConvenience method to set all parameters required for eDelivery AS4 2.0 ECDSA/ECDH-ES key agreement: ECDH-ES key agreement, HKDF key derivation, AES-128 key wrap.final @NonNull AS4CryptParamsConvenience method to set all parameters required for eDelivery AS4 2.0 EdDSA/X25519 key agreement: X25519 key agreement, HKDF key derivation, AES-128 key wrap.final @NonNull AS4CryptParamssetEncryptSymmetricSessionKey(boolean b) Enable or disable the inclusion of the symmetric session key into the transmission or not.final @NonNull AS4CryptParamssetFromPMode(@Nullable PModeLegSecurity aSecurity) This method callssetAlgorithmCrypt(ECryptoAlgorithmCrypt)based on the PMode parameters.final @NonNull AS4CryptParamssetKeyAgreementMethod(@Nullable ECryptoKeyAgreementMethod eKeyAgreementMethod) Set the key agreement method to use.final @NonNull AS4CryptParamssetKeyDerivationMethod(@Nullable ECryptoKeyDerivationMethod eKeyDerivationMethod) Set the key derivation function to use with key agreement (e.g.final @NonNull AS4CryptParamssetKeyEncAlgorithm(@NonNull ECryptoKeyEncryptionAlgorithm eKeyEncAlgorithm) final @NonNull AS4CryptParamssetKeyIdentifierType(@NonNull ECryptoKeyIdentifierType eKeyIdentifierType) Set the key identifier type to use.final @NonNull AS4CryptParamssetKeyWrapAlgorithm(@Nullable ECryptoKeyWrapAlgorithm eKeyWrapAlgorithm) Set the key wrap algorithm to use with key agreement (e.g.final @NonNull AS4CryptParamssetMGFAlgorithm(@NonNull @Nonempty String sMGFAlgorithm) Set the mask generation function (MGF) algorithm to use with the RSA-OAEP key transport algorithm.final @NonNull AS4CryptParamssetSecurityProvider(@Nullable Provider aSecurityProvider) Set the security provider to be used for encryption and decryption.final @NonNull AS4CryptParamssetSecurityProviderDecrypt(@Nullable Provider aSecurityProviderDecrypt) Set the security provider to be used for decryption (not for encryption).
Note: this is currently not used by WSS4Jfinal @NonNull AS4CryptParamssetSecurityProviderEncrypt(@Nullable Provider aSecurityProviderEncrypt) Set the security provider to be used for encryption (not for decryption).
Note: this is currently not used by WSS4Jfinal @NonNull AS4CryptParamssetSessionKeyProvider(@NonNull ICryptoSessionKeyProvider aSessionKeyProvider) Set the session key provider to be used for encryption.final @NonNull AS4CryptParamssetWSSecEncryptCustomizer(@Nullable IWSSecEncryptCustomizer a) toString()
-
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
public final @NonNull 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
public final @NonNull 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
public final @NonNull 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
public final @NonNull AS4CryptParams setMGFAlgorithm(@Nonempty @NonNull @Nonempty String sMGFAlgorithm) 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
public final @NonNull AS4CryptParams setDigestAlgorithm(@Nonempty @NonNull @Nonempty String sDigestAlgorithm) 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
-
getKeyAgreementMethod
- Returns:
- The key agreement method to use. May be
null, in which case key transport (e.g. RSA-OAEP) is used instead of key agreement. - Since:
- 4.4.0
-
hasKeyAgreementMethod
public final boolean hasKeyAgreementMethod()- Returns:
trueif a key agreement method is set,falseif not.- Since:
- 4.4.0
-
setKeyAgreementMethod
public final @NonNull AS4CryptParams setKeyAgreementMethod(@Nullable ECryptoKeyAgreementMethod eKeyAgreementMethod) Set the key agreement method to use. When set, the encryption will use key agreement (e.g. ECDH-ES, X25519) instead of key transport (e.g. RSA-OAEP). If set tonull, key transport is used.- Parameters:
eKeyAgreementMethod- The key agreement method. May benull.- Returns:
- this for chaining
- Since:
- 4.4.0
-
getKeyDerivationMethod
- Returns:
- The key derivation function to use with key agreement. May be
null. - Since:
- 4.4.0
-
setKeyDerivationMethod
public final @NonNull AS4CryptParams setKeyDerivationMethod(@Nullable ECryptoKeyDerivationMethod eKeyDerivationMethod) Set the key derivation function to use with key agreement (e.g. HKDF, ConcatKDF).- Parameters:
eKeyDerivationMethod- The key derivation method. May benull.- Returns:
- this for chaining
- Since:
- 4.4.0
-
getKeyWrapAlgorithm
- Returns:
- The key wrap algorithm to use with key agreement. May be
null. - Since:
- 4.4.0
-
setKeyWrapAlgorithm
public final @NonNull AS4CryptParams setKeyWrapAlgorithm(@Nullable ECryptoKeyWrapAlgorithm eKeyWrapAlgorithm) Set the key wrap algorithm to use with key agreement (e.g. AES-128 KeyWrap).- Parameters:
eKeyWrapAlgorithm- The key wrap algorithm. May benull.- Returns:
- this for chaining
- Since:
- 4.4.0
-
setEDelivery2KeyAgreementX25519
Convenience method to set all parameters required for eDelivery AS4 2.0 EdDSA/X25519 key agreement: X25519 key agreement, HKDF key derivation, AES-128 key wrap.- Returns:
- this for chaining
- Since:
- 4.4.0
-
setEDelivery2KeyAgreementECDHES
Convenience method to set all parameters required for eDelivery AS4 2.0 ECDSA/ECDH-ES key agreement: ECDH-ES key agreement, HKDF key derivation, AES-128 key wrap.- Returns:
- this for chaining
- Since:
- 4.4.0
-
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
public final @NonNull 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
public final @NonNull 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
public final @NonNull 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.base.clone.ICloneable<AS4CryptParams>
-
toString
-
createDefault
- Returns:
- A non-
nulldefault instance. - See Also:
-