Commit 5416f081 authored by michael.simon's avatar michael.simon
Browse files

make service password location configurable via service properties

parent e04cfd30
......@@ -459,8 +459,18 @@ public class RegisterUserServiceImpl implements RegisterUserService {
auditor.setDetail("Setting service password for user " + registry.getUser().getEppn() + " for service " + serviceEntity.getName());
auditor.setRegistry(registry);
registry.getRegistryValues().put("userPassword", passwordUtil.generatePassword("SHA-512", password));
((SetPasswordCapable) workflow).setPassword(userEntity, serviceEntity, registry, auditor, password);
if (serviceEntity.getServiceProps().containsKey("pw_location") &&
serviceEntity.getServiceProps().get("pw_location").equalsIgnoreCase("registry")) {
registry.getRegistryValues().put("userPassword", passwordUtil.generatePassword("SHA-512", password));
}
if (serviceEntity.getServiceProps().containsKey("pw_location") &&
serviceEntity.getServiceProps().get("pw_location").equalsIgnoreCase("both")) {
registry.getRegistryValues().put("userPassword", passwordUtil.generatePassword("SHA-512", password));
((SetPasswordCapable) workflow).setPassword(userEntity, serviceEntity, registry, auditor, password);
}
else {
((SetPasswordCapable) workflow).setPassword(userEntity, serviceEntity, registry, auditor, password);
}
registry = registryDao.persist(registry);
......
......@@ -250,7 +250,9 @@ public abstract class AbstractLdapRegisterWorkflow
LdapWorker ldapWorker = new LdapWorker(prop, auditor, isSambaEnabled());
ldapWorker.reconUser(cn, sn, givenName, mail, localUid, uidNumber, gidNumber, homeDir, description);
if (! registry.getRegistryValues().containsKey("userPassword")) {
if ((prop.hasProp("pw_location") &&
(prop.readPropOrNull("pw_location").equalsIgnoreCase("registry")) || prop.readPropOrNull("pw_location").equalsIgnoreCase("both"))
&& (! registry.getRegistryValues().containsKey("userPassword"))) {
List<String> pwList = ldapWorker.getPasswords(localUid);
if (pwList.size() > 0) {
logger.debug("userPassword is not set in registry but in LDAP ({}). Importing from LDAP", pwList.size());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment