diff options
Diffstat (limited to 'base/common/src/com/netscape/cms/servlet/admin')
-rw-r--r-- | base/common/src/com/netscape/cms/servlet/admin/GroupMemberService.java (renamed from base/common/src/com/netscape/cms/servlet/admin/GroupMemberResourceService.java) | 40 | ||||
-rw-r--r-- | base/common/src/com/netscape/cms/servlet/admin/GroupService.java (renamed from base/common/src/com/netscape/cms/servlet/admin/GroupResourceService.java) | 38 | ||||
-rw-r--r-- | base/common/src/com/netscape/cms/servlet/admin/SystemCertService.java (renamed from base/common/src/com/netscape/cms/servlet/admin/SystemCertificateResourceService.java) | 9 | ||||
-rw-r--r-- | base/common/src/com/netscape/cms/servlet/admin/SystemCertificateResource.java | 25 | ||||
-rw-r--r-- | base/common/src/com/netscape/cms/servlet/admin/UserCertService.java (renamed from base/common/src/com/netscape/cms/servlet/admin/UserCertResourceService.java) | 60 | ||||
-rw-r--r-- | base/common/src/com/netscape/cms/servlet/admin/UserService.java (renamed from base/common/src/com/netscape/cms/servlet/admin/UserResourceService.java) | 54 |
6 files changed, 101 insertions, 125 deletions
diff --git a/base/common/src/com/netscape/cms/servlet/admin/GroupMemberResourceService.java b/base/common/src/com/netscape/cms/servlet/admin/GroupMemberService.java index c192815aa..0854be3aa 100644 --- a/base/common/src/com/netscape/cms/servlet/admin/GroupMemberResourceService.java +++ b/base/common/src/com/netscape/cms/servlet/admin/GroupMemberService.java @@ -31,6 +31,7 @@ import org.jboss.resteasy.plugins.providers.atom.Link; import com.netscape.certsrv.apps.CMS; import com.netscape.certsrv.base.EBaseException; import com.netscape.certsrv.base.IConfigStore; +import com.netscape.certsrv.base.PKIException; import com.netscape.certsrv.base.SessionContext; import com.netscape.certsrv.common.OpDef; import com.netscape.certsrv.common.ScopeDef; @@ -43,13 +44,12 @@ import com.netscape.certsrv.logging.ILogger; import com.netscape.certsrv.user.UserResource; import com.netscape.certsrv.usrgrp.IGroup; import com.netscape.certsrv.usrgrp.IUGSubsystem; -import com.netscape.cms.servlet.base.CMSException; -import com.netscape.cms.servlet.base.CMSResourceService; +import com.netscape.cms.servlet.base.PKIService; /** * @author Endi S. Dewata */ -public class GroupMemberResourceService extends CMSResourceService implements GroupMemberResource { +public class GroupMemberService extends PKIService implements GroupMemberResource { public final static int DEFAULT_SIZE = 20; @@ -81,13 +81,13 @@ public class GroupMemberResourceService extends CMSResourceService implements Gr if (groupID == null) { log(ILogger.LL_FAILURE, CMS.getLogMessage("ADMIN_SRVLT_NULL_RS_ID")); - throw new CMSException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID")); + throw new PKIException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID")); } IGroup group = userGroupManager.getGroupFromName(groupID); if (group == null) { log(ILogger.LL_FAILURE, CMS.getLogMessage("USRGRP_SRVLT_GROUP_NOT_EXIST")); - throw new CMSException(getUserMessage("CMS_USRGRP_SRVLT_GROUP_NOT_EXIST")); + throw new PKIException(getUserMessage("CMS_USRGRP_SRVLT_GROUP_NOT_EXIST")); } GroupMemberCollection response = new GroupMemberCollection(); @@ -120,12 +120,12 @@ public class GroupMemberResourceService extends CMSResourceService implements Gr return response; - } catch (CMSException e) { + } catch (PKIException e) { throw e; } catch (Exception e) { CMS.debug(e); - throw new CMSException(getUserMessage("CMS_INTERNAL_ERROR")); + throw new PKIException(getUserMessage("CMS_INTERNAL_ERROR")); } } @@ -141,13 +141,13 @@ public class GroupMemberResourceService extends CMSResourceService implements Gr try { if (groupID == null) { log(ILogger.LL_FAILURE, CMS.getLogMessage("ADMIN_SRVLT_NULL_RS_ID")); - throw new CMSException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID")); + throw new PKIException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID")); } IGroup group = userGroupManager.getGroupFromName(groupID); if (group == null) { log(ILogger.LL_FAILURE, CMS.getLogMessage("USRGRP_SRVLT_GROUP_NOT_EXIST")); - throw new CMSException(getUserMessage("CMS_USRGRP_SRVLT_GROUP_NOT_EXIST")); + throw new PKIException(getUserMessage("CMS_USRGRP_SRVLT_GROUP_NOT_EXIST")); } String memberID = groupMemberData.getID(); @@ -199,14 +199,14 @@ public class GroupMemberResourceService extends CMSResourceService implements Gr .type(MediaType.APPLICATION_XML) .build(); - } catch (CMSException e) { + } catch (PKIException e) { auditAddGroupMember(groupID, groupMemberData, ILogger.FAILURE); throw e; } catch (Exception e) { log(ILogger.LL_FAILURE, e.toString()); auditAddGroupMember(groupID, groupMemberData, ILogger.FAILURE); - throw new CMSException(getUserMessage("CMS_USRGRP_USER_ADD_FAILED")); + throw new PKIException(getUserMessage("CMS_USRGRP_USER_ADD_FAILED")); } } @@ -289,13 +289,13 @@ public class GroupMemberResourceService extends CMSResourceService implements Gr try { if (groupID == null) { log(ILogger.LL_FAILURE, CMS.getLogMessage("ADMIN_SRVLT_NULL_RS_ID")); - throw new CMSException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID")); + throw new PKIException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID")); } IGroup group = userGroupManager.getGroupFromName(groupID); if (group == null) { log(ILogger.LL_FAILURE, CMS.getLogMessage("USRGRP_SRVLT_GROUP_NOT_EXIST")); - throw new CMSException(getUserMessage("CMS_USRGRP_SRVLT_GROUP_NOT_EXIST")); + throw new PKIException(getUserMessage("CMS_USRGRP_SRVLT_GROUP_NOT_EXIST")); } Enumeration<String> e = group.getMemberNames(); @@ -307,14 +307,14 @@ public class GroupMemberResourceService extends CMSResourceService implements Gr return groupMemberData; } - throw new CMSException("Group member not found"); + throw new PKIException("Group member not found"); - } catch (CMSException e) { + } catch (PKIException e) { throw e; } catch (Exception e) { log(ILogger.LL_FAILURE, e.toString()); - throw new CMSException(e.getMessage()); + throw new PKIException(e.getMessage()); } } @@ -329,13 +329,13 @@ public class GroupMemberResourceService extends CMSResourceService implements Gr try { if (groupID == null) { log(ILogger.LL_FAILURE, CMS.getLogMessage("ADMIN_SRVLT_NULL_RS_ID")); - throw new CMSException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID")); + throw new PKIException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID")); } IGroup group = userGroupManager.getGroupFromName(groupID); if (group == null) { log(ILogger.LL_FAILURE, CMS.getLogMessage("USRGRP_SRVLT_GROUP_NOT_EXIST")); - throw new CMSException(getUserMessage("CMS_USRGRP_SRVLT_GROUP_NOT_EXIST")); + throw new PKIException(getUserMessage("CMS_USRGRP_SRVLT_GROUP_NOT_EXIST")); } String member = groupMemberData.getID(); @@ -351,14 +351,14 @@ public class GroupMemberResourceService extends CMSResourceService implements Gr auditDeleteGroupMember(groupID, groupMemberData, ILogger.SUCCESS); - } catch (CMSException e) { + } catch (PKIException e) { auditDeleteGroupMember(groupID, groupMemberData, ILogger.FAILURE); throw e; } catch (Exception e) { log(ILogger.LL_FAILURE, e.toString()); auditDeleteGroupMember(groupID, groupMemberData, ILogger.FAILURE); - throw new CMSException(getUserMessage("CMS_USRGRP_USER_ADD_FAILED")); + throw new PKIException(getUserMessage("CMS_USRGRP_USER_ADD_FAILED")); } } diff --git a/base/common/src/com/netscape/cms/servlet/admin/GroupResourceService.java b/base/common/src/com/netscape/cms/servlet/admin/GroupService.java index ce665ae3e..b82df9a2f 100644 --- a/base/common/src/com/netscape/cms/servlet/admin/GroupResourceService.java +++ b/base/common/src/com/netscape/cms/servlet/admin/GroupService.java @@ -31,6 +31,7 @@ import org.jboss.resteasy.plugins.providers.atom.Link; import com.netscape.certsrv.apps.CMS; import com.netscape.certsrv.base.EBaseException; +import com.netscape.certsrv.base.PKIException; import com.netscape.certsrv.common.OpDef; import com.netscape.certsrv.common.ScopeDef; import com.netscape.certsrv.group.GroupCollection; @@ -40,14 +41,13 @@ import com.netscape.certsrv.logging.IAuditor; import com.netscape.certsrv.logging.ILogger; import com.netscape.certsrv.usrgrp.IGroup; import com.netscape.certsrv.usrgrp.IUGSubsystem; -import com.netscape.cms.servlet.base.CMSException; -import com.netscape.cms.servlet.base.CMSResourceService; +import com.netscape.cms.servlet.base.PKIService; import com.netscape.cmsutil.ldap.LDAPUtil; /** * @author Endi S. Dewata */ -public class GroupResourceService extends CMSResourceService implements GroupResource { +public class GroupService extends PKIService implements GroupResource { public final static int DEFAULT_SIZE = 20; @@ -115,7 +115,7 @@ public class GroupResourceService extends CMSResourceService implements GroupRes return response; } catch (Exception e) { - throw new CMSException(getUserMessage("CMS_INTERNAL_ERROR")); + throw new PKIException(getUserMessage("CMS_INTERNAL_ERROR")); } } @@ -131,22 +131,22 @@ public class GroupResourceService extends CMSResourceService implements GroupRes try { if (groupID == null) { log(ILogger.LL_FAILURE, CMS.getLogMessage("ADMIN_SRVLT_NULL_RS_ID")); - throw new CMSException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID")); + throw new PKIException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID")); } IGroup group = userGroupManager.getGroupFromName(groupID); if (group == null) { log(ILogger.LL_FAILURE, CMS.getLogMessage("USRGRP_SRVLT_GROUP_NOT_EXIST")); - throw new CMSException(getUserMessage("CMS_USRGRP_SRVLT_GROUP_NOT_EXIST")); + throw new PKIException(getUserMessage("CMS_USRGRP_SRVLT_GROUP_NOT_EXIST")); } return createGroupData(group); - } catch (CMSException e) { + } catch (PKIException e) { throw e; } catch (Exception e) { - throw new CMSException(getUserMessage("CMS_INTERNAL_ERROR")); + throw new PKIException(getUserMessage("CMS_INTERNAL_ERROR")); } } @@ -173,7 +173,7 @@ public class GroupResourceService extends CMSResourceService implements GroupRes try { if (groupID == null) { log(ILogger.LL_FAILURE, CMS.getLogMessage("ADMIN_SRVLT_NULL_RS_ID")); - throw new CMSException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID")); + throw new PKIException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID")); } IGroup group = userGroupManager.createGroup(groupID); @@ -201,16 +201,16 @@ public class GroupResourceService extends CMSResourceService implements GroupRes .build(); } catch (Exception e) { - throw new CMSException(getUserMessage("CMS_USRGRP_GROUP_ADD_FAILED")); + throw new PKIException(getUserMessage("CMS_USRGRP_GROUP_ADD_FAILED")); } - } catch (CMSException e) { + } catch (PKIException e) { auditAddGroup(groupID, groupData, ILogger.FAILURE); throw e; } catch (EBaseException e) { auditAddGroup(groupID, groupData, ILogger.FAILURE); - throw new CMSException(e.getMessage()); + throw new PKIException(e.getMessage()); } } @@ -237,7 +237,7 @@ public class GroupResourceService extends CMSResourceService implements GroupRes try { if (groupID == null) { log(ILogger.LL_FAILURE, CMS.getLogMessage("ADMIN_SRVLT_NULL_RS_ID")); - throw new CMSException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID")); + throw new PKIException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID")); } IGroup group = userGroupManager.getGroupFromName(groupID); @@ -261,16 +261,16 @@ public class GroupResourceService extends CMSResourceService implements GroupRes } catch (Exception e) { log(ILogger.LL_FAILURE, e.toString()); - throw new CMSException(getUserMessage("CMS_USRGRP_GROUP_MODIFY_FAILED")); + throw new PKIException(getUserMessage("CMS_USRGRP_GROUP_MODIFY_FAILED")); } - } catch (CMSException e) { + } catch (PKIException e) { auditModifyGroup(groupID, groupData, ILogger.FAILURE); throw e; } catch (EBaseException e) { auditModifyGroup(groupID, groupData, ILogger.FAILURE); - throw new CMSException(e.getMessage()); + throw new PKIException(e.getMessage()); } } @@ -295,7 +295,7 @@ public class GroupResourceService extends CMSResourceService implements GroupRes try { if (groupID == null) { log(ILogger.LL_FAILURE, CMS.getLogMessage("ADMIN_SRVLT_NULL_RS_ID")); - throw new CMSException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID")); + throw new PKIException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID")); } // if fails, let the exception fall through @@ -303,13 +303,13 @@ public class GroupResourceService extends CMSResourceService implements GroupRes auditDeleteGroup(groupID, ILogger.SUCCESS); - } catch (CMSException e) { + } catch (PKIException e) { auditDeleteGroup(groupID, ILogger.FAILURE); throw e; } catch (EBaseException e) { auditDeleteGroup(groupID, ILogger.FAILURE); - throw new CMSException(e.getMessage()); + throw new PKIException(e.getMessage()); } } diff --git a/base/common/src/com/netscape/cms/servlet/admin/SystemCertificateResourceService.java b/base/common/src/com/netscape/cms/servlet/admin/SystemCertService.java index 72106a903..bd84f1141 100644 --- a/base/common/src/com/netscape/cms/servlet/admin/SystemCertificateResourceService.java +++ b/base/common/src/com/netscape/cms/servlet/admin/SystemCertService.java @@ -24,10 +24,11 @@ import javax.ws.rs.WebApplicationException; import javax.ws.rs.core.Response; import com.netscape.certsrv.apps.CMS; +import com.netscape.certsrv.cert.CertData; import com.netscape.certsrv.kra.IKeyRecoveryAuthority; import com.netscape.certsrv.security.ITransportKeyUnit; -import com.netscape.cms.servlet.base.CMSResourceService; -import com.netscape.cms.servlet.cert.model.CertificateData; +import com.netscape.certsrv.system.SystemCertificateResource; +import com.netscape.cms.servlet.base.PKIService; /** * This is the class used to list, retrieve and modify system certificates for all Java subsystems. @@ -35,13 +36,13 @@ import com.netscape.cms.servlet.cert.model.CertificateData; * @author alee * */ -public class SystemCertificateResourceService extends CMSResourceService implements SystemCertificateResource { +public class SystemCertService extends PKIService implements SystemCertificateResource { /** * Used to retrieve the transport certificate */ public Response getTransportCert() { - CertificateData cert = null; + CertData cert = null; IKeyRecoveryAuthority kra = null; // auth and authz diff --git a/base/common/src/com/netscape/cms/servlet/admin/SystemCertificateResource.java b/base/common/src/com/netscape/cms/servlet/admin/SystemCertificateResource.java deleted file mode 100644 index aaf3fa129..000000000 --- a/base/common/src/com/netscape/cms/servlet/admin/SystemCertificateResource.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.netscape.cms.servlet.admin; - -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - -import org.jboss.resteasy.annotations.ClientResponseType; - -import com.netscape.cms.servlet.cert.model.CertificateData; - -@Path("config/cert") -public interface SystemCertificateResource { - - /** - * Used to retrieve the transport certificate - */ - @GET - @Path("transport") - @ClientResponseType(entityType=CertificateData.class) - @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) - public Response getTransportCert(); - -}
\ No newline at end of file diff --git a/base/common/src/com/netscape/cms/servlet/admin/UserCertResourceService.java b/base/common/src/com/netscape/cms/servlet/admin/UserCertService.java index e0e2ddfde..16a584ff8 100644 --- a/base/common/src/com/netscape/cms/servlet/admin/UserCertResourceService.java +++ b/base/common/src/com/netscape/cms/servlet/admin/UserCertService.java @@ -40,6 +40,7 @@ import org.mozilla.jss.crypto.InternalCertificate; import com.netscape.certsrv.apps.CMS; import com.netscape.certsrv.base.ICertPrettyPrint; +import com.netscape.certsrv.base.PKIException; import com.netscape.certsrv.common.OpDef; import com.netscape.certsrv.common.ScopeDef; import com.netscape.certsrv.dbs.certdb.CertId; @@ -50,15 +51,14 @@ import com.netscape.certsrv.user.UserCertData; import com.netscape.certsrv.user.UserCertResource; import com.netscape.certsrv.usrgrp.IUGSubsystem; import com.netscape.certsrv.usrgrp.IUser; -import com.netscape.cms.servlet.base.CMSException; -import com.netscape.cms.servlet.base.CMSResourceService; +import com.netscape.cms.servlet.base.PKIService; import com.netscape.cmsutil.util.Cert; import com.netscape.cmsutil.util.Utils; /** * @author Endi S. Dewata */ -public class UserCertResourceService extends CMSResourceService implements UserCertResource { +public class UserCertService extends PKIService implements UserCertResource { public final static int DEFAULT_SIZE = 20; @@ -96,7 +96,7 @@ public class UserCertResourceService extends CMSResourceService implements UserC if (userID == null) { log(ILogger.LL_FAILURE, CMS.getLogMessage("ADMIN_SRVLT_NULL_RS_ID")); - throw new CMSException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID")); + throw new PKIException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID")); } IUser user = null; @@ -104,12 +104,12 @@ public class UserCertResourceService extends CMSResourceService implements UserC try { user = userGroupManager.getUser(userID); } catch (Exception e) { - throw new CMSException(getUserMessage("CMS_USRGRP_SRVLT_USER_NOT_EXIST")); + throw new PKIException(getUserMessage("CMS_USRGRP_SRVLT_USER_NOT_EXIST")); } if (user == null) { log(ILogger.LL_FAILURE, CMS.getLogMessage("USRGRP_SRVLT_USER_NOT_EXIST")); - throw new CMSException(getUserMessage("CMS_USRGRP_SRVLT_USER_NOT_EXIST")); + throw new PKIException(getUserMessage("CMS_USRGRP_SRVLT_USER_NOT_EXIST")); } UserCertCollection response = new UserCertCollection(); @@ -134,11 +134,11 @@ public class UserCertResourceService extends CMSResourceService implements UserC return response; - } catch (CMSException e) { + } catch (PKIException e) { throw e; } catch (Exception e) { - throw new CMSException(e.getMessage()); + throw new PKIException(e.getMessage()); } } @@ -148,7 +148,7 @@ public class UserCertResourceService extends CMSResourceService implements UserC if (userID == null) { log(ILogger.LL_FAILURE, CMS.getLogMessage("ADMIN_SRVLT_NULL_RS_ID")); - throw new CMSException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID")); + throw new PKIException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID")); } IUser user = null; @@ -156,24 +156,24 @@ public class UserCertResourceService extends CMSResourceService implements UserC try { user = userGroupManager.getUser(userID); } catch (Exception e) { - throw new CMSException(getUserMessage("CMS_USRGRP_SRVLT_USER_NOT_EXIST")); + throw new PKIException(getUserMessage("CMS_USRGRP_SRVLT_USER_NOT_EXIST")); } if (user == null) { log(ILogger.LL_FAILURE, CMS.getLogMessage("USRGRP_SRVLT_USER_NOT_EXIST")); - throw new CMSException(getUserMessage("CMS_USRGRP_SRVLT_USER_NOT_EXIST")); + throw new PKIException(getUserMessage("CMS_USRGRP_SRVLT_USER_NOT_EXIST")); } X509Certificate[] certs = user.getX509Certificates(); if (certs == null) { - throw new CMSException("Certificate not found"); + throw new PKIException("Certificate not found"); } try { certID = URLDecoder.decode(certID, "UTF-8"); } catch (Exception e) { - throw new CMSException(e.getMessage()); + throw new PKIException(e.getMessage()); } for (X509Certificate cert : certs) { @@ -192,13 +192,13 @@ public class UserCertResourceService extends CMSResourceService implements UserC return userCertData; } - throw new CMSException("Certificate not found"); + throw new PKIException("Certificate not found"); - } catch (CMSException e) { + } catch (PKIException e) { throw e; } catch (Exception e) { - throw new CMSException(e.getMessage()); + throw new PKIException(e.getMessage()); } } @@ -223,7 +223,7 @@ public class UserCertResourceService extends CMSResourceService implements UserC try { if (userID == null) { log(ILogger.LL_FAILURE, CMS.getLogMessage("ADMIN_SRVLT_NULL_RS_ID")); - throw new CMSException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID")); + throw new PKIException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID")); } IUser user = userGroupManager.createUser(userID); @@ -266,7 +266,7 @@ public class UserCertResourceService extends CMSResourceService implements UserC X509Certificate p7certs[] = pkcs7.getCertificates(); if (p7certs.length == 0) { - throw new CMSException(getUserMessage("CMS_USRGRP_SRVLT_CERT_ERROR")); + throw new PKIException(getUserMessage("CMS_USRGRP_SRVLT_CERT_ERROR")); } // fix for 370099 - cert ordering can not be assumed @@ -292,7 +292,7 @@ public class UserCertResourceService extends CMSResourceService implements UserC } else { // not a chain, or in random order CMS.debug("UserCertResourceService: " + CMS.getLogMessage("ADMIN_SRVLT_CERT_BAD_CHAIN")); - throw new CMSException(getUserMessage("CMS_USRGRP_SRVLT_CERT_ERROR")); + throw new PKIException(getUserMessage("CMS_USRGRP_SRVLT_CERT_ERROR")); } CMS.debug("UserCertResourceService: " @@ -343,7 +343,7 @@ public class UserCertResourceService extends CMSResourceService implements UserC */ } catch (Exception e) { log(ILogger.LL_FAILURE, CMS.getLogMessage("USRGRP_SRVLT_CERT_ERROR", e.toString())); - throw new CMSException(getUserMessage("CMS_USRGRP_SRVLT_CERT_ERROR")); + throw new PKIException(getUserMessage("CMS_USRGRP_SRVLT_CERT_ERROR")); } } @@ -375,29 +375,29 @@ public class UserCertResourceService extends CMSResourceService implements UserC } catch (CertificateExpiredException e) { log(ILogger.LL_FAILURE, CMS.getLogMessage("ADMIN_SRVLT_ADD_CERT_EXPIRED", String.valueOf(cert.getSubjectDN()))); - throw new CMSException(getUserMessage("CMS_USRGRP_SRVLT_CERT_EXPIRED")); + throw new PKIException(getUserMessage("CMS_USRGRP_SRVLT_CERT_EXPIRED")); } catch (CertificateNotYetValidException e) { log(ILogger.LL_FAILURE, CMS.getLogMessage("USRGRP_SRVLT_CERT_NOT_YET_VALID", String.valueOf(cert.getSubjectDN()))); - throw new CMSException(getUserMessage("CMS_USRGRP_SRVLT_CERT_NOT_YET_VALID")); + throw new PKIException(getUserMessage("CMS_USRGRP_SRVLT_CERT_NOT_YET_VALID")); } catch (LDAPException e) { if (e.getLDAPResultCode() == LDAPException.ATTRIBUTE_OR_VALUE_EXISTS) { - throw new CMSException(getUserMessage("CMS_USRGRP_SRVLT_USER_CERT_EXISTS")); + throw new PKIException(getUserMessage("CMS_USRGRP_SRVLT_USER_CERT_EXISTS")); } else { - throw new CMSException(getUserMessage("CMS_USRGRP_USER_MOD_FAILED")); + throw new PKIException(getUserMessage("CMS_USRGRP_USER_MOD_FAILED")); } } - } catch (CMSException e) { + } catch (PKIException e) { auditAddUserCert(userID, userCertData, ILogger.FAILURE); throw e; } catch (Exception e) { log(ILogger.LL_FAILURE, e.toString()); auditAddUserCert(userID, userCertData, ILogger.FAILURE); - throw new CMSException(getUserMessage("CMS_USRGRP_USER_MOD_FAILED")); + throw new PKIException(getUserMessage("CMS_USRGRP_USER_MOD_FAILED")); } } @@ -423,7 +423,7 @@ public class UserCertResourceService extends CMSResourceService implements UserC try { certID = URLDecoder.decode(certID, "UTF-8"); } catch (Exception e) { - throw new CMSException(e.getMessage()); + throw new PKIException(e.getMessage()); } UserCertData userCertData = new UserCertData(); @@ -438,7 +438,7 @@ public class UserCertResourceService extends CMSResourceService implements UserC try { if (userID == null) { log(ILogger.LL_FAILURE, CMS.getLogMessage("ADMIN_SRVLT_NULL_RS_ID")); - throw new CMSException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID")); + throw new PKIException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID")); } IUser user = userGroupManager.createUser(userID); @@ -456,14 +456,14 @@ public class UserCertResourceService extends CMSResourceService implements UserC auditDeleteUserCert(userID, userCertData, ILogger.SUCCESS); - } catch (CMSException e) { + } catch (PKIException e) { auditDeleteUserCert(userID, userCertData, ILogger.FAILURE); throw e; } catch (Exception e) { log(ILogger.LL_FAILURE, e.toString()); auditDeleteUserCert(userID, userCertData, ILogger.FAILURE); - throw new CMSException(getUserMessage("CMS_USRGRP_USER_MOD_FAILED")); + throw new PKIException(getUserMessage("CMS_USRGRP_USER_MOD_FAILED")); } } diff --git a/base/common/src/com/netscape/cms/servlet/admin/UserResourceService.java b/base/common/src/com/netscape/cms/servlet/admin/UserService.java index 1639c5912..f28a8151f 100644 --- a/base/common/src/com/netscape/cms/servlet/admin/UserResourceService.java +++ b/base/common/src/com/netscape/cms/servlet/admin/UserService.java @@ -33,6 +33,7 @@ import org.jboss.resteasy.plugins.providers.atom.Link; import com.netscape.certsrv.apps.CMS; import com.netscape.certsrv.base.EBaseException; +import com.netscape.certsrv.base.PKIException; import com.netscape.certsrv.common.OpDef; import com.netscape.certsrv.common.ScopeDef; import com.netscape.certsrv.logging.IAuditor; @@ -45,14 +46,13 @@ import com.netscape.certsrv.usrgrp.EUsrGrpException; import com.netscape.certsrv.usrgrp.IGroup; import com.netscape.certsrv.usrgrp.IUGSubsystem; import com.netscape.certsrv.usrgrp.IUser; -import com.netscape.cms.servlet.base.CMSException; -import com.netscape.cms.servlet.base.CMSResourceService; +import com.netscape.cms.servlet.base.PKIService; import com.netscape.cmsutil.ldap.LDAPUtil; /** * @author Endi S. Dewata */ -public class UserResourceService extends CMSResourceService implements UserResource { +public class UserService extends PKIService implements UserResource { public final static int DEFAULT_SIZE = 20; @@ -123,7 +123,7 @@ public class UserResourceService extends CMSResourceService implements UserResou return response; } catch (Exception e) { - throw new CMSException(getUserMessage("CMS_INTERNAL_ERROR")); + throw new PKIException(getUserMessage("CMS_INTERNAL_ERROR")); } } @@ -142,7 +142,7 @@ public class UserResourceService extends CMSResourceService implements UserResou if (userID == null) { log(ILogger.LL_FAILURE, CMS.getLogMessage("ADMIN_SRVLT_NULL_RS_ID")); - throw new CMSException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID")); + throw new PKIException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID")); } IUser user; @@ -150,13 +150,13 @@ public class UserResourceService extends CMSResourceService implements UserResou try { user = userGroupManager.getUser(userID); } catch (Exception e) { - throw new CMSException(getUserMessage("CMS_INTERNAL_ERROR")); + throw new PKIException(getUserMessage("CMS_INTERNAL_ERROR")); } if (user == null) { log(ILogger.LL_FAILURE, CMS.getLogMessage("USRGRP_SRVLT_USER_NOT_EXIST")); - throw new CMSException(getUserMessage("CMS_USRGRP_SRVLT_USER_NOT_EXIST")); + throw new PKIException(getUserMessage("CMS_USRGRP_SRVLT_USER_NOT_EXIST")); } UserData userData = createUserData(user); @@ -175,11 +175,11 @@ public class UserResourceService extends CMSResourceService implements UserResou return userData; - } catch (CMSException e) { + } catch (PKIException e) { throw e; } catch (Exception e) { - throw new CMSException(e.getMessage()); + throw new PKIException(e.getMessage()); } } @@ -207,19 +207,19 @@ public class UserResourceService extends CMSResourceService implements UserResou try { if (userID == null) { log(ILogger.LL_FAILURE, CMS.getLogMessage("ADMIN_SRVLT_NULL_RS_ID")); - throw new CMSException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID")); + throw new PKIException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID")); } if (userID.indexOf(BACK_SLASH) != -1) { // backslashes (BS) are not allowed log(ILogger.LL_FAILURE, CMS.getLogMessage("ADMIN_SRVLT_RS_ID_BS")); - throw new CMSException(getUserMessage("CMS_ADMIN_SRVLT_RS_ID_BS")); + throw new PKIException(getUserMessage("CMS_ADMIN_SRVLT_RS_ID_BS")); } if (userID.equals(SYSTEM_USER)) { // backslashes (BS) are not allowed log(ILogger.LL_FAILURE, CMS.getLogMessage("ADMIN_SRVLT_SPECIAL_ID", userID)); - throw new CMSException(getUserMessage("CMS_ADMIN_SRVLT_SPECIAL_ID", userID)); + throw new PKIException(getUserMessage("CMS_ADMIN_SRVLT_SPECIAL_ID", userID)); } IUser user = userGroupManager.createUser(userID); @@ -229,7 +229,7 @@ public class UserResourceService extends CMSResourceService implements UserResou String msg = getUserMessage("CMS_USRGRP_USER_ADD_FAILED_1", "full name"); log(ILogger.LL_FAILURE, msg); - throw new CMSException(msg); + throw new PKIException(msg); } else { user.setFullName(fname); @@ -292,27 +292,27 @@ public class UserResourceService extends CMSResourceService implements UserResou log(ILogger.LL_FAILURE, e.toString()); if (user.getUserID() == null) { - throw new CMSException(getUserMessage("CMS_USRGRP_USER_ADD_FAILED_1", "uid")); + throw new PKIException(getUserMessage("CMS_USRGRP_USER_ADD_FAILED_1", "uid")); } else { - throw new CMSException(getUserMessage("CMS_USRGRP_USER_ADD_FAILED")); + throw new PKIException(getUserMessage("CMS_USRGRP_USER_ADD_FAILED")); } } catch (LDAPException e) { log(ILogger.LL_FAILURE, CMS.getLogMessage("ADMIN_SRVLT_ADD_USER_FAIL", e.toString())); - throw new CMSException(getUserMessage("CMS_USRGRP_USER_ADD_FAILED")); + throw new PKIException(getUserMessage("CMS_USRGRP_USER_ADD_FAILED")); } catch (Exception e) { log(ILogger.LL_FAILURE, e.toString()); - throw new CMSException(getUserMessage("CMS_USRGRP_USER_ADD_FAILED")); + throw new PKIException(getUserMessage("CMS_USRGRP_USER_ADD_FAILED")); } - } catch (CMSException e) { + } catch (PKIException e) { auditAddUser(userID, userData, ILogger.FAILURE); throw e; } catch (EBaseException e) { auditAddUser(userID, userData, ILogger.FAILURE); - throw new CMSException(e.getMessage()); + throw new PKIException(e.getMessage()); } } @@ -337,7 +337,7 @@ public class UserResourceService extends CMSResourceService implements UserResou try { if (userID == null) { log(ILogger.LL_FAILURE, CMS.getLogMessage("ADMIN_SRVLT_NULL_RS_ID")); - throw new CMSException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID")); + throw new PKIException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID")); } IUser user = userGroupManager.createUser(userID); @@ -388,16 +388,16 @@ public class UserResourceService extends CMSResourceService implements UserResou } catch (Exception e) { log(ILogger.LL_FAILURE, e.toString()); - throw new CMSException(getUserMessage("CMS_USRGRP_USER_MOD_FAILED")); + throw new PKIException(getUserMessage("CMS_USRGRP_USER_MOD_FAILED")); } - } catch (CMSException e) { + } catch (PKIException e) { auditModifyUser(userID, userData, ILogger.FAILURE); throw e; } catch (EBaseException e) { auditModifyUser(userID, userData, ILogger.FAILURE); - throw new CMSException(e.getMessage()); + throw new PKIException(e.getMessage()); } } @@ -425,7 +425,7 @@ public class UserResourceService extends CMSResourceService implements UserResou try { if (userID == null) { log(ILogger.LL_FAILURE, CMS.getLogMessage("ADMIN_SRVLT_NULL_RS_ID")); - throw new CMSException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID")); + throw new PKIException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID")); } // get list of groups, and see if uid belongs to any @@ -435,7 +435,7 @@ public class UserResourceService extends CMSResourceService implements UserResou groups = userGroupManager.findGroups("*"); } catch (Exception e) { - throw new CMSException(getUserMessage("CMS_INTERNAL_ERROR")); + throw new PKIException(getUserMessage("CMS_INTERNAL_ERROR")); } try { @@ -452,10 +452,10 @@ public class UserResourceService extends CMSResourceService implements UserResou auditDeleteUser(userID, ILogger.SUCCESS); } catch (Exception e) { - throw new CMSException(getUserMessage("CMS_USRGRP_SRVLT_FAIL_USER_RMV")); + throw new PKIException(getUserMessage("CMS_USRGRP_SRVLT_FAIL_USER_RMV")); } - } catch (CMSException e) { + } catch (PKIException e) { auditDeleteUser(userID, ILogger.FAILURE); throw e; } |