Package com.helger.smpclient.httpclient
Class SMPHttpResponseHandlerSigned<T>
java.lang.Object
com.helger.smpclient.httpclient.AbstractSMPResponseHandler<T>
com.helger.smpclient.httpclient.SMPHttpResponseHandlerSigned<T>
- Type Parameters:
T- The type of object to be handled.
- All Implemented Interfaces:
org.apache.hc.core5.http.io.HttpClientResponseHandler<T>
This is the Apache HTTP client response handler to verify signed HTTP
response messages.
Note: this class is also licensed under Apache 2 license, as it was not part of the original implementation
- Author:
- Philip Helger
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final booleanstatic final boolean -
Constructor Summary
ConstructorsConstructorDescriptionSMPHttpResponseHandlerSigned(com.helger.jaxb.GenericJAXBMarshaller<T> aMarshaller, KeyStore aTrustStore) Constructor -
Method Summary
Modifier and TypeMethodDescriptionstatic com.helger.commons.state.ESuccesscheckSignature(Document aDocument, KeySelector aKeySelector, boolean bSecureValidation) final KeyStorehandleEntity(org.apache.hc.core5.http.HttpEntity aEntity) Handle the response entity and transform it into the actual response object.final booleanfinal booleanfinal SMPHttpResponseHandlerSigned<T> setSecureValidation(boolean bSecureValidation) Enable or disable the usage of secure XMLDsig validation.final SMPHttpResponseHandlerSigned<T> setTrustStore(KeyStore aTrustStore) Set the trust store to be used.final SMPHttpResponseHandlerSigned<T> setVerifySignature(boolean bVerifySignature) Check the certificate retrieved from a signed SMP response?Methods inherited from class com.helger.smpclient.httpclient.AbstractSMPResponseHandler
handleResponse
-
Field Details
-
DEFAULT_VERIFY_SIGNATURE
public static final boolean DEFAULT_VERIFY_SIGNATURE- See Also:
-
DEFAULT_SECURE_VALIDATION
public static final boolean DEFAULT_SECURE_VALIDATION- See Also:
-
-
Constructor Details
-
SMPHttpResponseHandlerSigned
public SMPHttpResponseHandlerSigned(@Nonnull com.helger.jaxb.GenericJAXBMarshaller<T> aMarshaller, @Nullable KeyStore aTrustStore) Constructor- Parameters:
aMarshaller- The JAXB marshaller to be used. May not benull.aTrustStore- The trust store to be used. May benull.- Since:
- 8.1.1
-
-
Method Details
-
isVerifySignature
public final boolean isVerifySignature()- Returns:
trueif SMP client response certificate checking is enabled,falseif it is disabled. By default this check is enabled (seeDEFAULT_VERIFY_SIGNATURE).- Since:
- 8.0.3
-
setVerifySignature
Check the certificate retrieved from a signed SMP response? This may be helpful for debugging and testing of SMP client connections!
Uses the trust store configured in the SMP client configuration.- Parameters:
bVerifySignature-trueto enable SMP response checking (on by default) orfalseto disable it.- Returns:
- this for chaining
- Since:
- 8.0.3
-
isSecureValidation
public final boolean isSecureValidation()- Returns:
trueif SMP client response certificate checking should use secure validation,falseif validation also allows deprecated algorithms. By default this check is enabled (seeDEFAULT_SECURE_VALIDATION).- Since:
- 9.0.5
-
setSecureValidation
@Nonnull public final SMPHttpResponseHandlerSigned<T> setSecureValidation(boolean bSecureValidation) Enable or disable the usage of secure XMLDsig validation. By default secure validation is enabled. Java 17 disables the usage of SHA-1 in XMLDsig by default, as documented in https://bugs.openjdk.org/browse/JDK-8261246. Currently the Peppol SMP still uses SHA-1 so you might want to disable this for the sake of sanity.- Parameters:
bSecureValidation-trueto enable SMP secure certificate validation (enabled by default) orfalseto disable it.- Returns:
- this for chaining
- Since:
- 9.0.5
-
getTrustStore
- Returns:
- The trust store to be used for verifying the signature. May be
nullif an invalid trust store is configured. - Since:
- 8.1.1
-
setTrustStore
Set the trust store to be used. If signature verification is enabled, a trust store MUST be preset.- Parameters:
aTrustStore- The trust store to be used. May benull.- Returns:
- this for chaining
- Since:
- 8.1.1
-
checkSignature
@Nonnull public static com.helger.commons.state.ESuccess checkSignature(@Nonnull Document aDocument, @Nonnull KeySelector aKeySelector, boolean bSecureValidation) throws MarshalException, XMLSignatureException -
handleEntity
@Nonnull public T handleEntity(@Nonnull org.apache.hc.core5.http.HttpEntity aEntity) throws SMPClientBadResponseException, IOException Description copied from class:AbstractSMPResponseHandlerHandle the response entity and transform it into the actual response object.- Specified by:
handleEntityin classAbstractSMPResponseHandler<T>- Parameters:
aEntity- The entity to handle. Nevernull.- Returns:
- the result. May be
null. - Throws:
SMPClientBadResponseException- if something goes wrongIOException- on IO error
-