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 Details

  • Constructor Details

    • DefaultSecureTokenService

      public DefaultSecureTokenService()
  • Method Details

    • afterPropertiesSet

      public void afterPropertiesSet() throws org.apache.commons.codec.DecoderException, NoSuchAlgorithmException
      Specified by:
      afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
      Throws:
      org.apache.commons.codec.DecoderException
      NoSuchAlgorithmException
    • getRandom

      protected SecureRandom getRandom()
    • getSignatureKeyBytes

      protected byte[] getSignatureKeyBytes()
    • getEncryptionKeyBytes

      protected byte[] getEncryptionKeyBytes()
    • encryptData

      public String encryptData(SecureToken data)
      Description copied from interface: SecureTokenService
      Encrypt the SecureToken parameter to a String
      Specified by:
      encryptData in interface SecureTokenService
      Parameters:
      data - The unencrypted token data
      Returns:
      encrypted token
    • decryptData

      public SecureToken decryptData(String token)
      Description copied from interface: SecureTokenService
      Decrypt the token to a SecureToken.
      Specified by:
      decryptData in interface SecureTokenService
      Parameters:
      token - the encrypted token data
      Returns:
      decrypted SecureToken
    • decodeHexString

      protected byte[] decodeHexString(String text) throws org.apache.commons.codec.DecoderException
      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

      protected String convert(byte[] data)
    • buildSecretKey

      protected SecretKeySpec buildSecretKey(byte[] encryptionKeyBytes)
    • skipPadding

      protected void skipPadding(DataInputStream dataInputStream) throws IOException
      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

      protected String createChecksum(String data) throws IOException, NoSuchAlgorithmException
      Throws:
      IOException
      NoSuchAlgorithmException
    • getSignatureKeyHex

      protected String getSignatureKeyHex()
    • setSignatureKeyHex

      public void setSignatureKeyHex(String signatureKeyHex)
      Parameters:
      signatureKeyHex - the signatureKeyHex to set
    • getEncryptionKeyHex

      protected String getEncryptionKeyHex()
    • setEncryptionKeyHex

      public void setEncryptionKeyHex(String encryptionKeyHex)
      Parameters:
      encryptionKeyHex - the encryptionKeyHex to set