KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > console > ca > ProcessCSRHandler


1 /**
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one or more
4  * contributor license agreements. See the NOTICE file distributed with
5  * this work for additional information regarding copyright ownership.
6  * The ASF licenses this file to You under the Apache License, Version 2.0
7  * (the "License"); you may not use this file except in compliance with
8  * the License. You may obtain a copy of the License at
9  *
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  */

18 package org.apache.geronimo.console.ca;
19
20 import java.io.IOException JavaDoc;
21 import java.util.Map JavaDoc;
22
23 import javax.portlet.ActionRequest;
24 import javax.portlet.ActionResponse;
25 import javax.portlet.PortletException;
26 import javax.portlet.RenderRequest;
27 import javax.portlet.RenderResponse;
28
29 import org.apache.commons.logging.Log;
30 import org.apache.commons.logging.LogFactory;
31 import org.apache.geronimo.console.MultiPageModel;
32 import org.apache.geronimo.util.CaUtils;
33
34 /**
35  * Handler for process CSR screen.
36  *
37  * @version $Rev: 476291 $ $Date: 2006-11-17 15:05:24 -0500 (Fri, 17 Nov 2006) $
38  */

39 public class ProcessCSRHandler extends BaseCAHandler {
40     private final static Log log = LogFactory.getLog(ProcessCSRHandler.class);
41     public ProcessCSRHandler() {
42         super(PROCESS_CSR_MODE, "/WEB-INF/view/ca/processCSR.jsp");
43     }
44
45     public String JavaDoc actionBeforeView(ActionRequest request, ActionResponse response, MultiPageModel model) throws PortletException, IOException JavaDoc {
46         String JavaDoc[] params = {ERROR_MSG, INFO_MSG};
47         for(int i = 0; i < params.length; ++i) {
48             String JavaDoc value = request.getParameter(params[i]);
49             if(value != null) response.setRenderParameter(params[i], value);
50         }
51         return getMode();
52     }
53
54     public void renderView(RenderRequest request, RenderResponse response, MultiPageModel model) throws PortletException, IOException JavaDoc {
55         String JavaDoc[] params = {ERROR_MSG, INFO_MSG};
56         for(int i = 0; i < params.length; ++i) {
57             Object JavaDoc value = request.getParameter(params[i]);
58             if(value != null) request.setAttribute(params[i], value);
59         }
60     }
61
62     public String JavaDoc actionAfterView(ActionRequest request, ActionResponse response, MultiPageModel model) throws PortletException, IOException JavaDoc {
63         String JavaDoc errorMsg = null;
64         try {
65             // Process the PKCS10 Certificate Request
66
String JavaDoc pkcs10certreq = request.getParameter("pkcs10certreq");
67             Map JavaDoc certReqMap = CaUtils.processPKCS10Request(pkcs10certreq);
68             response.setRenderParameter("pkcs10certreq", pkcs10certreq);
69             // Set the subject and publickey values to be shown in subsequent screens
70
response.setRenderParameter("subject", certReqMap.get(CaUtils.CERT_REQ_SUBJECT).toString());
71             response.setRenderParameter("publickey", certReqMap.get(CaUtils.CERT_REQ_PUBLICKEY_OBJ).toString());
72             return CERT_REQ_DETAILS_MODE+BEFORE_ACTION;
73         } catch(Exception JavaDoc e) {
74             errorMsg = e.toString();
75             log.error("Errors while processing a CSR.", e);
76         }
77         response.setRenderParameter(ERROR_MSG, errorMsg);
78         return getMode()+BEFORE_ACTION;
79     }
80 }
81
Popular Tags