Package com.almis.awe.service
Class EncodeService
java.lang.Object
com.almis.awe.config.ServiceConfig
com.almis.awe.service.EncodeService
- All Implemented Interfaces:
org.springframework.beans.factory.Aware
,org.springframework.context.ApplicationContextAware
Encode Service Class
Encode Utilities for awe
- Author:
- Pablo GARCIA - 17/MAR/2011
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
Static class to store hashing algorithms to make the call to these algorithms more understandable. -
Constructor Summary
ConstructorDescriptionEncodeService
(BaseConfigProperties baseConfigProperties, SecurityConfigProperties securityConfigProperties) Hide the constructor -
Method Summary
Modifier and TypeMethodDescriptionbase64Decode
(byte[] text) Base64 decode byte arraybase64Decode
(String text) Base64 decode stringbyte[]
Base64 decode stringstatic String
base64Encode
(byte[] text) Base64 encode byte arraystatic String
base64Encode
(String text) Base64 encode stringDecodes a text in HexdecodeSymmetric
(String text) Decodes a text in DES (Symmetric)byte[]
Decodes a text in DES (Symmetric)decodeTransmission
(String text, boolean active) Decodes a text in DES (Symmetric)Symmetric decryptiondecryptAes
(String text) Decrypts a string with AesdecryptAes
(String text, String password) Decrypts a string with AesdecryptRipEmd160
(String text) Decrypts a string with RipEmd160decryptRipEmd160WithPhraseKey
(String text, String phraseKey, String encoding) Decrypts a string with RipEmd160 and phraseKeyEncodes a text in Hexstatic String
encodeLanguage
(String text, String encoding) Encode given text to the given encodingHashes a String with a PBKDF2 algorithm based on SHA-1encodePBKDF2WithHmacSHA1
(String text, String salt) Hashes a String with a PBKDF2 algorithm based on SHA-1encodePBKDF2WithHmacSHA1
(String text, String salt, int iterations) Hashes a String with a PBKDF2 algorithm based on SHA-1encodePBKDF2WithHmacSHA1
(String text, String salt, int iterations, int keyLength) Hashes a String with a PBKDF2 algorithm based on SHA-1static String
encodeRipEmd160
(String text) Encodes a text in RIPEMD-160static String
encodeSymmetric
(byte[] encodeValue) Encodes a text in DES (Symmetric)static String
encodeSymmetric
(String text) Encodes a text in DES (Symmetric)encodeTransmission
(String text, boolean active) Decodes a text in DES (Symmetric)Symmetric encryptionencryptAes
(String text) Encrypts a string with AesencryptAes
(String text, String password) Encrypts a string with AesencryptRipEmd160
(String text) Encrypts a string with RipEmd160encryptRipEmd160WithPhraseKey
(String text, String phraseKey) Encrypts a string with RipEmd160 and phraseKeyencryptRipEmd160WithPhraseKey
(String text, String phraseKey, String encoding) Encrypts a string with RipEmd160 and phraseKeystatic SecureRandom
generate secure random objectCreate a secure random string of the given length with the alphabetHashes a String with an SHA-X algorithm without any salt, where X is the algorithm given in the algorithm variableHashes a String with an SHA-X algorithm with a salt, where X is the algorithm given in the algorithm variableMethods inherited from class com.almis.awe.config.ServiceConfig
containsBean, getApplicationContext, getBean, getBean, getElements, getLocale, getLocale, getProperty, getProperty, getRequest, getSession, setApplicationContext
-
Constructor Details
-
EncodeService
public EncodeService(BaseConfigProperties baseConfigProperties, SecurityConfigProperties securityConfigProperties) Hide the constructor- Parameters:
baseConfigProperties
- Base config propertiessecurityConfigProperties
- Security config properties
-
-
Method Details
-
encodeRipEmd160
Encodes a text in RIPEMD-160- Parameters:
text
- Text to encode- Returns:
- Text encoded
-
decryptRipEmd160
Decrypts a string with RipEmd160- Parameters:
text
- String to be decrypted- Returns:
- String decrypted
- Throws:
AWException
- Error in decryption
-
encryptRipEmd160
Encrypts a string with RipEmd160- Parameters:
text
- String to be encrypted- Returns:
- String encrypted
- Throws:
AWException
- Error in encryption
-
encryptRipEmd160WithPhraseKey
Encrypts a string with RipEmd160 and phraseKey- Parameters:
text
- String to be encryptedphraseKey
- Phrase key- Returns:
- String encrypted
- Throws:
AWException
- Error in encryption
-
encryptRipEmd160WithPhraseKey
public String encryptRipEmd160WithPhraseKey(String text, String phraseKey, String encoding) throws AWException Encrypts a string with RipEmd160 and phraseKey- Parameters:
text
- String to be encryptedphraseKey
- Phrase keyencoding
- Encoding- Returns:
- String encrypted
- Throws:
AWException
- Error in encryption
-
decryptRipEmd160WithPhraseKey
public String decryptRipEmd160WithPhraseKey(String text, String phraseKey, String encoding) throws AWException Decrypts a string with RipEmd160 and phraseKey- Parameters:
text
- String to be decryptedphraseKey
- Phrase keyencoding
- Encoding- Returns:
- String decrypted
- Throws:
AWException
- Error in decryption
-
decryptAes
Decrypts a string with Aes- Parameters:
text
- String to be decrypted- Returns:
- String decrypted
- Throws:
AWException
- Error in decryption
-
decryptAes
Decrypts a string with Aes- Parameters:
text
- String to be decryptedpassword
- Password- Returns:
- String decrypted
- Throws:
AWException
- Error in decryption
-
encryptAes
Encrypts a string with Aes- Parameters:
text
- String to be encrypted- Returns:
- String encrypted
- Throws:
AWException
- Error in encryption
-
encryptAes
Encrypts a string with Aes- Parameters:
text
- String to be encryptedpassword
- Password- Returns:
- String encrypted
- Throws:
AWException
- Error in encryption
-
encodeSymmetric
Encodes a text in DES (Symmetric)- Parameters:
encodeValue
- Text to encode- Returns:
- Text encoded
- Throws:
AWException
- Error in encoding
-
encodeSymmetric
Encodes a text in DES (Symmetric)- Parameters:
text
- Text to encode- Returns:
- Text encoded
- Throws:
AWException
- Error in encoding
-
decodeSymmetric
Decodes a text in DES (Symmetric)- Parameters:
text
- Text to decode- Returns:
- Text decoded
- Throws:
AWException
- Error in decoding
-
decodeSymmetricAsByteArray
Decodes a text in DES (Symmetric)- Parameters:
text
- Text to decode- Returns:
- Text decoded
- Throws:
AWException
- Error in decoding
-
encodeHex
Encodes a text in Hex- Parameters:
text
- Text to encode- Returns:
- Text encoded
- Throws:
AWException
- Error encoding
-
decodeHex
Decodes a text in Hex- Parameters:
text
- Text to decode- Returns:
- Text decoded
- Throws:
AWException
- Error decoding
-
encodeTransmission
Decodes a text in DES (Symmetric)- Parameters:
text
- Text to decodeactive
- Encoding enabled- Returns:
- Text decoded
- Throws:
AWException
- Error encoding
-
decodeTransmission
Decodes a text in DES (Symmetric)- Parameters:
text
- Text to decodeactive
- Encoding enabled- Returns:
- Text decoded
- Throws:
AWException
- Error decoding
-
hash
Hashes a String with an SHA-X algorithm without any salt, where X is the algorithm given in the algorithm variable- Parameters:
algorithm
- Algorithmtext
- Text to hash- Returns:
- String Hexadecimal format of the output bytearray
- Throws:
AWException
- Error hashing
-
hash
Hashes a String with an SHA-X algorithm with a salt, where X is the algorithm given in the algorithm variable- Parameters:
algorithm
- Algorithmtext
- Text to hashsalt
- The salt to be applied to the algorithm- Returns:
- String Hexadecimal format of the output bytearray
- Throws:
AWException
- Error hashing
-
encodePBKDF2WithHmacSHA1
Hashes a String with a PBKDF2 algorithm based on SHA-1- Parameters:
text
- Text to encode- Returns:
- String in Hexadecimal format
- Throws:
AWException
- Error encoding
-
encodePBKDF2WithHmacSHA1
Hashes a String with a PBKDF2 algorithm based on SHA-1- Parameters:
text
- Text to encodesalt
- should be of about 160 bit size or more to create a strong salt- Returns:
- String in Hexadecimal format
- Throws:
AWException
- Error encoding
-
encodePBKDF2WithHmacSHA1
Hashes a String with a PBKDF2 algorithm based on SHA-1- Parameters:
text
- Text to encodesalt
- should be of about 160 bit size or more to create a strong saltiterations
- Number of iterations- Returns:
- String in Hexadecimal format
- Throws:
AWException
- Error encoding
-
encodePBKDF2WithHmacSHA1
public String encodePBKDF2WithHmacSHA1(String text, String salt, int iterations, int keyLength) throws AWException Hashes a String with a PBKDF2 algorithm based on SHA-1- Parameters:
text
- Text to encodesalt
- should be of about 160 bit size or more to create a strong saltiterations
- recommended value is 256000 in 2016, double this value every 2 yearskeyLength
- should not be bigger than the maximum output length of the SHA-1 algorithm which is 160 bit (40 hex characters)- Returns:
- String in Hexadecimal format
- Throws:
AWException
- Error encoding
-
getSecureRandom
generate secure random object- Returns:
- Secure random
-
getSecureRandomString
Create a secure random string of the given length with the alphabet- Returns:
- Random string
-
encodeLanguage
public static String encodeLanguage(String text, String encoding) throws UnsupportedEncodingException Encode given text to the given encoding- Parameters:
text
- Text to encodeencoding
- Encoding- Returns:
- Text encoded
- Throws:
UnsupportedEncodingException
- Error encoding
-
encrypt
Symmetric encryption- Parameters:
digest
- DigestvalueEnc
- Value to encodesecretKey
- Key- Returns:
- Value encoded
-
decrypt
Symmetric decryption- Parameters:
digest
- DigestencryptedValue
- Encrypted valuesecretKey
- Key- Returns:
- Decrypted value
-
base64Encode
Base64 encode string- Parameters:
text
- Text to encode- Returns:
- Text encoded
-
base64Encode
Base64 encode byte array- Parameters:
text
- Text to encode- Returns:
- Text encoded
-
base64Decode
Base64 decode string- Parameters:
text
- Text to decode- Returns:
- Text decoded
- Throws:
UnsupportedEncodingException
- unsupported encoding exception
-
base64DecodeAsByteArray
Base64 decode string- Parameters:
text
- Text to decode- Returns:
- Text decoded
-
base64Decode
Base64 decode byte array- Parameters:
text
- Text to decode- Returns:
- Text decoded
- Throws:
UnsupportedEncodingException
- unsupported encoding exception
-