Package org.compiere.util
Class Secure
java.lang.Object
org.compiere.util.Secure
- All Implemented Interfaces:
SecureInterface
Default implementation of
SecureInterface for encryption and decryption.
Change log:
- 2007-01-27 - teo_sarca - [ 1598095 ] class Secure is not working with UTF8
- Version:
- $Id: Secure.java,v 1.2 2006/07/30 00:52:23 jjanke Exp $
- Author:
- Jorg Janke
-
Field Summary
Fields inherited from interface org.compiere.util.SecureInterface
ADEMPIERE_SECURE, ADEMPIERE_SECURE_DEFAULT, CLEARVALUE_END, CLEARVALUE_START, ENCRYPTEDVALUE_END, ENCRYPTEDVALUE_START -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]convertHexString(String hexString) Convert Hex String to Byte Arraystatic StringconvertToHexString(byte[] bytes) Convert Byte Array to Hex StringNot implemented, just return value as it isDecryption.decrypt(BigDecimal value, int ad_client_id) Not implemented, just return value as it isNot implemented, just return value as it isNot implemented, just return value as it isEncryption.encrypt(BigDecimal value, int ad_client_id) Not implemented, just return value as it isNot implemented, just return value as it isprotected CipherGet Cipher Instanceprotected StringGet Cipher ProviderPerform MD5 Digest of value JavaScript version see - http://pajhome.org.uk/crypt/md5/index.htmlgetSHA256Digest(String value) Convert String to SHA-256 digestgetSHA512Hash(int iterations, String value, byte[] salt) Convert String and salt to SHA-512 hash with iterations https://www.owasp.org/index.php/Hashing_Javastatic intHash checksum numberbooleanChecks, if value is a valid digestbooleanisSHA256Digest(String value) Check if value is a valid SHA-256 digesttoString()String Representation
-
Constructor Details
-
Secure
public Secure()iDempiere Security
-
-
Method Details
-
hash
Hash checksum number- Parameters:
key- key- Returns:
- checksum number
-
convertToHexString
Convert Byte Array to Hex String- Parameters:
bytes- bytes- Returns:
- HexString
-
convertHexString
Convert Hex String to Byte Array- Parameters:
hexString- hex string- Returns:
- byte array
-
encrypt
Encryption.- Specified by:
encryptin interfaceSecureInterface- Parameters:
value- clear valueAD_Client_ID-- Returns:
- encrypted String
-
getCipherInstance
protected Cipher getCipherInstance() throws NoSuchAlgorithmException, NoSuchPaddingException, NoSuchProviderExceptionGet Cipher Instance- Returns:
- cipher
- Throws:
NoSuchAlgorithmExceptionNoSuchPaddingExceptionNoSuchProviderException
-
getCipherProvider
Get Cipher Provider- Returns:
- cipher provider or null if default provider should be used
-
decrypt
Decryption. The methods must recognize clear text values- Specified by:
decryptin interfaceSecureInterface- Parameters:
value- encrypted valueAD_Client_ID-- Returns:
- decrypted String
-
encrypt
Not implemented, just return value as it is- Specified by:
encryptin interfaceSecureInterface- Parameters:
value- clear valuead_client_id-- Returns:
- integer value
-
decrypt
Not implemented, just return value as it is- Specified by:
decryptin interfaceSecureInterface- Parameters:
value- encrypted value- Returns:
- integer value
-
encrypt
Not implemented, just return value as it is- Specified by:
encryptin interfaceSecureInterface- Parameters:
value- clear valuead_client_id-- Returns:
- BigDecimal value
-
decrypt
Not implemented, just return value as it is- Specified by:
decryptin interfaceSecureInterface- Parameters:
value- encrypted value- Returns:
- Big decimal value
-
encrypt
Not implemented, just return value as it is- Specified by:
encryptin interfaceSecureInterface- Parameters:
value- clear valuead_client_id-- Returns:
- Timestamp value
-
decrypt
Not implemented, just return value as it is- Specified by:
decryptin interfaceSecureInterface- Parameters:
value- encrypted value- Returns:
- Timestamp value
-
getDigest
Perform MD5 Digest of value JavaScript version see - http://pajhome.org.uk/crypt/md5/index.html- Specified by:
getDigestin interfaceSecureInterface- Parameters:
value- text to digest- Returns:
- HexString of digested message (length = 32 characters)
-
isDigest
Checks, if value is a valid digest- Specified by:
isDigestin interfaceSecureInterface- Parameters:
value- digest string- Returns:
- true if valid digest
-
getSHA256Digest
Description copied from interface:SecureInterfaceConvert String to SHA-256 digest- Specified by:
getSHA256Digestin interfaceSecureInterface- Returns:
- HexString of digested message (length = 64 characters)
-
isSHA256Digest
Description copied from interface:SecureInterfaceCheck if value is a valid SHA-256 digest- Specified by:
isSHA256Digestin interfaceSecureInterface- Returns:
- true if valid SHA-256 digest
-
getSHA512Hash
public String getSHA512Hash(int iterations, String value, byte[] salt) throws NoSuchAlgorithmException, UnsupportedEncodingException Convert String and salt to SHA-512 hash with iterations https://www.owasp.org/index.php/Hashing_Java- Specified by:
getSHA512Hashin interfaceSecureInterface- Parameters:
value- message- Returns:
- HexString of message (length = 128 characters)
- Throws:
NoSuchAlgorithmExceptionUnsupportedEncodingException
-
toString
String Representation -
getKeyStore
- Returns:
- keystore
-