use of com.epam.reportportal.auth.store.entity.AuthConfigEntity in project service-authorization by reportportal.
the class AuthAttributesEventListenerTest method testPassEncryption.
@Test
public void testPassEncryption() {
LdapConfig ldapConfig = new LdapConfig();
ldapConfig.setManagerPassword(encryptor.encrypt("managerPassword"));
ldapConfig.setUserDnPattern("userDnPattern");
repository.updateLdap(ldapConfig);
AuthConfigEntity entity = new AuthConfigEntity();
entity.setLdap(ldapConfig);
AuthConfigEntity dbEntity = repository.findDefault();
Assert.assertThat(dbEntity.getLdap().getManagerPassword(), Matchers.is("managerPassword"));
}
use of com.epam.reportportal.auth.store.entity.AuthConfigEntity in project service-authorization by reportportal.
the class AuthConfigRepositoryImpl method createDefaultProfileIfAbsent.
@Override
public void createDefaultProfileIfAbsent() {
if (null == mongoOperations.findOne(findDefaultQuery(), AuthConfigEntity.class)) {
AuthConfigEntity entity = new AuthConfigEntity();
entity.setId(AuthConfigRepository.DEFAULT_PROFILE);
mongoOperations.save(entity);
}
}
use of com.epam.reportportal.auth.store.entity.AuthConfigEntity in project service-authorization by reportportal.
the class AuthAttributesEventListener method onAfterLoad.
@Override
public void onAfterLoad(AfterLoadEvent<AuthConfigEntity> event) {
Optional.ofNullable(event.getSource()).flatMap(dbo -> Optional.ofNullable(dbo.get("ldap"))).ifPresent(ldapDbo -> {
DBObject ldap = ((DBObject) ldapDbo);
Object managerPassword = ldap.get(MANAGER_PASSWORD_FIELD);
if (null != managerPassword) {
try {
String decrypted = encryptor.decrypt((String) managerPassword);
ldap.put(MANAGER_PASSWORD_FIELD, decrypted);
} catch (Exception e) {
LOGGER.error("Cannot decrypt password", e);
// do nothing
}
}
});
}
Aggregations