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_ALGORITHMS
Set of known canonicalization algorithm URIs.
-
Constructor Summary
Constructors Modifier Constructor Description private
SignatureSupport()
Constructor.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static void
addOrReplaceReferenceCanonicalizationTransform(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.Logger
getLogger()
Get an SLF4J Logger.private static boolean
isCanonicalizationAlgorithm(String uri)
Evaluate whether the indicated algorithm URI is a canonicalization algorithm URI.static void
prepareSignatureParams(Signature signature, SignatureSigningParameters parameters)
Prepare aSignature
with necessary additional information prior to signing.private static void
processContentReferences(Signature signature, SignatureSigningParameters parameters)
Prepare the content references.private static void
processKeyInfo(Signature signature, SignatureSigningParameters parameters)
Prepare the content references.static void
signObject(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 SecurityException
Prepare aSignature
with 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
KeyInfo
element 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, aSecurityException
will be thrown.- Parameters:
signature
- the Signature to be updatedparameters
- the signing parameters to use- Throws:
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 SecurityException
Prepare the content references.- Parameters:
signature
- the Signature to be updatedparameters
- the signing parameters to use- Throws:
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 SecurityException
Prepare the content references.- Parameters:
signature
- the Signature to be updatedparameters
- the signing parameters to use- Throws:
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 SecurityException, MarshallingException, SignatureException
Signs aSignableXMLObject
.- Parameters:
signable
- the signable XMLObject to signparameters
- the signing parameters to use- Throws:
SecurityException
- if there is a problem preparing the signatureMarshallingException
- if there is a problem marshalling the XMLObjectSignatureException
- if there is a problem with the signature operation
-
-