summaryrefslogtreecommitdiffstats
path: root/base/server/cms/src/com/netscape/cms/servlet/csadmin/ConfigurationUtils.java
diff options
context:
space:
mode:
authorEndi S. Dewata <edewata@redhat.com>2013-11-05 11:10:15 -0500
committerEndi S. Dewata <edewata@redhat.com>2013-11-07 11:49:38 -0500
commit66eabd97adafa95f97215202a825d73f5fca7692 (patch)
treed5759739e4bd0042e0d02124ad351d8b3cfb0040 /base/server/cms/src/com/netscape/cms/servlet/csadmin/ConfigurationUtils.java
parent89eebe6729b8a7ed53441649d0baa98c98fdfa7f (diff)
downloadpki-66eabd97adafa95f97215202a825d73f5fca7692.tar.gz
pki-66eabd97adafa95f97215202a825d73f5fca7692.tar.xz
pki-66eabd97adafa95f97215202a825d73f5fca7692.zip
Fixed return code for user and group services.
The user and group services have been modified to return consistent HTTP return codes under various situations. The UGSubsystem has been modified to capture any LDAP exceptions and throw the proper PKIException subclass that represents the appropriate HTTP error code for the situation. Ticket #669, #749
Diffstat (limited to 'base/server/cms/src/com/netscape/cms/servlet/csadmin/ConfigurationUtils.java')
-rw-r--r--base/server/cms/src/com/netscape/cms/servlet/csadmin/ConfigurationUtils.java21
1 files changed, 8 insertions, 13 deletions
diff --git a/base/server/cms/src/com/netscape/cms/servlet/csadmin/ConfigurationUtils.java b/base/server/cms/src/com/netscape/cms/servlet/csadmin/ConfigurationUtils.java
index bbfb17374..b2634f6c2 100644
--- a/base/server/cms/src/com/netscape/cms/servlet/csadmin/ConfigurationUtils.java
+++ b/base/server/cms/src/com/netscape/cms/servlet/csadmin/ConfigurationUtils.java
@@ -137,6 +137,7 @@ import com.netscape.certsrv.apps.CMS;
import com.netscape.certsrv.authentication.EAuthException;
import com.netscape.certsrv.authentication.IAuthSubsystem;
import com.netscape.certsrv.authorization.IAuthzSubsystem;
+import com.netscape.certsrv.base.ConflictingOperationException;
import com.netscape.certsrv.base.EBaseException;
import com.netscape.certsrv.base.EPropertyNotFound;
import com.netscape.certsrv.base.IConfigStore;
@@ -3121,7 +3122,7 @@ public class ConfigurationUtils {
}
public static void createAdmin(String uid, String email, String name, String pwd) throws IOException,
- EBaseException {
+ EBaseException, LDAPException {
IUGSubsystem system = (IUGSubsystem) (CMS.getSubsystem(IUGSubsystem.ID));
IConfigStore config = CMS.getConfigStore();
String groupNames = config.getString("preop.admin.group", "Certificate Manager Agents,Administrators");
@@ -3137,14 +3138,10 @@ public class ConfigurationUtils {
user.setState("1");
user.setPhone("");
system.addUser(user);
- } catch (LDAPException e) {
- CMS.debug("AdminPanel createAdmin: addUser " + e.toString());
- if (e.getLDAPResultCode() != LDAPException.ENTRY_ALREADY_EXISTS) {
- throw new IOException(e.toString());
- }
- } catch (Exception e) {
+
+ } catch (ConflictingOperationException e) {
CMS.debug("AdminPanel createAdmin: addUser " + e.toString());
- throw new IOException(e.toString());
+ // ignore
}
IGroup group = null;
@@ -3529,10 +3526,8 @@ public class ConfigurationUtils {
user.setX509Certificates(certs);
try {
system.addUser(user);
- } catch (LDAPException e) {
- if (e.getLDAPResultCode() != LDAPException.ENTRY_ALREADY_EXISTS) {
- throw e;
- }
+ } catch (ConflictingOperationException e) {
+ // ignore if
}
CMS.debug("DonePanel display: successfully add the user");
system.addUserCert(user);
@@ -3777,7 +3772,7 @@ public class ConfigurationUtils {
removeOldDBUsers(certs[0].getSubjectDN().toString());
}
- public static void addProfilesToTPSUser(String adminID) throws EUsrGrpException {
+ public static void addProfilesToTPSUser(String adminID) throws EUsrGrpException, LDAPException {
CMS.debug("Adding all profiles to TPS admin user");
IUGSubsystem system = (IUGSubsystem) CMS.getSubsystem(IUGSubsystem.ID);
IUser user = system.getUser(adminID);