0

I would like to use Jasypt (a java library) in an Xpage to encrypt/decrypt some data. www.jasypt.org

I copied the jar files into WebContent/WEB-INF/lib of my nsf file.

In my nsf I went to "Project Properties" "Java Build Path" "Libraries" "Add class folder" I added this folder to it.

On an Xpage I added a button and in the onclick event I've put:

userPassword = "test";
importPackage(StrongPasswordEncryptor);
passwordEncryptor = new StrongPasswordEncryptor();
encryptedPassword = passwordEncryptor.encryptPassword(userPassword);
viewScope.test = encryptedPassword;

I'm getting a reference error for StrongPasswordEncryptor

I guess I have to import the library in another way ?

Marc Jonkers
  • 496
  • 1
  • 7
  • 17

1 Answers1

0

If you want to use the org.jasypt.util.password.StrongPasswordEncryptor class, you have to write

importPackage(org.jasypt.util.password);

instead of

importPackage(StrongPasswordEncryptor);

As the name of the function suggests, you have to provide the package and not the class you want to import.

xpages-noob
  • 1,569
  • 1
  • 10
  • 37
  • Now I get another error : Error calling method 'encryptPassword(string)' on java class 'org.jasypt.util.password.StrongPasswordEncryptor' – Marc Jonkers May 20 '16 at 06:37
  • @MarcJonkers: First you should check if the encryptPassword function is defined: `typeof(passwordEncryptor.encryptPassword)==="function"`. If that is the case, the error is thrown inside that function and you should take a look at / provide us with the error details (for example the first lines of the stacktrace). – xpages-noob May 20 '16 at 12:05