View Javadoc

1   /**
2    *
3    * Copyright 2004, 2005 The Apache Software Foundation or its licensors, as applicable.
4    *
5    *  Licensed under the Apache License, Version 2.0 (the "License");
6    *  you may not use this file except in compliance with the License.
7    *  You may obtain a copy of the License at
8    *
9    *     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   */
17  
18  package org.apache.geronimo.console.certmanager.actions;
19  
20  import java.io.IOException;
21  
22  import javax.portlet.ActionRequest;
23  import javax.portlet.ActionResponse;
24  import javax.portlet.PortletException;
25  import javax.portlet.PortletRequestDispatcher;
26  import javax.portlet.RenderRequest;
27  import javax.portlet.RenderResponse;
28  
29  import org.apache.geronimo.console.certmanager.CertManagerPortlet;
30  import org.apache.geronimo.kernel.KernelRegistry;
31  
32  public class GenerateCSR {
33      public static void action(CertManagerPortlet portlet,
34              ActionRequest request, ActionResponse response)
35              throws PortletException, IOException {
36          response.setRenderParameter("action", request.getParameter("action"));
37      }
38  
39      public static void render(CertManagerPortlet portlet,
40              RenderRequest request, RenderResponse response)
41              throws PortletException, IOException {
42  
43          String alias = request.getParameter("alias");
44  
45          try {
46              String csr = (String) KernelRegistry.getSingleKernel()
47                      .invoke(portlet.getKeyStoreObjectName(), "generateCSR",
48                              new Object[] { alias },
49                              new String[] { "java.lang.String" });
50  
51              request.setAttribute("org.apache.geronimo.console.cert.csr", csr);
52              request.setAttribute("alias", alias);
53          } catch (Exception e) {
54              throw new PortletException(e);
55          }
56  
57          PortletRequestDispatcher rd = portlet.getPortletContext()
58                  .getRequestDispatcher(
59                          "/WEB-INF/view/certmanager/generateCSRNormal.jsp");
60  
61          rd.include(request, response);
62      }
63  }