Class SAMLObjectSigner

java.lang.Object
se.swedenconnect.opensaml.xmlsec.signature.support.SAMLObjectSigner

public class SAMLObjectSigner extends Object
Utility methods for signatures.
Author:
Martin Lindström (martin@idsec.se)
  • Method Details

    • sign

      public static <T extends SignableSAMLObject> void sign(T object, Credential signingCredentials, SignatureSigningConfiguration... configs) throws SignatureException
      Signs the supplied SAML object using the supplied credentials and signature configuration(s).

      Note: If you have obtained the peer's prefered signature credentials, this configuration should be supplied first ...

      Type Parameters:
      T - the object type
      Parameters:
      object - object to sign
      signingCredentials - signature credentials
      configs - signature configuration
      Throws:
      SignatureException - for signature creation errors
    • sign

      public static <T extends SignableSAMLObject> void sign(T object, Credential signingCredentials, SignatureSigningConfiguration config, EntityDescriptor recipientMetadata) throws SignatureException
      Signs the supplied SAML object using the supplied credentials and signature configuration and also handles the peer signature requirements.

      This method corresponds to: SignatureSigningConfiguration peerConfig = getSignaturePreferences(recipientMetadata); followed by sign(object, signingCredentials, config, peerConfig);. If no peer config is found, this is not passed.

      Type Parameters:
      T - the object type
      Parameters:
      object - object to sign
      signingCredentials - signature credentials
      config - signature configuration
      recipientMetadata - recipient's metadata
      Throws:
      SignatureException - for signature errors
    • getSignaturePreferences

      public static SignatureSigningConfiguration getSignaturePreferences(EntityDescriptor metadata)
      A recipient of a signed message may specify the signature algorithm it prefers by including the <alg:SigningMethod> element in its metadata. This method locates these elements, and if present, creates a SignatureSigningConfiguration object that should be supplied to sign(SignableSAMLObject, Credential, SignatureSigningConfiguration...).
      Parameters:
      metadata - the recipient's metadata
      Returns:
      a SignatureSigningConfiguration element, or null if no preferred signing algorithms were specified