use of org.springframework.data.mongodb.core.mapping.event.AfterLoadEvent 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