Class IdAuthSecurityManager
- java.lang.Object
-
- io.mosip.authentication.common.service.transaction.manager.IdAuthSecurityManager
-
@Component public class IdAuthSecurityManager extends Object
The Class IdAuthSecurityManager.- Author:
- Manoj SP
-
-
Constructor Summary
Constructors Constructor Description IdAuthSecurityManager()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]asymmetricEncryption(byte[] dataToEncrypt, String partnerCertificate)byte[]combineDataToEncrypt(byte[] encryptedData, byte[] encryptedSymmetricKey)Combine data to encrypt.StringcreateRandomToken(byte[] dataToEncrypt)Creates the random token.static byte[]decodeHex(String hexData)Decode hex.byte[]decrypt(String dataToDecrypt, String refId, String aad, String saltToDecrypt, Boolean isThumbprintEnabled)Decrypt.static StringdigestAsPlainText(byte[] data)Digest as plain text.byte[]encrypt(String dataToEncrypt, String refId, String aad, String saltToEncrypt)Encrypt.reactor.util.function.Tuple2<byte[],byte[]>encrypt(PublicKey publicKey, byte[] dataToEncrypt)Encrypt.reactor.util.function.Tuple3<String,String,String>encryptData(byte[] data, String partnerCertificate)Encrypt data.StringgenerateArgon2Hash(String anyString, String salt)static byte[]generateHash(byte[] data)Generate hash.static StringgenerateHashAndDigestAsPlainText(byte[] data)Generate hash and digest as plain text.Map.Entry<String,String>generateKeyBindingCertificate(PublicKey publicKey, io.mosip.kernel.core.keymanager.model.CertificateParameters certParams)StringgenerateKeyedHash(byte[] bytesToHash)static byte[]getBytesFromThumbprint(String thumbprint)Gets the bytes from thumbprint.intgetSaltKeyForId(String id)StringgetUser()Gets the user.Stringhash(String id)StringjwsSignWithPayload(String data)StringjwtEncrypt(String dataToEncrypt, String certificateData)voidreEncryptAndStoreRandomKey(String index, String key)Re encrypt and store random key.StringreEncryptRandomKey(String encryptedKey)Re encrypt random key.Stringsign(String data)Sign.StringsignWithPayload(String data)static StringtoHex(byte[] bytes)To hex.static StringtrimBeginEnd(String pKey)Trim begin end.booleanverifySignature(String signature, String domain, String requestData, Boolean isTrustValidationRequired)Verify signature.Map<String,String>zkDecrypt(String id, Map<String,String> encryptedAttributes)Zk decrypt.
-
-
-
Method Detail
-
getUser
public String getUser()
Gets the user.- Returns:
- the user
-
encrypt
public byte[] encrypt(String dataToEncrypt, String refId, String aad, String saltToEncrypt) throws IdAuthenticationBusinessException
Encrypt.- Parameters:
dataToEncrypt- the data to encryptrefId- the ref idaad- the aadsaltToEncrypt- the salt to encrypt- Returns:
- the byte[]
- Throws:
IdAuthenticationBusinessException- the id authentication business exception
-
decrypt
public byte[] decrypt(String dataToDecrypt, String refId, String aad, String saltToDecrypt, Boolean isThumbprintEnabled) throws IdAuthenticationBusinessException
Decrypt.- Parameters:
dataToDecrypt- the data to decryptrefId- the ref idaad- the aadsaltToDecrypt- the salt to decryptisThumbprintEnabled- the is thumbprint enabled- Returns:
- the byte[]
- Throws:
IdAuthenticationBusinessException- the id authentication business exception
-
reEncryptRandomKey
public String reEncryptRandomKey(String encryptedKey)
Re encrypt random key.- Parameters:
encryptedKey- the encrypted key- Returns:
- the string
-
reEncryptAndStoreRandomKey
public void reEncryptAndStoreRandomKey(String index, String key)
Re encrypt and store random key.- Parameters:
index- the indexkey- the key
-
zkDecrypt
public Map<String,String> zkDecrypt(String id, Map<String,String> encryptedAttributes) throws IdAuthenticationBusinessException
Zk decrypt.- Parameters:
id- the idencryptedAttributes- the encrypted attributes- Returns:
- the map
- Throws:
IdAuthenticationBusinessException- the id authentication business exception
-
createRandomToken
public String createRandomToken(byte[] dataToEncrypt) throws IdAuthenticationBusinessException
Creates the random token.- Parameters:
dataToEncrypt- the data to encrypt- Returns:
- the string
- Throws:
IdAuthenticationBusinessException- the id authentication business exception
-
verifySignature
public boolean verifySignature(String signature, String domain, String requestData, Boolean isTrustValidationRequired)
Verify signature.- Parameters:
signature- the signaturedomain- the domainrequestData- the request dataisTrustValidationRequired- the is trust validation required- Returns:
- true, if successful
-
hash
public String hash(String id) throws IdAuthenticationBusinessException
-
getSaltKeyForId
public int getSaltKeyForId(String id)
-
encryptData
public reactor.util.function.Tuple3<String,String,String> encryptData(byte[] data, String partnerCertificate) throws IdAuthenticationBusinessException
Encrypt data.- Parameters:
data- the datapartnerCertificate- the partner certificate- Returns:
- the tuple 2
- Throws:
IdAuthenticationBusinessException- the id authentication business exception
-
asymmetricEncryption
public byte[] asymmetricEncryption(byte[] dataToEncrypt, String partnerCertificate) throws IdAuthenticationBusinessException
-
encrypt
public reactor.util.function.Tuple2<byte[],byte[]> encrypt(PublicKey publicKey, byte[] dataToEncrypt)
Encrypt.- Parameters:
publicKey- the public keydataToEncrypt- the data to encrypt- Returns:
- the byte[]
-
combineDataToEncrypt
public byte[] combineDataToEncrypt(byte[] encryptedData, byte[] encryptedSymmetricKey)Combine data to encrypt.- Parameters:
encryptedData- the encrypted dataencryptedSymmetricKey- the encrypted symmetric key- Returns:
- the byte[]
-
trimBeginEnd
public static String trimBeginEnd(String pKey)
Trim begin end.- Parameters:
pKey- the key- Returns:
- the string
-
digestAsPlainText
public static String digestAsPlainText(byte[] data)
Digest as plain text.- Parameters:
data- the data- Returns:
- the string
-
generateHashAndDigestAsPlainText
public static String generateHashAndDigestAsPlainText(byte[] data)
Generate hash and digest as plain text.- Parameters:
data- the data- Returns:
- the string
-
generateHash
public static byte[] generateHash(byte[] data) throws NoSuchAlgorithmExceptionGenerate hash.- Parameters:
data- the data- Returns:
- the byte[]
- Throws:
NoSuchAlgorithmException- the no such algorithm exception
-
decodeHex
public static byte[] decodeHex(String hexData) throws org.apache.commons.codec.DecoderException
Decode hex.- Parameters:
hexData- the hex data- Returns:
- the byte[]
- Throws:
org.apache.commons.codec.DecoderException- the decoder exception
-
toHex
public static String toHex(byte[] bytes)
To hex.- Parameters:
bytes- the bytes- Returns:
- the string
-
getBytesFromThumbprint
public static byte[] getBytesFromThumbprint(String thumbprint)
Gets the bytes from thumbprint.- Parameters:
thumbprint- the thumbprint- Returns:
- the bytes from thumbprint
-
generateKeyedHash
public String generateKeyedHash(byte[] bytesToHash)
-
generateKeyBindingCertificate
public Map.Entry<String,String> generateKeyBindingCertificate(PublicKey publicKey, io.mosip.kernel.core.keymanager.model.CertificateParameters certParams) throws CertificateEncodingException
- Throws:
CertificateEncodingException
-
-