Class SAMLObjectEncrypter
java.lang.Object
se.swedenconnect.opensaml.xmlsec.encryption.support.SAMLObjectEncrypter
Utility class for encrypting an element for a SAML entity.
- Author:
- Martin Lindström (martin@idsec.se)
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Represents the peer when performing encryption. -
Constructor Summary
ConstructorDescriptionSets 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 TypeMethodDescriptionorg.opensaml.xmlsec.encryption.EncryptedData
encrypt
(org.opensaml.core.xml.XMLObject xmlObject, SAMLObjectEncrypter.Peer peer) Maps toencrypt(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 theAlgorithmRegistry
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.
-
Constructor Details
-
SAMLObjectEncrypter
public SAMLObjectEncrypter() throws net.shibboleth.shared.component.ComponentInitializationExceptionSets up the object encrypter without a metadata provider. This means that the peer metadata has to be supplied in calls toencrypt(XMLObject, Peer)
andencrypt(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 toencrypt(XMLObject, Peer, EncryptionConfiguration)
where the default encryption configuration is supplied.- Parameters:
xmlObject
- the object to encryptpeer
- 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 encryptpeer
- the peer to whom we encrypt forconfiguration
- 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 theAlgorithmRegistry
instance used when resolving algorithm URIs. Defaults to the registry resolved viaAlgorithmSupport.getGlobalAlgorithmRegistry()
.- Parameters:
algorithmRegistry
- the new algorithm registry instance
-