01: /**
02: *
03: * Licensed to the Apache Software Foundation (ASF) under one or more
04: * contributor license agreements. See the NOTICE file distributed with
05: * this work for additional information regarding copyright ownership.
06: * The ASF licenses this file to You under the Apache License, Version 2.0
07: * (the "License"); you may not use this file except in compliance with
08: * the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing, software
13: * distributed under the License is distributed on an "AS IS" BASIS,
14: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: * See the License for the specific language governing permissions and
16: * limitations under the License.
17: */package org.apache.geronimo.console.ca;
18:
19: import java.io.IOException;
20: import java.util.Map;
21:
22: import javax.portlet.ActionRequest;
23: import javax.portlet.ActionResponse;
24: import javax.portlet.PortletException;
25: import javax.portlet.RenderRequest;
26: import javax.portlet.RenderResponse;
27:
28: import org.apache.commons.logging.Log;
29: import org.apache.commons.logging.LogFactory;
30: import org.apache.geronimo.console.MultiPageModel;
31: import org.apache.geronimo.crypto.CaUtils;
32:
33: /**
34: * Handler for process CSR screen.
35: *
36: * @version $Rev: 617588 $ $Date: 2008-02-01 10:20:07 -0800 (Fri, 01 Feb 2008) $
37: */
38: public class ProcessCSRHandler extends BaseCAHandler {
39: private final static Log log = LogFactory
40: .getLog(ProcessCSRHandler.class);
41:
42: public ProcessCSRHandler() {
43: super (PROCESS_CSR_MODE, "/WEB-INF/view/ca/processCSR.jsp");
44: }
45:
46: public String actionBeforeView(ActionRequest request,
47: ActionResponse response, MultiPageModel model)
48: throws PortletException, IOException {
49: String[] params = { ERROR_MSG, INFO_MSG };
50: for (int i = 0; i < params.length; ++i) {
51: String value = request.getParameter(params[i]);
52: if (value != null)
53: response.setRenderParameter(params[i], value);
54: }
55: return getMode();
56: }
57:
58: public void renderView(RenderRequest request,
59: RenderResponse response, MultiPageModel model)
60: throws PortletException, IOException {
61: String[] params = { ERROR_MSG, INFO_MSG };
62: for (int i = 0; i < params.length; ++i) {
63: Object value = request.getParameter(params[i]);
64: if (value != null)
65: request.setAttribute(params[i], value);
66: }
67: }
68:
69: public String actionAfterView(ActionRequest request,
70: ActionResponse response, MultiPageModel model)
71: throws PortletException, IOException {
72: String errorMsg = null;
73: try {
74: // Process the PKCS10 Certificate Request
75: String pkcs10certreq = request
76: .getParameter("pkcs10certreq");
77: Map certReqMap = CaUtils
78: .processPKCS10Request(pkcs10certreq);
79: response.setRenderParameter("pkcs10certreq", pkcs10certreq);
80: // Set the subject and publickey values to be shown in subsequent screens
81: response.setRenderParameter("subject", certReqMap.get(
82: CaUtils.CERT_REQ_SUBJECT).toString());
83: response.setRenderParameter("publickey", certReqMap.get(
84: CaUtils.CERT_REQ_PUBLICKEY_OBJ).toString());
85: return CERT_REQ_DETAILS_MODE + BEFORE_ACTION;
86: } catch (Exception e) {
87: errorMsg = e.toString();
88: log.error("Errors while processing a CSR.", e);
89: }
90: response.setRenderParameter(ERROR_MSG, errorMsg);
91: return getMode() + BEFORE_ACTION;
92: }
93: }
|