com.pivotal.gemfirexd.internal.client.am

## Class EncryptionManager

- java.lang.Object
- - com.pivotal.gemfirexd.internal.client.am.EncryptionManager

    public class EncryptionManager
    extends Object

### Field Summary

Fields
`static String` `SHA_1_DIGEST_ALGORITHM`

### Constructor Summary

Constructors
Constructor and Description
`EncryptionManager(Agent agent)`
`EncryptionManager(Agent agent, String algorithm)`

### Method Summary

Methods
`byte[]` `decryptData(byte[] cipherText, int securityMechanism, byte[] initVector, byte[] targetPublicKey)`
`byte[]` `encryptData(byte[] plainText, int securityMechanism, byte[] initVector, byte[] targetPublicKey)`
`byte[]` `generateSeed()` This method generates an 8-Byte random seed for the client (source).
`byte[]` `obtainPublicKey()`
`void` `resetSecurityKeys()`
`void` `setInitVector(byte[] initVector)`
`void` `setSecKey(byte[] secKey)`
`byte[]` `substitutePassword(String userName, String password, byte[] sourceSeed_, byte[] targetSeed_)` Strong Password Substitution (USRSSBPWD).

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### SHA_1_DIGEST_ALGORITHM

    public static final String SHA_1_DIGEST_ALGORITHM

See Also:
  Constant Field Values

### Constructor Detail

#### EncryptionManager

    public EncryptionManager(Agent agent)
                      throws SqlException

Throws:
  `SqlException`

#### EncryptionManager

    public EncryptionManager(Agent agent,
                     String algorithm)
                      throws SqlException

Throws:
  `SqlException`

### Method Detail

#### obtainPublicKey

    public byte[] obtainPublicKey()

#### encryptData

    public byte[] encryptData(byte[] plainText,
                     int securityMechanism,
                     byte[] initVector,
                     byte[] targetPublicKey)
                       throws SqlException

Throws:
  `SqlException`

#### decryptData

    public byte[] decryptData(byte[] cipherText,
                     int securityMechanism,
                     byte[] initVector,
                     byte[] targetPublicKey)
                       throws SqlException

Throws:
  `SqlException`

#### setInitVector

    public void setInitVector(byte[] initVector)

#### setSecKey

    public void setSecKey(byte[] secKey)

#### resetSecurityKeys

    public void resetSecurityKeys()

#### generateSeed

    public byte[] generateSeed()

This method generates an 8-Byte random seed for the client (source).

Returns:
  a random 8-Byte seed.

#### substitutePassword

    public byte[] substitutePassword(String userName,
                            String password,
                            byte[] sourceSeed_,
                            byte[] targetSeed_)
                              throws SqlException

Strong Password Substitution (USRSSBPWD). This method generate a password subtitute to send to the target server. Substitution algorithm works as follow: PW_TOKEN = SHA-1(PW, ID) The password (PW) and user name (ID) can be of any length greater than or equal to 1 byte. The client generates a 20-byte password substitute (PW_SUB) as follows: PW_SUB = SHA-1(PW_TOKEN, RDr, RDs, ID, PWSEQs) w/ (RDs) as the random client seed and (RDr) as the server one. See PWDSSB - Strong Password Substitution Security Mechanism (DRDA Vol.3 - P.650)

Parameters:
  `userName` - The user's name
  `password` - The user's password
  `sourceSeed_` - random client seed (RDs)
  `targetSeed_` - random server seed (RDr)
Returns:
  a password substitute.
Throws:
  `SqlException`