com.evolveum.midpoint.common.crypto
Class AESProtector

java.lang.Object
  extended by com.evolveum.midpoint.common.crypto.AESProtector
All Implemented Interfaces:
Protector

public class AESProtector
extends java.lang.Object
implements Protector

Class that manages encrypted string values. Java Cryptography Extension is needed because this class is using AES-256 for encrypting/decrypting xml data.

Author:
Radovan Semancik, lazyman

Constructor Summary
AESProtector()
           
 
Method Summary
 org.w3c.dom.Element decrypt(ProtectedStringType protectedString)
           
 java.lang.String decryptString(ProtectedStringType protectedString)
           
 ProtectedStringType encrypt(org.w3c.dom.Element plain)
           
 void encrypt(ProtectedStringType ps)
          Encrypts the ProtectedStringType "in place".
 ProtectedStringType encryptString(java.lang.String text)
           
 PrismContext getPrismContext()
           
 java.util.List<javax.net.ssl.TrustManager> getTrustManagers()
          Returns a list of trust managers that will be used to validate communicating party credentials.
 java.lang.String getXmlCipher()
           
 void init()
           
 boolean isEncrypted(ProtectedStringType ps)
          Returns true if protected string contains encrypted data that seems valid.
 void setEncryptionKeyAlias(java.lang.String encryptionKeyAlias)
           
 void setKeyStorePassword(java.lang.String keyStorePassword)
           
 void setKeyStorePath(java.lang.String keyStorePath)
           
 void setPrismContext(PrismContext prismContext)
           
 void setXmlCipher(java.lang.String xmlCipher)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AESProtector

public AESProtector()
Method Detail

init

public void init()
Throws:
SystemException - if jceks keystore is not available on getKeyStorePath()

getXmlCipher

public java.lang.String getXmlCipher()

setXmlCipher

public void setXmlCipher(java.lang.String xmlCipher)

getPrismContext

public PrismContext getPrismContext()

setPrismContext

public void setPrismContext(PrismContext prismContext)

setEncryptionKeyAlias

public void setEncryptionKeyAlias(java.lang.String encryptionKeyAlias)
Parameters:
encryptionKeyAlias - Alias of the encryption key SecretKey which is used for encryption
Throws:
java.lang.IllegalArgumentException - if encryption key digest is null or empty string

setKeyStorePassword

public void setKeyStorePassword(java.lang.String keyStorePassword)
Parameters:
keyStorePassword -
Throws:
java.lang.IllegalArgumentException - if keystore password is null string

setKeyStorePath

public void setKeyStorePath(java.lang.String keyStorePath)
Parameters:
keyStorePath -
Throws:
java.lang.IllegalArgumentException - if keystore path is null string

decryptString

public java.lang.String decryptString(ProtectedStringType protectedString)
                               throws EncryptionException
Specified by:
decryptString in interface Protector
Returns:
decrypted String from protectedString object
Throws:
EncryptionException - this is thrown probably in case JRE/JDK doesn't have JCE installed

decrypt

public org.w3c.dom.Element decrypt(ProtectedStringType protectedString)
                            throws EncryptionException
Specified by:
decrypt in interface Protector
Returns:
decrypted DOM Element
Throws:
EncryptionException - this is thrown probably in case JRE/JDK doesn't have JCE installed

encryptString

public ProtectedStringType encryptString(java.lang.String text)
                                  throws EncryptionException
Specified by:
encryptString in interface Protector
Returns:
ProtectedStringType with encrypted string inside it. If input argument is null or empty, method returns null.
Throws:
EncryptionException - this is thrown probably in case JRE/JDK doesn't have JCE installed

encrypt

public ProtectedStringType encrypt(org.w3c.dom.Element plain)
                            throws EncryptionException
Specified by:
encrypt in interface Protector
Returns:
ProtectedStringType with encrypted element inside it. If input argument is null, method returns null.
Throws:
EncryptionException - this is thrown probably in case JRE/JDK doesn't have JCE installed

encrypt

public void encrypt(ProtectedStringType ps)
             throws EncryptionException
Description copied from interface: Protector
Encrypts the ProtectedStringType "in place".

Specified by:
encrypt in interface Protector
Throws:
EncryptionException

isEncrypted

public boolean isEncrypted(ProtectedStringType ps)
Description copied from interface: Protector
Returns true if protected string contains encrypted data that seems valid.

Specified by:
isEncrypted in interface Protector

getTrustManagers

public java.util.List<javax.net.ssl.TrustManager> getTrustManagers()
Description copied from interface: Protector
Returns a list of trust managers that will be used to validate communicating party credentials. (e.g. used to validate remote connector connections).

Specified by:
getTrustManagers in interface Protector


Copyright © 2012 evolveum. All Rights Reserved.