diff options
author | Ade Lee <alee@redhat.com> | 2011-12-07 16:58:12 -0500 |
---|---|---|
committer | Ade Lee <alee@redhat.com> | 2011-12-07 16:58:12 -0500 |
commit | 32150d3ee32f8ac27118af7c792794b538c78a2f (patch) | |
tree | 52dd96f664a6fa51be25b28b6f10adc5f2c9f660 /pki/base/common/src/com/netscape/cms/servlet/admin/RAAdminServlet.java | |
parent | f05d58a46795553beb8881039cc922974b40db34 (diff) | |
download | pki-32150d3ee32f8ac27118af7c792794b538c78a2f.tar.gz pki-32150d3ee32f8ac27118af7c792794b538c78a2f.tar.xz pki-32150d3ee32f8ac27118af7c792794b538c78a2f.zip |
Formatting
Formatted project according to eclipse project settings
Diffstat (limited to 'pki/base/common/src/com/netscape/cms/servlet/admin/RAAdminServlet.java')
-rw-r--r-- | pki/base/common/src/com/netscape/cms/servlet/admin/RAAdminServlet.java | 246 |
1 files changed, 118 insertions, 128 deletions
diff --git a/pki/base/common/src/com/netscape/cms/servlet/admin/RAAdminServlet.java b/pki/base/common/src/com/netscape/cms/servlet/admin/RAAdminServlet.java index 35bbb91aa..97590e0bb 100644 --- a/pki/base/common/src/com/netscape/cms/servlet/admin/RAAdminServlet.java +++ b/pki/base/common/src/com/netscape/cms/servlet/admin/RAAdminServlet.java @@ -17,7 +17,6 @@ // --- END COPYRIGHT BLOCK --- package com.netscape.cms.servlet.admin; - import java.io.IOException; import java.util.Enumeration; @@ -36,13 +35,11 @@ import com.netscape.certsrv.common.ScopeDef; import com.netscape.certsrv.ra.IRegistrationAuthority; import com.netscape.certsrv.request.IRequestListener; - /** - * A class representings an administration servlet for Registration - * Authority. This servlet is responsible to serve RA - * administrative operations such as configuration parameter - * updates. - * + * A class representings an administration servlet for Registration Authority. + * This servlet is responsible to serve RA administrative operations such as + * configuration parameter updates. + * * @version $Revision$, $Date$ */ public class RAAdminServlet extends AdminServlet { @@ -53,15 +50,17 @@ public class RAAdminServlet extends AdminServlet { protected static final String PROP_ENABLED = "enabled"; - /*========================================================== - * variables - *==========================================================*/ + /* + * ========================================================== variables + * ========================================================== + */ private final static String INFO = "RAAdminServlet"; private IRegistrationAuthority mRA = null; - /*========================================================== - * constructors - *==========================================================*/ + /* + * ========================================================== constructors + * ========================================================== + */ /** * Constructs RA servlet. @@ -70,9 +69,10 @@ public class RAAdminServlet extends AdminServlet { super(); } - /*========================================================== - * public methods - *==========================================================*/ + /* + * ========================================================== public methods + * ========================================================== + */ /** * Initializes this servlet. @@ -90,35 +90,34 @@ public class RAAdminServlet extends AdminServlet { } /** - * Serves HTTP request. Each request is authenticated to - * the authenticate manager. + * Serves HTTP request. Each request is authenticated to the authenticate + * manager. */ public void service(HttpServletRequest req, HttpServletResponse resp) - throws ServletException, IOException { + throws ServletException, IOException { super.service(req, resp); - //get all operational flags + // get all operational flags String op = req.getParameter(Constants.OP_TYPE); String scope = req.getParameter(Constants.OP_SCOPE); - //check operational flags + // check operational flags if ((op == null) || (scope == null)) { sendResponse(1, "Invalid Protocol", null, resp); return; } - //authenticate the user + // authenticate the user super.authenticate(req); - //perform services + // perform services try { AUTHZ_RES_NAME = "certServer.ra.configuration"; if (op.equals(OpDef.OP_READ)) { mOp = "read"; if ((mToken = super.authorize(req)) == null) { - sendResponse(ERROR, - CMS.getUserMessage(getLocale(req), "CMS_ADMIN_SRVLT_AUTHZ_FAILED"), - null, resp); + sendResponse(ERROR, CMS.getUserMessage(getLocale(req), + "CMS_ADMIN_SRVLT_AUTHZ_FAILED"), null, resp); return; } if (scope.equals(ScopeDef.SC_GENERAL)) { @@ -143,9 +142,8 @@ public class RAAdminServlet extends AdminServlet { } else if (op.equals(OpDef.OP_MODIFY)) { mOp = "modify"; if ((mToken = super.authorize(req)) == null) { - sendResponse(ERROR, - CMS.getUserMessage(getLocale(req), "CMS_ADMIN_SRVLT_AUTHZ_FAILED"), - null, resp); + sendResponse(ERROR, CMS.getUserMessage(getLocale(req), + "CMS_ADMIN_SRVLT_AUTHZ_FAILED"), null, resp); return; } if (scope.equals(ScopeDef.SC_GENERAL)) { @@ -157,7 +155,7 @@ public class RAAdminServlet extends AdminServlet { } else if (scope.equals(ScopeDef.SC_NOTIFICATION_REQ_COMP)) { setNotificationReqCompConfig(req, resp); return; - }else if (scope.equals(ScopeDef.SC_NOTIFICATION_REV_COMP)) { + } else if (scope.equals(ScopeDef.SC_NOTIFICATION_REV_COMP)) { setNotificationRevCompConfig(req, resp); return; } else if (scope.equals(ScopeDef.SC_NOTIFICATION_RIQ)) { @@ -169,22 +167,23 @@ public class RAAdminServlet extends AdminServlet { } } } catch (Exception e) { - //System.out.println("XXX >>>" + e.toString() + "<<<"); + // System.out.println("XXX >>>" + e.toString() + "<<<"); sendResponse(1, "Unknown operation", null, resp); } return; } - /*========================================================== - * private methods - *==========================================================*/ - + /* + * ========================================================== private + * methods========================================================== + */ + /* * handle getting completion (cert issued) notification config info */ private void getNotificationCompConfig(HttpServletRequest req, - HttpServletResponse resp, IConfigStore rc) throws ServletException, + HttpServletResponse resp, IConfigStore rc) throws ServletException, IOException, EBaseException { NameValuePairs params = new NameValuePairs(); Enumeration e = req.getParameterNames(); @@ -203,35 +202,37 @@ public class RAAdminServlet extends AdminServlet { params.add(name, rc.getString(name, "")); } - params.add(Constants.PR_ENABLE, - rc.getString(PROP_ENABLED, Constants.FALSE)); - //System.out.println("Send: "+params.toString()); + params.add(Constants.PR_ENABLE, + rc.getString(PROP_ENABLED, Constants.FALSE)); + // System.out.println("Send: "+params.toString()); sendResponse(SUCCESS, null, params, resp); } private void getNotificationReqCompConfig(HttpServletRequest req, - HttpServletResponse resp) throws ServletException, - IOException, EBaseException { + HttpServletResponse resp) throws ServletException, IOException, + EBaseException { IConfigStore config = mRA.getConfigStore(); - IConfigStore nc = - config.getSubStore(IRegistrationAuthority.PROP_NOTIFY_SUBSTORE); + IConfigStore nc = config + .getSubStore(IRegistrationAuthority.PROP_NOTIFY_SUBSTORE); - IConfigStore rc = nc.getSubStore(IRegistrationAuthority.PROP_CERT_ISSUED_SUBSTORE); + IConfigStore rc = nc + .getSubStore(IRegistrationAuthority.PROP_CERT_ISSUED_SUBSTORE); getNotificationCompConfig(req, resp, rc); } private void getNotificationRevCompConfig(HttpServletRequest req, - HttpServletResponse resp) throws ServletException, - IOException, EBaseException { + HttpServletResponse resp) throws ServletException, IOException, + EBaseException { IConfigStore config = mRA.getConfigStore(); - IConfigStore nc = - config.getSubStore(IRegistrationAuthority.PROP_NOTIFY_SUBSTORE); + IConfigStore nc = config + .getSubStore(IRegistrationAuthority.PROP_NOTIFY_SUBSTORE); - IConfigStore rc = nc.getSubStore(IRegistrationAuthority.PROP_CERT_REVOKED_SUBSTORE); + IConfigStore rc = nc + .getSubStore(IRegistrationAuthority.PROP_CERT_REVOKED_SUBSTORE); getNotificationCompConfig(req, resp, rc); @@ -241,16 +242,17 @@ public class RAAdminServlet extends AdminServlet { * handle getting request in queue notification config info */ private void getNotificationRIQConfig(HttpServletRequest req, - HttpServletResponse resp) throws ServletException, - IOException, EBaseException { + HttpServletResponse resp) throws ServletException, IOException, + EBaseException { NameValuePairs params = new NameValuePairs(); IConfigStore config = mRA.getConfigStore(); - IConfigStore nc = - config.getSubStore(IRegistrationAuthority.PROP_NOTIFY_SUBSTORE); + IConfigStore nc = config + .getSubStore(IRegistrationAuthority.PROP_NOTIFY_SUBSTORE); - IConfigStore riq = nc.getSubStore(IRegistrationAuthority.PROP_REQ_IN_Q_SUBSTORE); + IConfigStore riq = nc + .getSubStore(IRegistrationAuthority.PROP_REQ_IN_Q_SUBSTORE); Enumeration e = req.getParameterNames(); @@ -268,9 +270,9 @@ public class RAAdminServlet extends AdminServlet { params.add(name, riq.getString(name, "")); } - params.add(Constants.PR_ENABLE, - riq.getString(PROP_ENABLED, Constants.FALSE)); - //System.out.println("Send: "+params.toString()); + params.add(Constants.PR_ENABLE, + riq.getString(PROP_ENABLED, Constants.FALSE)); + // System.out.println("Send: "+params.toString()); sendResponse(SUCCESS, null, params, resp); } @@ -278,15 +280,16 @@ public class RAAdminServlet extends AdminServlet { * handle setting request in queue notification config info */ private void setNotificationRIQConfig(HttpServletRequest req, - HttpServletResponse resp) throws ServletException, - IOException, EBaseException { + HttpServletResponse resp) throws ServletException, IOException, + EBaseException { IConfigStore config = mRA.getConfigStore(); - IConfigStore nc = - config.getSubStore(IRegistrationAuthority.PROP_NOTIFY_SUBSTORE); + IConfigStore nc = config + .getSubStore(IRegistrationAuthority.PROP_NOTIFY_SUBSTORE); - IConfigStore riq = nc.getSubStore(IRegistrationAuthority.PROP_REQ_IN_Q_SUBSTORE); + IConfigStore riq = nc + .getSubStore(IRegistrationAuthority.PROP_REQ_IN_Q_SUBSTORE); - //set rest of the parameters + // set rest of the parameters Enumeration e = req.getParameterNames(); while (e.hasMoreElements()) { @@ -321,9 +324,10 @@ public class RAAdminServlet extends AdminServlet { * handle setting request complete notification config info */ private void setNotificationCompConfig(HttpServletRequest req, - HttpServletResponse resp, IConfigStore rc, IRequestListener thisListener) throws ServletException, + HttpServletResponse resp, IConfigStore rc, + IRequestListener thisListener) throws ServletException, IOException, EBaseException { - //set rest of the parameters + // set rest of the parameters Enumeration e = req.getParameterNames(); while (e.hasMoreElements()) { @@ -355,33 +359,35 @@ public class RAAdminServlet extends AdminServlet { } private void setNotificationReqCompConfig(HttpServletRequest req, - HttpServletResponse resp) throws ServletException, - IOException, EBaseException { + HttpServletResponse resp) throws ServletException, IOException, + EBaseException { IConfigStore config = mRA.getConfigStore(); - IConfigStore nc = - config.getSubStore(IRegistrationAuthority.PROP_NOTIFY_SUBSTORE); + IConfigStore nc = config + .getSubStore(IRegistrationAuthority.PROP_NOTIFY_SUBSTORE); - IConfigStore rc = nc.getSubStore(IRegistrationAuthority.PROP_CERT_ISSUED_SUBSTORE); + IConfigStore rc = nc + .getSubStore(IRegistrationAuthority.PROP_CERT_ISSUED_SUBSTORE); setNotificationCompConfig(req, resp, rc, mRA.getCertIssuedListener()); - + } private void setNotificationRevCompConfig(HttpServletRequest req, - HttpServletResponse resp) throws ServletException, - IOException, EBaseException { + HttpServletResponse resp) throws ServletException, IOException, + EBaseException { IConfigStore config = mRA.getConfigStore(); - IConfigStore nc = - config.getSubStore(IRegistrationAuthority.PROP_NOTIFY_SUBSTORE); + IConfigStore nc = config + .getSubStore(IRegistrationAuthority.PROP_NOTIFY_SUBSTORE); - IConfigStore rc = nc.getSubStore(IRegistrationAuthority.PROP_CERT_REVOKED_SUBSTORE); + IConfigStore rc = nc + .getSubStore(IRegistrationAuthority.PROP_CERT_REVOKED_SUBSTORE); setNotificationCompConfig(req, resp, rc, mRA.getCertRevokedListener()); } private void getConnectorConfig(HttpServletRequest req, - HttpServletResponse resp) throws ServletException, - IOException, EBaseException { + HttpServletResponse resp) throws ServletException, IOException, + EBaseException { IConfigStore raConfig = mRA.getConfigStore(); IConfigStore connectorConfig = raConfig.getSubStore("connector"); IConfigStore caConnectorConfig = null; @@ -395,15 +401,10 @@ public class RAAdminServlet extends AdminServlet { } /* - Enumeration enum = req.getParameterNames(); - NameValuePairs params = new NameValuePairs(); - while (enum.hasMoreElements()) { - String key = (String)enum.nextElement(); - if (key.equals("RS_ID")) { - String val = req.getParameter(key); - if (val.equals("CA Connector")) - } - } + * Enumeration enum = req.getParameterNames(); NameValuePairs params = + * new NameValuePairs(); while (enum.hasMoreElements()) { String key = + * (String)enum.nextElement(); if (key.equals("RS_ID")) { String val = + * req.getParameter(key); if (val.equals("CA Connector")) } } */ Enumeration enum1 = req.getParameterNames(); @@ -427,13 +428,13 @@ public class RAAdminServlet extends AdminServlet { } private void setConnectorConfig(HttpServletRequest req, - HttpServletResponse resp) throws ServletException, - IOException, EBaseException { + HttpServletResponse resp) throws ServletException, IOException, + EBaseException { IConfigStore raConfig = mRA.getConfigStore(); IConfigStore connectorConfig = raConfig.getSubStore("connector"); IConfigStore caConnectorConfig = null; - // String nickname = raConfig.getString("certNickname", ""); + // String nickname = raConfig.getString("certNickname", ""); if (isCAConnector(req)) { caConnectorConfig = connectorConfig.getSubStore("CA"); @@ -455,12 +456,10 @@ public class RAAdminServlet extends AdminServlet { continue; if (name.equals(Constants.OP_SCOPE)) continue; -/* - if (name.equals("nickName")) { - caConnectorConfig.putString(name, nickname); - continue; - } -*/ + /* + * if (name.equals("nickName")) { + * caConnectorConfig.putString(name, nickname); continue; } + */ caConnectorConfig.putString(name, req.getParameter(name)); } } @@ -526,50 +525,41 @@ public class RAAdminServlet extends AdminServlet { return false; } - //reading the RA general information + // reading the RA general information private void readGeneralConfig(HttpServletRequest req, - HttpServletResponse resp) throws ServletException, - IOException, EBaseException { + HttpServletResponse resp) throws ServletException, IOException, + EBaseException { NameValuePairs params = new NameValuePairs(); /* - ISubsystem eeGateway = - SubsystemRegistry.getInstance().get("eeGateway"); - String value = "false"; - if (eeGateway != null) { - IConfigStore eeConfig = eeGateway.getConfigStore(); - if (eeConfig != null) - value = eeConfig.getString("enabled", "true"); - } - params.add(Constants.PR_EE_ENABLED, value); + * ISubsystem eeGateway = + * SubsystemRegistry.getInstance().get("eeGateway"); String value = + * "false"; if (eeGateway != null) { IConfigStore eeConfig = + * eeGateway.getConfigStore(); if (eeConfig != null) value = + * eeConfig.getString("enabled", "true"); } + * params.add(Constants.PR_EE_ENABLED, value); */ - + sendResponse(SUCCESS, null, params, resp); } - //mdify RA General Information + // mdify RA General Information private void modifyGeneralConfig(HttpServletRequest req, - HttpServletResponse resp) throws ServletException, - IOException, EBaseException { + HttpServletResponse resp) throws ServletException, IOException, + EBaseException { /* - ISubsystem eeGateway = - SubsystemRegistry.getInstance().get("eeGateway"); - IConfigStore eeConfig = null; - if (eeGateway != null) - eeConfig = eeGateway.getConfigStore(); - - Enumeration enum = req.getParameterNames(); - while (enum.hasMoreElements()) { - String key = (String)enum.nextElement(); - if (key.equals(Constants.PR_EE_ENABLED)) { - if (eeConfig != null) - eeConfig.putString("enabled", - req.getParameter(Constants.PR_EE_ENABLED)); - } - } - + * ISubsystem eeGateway = + * SubsystemRegistry.getInstance().get("eeGateway"); IConfigStore + * eeConfig = null; if (eeGateway != null) eeConfig = + * eeGateway.getConfigStore(); + * + * Enumeration enum = req.getParameterNames(); while + * (enum.hasMoreElements()) { String key = (String)enum.nextElement(); + * if (key.equals(Constants.PR_EE_ENABLED)) { if (eeConfig != null) + * eeConfig.putString("enabled", + * req.getParameter(Constants.PR_EE_ENABLED)); } } */ sendResponse(RESTART, null, null, resp); commit(true); |