Encrypting User Passwords¶
Warning
As of JasperReports Server 7.5, all encryption in the server relies on cryptographic keys stored in the server's keystore. For more information, see Key and Keystore Management.
The configuration files and properties described in this section are no longer used by this feature. They are documented here only for legacy purposes.
User passwords are stored along with user profiles in JasperReports Server's private database. Password encryption is enabled and passwords are stored as cipher text in the database by default. The following procedure enables system administrators to turn user password encryption on or off. They can also change the encryption algorithm and specify the salt key used to initiate the encryption algorithm.
To Configure User Password Encryption:
-
As a precaution, back up the server's private
jasperserverdatabase. To back up the default PostgreSQL database, go to the <js-install> directory and run the following command:pg_dump -U postgres jasperserver > js-backup.sqlTo back up DB2, Oracle, Microsoft SQL Server, and MySQL databases, refer to your database product documentation.
-
Stop your application server. Leave your database running.
-
Export the entire contents of the repository, which includes user profiles and their passwords, with the following commands. Note that there are two dashes (
--) in front of the command options:Windows:
cd <js-install>\buildomatic
js-export.bat --everything --output-dir js-backup-catalogLinux:
cd <js-install>/buildomatic
js-export.sh --everything --output-dir js-backup-catalogIn the export operation, passwords are decrypted using the existing user password ciphers and re-encrypted with the import-export encryption key. This is a separate encryption that ensures that passwords are never in plain text, even when exported. For more information, see "Import and Export" in the JasperReports Server Administrator Guide.
-
Edit the properties in the following table to configure different ciphers. Both the server and the import-export scripts access the user profiles and must be configured identically. Make the same changes in both files:
User Password Encryption Configuration
DEPRECATED User Password Encryption Configuration
<jasperserver-pro-war>/WEB-INF/applicationContext-security.xml
<js-install>/buildomatic/conf_source/iePro/applicationContext-security.xml
Property
Bean
Description
allowEncodingpasswordEncoder
With the default setting of
true, user passwords are encrypted when stored. Whenfalse, user passwords are stored in clear text in JasperReports Server's private database. We do not recommend changing this setting.keyInPlainTextpasswordEncoderWhen
true, thesecretKeyvalue is given as a plain text string. Whenfalse, thesecretKeyvalue is a numeric representation that can be parsed by Java's Integer.decode() method. By default, this setting is false, and thesecretKeyis in hexadecimal notation (0xAB).secretKeypasswordEncoderThis value is the salt used by the encryption algorithm to make encrypted values unique. This value can be a text string or a numeric representation depending on the value of
keyInPlainText.secretKeyAlgorithmpasswordEncoderThe name of the algorithm used to process the key, by default
DESede.cipher
TransformationpasswordEncoderThe name of the cipher transformation used to encrypt passwords, by default
DESede/CBC/ PKCS5Padding.Warning
Change the
secretKeyvalue so it is different from the default.The
secretKey,secretKeyAlgorithm, andcipherTransformationproperties must be consistent. For example, thesecretKeymust be 24 bytes long in hexadecimal notation or 24 characters in plain text for the default cipher (DESede/CBC/PKCS5Padding). Different algorithms expect different key lengths. For more information, see Java'sjavax.cryptodocumentation. -
Next, drop your existing
jasperserverdatabase, where the passwords had the old encoding, and recreate an emptyjasperserverdatabase. Follow the instructions for your database server: -
Import your exported repository contents with the following commands. The import operation restores the contents of JasperReports Server's private database, including user profiles. As the user profiles are imported, the passwords are encrypted using the new cipher settings.
Note that there are two dashes (
--) in front of the command options:Windows:
cd <js-install>\buildomatic
js-import.bat --input-dir js-backup-catalogLinux:
cd <js-install>/buildomatic
js-import.sh --input-dir js-backup-catalogDuring the import operation, passwords are decrypted with the import-export encryption key and then re-encrypted in the database with the new user password encryption settings. For more information, see Setting the Import-Export Encryption Key in the JasperReports Server Administrator Guide.
-
Use a database like the SQuirreL tool to check the contents of the
JIUsertable in thejasperserverdatabase and verify that the password column values are encrypted. -
Restart your application server. Your database should already be running.
-
Log into JasperReports Server to verify that encryption is working properly during the log in process.
Dropping and Recreating the Database in PostgreSQL¶
-
Change the directory to
<js-install>/buildomatic/install_resources/sql/postgresql. -
Start psql using an administrator account such as PostgreSQL:
psql -U postgres -
Drop the
jasperserverdatabase, create a one, and load thejasperserverschema:
Dropping and Recreating the Database in MySQL¶
-
Change the directory to
<js-install>/buildomatic/install_resources/sql/mysql. -
Log in to your MySQL client:
mysql -u root -p -
Drop the
jasperserverdatabase, create a one, and load thejasperserverschema:
Dropping and Recreating the Database in Oracle¶
-
Change the directory to
<js-install>/buildomatic/install_resources/sql/oracle. -
Log in to your SQLPlus client, for example:
sqlplus sys/sys as sysdba -
Drop the
jasperserverdatabase, create a one, and load thejasperserverschema:
Dropping and Recreating in the Database in Microsoft SQL Server¶
-
Change the directory to
<js-install>/buildomatic/install_resources/sql/sqlserver. -
Drop the
jasperserverdatabase, create a one, and load thejasperserverschema using the SQLCMD utility: