Class SAMLObjectEncrypter

java.lang.Object
se.swedenconnect.opensaml.xmlsec.encryption.support.SAMLObjectEncrypter

public class SAMLObjectEncrypter extends Object
Utility class for encrypting an element for a SAML entity.
Author:
Martin Lindström (martin@idsec.se)
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Represents the peer when performing encryption.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Sets up the object encrypter without a metadata provider.
    SAMLObjectEncrypter(org.opensaml.saml.metadata.resolver.MetadataResolver metadataResolver)
    Sets up the object encrypter with a metadata resolver from where we find the peer credentials.
  • Method Summary

    Modifier and Type
    Method
    Description
    org.opensaml.xmlsec.encryption.EncryptedData
    encrypt(org.opensaml.core.xml.XMLObject xmlObject, SAMLObjectEncrypter.Peer peer)
    Maps to encrypt(XMLObject, Peer, EncryptionConfiguration) where the default encryption configuration is supplied.
    org.opensaml.xmlsec.encryption.EncryptedData
    encrypt(org.opensaml.core.xml.XMLObject xmlObject, SAMLObjectEncrypter.Peer peer, org.opensaml.xmlsec.EncryptionConfiguration configuration)
    Encrypts the supplied XML object by locating the peer encryption credentials and using the supplied configuration.
    void
    setAlgorithmRegistry(org.opensaml.xmlsec.algorithm.AlgorithmRegistry algorithmRegistry)
    Sets the AlgorithmRegistry instance used when resolving algorithm URIs.
    void
    setDefaultEncryptionConfiguration(org.opensaml.xmlsec.EncryptionConfiguration encryptionConfiguration)
    Sets the default encryption configuration to use.
    void
    setEncrypter(org.opensaml.xmlsec.encryption.support.Encrypter encrypter)
    The encrypter to use.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • SAMLObjectEncrypter

      public SAMLObjectEncrypter() throws net.shibboleth.shared.component.ComponentInitializationException
      Sets up the object encrypter without a metadata provider. This means that the peer metadata has to be supplied in calls to encrypt(XMLObject, Peer) and encrypt(XMLObject, Peer, EncryptionConfiguration).
      Throws:
      net.shibboleth.shared.component.ComponentInitializationException - for init errors
    • SAMLObjectEncrypter

      public SAMLObjectEncrypter(org.opensaml.saml.metadata.resolver.MetadataResolver metadataResolver) throws net.shibboleth.shared.component.ComponentInitializationException
      Sets up the object encrypter with a metadata resolver from where we find the peer credentials.
      Parameters:
      metadataResolver - the metadata resolver
      Throws:
      net.shibboleth.shared.component.ComponentInitializationException - for init errors
  • Method Details

    • encrypt

      public org.opensaml.xmlsec.encryption.EncryptedData encrypt(org.opensaml.core.xml.XMLObject xmlObject, SAMLObjectEncrypter.Peer peer) throws org.opensaml.xmlsec.encryption.support.EncryptionException
      Maps to encrypt(XMLObject, Peer, EncryptionConfiguration) where the default encryption configuration is supplied.
      Parameters:
      xmlObject - the object to encrypt
      peer - the peer to whom we encrypt for
      Returns:
      an EncryptedData object
      Throws:
      org.opensaml.xmlsec.encryption.support.EncryptionException - for encryption errors
    • encrypt

      public org.opensaml.xmlsec.encryption.EncryptedData encrypt(org.opensaml.core.xml.XMLObject xmlObject, SAMLObjectEncrypter.Peer peer, org.opensaml.xmlsec.EncryptionConfiguration configuration) throws org.opensaml.xmlsec.encryption.support.EncryptionException
      Encrypts the supplied XML object by locating the peer encryption credentials and using the supplied configuration.
      Parameters:
      xmlObject - the object to encrypt
      peer - the peer to whom we encrypt for
      configuration - the encryption configuration
      Returns:
      an EncryptedData object
      Throws:
      org.opensaml.xmlsec.encryption.support.EncryptionException - for encryption errors
    • setEncrypter

      public void setEncrypter(org.opensaml.xmlsec.encryption.support.Encrypter encrypter)
      The encrypter to use.
      Parameters:
      encrypter - the encrypter
    • setDefaultEncryptionConfiguration

      public void setDefaultEncryptionConfiguration(org.opensaml.xmlsec.EncryptionConfiguration encryptionConfiguration)
      Sets the default encryption configuration to use.

      If not assigned, the system defaults will be used.

      Parameters:
      encryptionConfiguration - default encryption configuration
    • setAlgorithmRegistry

      public void setAlgorithmRegistry(org.opensaml.xmlsec.algorithm.AlgorithmRegistry algorithmRegistry)
      Sets the AlgorithmRegistry instance used when resolving algorithm URIs. Defaults to the registry resolved via AlgorithmSupport.getGlobalAlgorithmRegistry().
      Parameters:
      algorithmRegistry - the new algorithm registry instance