Class DefaultSecureTokenService
java.lang.Object
de.hybris.platform.commerceservices.security.impl.DefaultSecureTokenService
- All Implemented Interfaces:
SecureTokenService,org.springframework.beans.factory.InitializingBean
public class DefaultSecureTokenService
extends Object
implements SecureTokenService, org.springframework.beans.factory.InitializingBean
Default implementation of
SecureTokenService-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidprotected booleanarrayEquals(byte[] array1, int offset1, byte[] array2, int offset2, int length) protected SecretKeySpecbuildSecretKey(byte[] encryptionKeyBytes) protected int[]protected Stringconvert(byte[] data) protected StringcreateChecksum(String data) protected byte[]decodeHexString(String text) protected byte[]decryptData(String token) Decrypt the token to a SecureToken.protected Stringencrypt(byte[] plainText, byte[] encryptionKeyBytes) encryptData(SecureToken data) Encrypt the SecureToken parameter to a Stringprotected byte[]generatePadding(int length) protected byte[]generateSignature(byte[] data, int offset, int length, byte[] signatureKeyBytes) protected byte[]protected Stringprotected SecureRandomprotected byte[]protected StringvoidsetEncryptionKeyHex(String encryptionKeyHex) voidsetSignatureKeyHex(String signatureKeyHex) protected voidskipPadding(DataInputStream dataInputStream) protected booleanvalidateSignature(byte[] dataBytes, int dataOffset, int dataLength, byte[] signatureBytes, int signatureOffset, byte[] signatureKeyBytes)
-
Field Details
-
ENCRYPT_KEY_LENGTH
protected static final int ENCRYPT_KEY_LENGTH- See Also:
-
MD5_LENGTH
protected static final int MD5_LENGTH- See Also:
-
AESIV_LENGTH
protected static final int AESIV_LENGTH- See Also:
-
ENCRYPTION_CIPHER
- See Also:
-
RANDOM_ALGORITHM
- See Also:
-
MESSAGEDIGEST_ALGORITHM
- See Also:
-
-
Constructor Details
-
DefaultSecureTokenService
public DefaultSecureTokenService()
-
-
Method Details
-
afterPropertiesSet
public void afterPropertiesSet() throws org.apache.commons.codec.DecoderException, NoSuchAlgorithmException- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean- Throws:
org.apache.commons.codec.DecoderExceptionNoSuchAlgorithmException
-
getRandom
-
getSignatureKeyBytes
protected byte[] getSignatureKeyBytes() -
getEncryptionKeyBytes
protected byte[] getEncryptionKeyBytes() -
encryptData
Description copied from interface:SecureTokenServiceEncrypt the SecureToken parameter to a String- Specified by:
encryptDatain interfaceSecureTokenService- Parameters:
data- The unencrypted token data- Returns:
- encrypted token
-
decryptData
Description copied from interface:SecureTokenServiceDecrypt the token to a SecureToken.- Specified by:
decryptDatain interfaceSecureTokenService- Parameters:
token- the encrypted token data- Returns:
- decrypted SecureToken
-
decodeHexString
- Throws:
org.apache.commons.codec.DecoderException
-
computePaddingLengths
protected int[] computePaddingLengths() -
generatePadding
protected byte[] generatePadding(int length) -
generateSignature
protected byte[] generateSignature(byte[] data, int offset, int length, byte[] signatureKeyBytes) throws NoSuchAlgorithmException - Throws:
NoSuchAlgorithmException
-
encrypt
protected String encrypt(byte[] plainText, byte[] encryptionKeyBytes) throws GeneralSecurityException - Throws:
GeneralSecurityException
-
convert
-
buildSecretKey
-
skipPadding
- Throws:
IOException
-
validateSignature
protected boolean validateSignature(byte[] dataBytes, int dataOffset, int dataLength, byte[] signatureBytes, int signatureOffset, byte[] signatureKeyBytes) throws NoSuchAlgorithmException - Throws:
NoSuchAlgorithmException
-
arrayEquals
protected boolean arrayEquals(byte[] array1, int offset1, byte[] array2, int offset2, int length) -
decrypt
protected byte[] decrypt(String encryptedText, byte[] encryptionKeyBytes) throws GeneralSecurityException - Throws:
GeneralSecurityException
-
createChecksum
- Throws:
IOExceptionNoSuchAlgorithmException
-
getSignatureKeyHex
-
setSignatureKeyHex
- Parameters:
signatureKeyHex- the signatureKeyHex to set
-
getEncryptionKeyHex
-
setEncryptionKeyHex
- Parameters:
encryptionKeyHex- the encryptionKeyHex to set
-