001 /** 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017 package org.apache.geronimo.console.keystores; 018 019 import org.apache.geronimo.console.MultiPageModel; 020 import org.apache.geronimo.management.geronimo.KeystoreException; 021 022 import javax.portlet.ActionRequest; 023 import javax.portlet.ActionResponse; 024 import javax.portlet.PortletException; 025 import javax.portlet.RenderRequest; 026 import javax.portlet.RenderResponse; 027 import java.io.IOException; 028 029 /** 030 * Handler for generating a Certificate Signing Request (CSR) 031 * 032 * @version $Rev: 514091 $ $Date: 2007-03-03 01:26:39 -0500 (Sat, 03 Mar 2007) $ 033 */ 034 public class GenerateCSRHandler extends BaseKeystoreHandler { 035 public GenerateCSRHandler() { 036 super(GENERATE_CSR, "/WEB-INF/view/keystore/generateCSR.jsp"); 037 } 038 039 public String actionBeforeView(ActionRequest request, ActionResponse response, MultiPageModel model) throws PortletException, IOException { 040 String id = request.getParameter("id"); 041 String alias = request.getParameter("alias"); 042 response.setRenderParameter("id", id); 043 response.setRenderParameter("alias", alias); 044 return getMode(); 045 } 046 public void renderView(RenderRequest request, RenderResponse response, MultiPageModel model) throws PortletException, IOException { 047 String id = request.getParameter("id"); 048 String alias = request.getParameter("alias"); 049 request.setAttribute("id", id); 050 request.setAttribute("alias", alias); 051 KeystoreData data = ((KeystoreData) request.getPortletSession(true).getAttribute(KEYSTORE_DATA_PREFIX + id)); 052 try { 053 String csr = data.generateCSR(alias); 054 request.setAttribute("csr", csr); 055 } catch (KeystoreException e) { 056 throw new PortletException(e); 057 } 058 } 059 060 public String actionAfterView(ActionRequest request, ActionResponse response, MultiPageModel model) throws PortletException, IOException { 061 String id = request.getParameter("id"); 062 String alias = request.getParameter("alias"); 063 response.setRenderParameter("id", id); 064 response.setRenderParameter("alias", alias); 065 return CERTIFICATE_DETAILS+BEFORE_ACTION; 066 } 067 }