Advanced Configuration

#### Search Results

Search

# Advanced Configuration

- Encrypting Passwords

- Configuration File Option: Class Path

## Encrypting Passwords

Each password parameter should be encrypted in the application.properties file.

- Procedure

- Example

### Procedure

Follow these steps to encrypt a password:

1. Decide on which password to encrypt.

2. Run `encryptPassword.sh` under the /bin directory with the following command:

   `encryptPassword.sh --encryption-password <JASYPT_ENCRYPTOR_PASSWORD> <passphrase>`

   The `JASYPT_ENCRYPTOR_PASSWORD` property is the key to encrypt the passphrase. It can be any string combination.

3. Place the value received from running the shell script as the password value. This value should be wrapped in `‘ENC()’` string to mark the fact that this password is encrypted.

4. In a running testing or production environment, the `JASYPT_ENCRYPTOR_PASSWORD` should be set as an environment variable.

### Example

In the following example, the required password for the `spring.data.redis.password` property is `‘pass1’`, and the `JASYPT_ENCRYPTOR_PASSWORD` property was decided to be `‘pass2’`.

Run the shell script as follows:

`encryptPassword.sh --encryption-password pass2 pass1`

The output received from the shell script could be `AAAABBBB44444FFFBB`.

This value should be set as property in the application.properties as follows:

`spring.data.redis.password=ENC(AAAABBBB44444FFFBB)`

This process must be done for each password used in the application.properties file.

The same `JASYPT_ENCRYPTOR_PASSWORD` property must be used for all encrypted properties.

When subsequently accessing the server that runs the application (for production or testing), an environment variable must be set for the key `JASYPT_ENCRYPTOR_PASSWORD` with the value `pass2`.

## Configuration File Option: Class Path

An alternative option to supply the configuration files (application.properties and license file) is by adding a resource directory to the `NaturalAvailiablityServer` class path in the servlet container:

- For WildFly®

- For Tomcat®

### For WildFly®

A module needs to be defined in order to add filles to the class path:

1. Create a directory that contains the resource files.

2. Run the following command to add the module. The module name should stay as defined in the command:

   `/opt/jboss/wildfly/bin/jbos–cli.sh -c –command=”module add –name=natural-availability-server-configuration --resource-delimiter=, --resources=<path to folder created>/application.properties, <path to folder created>/nha<version-number>.xml"`

### For Tomcat®

Configure the location of the application.properties file:

1. In the application.properties, set the `licensePath` property pointing to the location of the license file.

2. Create the following file under Tomcat® installation:

   <tomcat installation>/conf/Catalina/myHost/NaturalAvailabilityServer.xml

   … where myHost is the host name.

3. In this file NaturalAvailabilityServer.xml, add the following element:

   `<Context> <Environment name=" spring_config_location" value="<location of application.properties>/application.properties" type="java.lang.String"/> </Context>`

### On this page

- Encrypting Passwords
- Configuration File Option: Class Path