Class CryptoService
java.lang.Object
fr.paris.lutece.portal.service.util.CryptoService
The Class CryptoService.
-
Method Summary
Modifier and TypeMethodDescriptionstatic Stringdigest(InputStream stream, String strAlgorithm) Get a digest of the content of a streamstatic StringEncrypt a data using an algorithm defined in lutece.propertiesstatic StringencryptLegacy(String strDataToEncrypt, String strAlgorithm) Deprecated, for removal: This API element is subject to removal in a future version.since 8.0 — will be removed once no legacy password hashes remain in any supported deployment.static StringGet the cryptographic key of the applicationstatic StringhmacSHA256(String message) Get the HmacSHA256 of a message using the app crypto key.
-
Method Details
-
encrypt
Encrypt a data using an algorithm defined in lutece.properties- Parameters:
strDataToEncrypt- The data to encryptstrAlgorithm- the algorithm- Returns:
- The encrypted string
-
encryptLegacy
@Deprecated(since="8.0", forRemoval=true) public static String encryptLegacy(String strDataToEncrypt, String strAlgorithm) Deprecated, for removal: This API element is subject to removal in a future version.since 8.0 — will be removed once no legacy password hashes remain in any supported deployment.Computes a digest WITHOUT checking the algorithm against the whitelist enforced byencrypt(String, String). Intended ONLY to verify legacy stored password hashes (MD5, SHA-1, SHA-256 without salt) so that the automatic rehash-to-PBKDF2 path inLuteceDefaultAdminAuthenticationcan still trigger on login.Do NOT use for any new functionality — use
encrypt(String, String)instead.- Parameters:
strDataToEncrypt- The data to digeststrAlgorithm- the digest algorithm (MUST already have been validated by the caller as supported byMessageDigest.getInstance(String))- Returns:
- The hex-encoded digest, or
nullon failure
-
digest
Get a digest of the content of a stream- Parameters:
stream- the stream containing the data to digeststrAlgorithm- the digest Algorithm- Returns:
- hex encoded digest string
- Since:
- 6.0.0
- See Also:
-
getCryptoKey
Get the cryptographic key of the application- Returns:
- The cryptographic key of the application
-
hmacSHA256
Get the HmacSHA256 of a message using the app crypto key. The UTF-8 representation of the key is used.- Parameters:
message- the message. The mac is calculated from the UTF-8 representation- Returns:
- the hmac as hex
- Since:
- 6.0.0
-