use of org.camunda.bpm.engine.identity.User in project camunda-bpm-platform by camunda.
the class WriteMultipleEntitiesInOneTransactionTest method testWriteMultipleEntitiesInOneTransaction.
public void testWriteMultipleEntitiesInOneTransaction() {
// the identity service provider registered with the engine creates a user, a group, and a membership
// in the following call:
Assert.assertTrue(identityService.checkPassword("multipleEntities", "inOneStep"));
User user = identityService.createUserQuery().userId("multipleEntities").singleResult();
Assert.assertNotNull(user);
Assert.assertEquals("multipleEntities", user.getId());
Assert.assertEquals("{SHA}pfdzmt+49nwknTy7xhZd7ZW5suI=", user.getPassword());
// It is expected, that the User is in exactly one Group
List<Group> groups = this.identityService.createGroupQuery().groupMember("multipleEntities").list();
Assert.assertEquals(1, groups.size());
Group group = groups.get(0);
Assert.assertEquals("multipleEntities_group", group.getId());
// clean the Db
identityService.deleteMembership("multipleEntities", "multipleEntities_group");
identityService.deleteGroup("multipleEntities_group");
identityService.deleteUser("multipleEntities");
}
use of org.camunda.bpm.engine.identity.User in project camunda-bpm-platform by camunda.
the class PasswordHashingTest method useSeveralCustomEncryptors.
@Test
public void useSeveralCustomEncryptors() {
// given three users with different hashed passwords
processEngineConfiguration.setSaltGenerator(new MyConstantSaltGenerator("12345678910"));
String userName1 = "Kermit";
createUserWithEncryptor(userName1, new MyCustomPasswordEncryptor(PASSWORD, ALGORITHM_NAME));
String userName2 = "Fozzie";
String anotherAlgorithmName = "marvelousAlgorithm";
createUserWithEncryptor(userName2, new MyCustomPasswordEncryptor(PASSWORD, anotherAlgorithmName));
String userName3 = "Gonzo";
createUserWithEncryptor(userName3, new ShaHashDigest());
List<PasswordEncryptor> additionalEncryptorsForPasswordChecking = new LinkedList<PasswordEncryptor>();
additionalEncryptorsForPasswordChecking.add(new MyCustomPasswordEncryptor(PASSWORD, ALGORITHM_NAME));
additionalEncryptorsForPasswordChecking.add(new MyCustomPasswordEncryptor(PASSWORD, anotherAlgorithmName));
PasswordEncryptor defaultEncryptor = new ShaHashDigest();
setEncryptors(defaultEncryptor, additionalEncryptorsForPasswordChecking);
// when
User user1 = identityService.createUserQuery().userId(userName1).singleResult();
User user2 = identityService.createUserQuery().userId(userName2).singleResult();
User user3 = identityService.createUserQuery().userId(userName3).singleResult();
// then
assertThat(user1.getPassword(), is("{" + ALGORITHM_NAME + "}xxx"));
assertThat(user2.getPassword(), is("{" + anotherAlgorithmName + "}xxx"));
assertThat(user3.getPassword(), is("{SHA}n3fE9/7XOmgD3BkeJlC+JLyb/Qg="));
}
use of org.camunda.bpm.engine.identity.User in project camunda-bpm-platform by camunda.
the class PasswordHashingTest method ensurePasswordIsCorrectlyHashedWithSHA512.
@Test
public void ensurePasswordIsCorrectlyHashedWithSHA512() {
// given
processEngineConfiguration.setSaltGenerator(new MyConstantSaltGenerator("12345678910"));
User user = identityService.newUser(USER_NAME);
user.setPassword(PASSWORD);
identityService.saveUser(user);
// when
user = identityService.createUserQuery().userId(USER_NAME).singleResult();
// then
// obtain the expected value on the command line like so: echo -n password12345678910 | openssl dgst -binary -sha512 | openssl base64
assertThat(user.getPassword(), is("{SHA-512}sM1U4nCzoDbdUugvJ7dJ6rLc7t1ZPPsnAbUpTqi5nXCYp7PTZCHExuzjoxLLYoUK" + "Gd637jKqT8d9tpsZs3K5+g=="));
}
use of org.camunda.bpm.engine.identity.User in project camunda-bpm-platform by camunda.
the class PasswordHashingTest method ensurePasswordIsCorrectlyHashedWithSHA1.
@Test
public void ensurePasswordIsCorrectlyHashedWithSHA1() {
// given
setDefaultEncryptor(new ShaHashDigest());
processEngineConfiguration.setSaltGenerator(new MyConstantSaltGenerator("12345678910"));
User user = identityService.newUser(USER_NAME);
user.setPassword(PASSWORD);
identityService.saveUser(user);
// when
user = identityService.createUserQuery().userId(USER_NAME).singleResult();
// then
// obtain the expected value on the command line like so: echo -n password12345678910 | openssl dgst -binary -sha1 | openssl base64
assertThat(user.getPassword(), is("{SHA}n3fE9/7XOmgD3BkeJlC+JLyb/Qg="));
}
use of org.camunda.bpm.engine.identity.User in project camunda-bpm-platform by camunda.
the class PasswordHashingTest method createUserWithEncryptor.
protected void createUserWithEncryptor(String userName, PasswordEncryptor encryptor) {
setEncryptors(encryptor, Collections.<PasswordEncryptor>emptyList());
User user = identityService.newUser(userName);
user.setPassword(PASSWORD);
identityService.saveUser(user);
}
Aggregations