Commit 729241a4 authored by michael.simon's avatar michael.simon
Browse files

Delete password function

parent 1dbd3d52
......@@ -45,5 +45,8 @@ public interface RegisterUserService {
void updateGroups(Set<GroupEntity> groupUpdateSet, String executor)
throws RegisterException;
void deletePassword(UserEntity user, ServiceEntity service,
RegistryEntity registry, String executor) throws RegisterException;
}
......@@ -463,6 +463,32 @@ public class RegisterUserServiceImpl implements RegisterUserService {
}
}
@Override
public void deletePassword(UserEntity user, ServiceEntity service,
RegistryEntity registry, String executor) throws RegisterException {
RegisterUserWorkflow workflow = getWorkflowInstance(registry.getRegisterBean());
try {
ServiceEntity serviceEntity = serviceDao.findByIdWithServiceProps(registry.getService().getId());
UserEntity userEntity = userDao.findByIdWithAll(registry.getUser().getId());
ServiceRegisterAuditor auditor = new ServiceRegisterAuditor(auditDao, auditDetailDao, appConfig);
auditor.startAuditTrail(executor);
auditor.setName(workflow.getClass().getName() + "-DeletePassword-Audit");
auditor.setDetail("Delete service password for user " + registry.getUser().getEppn() + " for service " + serviceEntity.getName());
auditor.setRegistry(registry);
((SetPasswordCapable) workflow).deletePassword(userEntity, serviceEntity, registry, auditor);
auditor.finishAuditTrail();
} catch (RegisterException e) {
throw e;
} catch (Throwable t) {
throw new RegisterException(t);
}
}
@Override
public Boolean checkWorkflow(String name) {
if (getWorkflowInstance(name) != null) {
......
......@@ -121,6 +121,27 @@ public class SetServicePasswordBean implements Serializable {
return null;
}
public String deleteServicePassword() {
if (! (RegistryStatus.ACTIVE.equals(registryEntity.getRegistryStatus()) ||
RegistryStatus.LOST_ACCESS.equals(registryEntity.getRegistryStatus()))) {
FacesContext.getCurrentInstance().addMessage("pw_error", new FacesMessage(FacesMessage.SEVERITY_FATAL, "Fehler:", "Servicepasswort kann für diesen Dienst nicht gelöscht werden"));
return null;
}
RegisterUserWorkflow registerUserWorkflow = registerUserService.getWorkflowInstance(serviceEntity.getRegisterBean());
if (registerUserWorkflow instanceof SetPasswordCapable) {
try {
registerUserService.deletePassword(userEntity, serviceEntity, registryEntity, "user-self");
} catch (RegisterException e) {
FacesContext.getCurrentInstance().addMessage("pw_error", new FacesMessage(FacesMessage.SEVERITY_ERROR, "Konnte das Passwort nicht löschen:", e.getMessage()));
}
}
else
FacesContext.getCurrentInstance().addMessage("pw_error", new FacesMessage(FacesMessage.SEVERITY_FATAL, "Fehler:", "Servicepasswort kann für diesen Dienst nicht geslöscht werden"));
return null;
}
public Long getId() {
return id;
}
......
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