Class EncryptionUtil
- java.lang.Object
-
- de.hybris.platform.util.encryption.EncryptionUtil
-
public class EncryptionUtil extends java.lang.ObjectHelper class for maintenance_reciper.jsp, maintenance_keygenerator.jsp (admin > maintenance > encryption key management) and de.hybris.platform.util.encryption.ValueEncryptor Rewrites the encrypted attribute with the configured default encyrption key (symmetric.key.file.default) see project.properties # attribute encryption # keyfile location: ${platformhome}/ext/core/resources/ ... symmetric.key.file.1=weak-symmetric.key.one symmetric.key.file.2=weak-symmetric.key.two symmetric.key.file.default=2
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringDEFAULT_KEYFILE_NAMEstatic java.lang.StringPROVIDER_CLASSstatic java.lang.StringSUBFOLDER
-
Constructor Summary
Constructors Constructor Description EncryptionUtil()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static java.lang.StringasHex(byte[] buf)Turns array of bytes into stringstatic booleancreateKey(java.lang.String filename, int keysize, java.lang.String cipherName, java.lang.String cipherAlgorithm, char[] password)static booleangenerateAESKey(java.lang.String keyfile, int keysize)static java.util.Map<ComposedType,java.util.List<AttributeDescriptor>>getAllTypesWhichHasEncyrptedAttributes()protected static ConfigIntfgetConfig()java.util.Map<java.lang.String,java.lang.String>getConfiguredEncryptionKey()Deprecated, for removal: This API element is subject to removal in a future version.since 1905 in favor ofgetConfiguredEncryptionKeys()static java.util.Map<java.lang.String,java.lang.String>getConfiguredEncryptionKeys()static java.lang.StringgetDefaultKeyFileId()static java.lang.StringgetDefaultKeyFileName()static java.lang.StringgetOldKeyFile()static javax.crypto.spec.PBEParameterSpecgetOldPBEParameterSpec()static byte[]getOldSalt()static java.util.Map<java.lang.String,javax.crypto.SecretKey>getSecretKeysFromConfig()static java.util.Map<java.lang.String,java.lang.Integer>getUsedKeys(java.lang.String type, java.lang.String qualifier)Returns used keysjava.util.Map<java.lang.String,java.lang.Integer>getUsedKeys(java.lang.String type, java.lang.String qualifier, JspContext jspc)Deprecated, for removal: This API element is subject to removal in a future version.since 1811static booleanisNewStyleKey(java.lang.String keyfile)static javax.crypto.SecretKeyloadDefaultKey(java.lang.String cipherName, java.lang.String cipherAlgorithm, char[] password)static javax.crypto.SecretKeyloadKey(java.io.InputStream fis, java.lang.String cipherName, java.lang.String cipherAlgorithm, char[] password)static javax.crypto.SecretKeyloadKey(java.lang.String keyID)static javax.crypto.SecretKeyloadKey(java.lang.String keyID, java.lang.String cipherName, java.lang.String cipherAlgorithm, char[] password)voidmigrate(java.lang.String type, java.lang.String attribute)static voidmigrate(java.lang.String type, java.lang.String qualifier, JspContext jspc)Performance (MacBook Pro/MySQL 5): Time: 1742901 m/s for '200100' steps-- 8 ms/step
-
-
-
Field Detail
-
SUBFOLDER
public static final java.lang.String SUBFOLDER
- See Also:
- Constant Field Values
-
PROVIDER_CLASS
public static final java.lang.String PROVIDER_CLASS
- See Also:
- Constant Field Values
-
DEFAULT_KEYFILE_NAME
public static final java.lang.String DEFAULT_KEYFILE_NAME
- See Also:
- Constant Field Values
-
-
Method Detail
-
getDefaultKeyFileName
public static java.lang.String getDefaultKeyFileName()
-
getDefaultKeyFileId
public static java.lang.String getDefaultKeyFileId()
-
getConfig
protected static ConfigIntf getConfig()
-
getOldKeyFile
public static java.lang.String getOldKeyFile()
-
getSecretKeysFromConfig
public static java.util.Map<java.lang.String,javax.crypto.SecretKey> getSecretKeysFromConfig()
-
getConfiguredEncryptionKeys
public static java.util.Map<java.lang.String,java.lang.String> getConfiguredEncryptionKeys()
-
getConfiguredEncryptionKey
@Deprecated(since="1905", forRemoval=true) public java.util.Map<java.lang.String,java.lang.String> getConfiguredEncryptionKey()Deprecated, for removal: This API element is subject to removal in a future version.since 1905 in favor ofgetConfiguredEncryptionKeys()
-
migrate
public void migrate(java.lang.String type, java.lang.String attribute)
-
migrate
public static void migrate(java.lang.String type, java.lang.String qualifier, JspContext jspc)Performance (MacBook Pro/MySQL 5): Time: 1742901 m/s for '200100' steps-- 8 ms/step- Parameters:
type- code of the ComposedTtypequalifier- name of the encrypted attributejspc- jspContext
-
getUsedKeys
public static java.util.Map<java.lang.String,java.lang.Integer> getUsedKeys(java.lang.String type, java.lang.String qualifier)Returns used keys- Parameters:
type- type to get keys forqualifier- attribute name in given type- Returns:
- keys
-
getUsedKeys
@Deprecated(since="1811", forRemoval=true) public java.util.Map<java.lang.String,java.lang.Integer> getUsedKeys(java.lang.String type, java.lang.String qualifier, JspContext jspc)Deprecated, for removal: This API element is subject to removal in a future version.since 1811Returns used keys- Parameters:
type- type to get keys forqualifier- attribute name in given typejspc- jspContext- Returns:
-
getAllTypesWhichHasEncyrptedAttributes
public static java.util.Map<ComposedType,java.util.List<AttributeDescriptor>> getAllTypesWhichHasEncyrptedAttributes()
-
generateAESKey
public static boolean generateAESKey(java.lang.String keyfile, int keysize) throws java.security.GeneralSecurityException, java.io.IOException- Throws:
java.security.GeneralSecurityExceptionjava.io.IOException
-
createKey
public static boolean createKey(java.lang.String filename, int keysize, java.lang.String cipherName, java.lang.String cipherAlgorithm, char[] password) throws java.security.GeneralSecurityException, java.io.IOException- Throws:
java.security.GeneralSecurityExceptionjava.io.IOException
-
loadKey
public static javax.crypto.SecretKey loadKey(java.lang.String keyID) throws java.security.GeneralSecurityException, java.io.IOException- Throws:
java.security.GeneralSecurityExceptionjava.io.IOException
-
loadDefaultKey
public static javax.crypto.SecretKey loadDefaultKey(java.lang.String cipherName, java.lang.String cipherAlgorithm, char[] password) throws java.security.InvalidKeyException, java.security.NoSuchAlgorithmException, java.security.spec.InvalidKeySpecException, javax.crypto.NoSuchPaddingException, javax.crypto.IllegalBlockSizeException, javax.crypto.BadPaddingException, java.security.InvalidAlgorithmParameterException, java.io.IOException- Throws:
java.security.InvalidKeyExceptionjava.security.NoSuchAlgorithmExceptionjava.security.spec.InvalidKeySpecExceptionjavax.crypto.NoSuchPaddingExceptionjavax.crypto.IllegalBlockSizeExceptionjavax.crypto.BadPaddingExceptionjava.security.InvalidAlgorithmParameterExceptionjava.io.IOException
-
loadKey
public static javax.crypto.SecretKey loadKey(java.lang.String keyID, java.lang.String cipherName, java.lang.String cipherAlgorithm, char[] password)
-
loadKey
public static javax.crypto.SecretKey loadKey(java.io.InputStream fis, java.lang.String cipherName, java.lang.String cipherAlgorithm, char[] password) throws java.io.IOException, java.security.NoSuchAlgorithmException, java.security.InvalidKeyException, java.security.spec.InvalidKeySpecException, javax.crypto.NoSuchPaddingException, javax.crypto.IllegalBlockSizeException, javax.crypto.BadPaddingException, java.security.InvalidAlgorithmParameterException- Throws:
java.io.IOExceptionjava.security.NoSuchAlgorithmExceptionjava.security.InvalidKeyExceptionjava.security.spec.InvalidKeySpecExceptionjavax.crypto.NoSuchPaddingExceptionjavax.crypto.IllegalBlockSizeExceptionjavax.crypto.BadPaddingExceptionjava.security.InvalidAlgorithmParameterException
-
getOldSalt
public static final byte[] getOldSalt()
-
getOldPBEParameterSpec
public static final javax.crypto.spec.PBEParameterSpec getOldPBEParameterSpec()
-
isNewStyleKey
public static boolean isNewStyleKey(java.lang.String keyfile)
-
asHex
public static java.lang.String asHex(byte[] buf)
Turns array of bytes into string- Parameters:
buf- Array of bytes to convert to hex string- Returns:
- Generated hex string
-
-