Package es.gob.afirma.tsl.utils
Class UtilsCrypto
- java.lang.Object
-
- es.gob.afirma.tsl.utils.UtilsCrypto
-
public final class UtilsCrypto extends java.lang.ObjectUtilities class for cryptographics operations.
Project:Library for the integration with the services of @Firma, eVisor and TS@.
- Version:
- 1.1, 15/06/2021.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static byte[]calculateDigest(java.lang.String algorithm, byte[] data, java.security.Provider provider)Calculate the digest of the input data with the algorithm specified.static byte[]calculateDigestReturnB64ByteArray(java.lang.String algorithm, byte[] data, java.security.Provider provider)Calculate the digest in base 64 of the input data with the algorithm specified.static java.lang.StringcalculateDigestReturnB64String(java.lang.String algorithm, byte[] data, java.security.Provider provider)Calculate the digest in base 64 of the input data with the algorithm specified.static java.lang.StringtranslateHashAlgorithmXML(java.lang.String algorithmURI)Method that obtains the name of certain algorithm from the URI of the algorithm (only for XML format).
-
-
-
Method Detail
-
translateHashAlgorithmXML
public static java.lang.String translateHashAlgorithmXML(java.lang.String algorithmURI) throws CommonUtilsExceptionMethod that obtains the name of certain algorithm from the URI of the algorithm (only for XML format). For example: "http://www.w3.org/2000/09/xmldsig#sha1" --< "SHA1".- Parameters:
algorithmURI- Parameter that represents the URI of the algorithm.- Returns:
- the name of the algorithm.
- Throws:
CommonUtilsException- If the algorithm isn't supported.
-
calculateDigest
public static byte[] calculateDigest(java.lang.String algorithm, byte[] data, java.security.Provider provider) throws CommonUtilsExceptionCalculate the digest of the input data with the algorithm specified.- Parameters:
algorithm- Hash algorithm to apply. It can not be null or empty.data- Array of bytes that represents the data to calculate the hash. It can not be null or empty.provider- Provider to use for calculate the hash algorithm. If it isnull, then tries to use the provider setted in java security providers configuration.- Returns:
- Array of bytes that represents the hash calculated.
- Throws:
CommonUtilsException- In case of the input hash or data are note properly defined, or that the input hash is not recognized.
-
calculateDigestReturnB64ByteArray
public static byte[] calculateDigestReturnB64ByteArray(java.lang.String algorithm, byte[] data, java.security.Provider provider) throws CommonUtilsExceptionCalculate the digest in base 64 of the input data with the algorithm specified.- Parameters:
algorithm- Hash algorithm to apply. It can not be null or empty.data- Array of bytes that represents the data to calculate the hash. It can not be null or empty.provider- Provider to use for calculate the hash algorithm. If it isnull, then tries to use the provider setted in java security providers configuration.- Returns:
- Array of bytes that represents the hash calculated in base 64 (not chunked).
- Throws:
CommonUtilsException- In case of the input hash or data are note properly defined, or that the input hash is not recognized.
-
calculateDigestReturnB64String
public static java.lang.String calculateDigestReturnB64String(java.lang.String algorithm, byte[] data, java.security.Provider provider) throws CommonUtilsExceptionCalculate the digest in base 64 of the input data with the algorithm specified.- Parameters:
algorithm- Hash algorithm to apply. It can not be null or empty.data- Array of bytes that represents the data to calculate the hash. It can not be null or empty.provider- Provider to use for calculate the hash algorithm. If it isnull, then tries to use the provider setted in java security providers configuration.- Returns:
Stringthat represents the hash calculated in base 64 (not chunked).- Throws:
CommonUtilsException- In case of the input hash or data are note properly defined, or that the input hash is not recognized.
-
-