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
(MetadataResolver metadataResolver) Sets up the object encrypter with a metadata resolver from where we find the peer credentials. -
Method Summary
Modifier and TypeMethodDescriptionencrypt
(XMLObject xmlObject, SAMLObjectEncrypter.Peer peer) Maps toencrypt(XMLObject, Peer, EncryptionConfiguration)
where the default encryption configuration is supplied.encrypt
(XMLObject xmlObject, SAMLObjectEncrypter.Peer peer, EncryptionConfiguration configuration) Encrypts the supplied XML object by locating the peer encryption credentials and using the supplied configuration.void
setAlgorithmRegistry
(AlgorithmRegistry algorithmRegistry) Sets theAlgorithmRegistry
instance used when resolving algorithm URIs.void
setDefaultEncryptionConfiguration
(EncryptionConfiguration encryptionConfiguration) Sets the default encryption configuration to use.void
setEncrypter
(Encrypter encrypter) The encrypter to use.
-
Constructor Details
-
SAMLObjectEncrypter
Sets 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:
ComponentInitializationException
- for init errors
-
SAMLObjectEncrypter
public SAMLObjectEncrypter(MetadataResolver metadataResolver) throws ComponentInitializationException Sets up the object encrypter with a metadata resolver from where we find the peer credentials.- Parameters:
metadataResolver
- the metadata resolver- Throws:
ComponentInitializationException
- for init errors
-
-
Method Details
-
encrypt
public EncryptedData encrypt(XMLObject xmlObject, SAMLObjectEncrypter.Peer peer) throws 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:
EncryptionException
- for encryption errors
-
encrypt
public EncryptedData encrypt(XMLObject xmlObject, SAMLObjectEncrypter.Peer peer, EncryptionConfiguration configuration) throws 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:
EncryptionException
- for encryption errors
-
setEncrypter
The encrypter to use.If not assigned, an instance of
Encrypter
is used.- Parameters:
encrypter
- the encrypter
-
setDefaultEncryptionConfiguration
Sets the default encryption configuration to use.If not assigned, the system defaults will be used.
- Parameters:
encryptionConfiguration
- default encryption configuration
-
setAlgorithmRegistry
Sets theAlgorithmRegistry
instance used when resolving algorithm URIs. Defaults to the registry resolved viaAlgorithmSupport.getGlobalAlgorithmRegistry()
.- Parameters:
algorithmRegistry
- the new algorithm registry instance
-