Commit 218da690 authored by michael.simon's avatar michael.simon
Browse files

make complete copy of ldap based register workflows

parent 2da470ee
...@@ -23,14 +23,12 @@ import edu.kit.scc.webreg.entity.ServiceEntity; ...@@ -23,14 +23,12 @@ import edu.kit.scc.webreg.entity.ServiceEntity;
import edu.kit.scc.webreg.entity.UserEntity; import edu.kit.scc.webreg.entity.UserEntity;
import edu.kit.scc.webreg.exc.RegisterException; import edu.kit.scc.webreg.exc.RegisterException;
import edu.kit.scc.webreg.service.reg.SetPasswordCapable; import edu.kit.scc.webreg.service.reg.SetPasswordCapable;
import edu.kit.scc.webreg.service.reg.ldap.AbstractSimpleGroupLdapRegisterWorkflow;
import edu.kit.scc.webreg.service.reg.ldap.LdapWorker;
import edu.kit.scc.webreg.service.reg.ldap.PropertyReader; import edu.kit.scc.webreg.service.reg.ldap.PropertyReader;
import jcifs.util.Hexdump; import jcifs.util.Hexdump;
import jcifs.util.MD4; import jcifs.util.MD4;
public abstract class AbstractSamba4RegisterWorkflow public abstract class AbstractSamba4RegisterWorkflow
extends AbstractSimpleGroupLdapRegisterWorkflow extends AbstractSimpleGroupSamba4RegisterWorkflow
implements SetPasswordCapable { implements SetPasswordCapable {
protected static Logger logger = LoggerFactory.getLogger(AbstractSamba4RegisterWorkflow.class); protected static Logger logger = LoggerFactory.getLogger(AbstractSamba4RegisterWorkflow.class);
...@@ -72,7 +70,7 @@ public abstract class AbstractSamba4RegisterWorkflow ...@@ -72,7 +70,7 @@ public abstract class AbstractSamba4RegisterWorkflow
ntPassword = calcNtPassword(password); ntPassword = calcNtPassword(password);
} }
LdapWorker ldapWorker = new LdapWorker(prop, auditor, isSambaEnabled()); Samba4Worker ldapWorker = new Samba4Worker(prop, auditor);
// SS: Password muss/soll für Samba4 gar nicht im LDAP auftauchen // SS: Password muss/soll für Samba4 gar nicht im LDAP auftauchen
if (isSambaEnabled()) { if (isSambaEnabled()) {
...@@ -90,7 +88,7 @@ public abstract class AbstractSamba4RegisterWorkflow ...@@ -90,7 +88,7 @@ public abstract class AbstractSamba4RegisterWorkflow
PropertyReader prop = PropertyReader.newRegisterPropReader(service); PropertyReader prop = PropertyReader.newRegisterPropReader(service);
Map<String, String> regMap = registry.getRegistryValues(); Map<String, String> regMap = registry.getRegistryValues();
String localUid = regMap.get("localUid"); String localUid = regMap.get("localUid");
LdapWorker ldapWorker = new LdapWorker(prop, auditor, isSambaEnabled()); Samba4Worker ldapWorker = new Samba4Worker(prop, auditor);
ldapWorker.deletePassword(localUid); ldapWorker.deletePassword(localUid);
ldapWorker.closeConnections(); ldapWorker.closeConnections();
} }
......
/*******************************************************************************
* Copyright (c) 2014 Michael Simon.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
*
* Contributors:
* Michael Simon - initial
******************************************************************************/
package edu.kit.scc.webreg.service.reg.samba;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import edu.kit.scc.webreg.audit.Auditor;
import edu.kit.scc.webreg.entity.GroupEntity;
import edu.kit.scc.webreg.entity.ServiceEntity;
import edu.kit.scc.webreg.entity.UserEntity;
import edu.kit.scc.webreg.exc.RegisterException;
import edu.kit.scc.webreg.service.reg.GroupCapable;
import edu.kit.scc.webreg.service.reg.impl.GroupUpdateStructure;
import edu.kit.scc.webreg.service.reg.ldap.PropertyReader;
public abstract class AbstractSimpleGroupSamba4RegisterWorkflow
extends AbstractSimpleSamba4RegisterWorkflow
implements GroupCapable {
protected static Logger logger = LoggerFactory.getLogger(AbstractSimpleGroupSamba4RegisterWorkflow.class);
protected abstract String constructHomeDir(String homeId, String homeUid, UserEntity user, Map<String, String> reconMap);
protected abstract String constructLocalUid(String homeId, String homeUid, UserEntity user, Map<String, String> reconMap);
protected abstract String constructGroupName(GroupEntity group);
protected abstract Boolean isSambaEnabled();
@Override
public void updateGroups(ServiceEntity service, GroupUpdateStructure updateStruct, Auditor auditor)
throws RegisterException {
PropertyReader prop = PropertyReader.newRegisterPropReader(service);
Samba4Worker ldapWorker = new Samba4Worker(prop, auditor);
for (GroupEntity group : updateStruct.getGroups()) {
long a = System.currentTimeMillis();
Set<UserEntity> users = updateStruct.getUsersForGroup(group);
logger.debug("Update Ldap Group for group {} and Service {}", group.getName(), service.getName());
Set<String> memberUids = new HashSet<String>(users.size());
Map<String, String> reconMap = new HashMap<String, String>();
for (UserEntity user : users) {
String homeId = user.getAttributeStore().get("http://bwidm.de/bwidmOrgId");
String homeUid = user.getAttributeStore().get("urn:oid:0.9.2342.19200300.100.1.1");
//Skip group member with incomplete data
if (homeId != null && homeUid != null) {
homeId = homeId.toLowerCase();
memberUids.add(constructLocalUid(homeId, homeUid, user, reconMap));
}
}
a = System.currentTimeMillis();
ldapWorker.reconGroup(constructGroupName(group), "" + group.getGidNumber(), memberUids);
logger.debug("reconGroup {} took {} ms", group.getName(), (System.currentTimeMillis() - a)); a = System.currentTimeMillis();
}
ldapWorker.closeConnections();
}
@Override
public void deleteGroup(GroupEntity group, ServiceEntity service, Auditor auditor)
throws RegisterException {
logger.debug("Delete Ldap Group for group {} and Service {}", group.getName(), service.getName());
PropertyReader prop = PropertyReader.newRegisterPropReader(service);
Samba4Worker ldapWorker = new Samba4Worker(prop, auditor);
ldapWorker.deleteGroup(constructGroupName(group));
ldapWorker.closeConnections();
}
}
...@@ -34,7 +34,6 @@ import edu.kit.scc.webreg.exc.RegisterException; ...@@ -34,7 +34,6 @@ import edu.kit.scc.webreg.exc.RegisterException;
import edu.kit.scc.webreg.service.reg.Infotainment; import edu.kit.scc.webreg.service.reg.Infotainment;
import edu.kit.scc.webreg.service.reg.InfotainmentCapable; import edu.kit.scc.webreg.service.reg.InfotainmentCapable;
import edu.kit.scc.webreg.service.reg.RegisterUserWorkflow; import edu.kit.scc.webreg.service.reg.RegisterUserWorkflow;
import edu.kit.scc.webreg.service.reg.ldap.LdapWorker;
import edu.kit.scc.webreg.service.reg.ldap.PropertyReader; import edu.kit.scc.webreg.service.reg.ldap.PropertyReader;
public abstract class AbstractSimpleSamba4RegisterWorkflow public abstract class AbstractSimpleSamba4RegisterWorkflow
...@@ -64,7 +63,7 @@ public abstract class AbstractSimpleSamba4RegisterWorkflow ...@@ -64,7 +63,7 @@ public abstract class AbstractSimpleSamba4RegisterWorkflow
String localUid = regMap.get("localUid"); String localUid = regMap.get("localUid");
LdapWorker ldapWorker = new LdapWorker(prop, auditor, isSambaEnabled()); Samba4Worker ldapWorker = new Samba4Worker(prop, auditor);
ldapWorker.deleteUser(localUid); ldapWorker.deleteUser(localUid);
ldapWorker.closeConnections(); ldapWorker.closeConnections();
} }
...@@ -204,7 +203,7 @@ public abstract class AbstractSimpleSamba4RegisterWorkflow ...@@ -204,7 +203,7 @@ public abstract class AbstractSimpleSamba4RegisterWorkflow
String homeDir = regMap.get("homeDir"); String homeDir = regMap.get("homeDir");
String description = registry.getId().toString(); String description = registry.getId().toString();
LdapWorker ldapWorker = new LdapWorker(prop, auditor, isSambaEnabled()); Samba4Worker ldapWorker = new Samba4Worker(prop, auditor);
ldapWorker.reconUser(cn, sn, givenName, mail, localUid, uidNumber, gidNumber, homeDir, description); ldapWorker.reconUser(cn, sn, givenName, mail, localUid, uidNumber, gidNumber, homeDir, description);
if (prop.hasProp("pw_location") && if (prop.hasProp("pw_location") &&
...@@ -228,7 +227,7 @@ public abstract class AbstractSimpleSamba4RegisterWorkflow ...@@ -228,7 +227,7 @@ public abstract class AbstractSimpleSamba4RegisterWorkflow
PropertyReader prop = PropertyReader.newRegisterPropReader(service); PropertyReader prop = PropertyReader.newRegisterPropReader(service);
Map<String, String> regMap = registry.getRegistryValues(); Map<String, String> regMap = registry.getRegistryValues();
String localUid = regMap.get("localUid"); String localUid = regMap.get("localUid");
LdapWorker ldapWorker = new LdapWorker(prop, null, isSambaEnabled()); Samba4Worker ldapWorker = new Samba4Worker(prop, null);
ldapWorker.getInfo(info, localUid); ldapWorker.getInfo(info, localUid);
...@@ -237,6 +236,12 @@ public abstract class AbstractSimpleSamba4RegisterWorkflow ...@@ -237,6 +236,12 @@ public abstract class AbstractSimpleSamba4RegisterWorkflow
return info; return info;
} }
@Override
public Infotainment getInfoForAdmin(RegistryEntity registry, UserEntity user,
ServiceEntity service) throws RegisterException {
return getInfo(registry, user, service);
}
protected String evalTemplate(String template, UserEntity user, Map<String, String> reconMap, String homeId, String homeUid) protected String evalTemplate(String template, UserEntity user, Map<String, String> reconMap, String homeId, String homeUid)
throws RegisterException { throws RegisterException {
VelocityEngine engine = new VelocityEngine(); VelocityEngine engine = new VelocityEngine();
......
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