Class CryptoService


  • public final class CryptoService
    extends java.lang.Object
    The Class CryptoService.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String digest​(java.io.InputStream stream, java.lang.String strAlgorithm)
      Get a digest of the content of a stream
      static java.lang.String encrypt​(java.lang.String strDataToEncrypt, java.lang.String strAlgorithm)
      Encrypt a data using an algorithm defined in lutece.properties
      static java.lang.String getCryptoKey()
      Get the cryptographic key of the application
      static java.lang.String hmacSHA256​(java.lang.String message)
      Get the HmacSHA256 of a message using the app crypto key.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • encrypt

        public static java.lang.String encrypt​(java.lang.String strDataToEncrypt,
                                               java.lang.String strAlgorithm)
        Encrypt a data using an algorithm defined in lutece.properties
        Parameters:
        strDataToEncrypt - The data to encrypt
        strAlgorithm - the algorithm
        Returns:
        The encrypted string
      • digest

        public static java.lang.String digest​(java.io.InputStream stream,
                                              java.lang.String strAlgorithm)
        Get a digest of the content of a stream
        Parameters:
        stream - the stream containing the data to digest
        strAlgorithm - the digest Algorithm
        Returns:
        hex encoded digest string
        Since:
        6.0.0
        See Also:
        MessageDigest
      • getCryptoKey

        public static java.lang.String getCryptoKey()
        Get the cryptographic key of the application
        Returns:
        The cryptographic key of the application
      • hmacSHA256

        public static java.lang.String hmacSHA256​(java.lang.String message)
        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