public class AMEncryptionProvider extends Object implements EncryptionProvider
AMEncryptionProvider
is a class for encrypting and
decrypting XML Documents which implements EncryptionProvider
.Modifier and Type | Field and Description |
---|---|
protected static Map |
keyMap
A static map contains provider id and symmetric keys as key value pairs.
|
protected KeyProvider |
keyProvider |
Constructor and Description |
---|
AMEncryptionProvider() |
Modifier and Type | Method and Description |
---|---|
Document |
decryptAndReplace(Document encryptedDoc,
Key privKey)
Decrypts an XML Document that contains encrypted data.
|
Document |
decryptAndReplace(Document encryptedDoc,
String certAlias)
Decrypts an XML Document that contains encrypted data.
|
Key |
decryptKey(Element encryptedKey,
String certAlias)
Decrypt the given encrypted key.
|
Document |
encryptAndReplace(Document doc,
Element element,
String secretKeyAlg,
int keyStrength,
Key kek,
int kekStrength,
String providerID)
Encrypts the given XML element in a given XML Context document.
|
Document |
encryptAndReplace(Document doc,
Element element,
String secretKeyAlg,
int keyStrength,
String certAlias,
int kekStrength)
Encrypts the given XML element in a given XML Context document.
|
Document |
encryptAndReplace(Document doc,
Element element,
String secretKeyAlg,
int keyStrength,
String certAlias,
int kekStrength,
String providerID)
Encrypts the given XML element in a given XML Context document.
|
Document |
encryptAndReplaceResourceID(Document doc,
Element element,
String secretKeyAlg,
int keyStrength,
Key kek,
int kekStrength,
String providerID)
Encrypts the given XML element in a given XML Context document.
|
Document |
encryptAndReplaceResourceID(Document doc,
Element element,
String secretKeyAlg,
int keyStrength,
String certAlias,
int kekStrength,
String providerID)
Encrypts the given ResourceID XML element in a given XML Context
document.
|
Document |
encryptAndReplaceWSSElements(Document doc,
Map elmMap,
String encDataEncAlg,
int encDataEncAlgStrength,
String certAlias,
int kekStrength,
String tokenType,
String providerID)
Encrypts the given WSS XML element in a given XML Context document.
|
protected SecretKey |
generateSecretKey(String algorithm,
int keyStrength)
Generates secret key for a given algorithm and key strength.
|
protected String |
getEncryptionAlgorithm(String algorithm,
int keyStrength)
Gets the equivalent XML encryption algorithm string for a given
algorithm and strength that is published by the provider.
|
protected PrivateKey |
getPrivateKey(org.apache.xml.security.keys.KeyInfo keyinfo)
Returns the private key for X509Certificate embedded in the KeyInfo
|
void |
initialize(KeyProvider keyprovider)
Initializes encryption provider.
|
protected KeyProvider keyProvider
protected static Map keyMap
public void initialize(KeyProvider keyprovider) throws EncryptionException
initialize
in interface EncryptionProvider
EncryptionException
public Document encryptAndReplace(Document doc, Element element, String secretKeyAlg, int keyStrength, String certAlias, int kekStrength) throws EncryptionException
encryptAndReplace
in interface EncryptionProvider
doc
- the context XML Document.element
- Element to be encrypted.secretKeyAlg
- Encryption Key Algorithm.keyStrength
- Encryption Key Strength.certAlias
- KeyEncryption Key cert alias.kekStrength
- Key Encryption Key Strength.EncryptionException
public Document encryptAndReplace(Document doc, Element element, String secretKeyAlg, int keyStrength, String certAlias, int kekStrength, String providerID) throws EncryptionException
encryptAndReplace
in interface EncryptionProvider
doc
- the context XML Document.element
- Element to be encrypted.secretKeyAlg
- Encryption Key Algorithm.keyStrength
- Encryption Key Strength.certAlias
- KeyEncryption Key cert alias.kekStrength
- Key Encryption Key Strength,providerID
- Provider ID.EncryptionException
public Document encryptAndReplaceResourceID(Document doc, Element element, String secretKeyAlg, int keyStrength, String certAlias, int kekStrength, String providerID) throws EncryptionException
encryptAndReplaceResourceID
in interface EncryptionProvider
doc
- the context XML Document.element
- Element to be encrypted.secretKeyAlg
- Encryption Key Algorithm.keyStrength
- Encryption Key Strength.certAlias
- KeyEncryption Key cert alias.kekStrength
- Key Encryption Key Strength,providerID
- Provider ID.EncryptionException
public Document encryptAndReplace(Document doc, Element element, String secretKeyAlg, int keyStrength, Key kek, int kekStrength, String providerID) throws EncryptionException
encryptAndReplace
in interface EncryptionProvider
doc
- the context XML Document.element
- Element to be encrypted.secretKeyAlg
- Encryption Key Algorithm.keyStrength
- Encryption Key Strength.kek
- Key Encryption Key.kekStrength
- Key Encryption Key Strength,providerID
- Provider IDEncryptionException
public Document encryptAndReplaceResourceID(Document doc, Element element, String secretKeyAlg, int keyStrength, Key kek, int kekStrength, String providerID) throws EncryptionException
encryptAndReplaceResourceID
in interface EncryptionProvider
doc
- the context XML Document.element
- Element to be encrypted.secretKeyAlg
- Encryption Key Algorithm.keyStrength
- Encryption Key Strength.kek
- Key Encryption Key.kekStrength
- Key Encryption Key Strength,providerID
- Provider IDEncryptionException
public Document encryptAndReplaceWSSElements(Document doc, Map elmMap, String encDataEncAlg, int encDataEncAlgStrength, String certAlias, int kekStrength, String tokenType, String providerID) throws EncryptionException
encryptAndReplaceWSSElements
in interface EncryptionProvider
doc
- the context XML Document.elmMap
- Map of (Element, wsu_id) to be encrypted.encDataEncAlg
- Encryption Key Algorithm.encDataEncAlgStrength
- Encryption Key Strength.certAlias
- Key Encryption Key cert alias.kekStrength
- Key Encryption Key Strength.tokenType
- Security token type.providerID
- Provider ID.EncryptionException
public Document decryptAndReplace(Document encryptedDoc, String certAlias) throws EncryptionException
decryptAndReplace
in interface EncryptionProvider
encryptedDoc
- XML Document with encrypted data.certAlias
- Private Key Certificate Alias.EncryptionException
public Document decryptAndReplace(Document encryptedDoc, Key privKey) throws EncryptionException
decryptAndReplace
in interface EncryptionProvider
encryptedDoc
- XML Document with encrypted data.privKey
- Key Encryption Key used for encryption.EncryptionException
protected String getEncryptionAlgorithm(String algorithm, int keyStrength) throws EncryptionException
EncryptionException
protected SecretKey generateSecretKey(String algorithm, int keyStrength) throws EncryptionException
EncryptionException
protected PrivateKey getPrivateKey(org.apache.xml.security.keys.KeyInfo keyinfo)
keyinfo
- KeyInfopublic Key decryptKey(Element encryptedKey, String certAlias)
decryptKey
in interface EncryptionProvider
encryptedKey
- the encrypted key elementcertAlias
- the private key aliasCopyright © 2010–2025 Open Identity Platform Community. All rights reserved.