summaryrefslogtreecommitdiffstats
path: root/base/server/cmscore
diff options
context:
space:
mode:
authorEndi S. Dewata <edewata@redhat.com>2015-12-24 17:20:58 +0100
committerEndi S. Dewata <edewata@redhat.com>2016-01-18 16:45:13 +0100
commit2c88b5d9c15487a796f65beea6c102b1ef04016f (patch)
tree45130adc9e1c4cb0bfd3f5d927cfa4a78fd4cdcd /base/server/cmscore
parent77d6c95527f2f7299e3baece465ef9d778815745 (diff)
downloadpki-2c88b5d9c15487a796f65beea6c102b1ef04016f.tar.gz
pki-2c88b5d9c15487a796f65beea6c102b1ef04016f.tar.xz
pki-2c88b5d9c15487a796f65beea6c102b1ef04016f.zip
Added table to manage TPS user profiles.
The TPS UI has been modified to provide a table as an interface to manage the user profiles. When adding a profile, the profile can be selected from a list of available profiles. The UserService and UGSubsystem have been modified to allow adding a user with no assigned profiles. https://fedorahosted.org/pki/ticket/1478
Diffstat (limited to 'base/server/cmscore')
-rw-r--r--base/server/cmscore/src/com/netscape/cmscore/usrgrp/UGSubsystem.java86
1 files changed, 30 insertions, 56 deletions
diff --git a/base/server/cmscore/src/com/netscape/cmscore/usrgrp/UGSubsystem.java b/base/server/cmscore/src/com/netscape/cmscore/usrgrp/UGSubsystem.java
index d1277279e..a11c551e5 100644
--- a/base/server/cmscore/src/com/netscape/cmscore/usrgrp/UGSubsystem.java
+++ b/base/server/cmscore/src/com/netscape/cmscore/usrgrp/UGSubsystem.java
@@ -25,19 +25,6 @@ import java.util.Enumeration;
import java.util.List;
import java.util.Vector;
-import netscape.ldap.LDAPAttribute;
-import netscape.ldap.LDAPAttributeSet;
-import netscape.ldap.LDAPConnection;
-import netscape.ldap.LDAPDN;
-import netscape.ldap.LDAPEntry;
-import netscape.ldap.LDAPException;
-import netscape.ldap.LDAPModification;
-import netscape.ldap.LDAPModificationSet;
-import netscape.ldap.LDAPSearchConstraints;
-import netscape.ldap.LDAPSearchResults;
-import netscape.ldap.LDAPv2;
-import netscape.security.x509.X509CertImpl;
-
import org.apache.commons.lang.StringUtils;
import com.netscape.certsrv.apps.CMS;
@@ -60,6 +47,19 @@ import com.netscape.cmscore.ldapconn.LdapBoundConnFactory;
import com.netscape.cmscore.util.Debug;
import com.netscape.cmsutil.ldap.LDAPUtil;
+import netscape.ldap.LDAPAttribute;
+import netscape.ldap.LDAPAttributeSet;
+import netscape.ldap.LDAPConnection;
+import netscape.ldap.LDAPDN;
+import netscape.ldap.LDAPEntry;
+import netscape.ldap.LDAPException;
+import netscape.ldap.LDAPModification;
+import netscape.ldap.LDAPModificationSet;
+import netscape.ldap.LDAPSearchConstraints;
+import netscape.ldap.LDAPSearchResults;
+import netscape.ldap.LDAPv2;
+import netscape.security.x509.X509CertImpl;
+
/**
* This class defines low-level LDAP usr/grp management
* usr/grp information is located remotely on another
@@ -738,11 +738,15 @@ public final class UGSubsystem implements IUGSubsystem {
}
// TODO add audit logging for profile
- if (id.getTpsProfiles() != null) {
- List<String> profiles = id.getTpsProfiles();
- for (String profile: profiles) {
- attrs.add(new LDAPAttribute(LDAP_ATTR_PROFILE_ID, profile));
+ List<String> profiles = id.getTpsProfiles();
+ if (profiles != null && profiles.size() > 0) {
+ CMS.debug("Adding " + LDAP_ATTR_PROFILE_ID + ":");
+ LDAPAttribute attr = new LDAPAttribute(LDAP_ATTR_PROFILE_ID);
+ for (String profile : profiles) {
+ CMS.debug(" - " + profile);
+ attr.addValue(profile);
}
+ attrs.add(attr);
}
LDAPEntry entry = new LDAPEntry("uid=" + LDAPUtil.escapeRDNValue(id.getUserID()) +
@@ -763,12 +767,14 @@ public final class UGSubsystem implements IUGSubsystem {
ldapconn.add(entry);
} catch (LDAPException e) {
+ CMS.debug(e);
log(ILogger.LL_FAILURE, CMS.getLogMessage("CMSCORE_USRGRP_ADD_USER", e.toString()));
throw LDAPExceptionConverter.toPKIException(e);
} catch (ELdapException e) {
+ CMS.debug(e);
log(ILogger.LL_FAILURE, CMS.getLogMessage("CMSCORE_USRGRP_ADD_USER", e.toString()));
- throw new EUsrGrpException(CMS.getUserMessage("CMS_USRGRP_ADD_USER_FAIL"));
+ throw new EUsrGrpException(CMS.getUserMessage("CMS_USRGRP_ADD_USER_FAIL"), e);
} finally {
if (ldapconn != null)
@@ -1229,7 +1235,8 @@ public final class UGSubsystem implements IUGSubsystem {
}
}
- if (user.getTpsProfiles() != null) {
+ List<String> profiles = user.getTpsProfiles();
+ if (profiles != null) {
// TODO add audit logging for profile
// replace the objectclass in case tpsProfile is not present
@@ -1238,44 +1245,11 @@ public final class UGSubsystem implements IUGSubsystem {
attrs.add(LDAPModification.REPLACE,
new LDAPAttribute(OBJECTCLASS_ATTR, oc));
- User ldapUser = (User) getUser(user.getUserID());
- List<String> oldProfiles = ldapUser.getTpsProfiles();
- List<String> profiles = user.getTpsProfiles();
-
- if (oldProfiles == null) {
- for (String profile : profiles) {
- attrs.add(LDAPModification.ADD,
- new LDAPAttribute(LDAP_ATTR_PROFILE_ID, profile));
- }
- } else {
- for (String profile : profiles) {
- boolean found = false;
- for (String oldProfile : oldProfiles) {
- if (profile.equals(oldProfile)) {
- found = true;
- break;
- }
- }
- if (!found) {
- attrs.add(LDAPModification.ADD,
- new LDAPAttribute(LDAP_ATTR_PROFILE_ID, profile));
- }
- }
-
- for (String oldProfile : oldProfiles) {
- boolean found = false;
- for (String profile : profiles) {
- if (profile.equals(oldProfile)) {
- found = true;
- break;
- }
- }
- if (!found) {
- attrs.add(LDAPModification.DELETE,
- new LDAPAttribute(LDAP_ATTR_PROFILE_ID, oldProfile));
- }
- }
+ LDAPAttribute attr = new LDAPAttribute(LDAP_ATTR_PROFILE_ID);
+ for (String profile : profiles) {
+ attr.addValue(profile);
}
+ attrs.add(LDAPModification.REPLACE, attr);
}
/**