01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */package org.apache.geronimo.console.keystores;
17:
18: import java.io.IOException;
19:
20: import javax.portlet.ActionRequest;
21: import javax.portlet.ActionResponse;
22: import javax.portlet.PortletException;
23: import javax.portlet.RenderRequest;
24: import javax.portlet.RenderResponse;
25:
26: import org.apache.geronimo.console.MultiPageModel;
27: import org.apache.geronimo.management.geronimo.KeystoreException;
28:
29: /**
30: * Handler for importing a certficate issued by a CA
31: *
32: * @version $Rev: 557653 $ $Date: 2007-07-19 08:10:34 -0700 (Thu, 19 Jul 2007) $
33: */
34: public class ImportCAReplyHandler extends BaseKeystoreHandler {
35: public ImportCAReplyHandler() {
36: super (IMPORT_CA_REPLY,
37: "/WEB-INF/view/keystore/importCAReply.jsp");
38: }
39:
40: public String actionBeforeView(ActionRequest request,
41: ActionResponse response, MultiPageModel model)
42: throws PortletException, IOException {
43: String id = request.getParameter("id");
44: String alias = request.getParameter("alias");
45: response.setRenderParameter("id", id);
46: response.setRenderParameter("alias", alias);
47: return getMode();
48: }
49:
50: public void renderView(RenderRequest request,
51: RenderResponse response, MultiPageModel model)
52: throws PortletException, IOException {
53: String id = request.getParameter("id");
54: String alias = request.getParameter("alias");
55: request.setAttribute("id", id);
56: request.setAttribute("alias", alias);
57: }
58:
59: public String actionAfterView(ActionRequest request,
60: ActionResponse response, MultiPageModel model)
61: throws PortletException, IOException {
62: String id = request.getParameter("id");
63: String alias = request.getParameter("alias");
64: response.setRenderParameter("id", id);
65: response.setRenderParameter("alias", alias);
66: if ("Cancel".equals(request.getParameter("submit")))
67: return CERTIFICATE_DETAILS + BEFORE_ACTION;
68: String pkcs7cert = request.getParameter("pkcs7cert");
69: if (pkcs7cert != null) {
70: pkcs7cert = pkcs7cert.trim();
71: }
72: KeystoreData data = ((KeystoreData) request.getPortletSession(
73: true).getAttribute(KEYSTORE_DATA_PREFIX + id));
74: try {
75: data.importPKCS7Certificate(alias, pkcs7cert);
76: } catch (KeystoreException e) {
77: throw new PortletException(e);
78: }
79: return CERTIFICATE_DETAILS + BEFORE_ACTION;
80: }
81: }
|