Class SignatureSupport
- java.lang.Object
-
- org.opensaml.xmlsec.signature.support.SignatureSupport
-
public final class SignatureSupport extends Object
Helper methods for working with XML Signature.
-
-
Field Summary
Fields Modifier and Type Field Description private static Set<String>C14N_ALGORITHMSSet of known canonicalization algorithm URIs.
-
Constructor Summary
Constructors Modifier Constructor Description privateSignatureSupport()Constructor.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static voidaddOrReplaceReferenceCanonicalizationTransform(ContentReference cr, String uri)Process the indicated content reference and either add or replace its canonicalization Transform algorithm with the indicated algorithm.private static org.slf4j.LoggergetLogger()Get an SLF4J Logger.private static booleanisCanonicalizationAlgorithm(String uri)Evaluate whether the indicated algorithm URI is a canonicalization algorithm URI.static voidprepareSignatureParams(Signature signature, SignatureSigningParameters parameters)Prepare aSignaturewith necessary additional information prior to signing.private static voidprocessContentReferences(Signature signature, SignatureSigningParameters parameters)Prepare the content references.private static voidprocessKeyInfo(Signature signature, SignatureSigningParameters parameters)Prepare the content references.static voidsignObject(SignableXMLObject signable, SignatureSigningParameters parameters)Signs aSignableXMLObject.
-
-
-
Method Detail
-
getLogger
@Nonnull private static org.slf4j.Logger getLogger()
Get an SLF4J Logger.- Returns:
- a Logger instance
-
prepareSignatureParams
public static void prepareSignatureParams(@Nonnull Signature signature, @Nonnull SignatureSigningParameters parameters) throws org.opensaml.security.SecurityExceptionPrepare aSignaturewith necessary additional information prior to signing.NOTE:Since this operation modifies the specified Signature object, it should be called prior to marshalling the Signature object.
The following Signature values will be added:
- signing credential
- signature algorithm URI
- canonicalization algorithm URI
- reference digest method
- HMAC output length (if applicable and a value is configured)
- a
KeyInfoelement representing the signing credential
Existing (non-null) values of these parameters on the specified signature will NOT be overwritten, however.
All values are determined by the specified
SignatureSigningParameters. If no value for a required parameter is specified or included on the passed signature, aSecurityExceptionwill be thrown.- Parameters:
signature- the Signature to be updatedparameters- the signing parameters to use- Throws:
org.opensaml.security.SecurityException- thrown if a required parameter is not supplied in the parameters instance or available on the Signature instance
-
processKeyInfo
private static void processKeyInfo(Signature signature, SignatureSigningParameters parameters) throws org.opensaml.security.SecurityException
Prepare the content references.- Parameters:
signature- the Signature to be updatedparameters- the signing parameters to use- Throws:
org.opensaml.security.SecurityException- thrown if a required parameter is not supplied in the parameters instance or available on the Signature instance
-
processContentReferences
private static void processContentReferences(@Nonnull Signature signature, @Nonnull SignatureSigningParameters parameters) throws org.opensaml.security.SecurityExceptionPrepare the content references.- Parameters:
signature- the Signature to be updatedparameters- the signing parameters to use- Throws:
org.opensaml.security.SecurityException- thrown if a required parameter is not supplied in the parameters instance or available on the Signature instance
-
addOrReplaceReferenceCanonicalizationTransform
private static void addOrReplaceReferenceCanonicalizationTransform(@Nullable ContentReference cr, @Nullable String uri)Process the indicated content reference and either add or replace its canonicalization Transform algorithm with the indicated algorithm.- Parameters:
cr- the content reference to processuri- the canonicalization algorithm to either add or replace
-
isCanonicalizationAlgorithm
private static boolean isCanonicalizationAlgorithm(@Nullable String uri)Evaluate whether the indicated algorithm URI is a canonicalization algorithm URI.- Parameters:
uri- the algorithm URI to evaluate- Returns:
- true if is a canonicalization algorithm, false otherwise
-
signObject
public static void signObject(@Nonnull SignableXMLObject signable, @Nonnull SignatureSigningParameters parameters) throws org.opensaml.security.SecurityException, org.opensaml.core.xml.io.MarshallingException, SignatureExceptionSigns aSignableXMLObject.- Parameters:
signable- the signable XMLObject to signparameters- the signing parameters to use- Throws:
org.opensaml.security.SecurityException- if there is a problem preparing the signatureorg.opensaml.core.xml.io.MarshallingException- if there is a problem marshalling the XMLObjectSignatureException- if there is a problem with the signature operation
-
-