com.adventnet.passtrix.ed

## Interface PMPEncryptDecrypt

-     public interface PMPEncryptDecrypt

  This is the Interface which contains the necessary methods needed for encryption and decryption which is used in PMP Application.
  The Custom Cryptography Class should implement this Interface to get it used in Password Manager Pro application.
  Each and every method in the implementation class should have a null check for the parameters passed to it.
  The 32 bit key which has been generated in the last call of generateCryptographicKey() should be returned whenever getPmp32BitKey() is called.
  Since:
    PMP 8100
  Version:
    1.0
  Author:
    ManageEngine Password Manager Pro.

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `byte[]` | `decrypt(byte[] cipherText, byte[] key)` Decrypts the given cipherText in byte array using the given key and return the decrypted text as byte array.
    `byte[]` | `decrypt(byte[] cipherText, java.lang.String key)` Decrypts the given cipherText in byte array using the given key and return the decrypted text as byte array.
    `byte[]` | `decryptCertStream(java.io.InputStream inStream)` Decrypts the given InputStream content and return the decrypted content as byte array.
    `byte[]` | `decryptCertStream(java.io.InputStream inStream, java.lang.String key)` Decrypts the given InputStream content using given key and return the decrypted content as byte array.
    `java.io.ByteArrayInputStream` | `decryptInputStream(java.io.InputStream inStream)` Decrypts the given InputStream content and return the decrypted content as ByteArrayInputStream.
    `java.io.ByteArrayInputStream` | `decryptInputStream(java.io.InputStream inStream, java.lang.String key)` Decrypts the given InputStream content using given key and return the decrypted content as ByteArrayInputStream.
    `java.lang.String` | `decryptPassword(java.lang.String encryptedPassword)` Decrypts the given encrypted String and return the decrypted text as String.
    `java.lang.String` | `decryptPassword(java.lang.String encryptedPassword, java.lang.String key)` Decrypts the given encrypted String using the given key and return the decrypted text as String.
    `byte[]` | `encrypt(byte[] plainText, byte[] key)` Encrypts the given plain text in byte array using the given key and return the encrypted text as byte array.
    `byte[]` | `encrypt(byte[] plainText, java.lang.String key)` Encrypts the given plain text in byte array using the given key and return the encrypted text as byte array.
    `byte[]` | `encrypt(java.lang.String plainText, byte[] key)` Encrypts the given plain text String using the given key and return the encrypted text as byte array.
    `byte[]` | `encrypt(java.lang.String plainText, java.lang.String key)` Encrypts the given plain text String using the given key and return the encrypted text as byte array.
    `java.io.ByteArrayInputStream` | `encryptCert(java.io.InputStream inStream)` Encrypts the given InputStream content and return the encrypted content as ByteArrayInputStream.
    `java.lang.String` | `encryptPassword(java.lang.String password)` Encrypts the given password String and return the encrypted text as String.
    `java.lang.String` | `encryptPassword(java.lang.String password, java.lang.String key)` Encrypts the given password String using given key String and return the encrypted text as String.
    `java.lang.String` | `generateCryptographicKey()` Generates a new 32 bit key.
    `java.lang.String` | `getMSSQLMasterKey()` Returns the MSSql database master encryption key.
    `java.lang.String` | `getPmp32BitKey()` Returns the 32 bit key which has been generated by generateCryptographicKey() recently.
    `void` | `setPmp32BitKey(java.lang.String pmp32BitKey)` The 32 bit key which has been generated in the last call of generateCryptographicKey() can be set in a private static variable using this method and shall be returned when getPmp32BitKey() is called.

- - ### Method Detail

    - #### decrypt

          byte[] decrypt(byte[] cipherText,
                       byte[] key)
                         throws java.lang.Exception

      Decrypts the given cipherText in byte array using the given key and return the decrypted text as byte array.
      Parameters:
        `cipherText` - which has to be decrypted.
        `key` - The encryption key.
      Returns:
        The resultant byte array containing the decrypted text.
      Throws:
        `java.lang.Exception`

    - #### decrypt

          byte[] decrypt(byte[] cipherText,
                       java.lang.String key)
                         throws java.lang.Exception

      Decrypts the given cipherText in byte array using the given key and return the decrypted text as byte array.
      Parameters:
        `cipherText` - which to be decrypted is given as byte array.
        `key` - The encryption key as String.
      Returns:
        The resultant byte array containing the encrypted text.
      Throws:
        `java.lang.Exception`

    - #### decryptCertStream

          byte[] decryptCertStream(java.io.InputStream inStream)
                                   throws java.lang.Exception

      Decrypts the given InputStream content and return the decrypted content as byte array. Encryption key can be obtained from getPmp32BitKey().
      Parameters:
        `inStream` - the content which has to be decrypted is given as InputStream format.
      Returns:
        The resultant byte array containing the decrypted content of the given InputStream.
      Throws:
        `java.lang.Exception`

    - #### decryptCertStream

          byte[] decryptCertStream(java.io.InputStream inStream,
                                 java.lang.String key)
                                   throws java.lang.Exception

      Decrypts the given InputStream content using given key and return the decrypted content as byte array.
      Parameters:
        `inStream` - the content which has to be decrypted is given as InputStream format.
        `key` - The encryption key as String.
      Returns:
        The resultant byte array containing the decrypted content.
      Throws:
        `java.lang.Exception`

    - #### decryptInputStream

          java.io.ByteArrayInputStream decryptInputStream(java.io.InputStream inStream)
                                                          throws java.lang.Exception

      Decrypts the given InputStream content and return the decrypted content as ByteArrayInputStream. Encryption key can be obtained from getPmp32BitKey().
      Parameters:
        `inStream` - the content which has to be decrypted is given as InputStream format.
      Returns:
        The ByteArrayInputStream containing the decrypted content.
      Throws:
        `java.lang.Exception`

    - #### decryptInputStream

          java.io.ByteArrayInputStream decryptInputStream(java.io.InputStream inStream,
                                                        java.lang.String key)
                                                          throws java.lang.Exception

      Decrypts the given InputStream content using given key and return the decrypted content as ByteArrayInputStream.
      Parameters:
        `inStream` - the content which has to be decrypted is given as InputStream format.
        `key` - The encryption key as String.
      Returns:
        The resultant ByteArrayInputStream containing the decrypted content.
      Throws:
        `java.lang.Exception`

    - #### decryptPassword

          java.lang.String decryptPassword(java.lang.String encryptedPassword)
                                           throws java.lang.Exception

      Decrypts the given encrypted String and return the decrypted text as String. Encryption key can be obtained from getPmp32BitKey().
      Parameters:
        `encryptedPassword` - which has to be decrypted.
      Returns:
        the decrypted text as String
      Throws:
        `java.lang.Exception`

    - #### decryptPassword

          java.lang.String decryptPassword(java.lang.String encryptedPassword,
                                         java.lang.String key)
                                           throws java.lang.Exception

      Decrypts the given encrypted String using the given key and return the decrypted text as String.
      Parameters:
        `encryptedPassword` - which has to be decrypted.
        `key` - the encryption key as String.
      Returns:
        the decrypted text as String.
      Throws:
        `java.lang.Exception`

    - #### encrypt

          byte[] encrypt(byte[] plainText,
                       byte[] key)
                         throws java.lang.Exception

      Encrypts the given plain text in byte array using the given key and return the encrypted text as byte array.
      Parameters:
        `plainText` - in byte array format which has to be encrypted.
        `key` - The encryption key in byte array format.
      Returns:
        The resultant byte array containing the encrypted text.
      Throws:
        `java.lang.Exception`

    - #### encrypt

          byte[] encrypt(byte[] plainText,
                       java.lang.String key)
                         throws java.lang.Exception

      Encrypts the given plain text in byte array using the given key and return the encrypted text as byte array.
      Parameters:
        `plainText` - in byte array format which has to be encrypted.
        `key` - The encryption key as String.
      Returns:
        The resultant byte array containing the encrypted text.
      Throws:
        `java.lang.Exception`

    - #### encrypt

          byte[] encrypt(java.lang.String plainText,
                       byte[] key)
                         throws java.lang.Exception

      Encrypts the given plain text String using the given key and return the encrypted text as byte array.
      Parameters:
        `plainText` - to be encrypted.
        `key` - The encryption key in byte array format.
      Returns:
        The resultant byte array containing the encrypted text.
      Throws:
        `java.lang.Exception`

    - #### encrypt

          byte[] encrypt(java.lang.String plainText,
                       java.lang.String key)
                         throws java.lang.Exception

      Encrypts the given plain text String using the given key and return the encrypted text as byte array.
      Parameters:
        `plainText` - which has to be encrypted.
        `key` - The encryption key as String.
      Returns:
        The resultant byte array containing the encrypted text.
      Throws:
        `java.lang.Exception`

    - #### encryptCert

          java.io.ByteArrayInputStream encryptCert(java.io.InputStream inStream)
                                                   throws java.lang.Exception

      Encrypts the given InputStream content and return the encrypted content as ByteArrayInputStream. Encryption key can be obtained from getPmp32BitKey().
      Parameters:
        `inStream` - the certificate or file content which has to be encrypted is given as InputStream format.
      Returns:
        The resultant ByteArrayInputStream containing the encrypted content of the given certificate or file.
      Throws:
        `java.lang.Exception`

    - #### encryptPassword

          java.lang.String encryptPassword(java.lang.String password)
                                           throws java.lang.Exception

      Encrypts the given password String and return the encrypted text as String. Encryption key can be obtained from getPmp32BitKey().
      Parameters:
        `password` - String which has to be encrypted.
      Returns:
        the encrypted text as String.
      Throws:
        `java.lang.Exception`

    - #### encryptPassword

          java.lang.String encryptPassword(java.lang.String password,
                                         java.lang.String key)
                                           throws java.lang.Exception

      Encrypts the given password String using given key String and return the encrypted text as String.
      Parameters:
        `password` - String which has to be encrypted.
        `key` - The encryption key as String.
      Returns:
        the encrypted text as String.
      Throws:
        `java.lang.Exception`

    - #### generateCryptographicKey

          java.lang.String generateCryptographicKey()
                                                    throws java.lang.Exception

      Generates a new 32 bit key.
      Returns:
        the newly generated 32 bit key as String.
      Throws:
        `java.lang.Exception`

    - #### getMSSQLMasterKey

          java.lang.String getMSSQLMasterKey()

      Returns the MSSql database master encryption key. It will be used while setting up the MSSQL Always-On cluster as backend.
      Returns:
        value of the key used for database level encryption. If the return value is null or empty-string, then cluster level nodes' switch-over operations will not be handled.
      Throws:
        `java.lang.Exception`

    - #### getPmp32BitKey

          java.lang.String getPmp32BitKey()

      Returns the 32 bit key which has been generated by generateCryptographicKey() recently.
      Returns:
        the 32 bit key String that has been generated in the last call of generateCryptographicKey()

    - #### setPmp32BitKey

          void setPmp32BitKey(java.lang.String pmp32BitKey)

      The 32 bit key which has been generated in the last call of generateCryptographicKey() can be set in a private static variable using this method and shall be returned when getPmp32BitKey() is called. Else the implementation Class could have the own logic to store the key in some file.
      Parameters:
        `pmp32BitKey` - sets the given value to either any variable or can have your own logic to store the key in some file.