Class CipherKey


  • public class CipherKey
    extends Object
    A key used in a cryptographic algorithm to encrypt a plain text or to decrypt a cipher text. This key can be either symmetric or asymmetric, it can be provided as such or in a file. This class is a wrapper of the actual representation of the cipher key so that it can be passed to the ciphers in the Silverpeas Cryptography API in different forms, according to the ciphers expectation.
    • Method Detail

      • aKeyFromHexText

        public static CipherKey aKeyFromHexText​(String hexKey)
                                         throws ParseException
        Constructs a new cipher key from the specified hexadecimal representation of the key.
        Parameters:
        hexKey - the text with hexadecimal-based characters.
        Returns:
        the cipher key.
        Throws:
        ParseException
      • aKeyFromBase64Text

        public static CipherKey aKeyFromBase64Text​(String base64Key)
        Constructs a new cipher key from the specified base64 representation of the key.
        Parameters:
        base64Key - the text of the key in Base64.
        Returns:
        the cipher key.
      • aKeyFromBinary

        public static CipherKey aKeyFromBinary​(byte[] binaryKey)
        Constructs a new cipher key from the specified binary representation of the key.
        Parameters:
        binaryKey - the key in binary.
        Returns:
        the cipher key.
      • aKeyFromFilePath

        public static CipherKey aKeyFromFilePath​(String path)
        Constructs a new cipher key from the path of the file in which is stored the key.
        Parameters:
        path - the path of the key file.
        Returns:
        a cipher key.
      • isInFile

        public boolean isInFile()
        Is the key in a file?
        Returns:
        true if the key is in a file and the file exists, false otherwise.
      • isRaw

        public boolean isRaw()
        Is this cipher key represents a key in itself and not the storage in which the key is?
        Returns:
        true if this cipher key represents a raw key.
      • getRawKey

        public byte[] getRawKey()
        Gets the raw representation of this cipher key.
        Returns:
        the key in binaries.
      • getKeyFilePath

        public String getKeyFilePath()
        Gets the path of the file that stores the key.
        Returns:
        the path of the key file or null if this key isn't stored in a file.