geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vamsic...@apache.org
Subject svn commit: r476229 [1/5] - in /geronimo/server/trunk: applications/ applications/console/geronimo-console-core/src/main/java/org/apache/geronimo/console/util/ applications/console/geronimo-console-framework/src/main/webapp/WEB-INF/data/ applications/c...
Date Fri, 17 Nov 2006 17:48:06 GMT
Author: vamsic007
Date: Fri Nov 17 09:48:02 2006
New Revision: 476229

URL: http://svn.apache.org/viewvc?view=rev&rev=476229
Log:
GERONIMO-2413 Add a Certification Authority (CA) portlet to Geronimo console

Added:
    geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/ca/
    geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/ca/BaseCAHandler.java
    geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/ca/CADetailsHandler.java
    geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/ca/CertReqDetailsHandler.java
    geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/ca/CertificationAuthorityPortlet.java
    geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/ca/ConfirmCAHandler.java
    geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/ca/ConfirmCertReqHandler.java
    geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/ca/ConfirmClientCertHandler.java
    geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/ca/IntroHandler.java
    geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/ca/ListRequestsIssueHandler.java
    geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/ca/ListRequestsVerifyHandler.java
    geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/ca/ProcessCSRHandler.java
    geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/ca/SetupCAHandler.java
    geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/ca/UnlockCAHandler.java
    geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/ca/ViewCertificateHandler.java
    geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/webapp/WEB-INF/view/ca/
    geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/webapp/WEB-INF/view/ca/_header.jsp
    geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/webapp/WEB-INF/view/ca/caDetails.jsp
    geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/webapp/WEB-INF/view/ca/certReqDetails.jsp
    geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/webapp/WEB-INF/view/ca/confirmCA.jsp
    geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/webapp/WEB-INF/view/ca/confirmCertReq.jsp
    geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/webapp/WEB-INF/view/ca/confirmClientCert.jsp
    geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/webapp/WEB-INF/view/ca/index.jsp
    geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/webapp/WEB-INF/view/ca/listRequestsIssue.jsp
    geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/webapp/WEB-INF/view/ca/listRequestsVerify.jsp
    geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/webapp/WEB-INF/view/ca/processCSR.jsp
    geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/webapp/WEB-INF/view/ca/setupCA.jsp
    geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/webapp/WEB-INF/view/ca/unlockCA.jsp
    geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/webapp/WEB-INF/view/ca/viewCertificate.jsp
    geronimo/server/trunk/applications/geronimo-ca-helper/
    geronimo/server/trunk/applications/geronimo-ca-helper/LICENSE.txt
    geronimo/server/trunk/applications/geronimo-ca-helper/NOTICE.txt
    geronimo/server/trunk/applications/geronimo-ca-helper/pom.xml
    geronimo/server/trunk/applications/geronimo-ca-helper/src/
    geronimo/server/trunk/applications/geronimo-ca-helper/src/main/
    geronimo/server/trunk/applications/geronimo-ca-helper/src/main/java/
    geronimo/server/trunk/applications/geronimo-ca-helper/src/main/java/org/
    geronimo/server/trunk/applications/geronimo-ca-helper/src/main/java/org/apache/
    geronimo/server/trunk/applications/geronimo-ca-helper/src/main/java/org/apache/geronimo/
    geronimo/server/trunk/applications/geronimo-ca-helper/src/main/java/org/apache/geronimo/ca/
    geronimo/server/trunk/applications/geronimo-ca-helper/src/main/java/org/apache/geronimo/ca/helper/
    geronimo/server/trunk/applications/geronimo-ca-helper/src/main/java/org/apache/geronimo/ca/helper/CertificateRequestServlet.java
    geronimo/server/trunk/applications/geronimo-ca-helper/src/main/java/org/apache/geronimo/ca/helper/DownloadCertificateServlet.java
    geronimo/server/trunk/applications/geronimo-ca-helper/src/main/java/org/apache/geronimo/ca/helper/util/
    geronimo/server/trunk/applications/geronimo-ca-helper/src/main/java/org/apache/geronimo/ca/helper/util/CAHelperUtils.java
    geronimo/server/trunk/applications/geronimo-ca-helper/src/main/webapp/
    geronimo/server/trunk/applications/geronimo-ca-helper/src/main/webapp/WEB-INF/
    geronimo/server/trunk/applications/geronimo-ca-helper/src/main/webapp/WEB-INF/web.xml
    geronimo/server/trunk/applications/geronimo-ca-helper/src/main/webapp/confirmRequest.jsp
    geronimo/server/trunk/applications/geronimo-ca-helper/src/main/webapp/downloadCACertificate.jsp
    geronimo/server/trunk/applications/geronimo-ca-helper/src/main/webapp/downloadCertificate.jsp
    geronimo/server/trunk/applications/geronimo-ca-helper/src/main/webapp/index.jsp
    geronimo/server/trunk/applications/geronimo-ca-helper/src/main/webapp/receivedCSR.jsp
    geronimo/server/trunk/applications/geronimo-ca-helper/src/main/webapp/requestCertificate.jsp
    geronimo/server/trunk/applications/geronimo-ca-helper/src/main/webapp/verifyCertificate.jsp
    geronimo/server/trunk/applications/geronimo-ca-helper/src/site/
    geronimo/server/trunk/applications/geronimo-ca-helper/src/site/apt/
    geronimo/server/trunk/applications/geronimo-ca-helper/src/site/site.xml
    geronimo/server/trunk/configs/ca-helper-jetty/
    geronimo/server/trunk/configs/ca-helper-jetty/LICENSE.txt
    geronimo/server/trunk/configs/ca-helper-jetty/NOTICE.txt
    geronimo/server/trunk/configs/ca-helper-jetty/pom.xml
    geronimo/server/trunk/configs/ca-helper-jetty/src/
    geronimo/server/trunk/configs/ca-helper-jetty/src/main/
    geronimo/server/trunk/configs/ca-helper-jetty/src/main/resources/
    geronimo/server/trunk/configs/ca-helper-jetty/src/main/resources/META-INF/
    geronimo/server/trunk/configs/ca-helper-jetty/src/main/resources/META-INF/geronimo-plugin.xml
    geronimo/server/trunk/configs/ca-helper-jetty/src/plan/
    geronimo/server/trunk/configs/ca-helper-jetty/src/plan/plan.xml
    geronimo/server/trunk/configs/ca-helper-jetty/src/site/
    geronimo/server/trunk/configs/ca-helper-jetty/src/site/apt/
    geronimo/server/trunk/configs/ca-helper-jetty/src/site/site.xml
    geronimo/server/trunk/configs/ca-helper-tomcat/
    geronimo/server/trunk/configs/ca-helper-tomcat/LICENSE.txt
    geronimo/server/trunk/configs/ca-helper-tomcat/NOTICE.txt
    geronimo/server/trunk/configs/ca-helper-tomcat/pom.xml
    geronimo/server/trunk/configs/ca-helper-tomcat/src/
    geronimo/server/trunk/configs/ca-helper-tomcat/src/main/
    geronimo/server/trunk/configs/ca-helper-tomcat/src/main/resources/
    geronimo/server/trunk/configs/ca-helper-tomcat/src/main/resources/META-INF/
    geronimo/server/trunk/configs/ca-helper-tomcat/src/main/resources/META-INF/geronimo-plugin.xml
    geronimo/server/trunk/configs/ca-helper-tomcat/src/plan/
    geronimo/server/trunk/configs/ca-helper-tomcat/src/plan/plan.xml
    geronimo/server/trunk/configs/ca-helper-tomcat/src/site/
    geronimo/server/trunk/configs/ca-helper-tomcat/src/site/apt/
    geronimo/server/trunk/configs/ca-helper-tomcat/src/site/site.xml
    geronimo/server/trunk/modules/geronimo-management/src/main/java/org/apache/geronimo/management/geronimo/CertificateRequestStore.java
    geronimo/server/trunk/modules/geronimo-management/src/main/java/org/apache/geronimo/management/geronimo/CertificateStore.java
    geronimo/server/trunk/modules/geronimo-management/src/main/java/org/apache/geronimo/management/geronimo/CertificateStoreException.java
    geronimo/server/trunk/modules/geronimo-management/src/main/java/org/apache/geronimo/management/geronimo/CertificationAuthority.java
    geronimo/server/trunk/modules/geronimo-management/src/main/java/org/apache/geronimo/management/geronimo/CertificationAuthorityException.java
    geronimo/server/trunk/modules/geronimo-security/src/main/java/org/apache/geronimo/security/ca/
    geronimo/server/trunk/modules/geronimo-security/src/main/java/org/apache/geronimo/security/ca/FileCertificateRequestStore.java
    geronimo/server/trunk/modules/geronimo-security/src/main/java/org/apache/geronimo/security/ca/FileCertificateStore.java
    geronimo/server/trunk/modules/geronimo-security/src/main/java/org/apache/geronimo/security/ca/GeronimoCertificationAuthority.java
    geronimo/server/trunk/modules/geronimo-util/src/main/java/org/apache/geronimo/util/CaUtils.java
Modified:
    geronimo/server/trunk/applications/console/geronimo-console-core/src/main/java/org/apache/geronimo/console/util/KernelManagementHelper.java
    geronimo/server/trunk/applications/console/geronimo-console-core/src/main/java/org/apache/geronimo/console/util/ManagementHelper.java
    geronimo/server/trunk/applications/console/geronimo-console-framework/src/main/webapp/WEB-INF/data/pageregistry.xml
    geronimo/server/trunk/applications/console/geronimo-console-framework/src/main/webapp/WEB-INF/data/portletentityregistry.xml
    geronimo/server/trunk/applications/console/geronimo-console-framework/src/main/webapp/js/forms.js
    geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/util/PortletManager.java
    geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/webapp/WEB-INF/portlet.xml
    geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/webapp/WEB-INF/web.xml
    geronimo/server/trunk/applications/pom.xml
    geronimo/server/trunk/assemblies/geronimo-jetty-j2ee/pom.xml
    geronimo/server/trunk/assemblies/geronimo-jetty-j2ee/src/main/var/config/config.xml
    geronimo/server/trunk/assemblies/geronimo-tomcat-j2ee/pom.xml
    geronimo/server/trunk/assemblies/geronimo-tomcat-j2ee/src/main/var/config/config.xml
    geronimo/server/trunk/configs/pom.xml
    geronimo/server/trunk/modules/geronimo-j2ee/src/main/java/org/apache/geronimo/j2ee/j2eeobjectnames/NameFactory.java
    geronimo/server/trunk/modules/geronimo-management/src/main/java/org/apache/geronimo/management/geronimo/KeystoreInstance.java
    geronimo/server/trunk/modules/geronimo-security/src/main/java/org/apache/geronimo/security/keystore/FileKeystoreInstance.java

Modified: geronimo/server/trunk/applications/console/geronimo-console-core/src/main/java/org/apache/geronimo/console/util/KernelManagementHelper.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/applications/console/geronimo-console-core/src/main/java/org/apache/geronimo/console/util/KernelManagementHelper.java?view=diff&rev=476229&r1=476228&r2=476229
==============================================================================
--- geronimo/server/trunk/applications/console/geronimo-console-core/src/main/java/org/apache/geronimo/console/util/KernelManagementHelper.java (original)
+++ geronimo/server/trunk/applications/console/geronimo-console-core/src/main/java/org/apache/geronimo/console/util/KernelManagementHelper.java Fri Nov 17 09:48:02 2006
@@ -36,14 +36,17 @@
 
 import org.apache.geronimo.gbean.AbstractName;
 import org.apache.geronimo.gbean.AbstractNameQuery;
+import org.apache.geronimo.gbean.GBeanData;
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
 import org.apache.geronimo.kernel.GBeanNotFoundException;
 import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.Naming;
 import org.apache.geronimo.kernel.config.Configuration;
 import org.apache.geronimo.kernel.config.ConfigurationInfo;
 import org.apache.geronimo.kernel.config.ConfigurationManager;
 import org.apache.geronimo.kernel.config.ConfigurationModuleType;
 import org.apache.geronimo.kernel.config.ConfigurationUtil;
+import org.apache.geronimo.kernel.config.EditableConfigurationManager;
 import org.apache.geronimo.kernel.config.InvalidConfigException;
 import org.apache.geronimo.kernel.config.NoSuchStoreException;
 import org.apache.geronimo.kernel.management.State;
@@ -548,6 +551,30 @@
         return result;
     }    
     
+    /**
+     * Adds a new GBean to an existing Configuration.
+     * @param configID  The configuration to add the GBean to.
+     * @param gbean     The data representing the GBean to add.
+     * @param start     If true, the GBean should be started as part of this call.
+     */
+    public void addGBeanToConfiguration(Artifact configID, GBeanData gbean, boolean start) {
+        EditableConfigurationManager mgr = ConfigurationUtil.getEditableConfigurationManager(kernel);
+        try {
+            mgr.addGBeanToConfiguration(configID, gbean, start);
+        } catch (InvalidConfigException e) {
+            throw new RuntimeException("Bad configID. configID = "+configID, e);
+        } finally {
+            ConfigurationUtil.releaseConfigurationManager(kernel, mgr);
+        }
+    }
+
+    /**
+     * This method returns the Naming object of the kernel.
+     */
+    public Naming getNaming() {
+        return kernel.getNaming();
+    }
+
     /**
      * Helper method to connect to a remote kernel.
      */

Modified: geronimo/server/trunk/applications/console/geronimo-console-core/src/main/java/org/apache/geronimo/console/util/ManagementHelper.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/applications/console/geronimo-console-core/src/main/java/org/apache/geronimo/console/util/ManagementHelper.java?view=diff&rev=476229&r1=476228&r2=476229
==============================================================================
--- geronimo/server/trunk/applications/console/geronimo-console-core/src/main/java/org/apache/geronimo/console/util/ManagementHelper.java (original)
+++ geronimo/server/trunk/applications/console/geronimo-console-core/src/main/java/org/apache/geronimo/console/util/ManagementHelper.java Fri Nov 17 09:48:02 2006
@@ -22,6 +22,8 @@
 import javax.security.auth.spi.LoginModule;
 
 import org.apache.geronimo.gbean.AbstractName;
+import org.apache.geronimo.gbean.GBeanData;
+import org.apache.geronimo.kernel.Naming;
 import org.apache.geronimo.kernel.config.ConfigurationModuleType;
 import org.apache.geronimo.kernel.repository.Artifact;
 import org.apache.geronimo.management.AppClientModule;
@@ -122,5 +124,19 @@
      * @return The Module, or null if the configuration is not running.
      */
     J2EEDeployedObject getModuleForConfiguration(Artifact configuration);
+
+    /**
+     * Adds a new GBean to an existing Configuration.
+     * @param configID  The configuration to add the GBean to.
+     * @param gbean     The data representing the GBean to add.
+     * @param start     If true, the GBean should be started as part of this call.
+     */
+    public void addGBeanToConfiguration(Artifact configID, GBeanData gbean, boolean start);
+
+    /**
+     * This method returns the Naming object of the kernel.
+     */
+    public Naming getNaming();
+
     Object[] getGBeansImplementing(Class iface);
 }

Modified: geronimo/server/trunk/applications/console/geronimo-console-framework/src/main/webapp/WEB-INF/data/pageregistry.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/applications/console/geronimo-console-framework/src/main/webapp/WEB-INF/data/pageregistry.xml?view=diff&rev=476229&r1=476228&r2=476229
==============================================================================
--- geronimo/server/trunk/applications/console/geronimo-console-framework/src/main/webapp/WEB-INF/data/pageregistry.xml (original)
+++ geronimo/server/trunk/applications/console/geronimo-console-framework/src/main/webapp/WEB-INF/data/pageregistry.xml Fri Nov 17 09:48:02 2006
@@ -533,6 +533,20 @@
             </fragment>
         </fragment>
 
+        <fragment name="ca" type="page">
+            <navigation>
+                <title>Certificate Authority</title>
+                <description>ico_doc_16x16.gif Certification Authority</description>
+            </navigation>
+
+            <fragment name="row1" type="row">
+                <fragment name="col1" type="column">
+                    <fragment name="p1" type="portlet">
+                        <property name="portlet" value="5.81"/>
+                    </fragment>
+                </fragment>
+            </fragment>
+        </fragment>
         <fragment name="keystore" type="page">
             <navigation>
                 <title>Old Keystore</title>

Modified: geronimo/server/trunk/applications/console/geronimo-console-framework/src/main/webapp/WEB-INF/data/portletentityregistry.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/applications/console/geronimo-console-framework/src/main/webapp/WEB-INF/data/portletentityregistry.xml?view=diff&rev=476229&r1=476228&r2=476229
==============================================================================
--- geronimo/server/trunk/applications/console/geronimo-console-framework/src/main/webapp/WEB-INF/data/portletentityregistry.xml (original)
+++ geronimo/server/trunk/applications/console/geronimo-console-framework/src/main/webapp/WEB-INF/data/portletentityregistry.xml Fri Nov 17 09:48:02 2006
@@ -158,5 +158,8 @@
         <portlet id="80">
             <definition-id>console-standard.ThreadPool</definition-id>
         </portlet>
+        <portlet id="81">
+            <definition-id>console-standard.CertificationAuthority</definition-id>
+        </portlet>
     </application>
 </portlet-entity-registry>

Modified: geronimo/server/trunk/applications/console/geronimo-console-framework/src/main/webapp/js/forms.js
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/applications/console/geronimo-console-framework/src/main/webapp/js/forms.js?view=diff&rev=476229&r1=476228&r2=476229
==============================================================================
--- geronimo/server/trunk/applications/console/geronimo-console-framework/src/main/webapp/js/forms.js (original)
+++ geronimo/server/trunk/applications/console/geronimo-console-framework/src/main/webapp/js/forms.js Fri Nov 17 09:48:02 2006
@@ -32,4 +32,42 @@
     }
     return true;
 }
+
+function checkDateMMDDYYYY(formName, elementName) {
+    var obj = eval("document.forms['" + formName + "'].elements['"+ elementName +"']");
+    if(validDateMMDDYYYY(obj.value)) return true;
+    else{
+        alert(elementName + " must be a date in MM/DD/YYYY format.");
+        obj.focus();
+        return false;
+    }
+}
+
+function checkDateMMDDYY(formName, elementName) {
+    var obj = eval("document.forms['" + formName + "'].elements['"+ elementName +"']");
+    if(validDateMMDDYY(obj.value)) return true;
+    else{
+        alert(elementName + " must be a date in MM/DD/YY format.");
+        obj.focus();
+        return false;
+    }
+}
+
+function validDateMMDDYYYY(inpDate) {
+    var d0 = new Date(inpDate);
+    var mm = (d0.getMonth() < 9 ? '0' : '') + (d0.getMonth()+1);
+    var dd = (d0.getDate() < 10 ? '0' : '') + d0.getDate();
+    var yyyy = d0.getFullYear();
+    var d1 = mm+'/'+dd+'/'+yyyy;
+    return inpDate == d1;
+}
+
+function validDateMMDDYY(inpDate) {
+    var d0 = new Date(inpDate);
+    var mm = (d0.getMonth() < 9 ? '0' : '') + (d0.getMonth()+1);
+    var dd = (d0.getDate() < 10 ? '0' : '') + d0.getDate();
+    var yy = (d0.getYear() < 10 ? '0' : '') + d0.getYear();
+    var d1 = mm+'/'+dd+'/'+yy;
+    return inpDate == d1;
+}
     

Added: geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/ca/BaseCAHandler.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/ca/BaseCAHandler.java?view=auto&rev=476229
==============================================================================
--- geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/ca/BaseCAHandler.java (added)
+++ geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/ca/BaseCAHandler.java Fri Nov 17 09:48:02 2006
@@ -0,0 +1,125 @@
+/**
+ *
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.console.ca;
+
+import javax.portlet.ActionResponse;
+import javax.portlet.PortletRequest;
+import javax.portlet.PortletSession;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.console.MultiPageAbstractHandler;
+import org.apache.geronimo.console.MultiPageModel;
+import org.apache.geronimo.console.util.PortletManager;
+import org.apache.geronimo.management.geronimo.CertificateRequestStore;
+import org.apache.geronimo.management.geronimo.CertificateStore;
+import org.apache.geronimo.management.geronimo.CertificationAuthority;
+import org.apache.geronimo.management.geronimo.KeystoreException;
+import org.apache.geronimo.management.geronimo.KeystoreInstance;
+
+/**
+ * The base class for all handlers for CA portlet
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class BaseCAHandler extends MultiPageAbstractHandler {
+    private final static Log log = LogFactory.getLog(BaseCAHandler.class);
+
+    protected static final String INDEX_MODE = "index";
+    protected static final String SETUPCA_MODE = "setupCA";
+    protected static final String CONFIRM_CA_MODE = "confirmCA";
+    protected static final String CADETAILS_MODE = "caDetails";
+    protected static final String UNLOCKCA_MODE = "unlockCA";
+    protected static final String PROCESS_CSR_MODE = "processCSR";
+    protected static final String CERT_REQ_DETAILS_MODE = "certReqDetails";
+    protected static final String CONFIRM_CLIENT_CERT_MODE = "confirmClientCert";
+    protected static final String VIEW_CERT_MODE = "viewCert";
+    protected static final String LIST_REQUESTS_ISSUE_MODE = "listRequestsIssue";
+    protected static final String LIST_REQUESTS_VERIFY_MODE = "listRequestsVerify";
+    protected static final String CONFIRM_CERT_REQ_MODE = "confirmCertReq";
+    
+    // Key algorithm for CA's keypair
+    protected static final String defaultKeyAlgorithm = "RSA";
+    // CA's private key and self-signed certificate is stored under this keystore created using KeystoreManager
+    // Using FileKeystoreManager, the file willbe <server-base-dir>/var/security/keystores/<defaultCAKeystore>
+    protected static final String defaultCAKeystore = "ca-keystore";
+    // CA's certificate store directory
+    protected static final String defaultCAStoreDir = "var/security/ca/certs";
+    // Certificate request store directory
+    protected static final String defaultCSRStoreDir = "var/security/ca/requests";
+
+    // Name of the attribute for error message to be displayed in a page
+    protected static final String ERROR_MSG = "errorMsg";
+    // Name of the attribute for information message to be displayed in a page
+    protected static final String INFO_MSG = "infoMsg";
+
+    /**
+     * Constructor
+     */
+    protected BaseCAHandler(String mode, String viewName) {
+        super(mode, viewName);
+    }
+
+    public final static class CAModel implements MultiPageModel {
+        public CAModel(PortletRequest request) {
+        }
+
+        public void save(ActionResponse response, PortletSession session) {
+        }
+    }
+    
+    /**
+     * This method returns CertificationAuthority GBbean.
+     * @param request PortletRequest to execute retrieve GBean
+     * @return  null if a CA GBean is not running.
+     */
+    protected CertificationAuthority getCertificationAuthority(PortletRequest request) {
+        Object[] cas = PortletManager.getManagedBeans(request, CertificationAuthority.class);
+        return (CertificationAuthority)(cas != null && cas.length > 0 ? cas[0] : null);
+    }
+
+    /**
+     * This methods creates CA's keystore using KeystoreManager.
+     * @param request PortletRequest to get KeystoreManager
+     * @param password Password for newly created Keystore
+     * @throws KeystoreException 
+     */
+    protected KeystoreInstance createCAKeystoreInstance(PortletRequest request, String password) throws KeystoreException {
+        return PortletManager.getCurrentServer(request).getKeystoreManager().createKeystore(defaultCAKeystore, password.toCharArray());
+    }
+    
+    /**
+     * This method returns CertificateRequestStore GBean.
+     * @param request PortletRequest to execute retrieve GBean
+     * @return  null if a CertificateRequestStore GBean is not running.
+     */
+    protected CertificateRequestStore getCertificateRequestStore(PortletRequest request) {
+        Object[] crs = PortletManager.getManagedBeans(request, CertificateRequestStore.class);
+        return (CertificateRequestStore)(crs != null && crs.length > 0 ? crs[0] : null);
+    }
+
+    /**
+     * This method returns CertificateStore GBean.
+     * @param request PortletRequest to execute retrieve GBean
+     * @return  null if a CertificateStore GBean is not running.
+     */
+    protected CertificateStore getCertificateStore(PortletRequest request) {
+        Object[] cs = PortletManager.getManagedBeans(request, CertificateStore.class);
+        return (CertificateStore)(cs != null && cs.length > 0 ? cs[0] : null);
+    }
+}

Added: geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/ca/CADetailsHandler.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/ca/CADetailsHandler.java?view=auto&rev=476229
==============================================================================
--- geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/ca/CADetailsHandler.java (added)
+++ geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/ca/CADetailsHandler.java Fri Nov 17 09:48:02 2006
@@ -0,0 +1,100 @@
+/**
+ *
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.console.ca;
+
+import java.io.IOException;
+import java.security.PublicKey;
+import java.security.cert.Certificate;
+import java.security.interfaces.RSAPublicKey;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.PortletException;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.console.MultiPageModel;
+import org.apache.geronimo.management.geronimo.CertificationAuthority;
+import org.apache.geronimo.util.CaUtils;
+import org.apache.geronimo.util.CertificateUtil;
+
+/**
+ * Handler for the CA details screen.
+ *
+ * @version $Rev$ $Date$
+ */
+public class CADetailsHandler extends BaseCAHandler {
+    private final static Log log = LogFactory.getLog(CADetailsHandler.class);
+    public CADetailsHandler() {
+        super(CADETAILS_MODE, "/WEB-INF/view/ca/caDetails.jsp");
+    }
+
+    public String actionBeforeView(ActionRequest request, ActionResponse response, MultiPageModel model) throws PortletException, IOException {
+        String[] params = {ERROR_MSG, INFO_MSG};
+        for(int i = 0; i < params.length; ++i) {
+            String value = request.getParameter(params[i]);
+            if(value != null) response.setRenderParameter(params[i], value);
+        }
+        return getMode();
+    }
+
+    public void renderView(RenderRequest request, RenderResponse response, MultiPageModel model) throws PortletException, IOException {
+        String[] params = {ERROR_MSG, INFO_MSG};
+        for(int i = 0; i < params.length; ++i) {
+            String value = request.getParameter(params[i]);
+            if(value != null) request.setAttribute(params[i], value);
+        }
+        try {
+            CertificationAuthority ca = getCertificationAuthority(request);
+            if(ca == null) {
+                throw new Exception("CA is not running. CA may not have been initialized.");
+            }
+            if(ca.isLocked()) {
+                request.setAttribute("caLocked", Boolean.TRUE);
+                throw new Exception("CA is locked.  Unlock CA to view details.");
+            }
+            
+            // Get CA details
+            Certificate caCert = ca.getCertificate();
+            request.setAttribute("cert", caCert);
+            request.setAttribute("highestSerial", ca.getHighestSerialNumber());
+            request.setAttribute("certText", CaUtils.base64Certificate(caCert));
+            PublicKey publickey = caCert.getPublicKey();
+            String keySize = null;
+            if(publickey instanceof RSAPublicKey) {
+                keySize = ""+((RSAPublicKey)publickey).getModulus().bitLength();
+                request.setAttribute("keySize", keySize);
+            }
+            Map fingerPrints = new HashMap();
+            fingerPrints.put("MD5", CertificateUtil.generateFingerprint(caCert, "MD5"));
+            fingerPrints.put("SHA1", CertificateUtil.generateFingerprint(caCert, "SHA1"));
+            request.setAttribute("fingerPrints", fingerPrints);
+        } catch (Exception e) {
+            request.setAttribute(ERROR_MSG, e.toString());
+            log.error("Errors while trying to view CA Details.", e);
+        }
+    }
+
+    public String actionAfterView(ActionRequest request, ActionResponse response, MultiPageModel model) throws PortletException, IOException {
+        return getMode()+BEFORE_ACTION;
+    }
+}

Added: geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/ca/CertReqDetailsHandler.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/ca/CertReqDetailsHandler.java?view=auto&rev=476229
==============================================================================
--- geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/ca/CertReqDetailsHandler.java (added)
+++ geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/ca/CertReqDetailsHandler.java Fri Nov 17 09:48:02 2006
@@ -0,0 +1,125 @@
+/**
+ *
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.console.ca;
+
+import java.io.IOException;
+import java.math.BigInteger;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.PortletException;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.console.MultiPageModel;
+import org.apache.geronimo.management.geronimo.CertificationAuthority;
+
+/**
+ * Handler for CSR details screen.
+ *
+ * @version $Rev$ $Date$
+ */
+public class CertReqDetailsHandler extends BaseCAHandler {
+    private final static Log log = LogFactory.getLog(CertReqDetailsHandler.class);
+    public CertReqDetailsHandler() {
+        super(CERT_REQ_DETAILS_MODE, "/WEB-INF/view/ca/certReqDetails.jsp");
+    }
+
+    public String actionBeforeView(ActionRequest request, ActionResponse response, MultiPageModel model) throws PortletException, IOException {
+        String[] params = {ERROR_MSG, INFO_MSG, "algorithm", "sNo", "validFrom", "validTo", "pkcs10certreq", "subject", "publickey", "requestId"};
+        for(int i = 0; i < params.length; ++i) {
+            String value = request.getParameter(params[i]);
+            if(value != null) response.setRenderParameter(params[i], value);
+        }
+        String sNo = request.getParameter("sNo");
+        if(sNo == null) {
+            // Freshly loading the certificate request details screen
+            CertificationAuthority ca = getCertificationAuthority(request);
+            try {
+                sNo = ca.getNextSerialNumber().toString();
+                response.setRenderParameter("sNo", sNo);
+            } catch (Exception e) {
+                log.error("Unable to get next serial number from CA.", e);
+                response.setRenderParameter(ERROR_MSG, e.toString());
+            }
+        }
+        return getMode();
+    }
+
+    public void renderView(RenderRequest request, RenderResponse response, MultiPageModel model) throws PortletException, IOException {
+        String[] params = {ERROR_MSG, INFO_MSG, "subject", "publickey", "sNo", "validFrom", "validTo", "algorithm", "pkcs10certreq", "requestId"};
+        for(int i = 0; i < params.length; ++i) {
+            Object value = request.getParameter(params[i]);
+            if(value != null) request.setAttribute(params[i], value);
+        }
+    }
+
+    public String actionAfterView(ActionRequest request, ActionResponse response, MultiPageModel model) throws PortletException, IOException {
+        String errorMsg = null;
+
+        try {
+            // Validate the Serial Number
+            String sNo = request.getParameter("sNo");
+            new BigInteger(sNo.trim());
+            
+            // Validate the from and to dates
+            String validFrom = request.getParameter("validFrom");
+            String validTo = request.getParameter("validTo");
+            DateFormat df = new SimpleDateFormat("MM/dd/yyyy");
+            // Check if the from date format is MM/DD/YYYY
+            Date validFromDate = df.parse(validFrom);
+            Calendar calendar = new GregorianCalendar();
+            calendar.setTime(validFromDate);
+            String mmddyyyy = (calendar.get(Calendar.MONTH) < 9 ? "0":"") + (calendar.get(Calendar.MONTH)+1);
+            mmddyyyy += "/"+(calendar.get(Calendar.DAY_OF_MONTH) < 10 ? "0":"") + (calendar.get(Calendar.DAY_OF_MONTH));
+            mmddyyyy += "/"+calendar.get(Calendar.YEAR);
+            if(!mmddyyyy.equals(validFrom)) {
+                throw new Exception("validFrom must be a date in MM/DD/YYYY format.");
+            }
+            // Check if the to date format is MM/DD/YYYY
+            Date validToDate = df.parse(validTo);
+            calendar.setTime(validToDate);
+            mmddyyyy = (calendar.get(Calendar.MONTH) < 9 ? "0":"") + (calendar.get(Calendar.MONTH)+1);
+            mmddyyyy += "/"+(calendar.get(Calendar.DAY_OF_MONTH) < 10 ? "0":"") + (calendar.get(Calendar.DAY_OF_MONTH));
+            mmddyyyy += "/"+calendar.get(Calendar.YEAR);
+            if(!mmddyyyy.equals(validTo)) {
+                throw new Exception("validTo must be a date in MM/DD/YYYY format.");
+            }
+            // Check if the from date is before the to date
+            if(validFromDate.after(validToDate)) {
+                throw new Exception("Validity: From date '"+validFrom+"' is before the To date '"+validTo+"'.");
+            }
+            
+            // Go to client certificate confirmation page
+            return CONFIRM_CLIENT_CERT_MODE+BEFORE_ACTION;
+        } catch(Exception e) {
+            errorMsg = e.toString();
+            log.error("Errors in user input while processing a CSR.", e);
+        }
+        
+        if(errorMsg != null) response.setRenderParameter(ERROR_MSG, errorMsg);
+        return getMode()+BEFORE_ACTION;
+    }
+}

Added: geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/ca/CertificationAuthorityPortlet.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/ca/CertificationAuthorityPortlet.java?view=auto&rev=476229
==============================================================================
--- geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/ca/CertificationAuthorityPortlet.java (added)
+++ geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/ca/CertificationAuthorityPortlet.java Fri Nov 17 09:48:02 2006
@@ -0,0 +1,56 @@
+/**
+ *
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.console.ca;
+
+import javax.portlet.PortletConfig;
+import javax.portlet.PortletException;
+import javax.portlet.PortletRequest;
+
+import org.apache.geronimo.console.MultiPageModel;
+import org.apache.geronimo.console.MultiPagePortlet;
+
+/**
+ * A portlet for Certification Authority.
+ *
+ * @version $Rev$ $Date$
+ */
+public class CertificationAuthorityPortlet extends MultiPagePortlet {
+    public void init(PortletConfig config) throws PortletException {
+        super.init(config);
+        addHelper(new IntroHandler(), config);
+        addHelper(new SetupCAHandler(), config);
+        addHelper(new ConfirmCAHandler(), config);
+        addHelper(new CADetailsHandler(), config);
+        addHelper(new UnlockCAHandler(), config);
+        addHelper(new ProcessCSRHandler(), config);
+        addHelper(new CertReqDetailsHandler(), config);
+        addHelper(new ConfirmClientCertHandler(), config);
+        addHelper(new ViewCertificateHandler(), config);
+        addHelper(new ListRequestsIssueHandler(), config);
+        addHelper(new ListRequestsVerifyHandler(), config);
+        addHelper(new ConfirmCertReqHandler(), config);
+    }
+
+    protected String getModelJSPVariableName() {
+        return "model";
+    }
+
+    protected MultiPageModel getModel(PortletRequest request) {
+        return new BaseCAHandler.CAModel(request);
+    }
+}

Added: geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/ca/ConfirmCAHandler.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/ca/ConfirmCAHandler.java?view=auto&rev=476229
==============================================================================
--- geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/ca/ConfirmCAHandler.java (added)
+++ geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/ca/ConfirmCAHandler.java Fri Nov 17 09:48:02 2006
@@ -0,0 +1,183 @@
+/**
+ *
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.console.ca;
+
+import java.io.IOException;
+import java.math.BigInteger;
+import java.net.URI;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.PortletException;
+import javax.portlet.PortletRequest;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.console.MultiPageModel;
+import org.apache.geronimo.console.util.PortletManager;
+import org.apache.geronimo.gbean.AbstractName;
+import org.apache.geronimo.gbean.GBeanData;
+import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
+import org.apache.geronimo.kernel.Naming;
+import org.apache.geronimo.kernel.proxy.GeronimoManagedBean;
+import org.apache.geronimo.kernel.repository.Artifact;
+import org.apache.geronimo.management.geronimo.CertificationAuthority;
+import org.apache.geronimo.management.geronimo.KeystoreInstance;
+import org.apache.geronimo.security.ca.FileCertificateRequestStore;
+import org.apache.geronimo.security.ca.FileCertificateStore;
+import org.apache.geronimo.security.ca.GeronimoCertificationAuthority;
+import org.apache.geronimo.system.serverinfo.ServerInfo;
+
+/**
+ * Handler for the CA confirmation screen.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ConfirmCAHandler extends BaseCAHandler {
+    private final static Log log = LogFactory.getLog(ConfirmCAHandler.class);
+    public ConfirmCAHandler() {
+        super(CONFIRM_CA_MODE, "/WEB-INF/view/ca/confirmCA.jsp");
+    }
+
+    public String actionBeforeView(ActionRequest request, ActionResponse response, MultiPageModel model) throws PortletException, IOException {
+        String[] params = {ERROR_MSG, INFO_MSG, "caCN", "caOU", "caO", "caL", "caST", "caC", "alias", "keyAlgorithm", "keySize", "algorithm", "validFrom", "validTo", "sNo", "password"};
+        for(int i = 0; i < params.length; ++i) {
+            String value = request.getParameter(params[i]);
+            if(value != null) response.setRenderParameter(params[i], value);
+        }
+        return getMode();
+    }
+
+    public void renderView(RenderRequest request, RenderResponse response, MultiPageModel model) throws PortletException, IOException {
+        String[] params = {ERROR_MSG, INFO_MSG, "caCN", "caOU", "caO", "caL", "caST", "caC", "alias", "keyAlgorithm", "keySize", "algorithm", "validFrom", "validTo", "sNo", "password"};
+        for(int i = 0; i < params.length; ++i) {
+            String value = request.getParameter(params[i]);
+            if(value != null) request.setAttribute(params[i], value);
+        }
+    }
+
+    public String actionAfterView(ActionRequest request, ActionResponse response, MultiPageModel model) throws PortletException, IOException {
+        String caCN = request.getParameter("caCN");
+        String caOU = request.getParameter("caOU");
+        String caO = request.getParameter("caO");
+        String caL = request.getParameter("caL");
+        String caST = request.getParameter("caST");
+        String caC = request.getParameter("caC");
+        String alias = request.getParameter("alias");
+        String password = request.getParameter("password");
+        String keyAlgorithm = request.getParameter("keyAlgorithm");
+        String keySize = request.getParameter("keySize");
+        String algorithm = request.getParameter("algorithm");
+        String validFrom = request.getParameter("validFrom");
+        String validTo = request.getParameter("validTo");
+        String sNo = request.getParameter("sNo");
+        String errorMsg = null;
+        
+        try {
+            // Generate keypair
+            // Check if the key algorithm is same as defaultKeyAlgorithm (which is "RSA")
+            if(!defaultKeyAlgorithm.equalsIgnoreCase(keyAlgorithm)) {
+                throw new Exception("Key Algorithm '"+keyAlgorithm+"' is not supported.");
+            }
+            // Create a KeystoreInstance and generate keypair
+            KeystoreInstance caKeystore = createCAKeystoreInstance(request, password);
+            caKeystore.unlockKeystore(password.toCharArray());
+            caKeystore.generateKeyPair(alias, password.toCharArray(), password.toCharArray(), keyAlgorithm, Integer.parseInt(keySize),
+                    algorithm, 365, caCN, caOU, caO, caL, caST, caC);
+            caKeystore.unlockPrivateKey(alias, password.toCharArray(), password.toCharArray());
+            
+            // Create CertificationAuthority, CertificateStore and CertificateRequestStore GBeans
+            createCARelatedGBeans(request, (GeronimoManagedBean)caKeystore, defaultCAStoreDir, defaultCSRStoreDir);
+
+            CertificationAuthority ca = getCertificationAuthority(request);
+            ca.unlock(password.toCharArray());
+
+            // Certificate validity and serial number.
+            // Validity of these have been checked before loading the confirmation page.
+            Date validFromDate = null, validToDate = null;
+            DateFormat df = new SimpleDateFormat("MM/dd/yyyy");
+            validFromDate = df.parse(validFrom);
+            validToDate = df.parse(validTo);
+            BigInteger serialNum = new BigInteger(sNo);
+            
+            // Instruct the CA to issue a self-signed certificate.
+            ca.issueOwnCertificate(serialNum, validFromDate, validToDate, algorithm);
+            // Publish the CA's certificate to CertificateStore.
+            getCertificateStore(request).storeCACertificate(ca.getCertificate());
+            
+            // CA Setup is succeessful.
+            // Load a page to show CA details.
+            response.setRenderParameter(INFO_MSG, "CA Setup is successful!");
+            log.info("CA Setup is successful.");
+            
+            return CADETAILS_MODE+BEFORE_ACTION;
+        } catch(Exception e) {
+            errorMsg = e.toString();
+            log.error("Errors in CA Setup process.", e);
+        }
+        
+        // An error occurred.  Go back to CA details entry page so that user can correct the errors.
+        if(errorMsg != null) response.setRenderParameter(ERROR_MSG, errorMsg);
+        return SETUPCA_MODE+BEFORE_ACTION;
+    }
+    
+    /**
+     * This method creates CerificationAuthority, CertificateStore and CertificateRequestStore GBeans.  The GBeans are
+     * created and added to the same configuration containing the caKeystore GBean.
+     * @param request PortletRequest to execute any kernel api's
+     * @param caKeystore Keystore to be used by the CA
+     * @param certStorePath Path for CertificateStore directory.  Note: This CA uses FileCertificateStore
+     * @param certReqStorePath Path for CertificateRequestStore directory: Note: This CA uses FileCertificateRequestStore
+     */
+    private void createCARelatedGBeans(PortletRequest request, GeronimoManagedBean caKeystore, String certStorePath, String certReqStorePath) {
+        // Get hold of configuration containing caKeystore GBean
+        AbstractName caKeystoreName = PortletManager.getNameFor(request, caKeystore);
+        Artifact configurationId =  PortletManager.getConfigurationFor(request, caKeystoreName);
+        ServerInfo serverInfo = PortletManager.getCurrentServer(request).getServerInfo();
+        AbstractName serverInfoName = PortletManager.getNameFor(request, serverInfo);
+        Naming naming = PortletManager.getManagementHelper(request).getNaming();
+        
+        // Add a CertificateStore GBean
+        AbstractName certStoreName = naming.createSiblingName(caKeystoreName, "geronimo-ca-cert-store", NameFactory.CERTIFICATE_STORE);
+        GBeanData certStore = new GBeanData(certStoreName, FileCertificateStore.GBEAN_INFO);
+        certStore.setAttribute("directoryPath", URI.create(certStorePath));
+        certStore.setReferencePattern("ServerInfo", serverInfoName);
+        PortletManager.addGBeanToConfiguration(request, configurationId, certStore, true);
+        
+        // Add a CertificateRequestStore GBean
+        AbstractName certReqStoreName = naming.createSiblingName(caKeystoreName, "geronimo-ca-cert-req-store", NameFactory.CERTIFICATE_REQUEST_STORE);
+        GBeanData certReqStore = new GBeanData(certReqStoreName, FileCertificateRequestStore.GBEAN_INFO);
+        certReqStore.setAttribute("directoryPath", URI.create(certReqStorePath));
+        certReqStore.setReferencePattern("ServerInfo", serverInfoName);
+        PortletManager.addGBeanToConfiguration(request, configurationId, certReqStore, true);
+        
+        // Add a CertificationAuthority GBean
+        AbstractName caName = naming.createSiblingName(caKeystoreName, "geronimo-ca", NameFactory.CERTIFICATION_AUTHORITY);
+        GBeanData ca = new GBeanData(caName, GeronimoCertificationAuthority.GBEAN_INFO);
+        ca.setReferencePattern("ServerInfo", serverInfoName);
+        ca.setReferencePattern("KeystoreInstance", caKeystoreName);
+        ca.setReferencePattern("CertificateStore", certStoreName);
+        ca.setReferencePattern("CertificateRequestStore", certReqStoreName);
+        PortletManager.addGBeanToConfiguration(request, configurationId, ca, true);
+    }
+}

Added: geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/ca/ConfirmCertReqHandler.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/ca/ConfirmCertReqHandler.java?view=auto&rev=476229
==============================================================================
--- geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/ca/ConfirmCertReqHandler.java (added)
+++ geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/ca/ConfirmCertReqHandler.java Fri Nov 17 09:48:02 2006
@@ -0,0 +1,70 @@
+/**
+ *
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.console.ca;
+
+import java.io.IOException;
+
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.PortletException;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+
+import org.apache.geronimo.console.MultiPageModel;
+
+/**
+ * Handler for the Confirm Certificate Request screen.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ConfirmCertReqHandler extends BaseCAHandler {
+    public ConfirmCertReqHandler() {
+        super(CONFIRM_CERT_REQ_MODE, "/WEB-INF/view/ca/confirmCertReq.jsp");
+    }
+
+    public String actionBeforeView(ActionRequest request, ActionResponse response, MultiPageModel model) throws PortletException, IOException {
+        String[] params = {ERROR_MSG, INFO_MSG, "subject", "publickey", "requestId"};
+        for(int i = 0; i < params.length; ++i) {
+            String value = request.getParameter(params[i]);
+            if(value != null) response.setRenderParameter(params[i], value);
+        }
+        return getMode();
+    }
+
+    public void renderView(RenderRequest request, RenderResponse response, MultiPageModel model) throws PortletException, IOException {
+        String[] params = {ERROR_MSG, INFO_MSG, "subject", "publickey", "requestId"};
+        for(int i = 0; i < params.length; ++i) {
+            String value = request.getParameter(params[i]);
+            if(value != null) request.setAttribute(params[i], value);
+        }
+    }
+
+    public String actionAfterView(ActionRequest request, ActionResponse response, MultiPageModel model) throws PortletException, IOException {
+        String requestId = request.getParameter("requestId");
+        String approve = request.getParameter("approve");
+        String reject = request.getParameter("reject");
+        if(approve != null) {
+            getCertificateRequestStore(request).setRequestVerified(requestId);
+            response.setRenderParameter(INFO_MSG, "Approved CSR. id = "+requestId);
+        } else if(reject != null) {
+            getCertificateRequestStore(request).deleteRequest(requestId);
+            response.setRenderParameter(INFO_MSG, "Rejected and deleted CSR. id = "+requestId);
+        }
+        return LIST_REQUESTS_VERIFY_MODE+BEFORE_ACTION;
+    }
+}

Added: geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/ca/ConfirmClientCertHandler.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/ca/ConfirmClientCertHandler.java?view=auto&rev=476229
==============================================================================
--- geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/ca/ConfirmClientCertHandler.java (added)
+++ geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/ca/ConfirmClientCertHandler.java Fri Nov 17 09:48:02 2006
@@ -0,0 +1,168 @@
+/**
+ *
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.console.ca;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.math.BigInteger;
+import java.security.PublicKey;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.PortletException;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.security.auth.x500.X500Principal;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.console.MultiPageModel;
+import org.apache.geronimo.management.geronimo.CertificationAuthority;
+import org.apache.geronimo.util.CaUtils;
+import org.apache.geronimo.util.asn1.x509.X509Name;
+
+/**
+ * Handler for Confirm Client Certificate Issue screen.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ConfirmClientCertHandler extends BaseCAHandler {
+    private final static Log log = LogFactory.getLog(ConfirmClientCertHandler.class);
+    public ConfirmClientCertHandler() {
+        super(CONFIRM_CLIENT_CERT_MODE, "/WEB-INF/view/ca/confirmClientCert.jsp");
+    }
+
+    public String actionBeforeView(ActionRequest request, ActionResponse response, MultiPageModel model) throws PortletException, IOException {
+        String[] params = {ERROR_MSG, INFO_MSG, "subject", "publickey", "algorithm", "validFrom", "validTo", "sNo", "pkcs10certreq", "requestId"};
+        for(int i = 0; i < params.length; ++i) {
+            String value = request.getParameter(params[i]);
+            if(value != null) response.setRenderParameter(params[i], value);
+        }
+        return getMode();
+    }
+
+    public void renderView(RenderRequest request, RenderResponse response, MultiPageModel model) throws PortletException, IOException {
+        String[] params = {ERROR_MSG, INFO_MSG, "subject", "publickey", "algorithm", "validFrom", "validTo", "sNo", "pkcs10certreq", "requestId"};
+        for(int i = 0; i < params.length; ++i) {
+            String value = request.getParameter(params[i]);
+            if(value != null) request.setAttribute(params[i], value);
+        }
+    }
+
+    public String actionAfterView(ActionRequest request, ActionResponse response, MultiPageModel model) throws PortletException, IOException {
+        String errorMsg = null;
+        try {
+            CertificationAuthority ca = getCertificationAuthority(request);
+            if(ca == null) {
+                throw new Exception("CA is not running.  CA may not have been initialized!!");
+            }
+            BigInteger sNo = new BigInteger(request.getParameter("sNo"));
+            if(ca.isCertificateIssued(sNo)) {
+                // A certificate with the serial number has already been issued.
+                // This may happen if the user clicks on "Issue Certificate" button a second time
+                log.warn("Second request to issue certificate with serial number'"+sNo+"'.  A certificate has already been issued.");
+                response.setRenderParameter("sNo", sNo.toString());
+                response.setRenderParameter(INFO_MSG, "A certificate with the serial number '"+sNo+"' has already been issued. "
+                        +"You may be seeing this message since you have clicked on 'Issue Certificate' button a second time.");
+                return VIEW_CERT_MODE;
+            }
+
+            X509Name subject = null;
+            PublicKey publickey = null;
+            // Process the CSR text to get subject details
+            String pkcs10certreq = null, certreq = null;
+            String challenge = null;
+            String requestId = request.getParameter("requestId");
+            if(requestId != null && !requestId.equals("")) {
+                // Certificate request is being processed using a previously stored request in CertificateRequestStore
+                String certreqText = getCertificateRequestStore(request).getRequest(requestId);
+                if(certreqText.startsWith(CaUtils.CERT_REQ_HEADER)) {
+                    // A PKCS 10 Certificate Request
+                    pkcs10certreq = certreqText;
+                } else {
+                    // Possibly a CSR received through web browser
+                    certreq = certreqText;
+                }
+            } else {
+                // No request id is found.  Get the PKCS10 request submitted through form input
+                pkcs10certreq = request.getParameter("pkcs10certreq");
+            }
+            
+            if(pkcs10certreq != null && !"".equals(pkcs10certreq)) {
+                // Process PKCS 10 Certificate Request text to get Subject name and public-key
+                Map certReqMap = CaUtils.processPKCS10Request(pkcs10certreq);
+                subject = (X509Name) certReqMap.get(CaUtils.CERT_REQ_SUBJECT);
+                publickey = (PublicKey) certReqMap.get(CaUtils.CERT_REQ_PUBLICKEY_OBJ);
+            } else {
+                // This is a custom request containing SPKAC and X509Name attributes received through web browser
+                Properties csrProps = new Properties();
+                csrProps.load(new ByteArrayInputStream(certreq.getBytes()));
+                String spkac = csrProps.getProperty("SPKAC");
+                String cn = csrProps.getProperty("CN");
+                String ou = csrProps.getProperty("OU");
+                String o = csrProps.getProperty("O");
+                String l = csrProps.getProperty("L");
+                String st = csrProps.getProperty("ST");
+                String c = csrProps.getProperty("C");
+                subject = CaUtils.getX509Name(cn, ou, o, l, st, c);
+                Map certReqMap = CaUtils.processSPKAC(spkac);
+                publickey = (PublicKey) certReqMap.get(CaUtils.CERT_REQ_PUBLICKEY_OBJ);
+                challenge = (String) certReqMap.get(CaUtils.PKAC_CHALLENGE);
+            }
+
+            // Dates have already been validated in the previous screen
+            String validFrom = request.getParameter("validFrom");
+            String validTo = request.getParameter("validTo");
+            DateFormat df = new SimpleDateFormat("MM/dd/yyyy");
+            Date validFromDate = df.parse(validFrom);
+            Date validToDate = df.parse(validTo);
+            String algorithm = request.getParameter("algorithm");
+            // Issue certificate
+            ca.issueCertificate(new X500Principal(subject.getEncoded()), publickey, sNo, validFromDate, validToDate, algorithm);
+            // Store the challenge phrase against the issued certificate serial number
+            if(challenge != null && !challenge.equals("")) {
+                getCertificateStore(request).setCertificateChallenge(sNo, challenge);
+            }
+            
+            if(requestId != null && !requestId.equals("")) {
+                // This request was processed using a requestId from CertificateRequestStore.  Delete the fulfilled request.
+                getCertificateRequestStore(request).setRequestFulfilled(requestId, sNo);
+                // The confirmation page will show a link to the "Requests to be fulfilled" page.
+                response.setRenderParameter("linkToListRequests", "true");
+            }
+
+            // Set the serial number and forward to view certificate page
+            response.setRenderParameter("sNo", sNo.toString());
+            response.setRenderParameter(INFO_MSG, "Certificate Issued successfully. This Certificate details can also be viewed using the serial number '"
+                    +sNo+"' with the 'View Issued Certificate' link provided in the CA home screen.");
+            log.info("Certificate with serial number '"+sNo+"' issued to "+subject);
+            return VIEW_CERT_MODE;
+        } catch(Exception e) {
+            errorMsg = e.toString();
+            log.error("Errors in issuing certificate.", e);
+        }
+        // An error occurred.  Go back to previous screen to let the user correct the errors.
+        response.setRenderParameter(ERROR_MSG, errorMsg);
+        return CERT_REQ_DETAILS_MODE+BEFORE_ACTION;
+    }
+}

Added: geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/ca/IntroHandler.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/ca/IntroHandler.java?view=auto&rev=476229
==============================================================================
--- geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/ca/IntroHandler.java (added)
+++ geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/ca/IntroHandler.java Fri Nov 17 09:48:02 2006
@@ -0,0 +1,93 @@
+/**
+ *
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.console.ca;
+
+import java.io.IOException;
+
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.PortletException;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.console.MultiPageModel;
+import org.apache.geronimo.management.geronimo.CertificationAuthority;
+
+/**
+ * Handler for the CA home screen.
+ *
+ * @version $Rev$ $Date$
+ */
+public class IntroHandler extends BaseCAHandler {
+    private final static Log log = LogFactory.getLog(IntroHandler.class);
+    public IntroHandler() {
+        super(INDEX_MODE, "/WEB-INF/view/ca/index.jsp");
+    }
+
+    public String actionBeforeView(ActionRequest request, ActionResponse response, MultiPageModel model) throws PortletException, IOException {
+        String[] params = new String[] {ERROR_MSG, INFO_MSG};
+        for(int i = 0; i < params.length; ++i) {
+            String value = request.getParameter(params[i]);
+            if(value != null) response.setRenderParameter(params[i], value);
+        }
+        return getMode();
+    }
+
+    public void renderView(RenderRequest request, RenderResponse response, MultiPageModel model) throws PortletException, IOException {
+        String[] params = {ERROR_MSG, INFO_MSG};
+        for(int i = 0; i < params.length; ++i) {
+            String value = request.getParameter(params[i]);
+            if(value != null) request.setAttribute(params[i], value);
+        }
+        
+        CertificationAuthority ca = getCertificationAuthority(request);
+        if(ca == null) {
+            // CA GBean is not running or the CA has not been initialized.
+            request.setAttribute("caNotSetup", Boolean.TRUE);
+        } else {
+            request.setAttribute("caNotSetup", Boolean.FALSE);
+            request.setAttribute("caLocked", ca.isLocked() ? Boolean.TRUE : Boolean.FALSE);
+        }
+    }
+
+    public String actionAfterView(ActionRequest request, ActionResponse response, MultiPageModel model) throws PortletException, IOException {
+        if(request.getParameter("lock") != null) {
+            CertificationAuthority ca = getCertificationAuthority(request);
+            if(ca == null) {
+                log.warn("CA is not running or CA may not have been initialized.  Unable to lock CA.");
+                response.setRenderParameter(ERROR_MSG, "CA is not running or CA may not have been initialized.  Unable to lock CA.");
+            } else {
+                ca.lock();
+                log.info("CA is now locked.");
+                response.setRenderParameter(INFO_MSG, "CA has been locked!");
+            }
+        } else if(request.getParameter("publish") != null) {
+            CertificationAuthority ca = getCertificationAuthority(request);
+            try {
+                getCertificateStore(request).storeCACertificate(ca.getCertificate());
+                response.setRenderParameter(INFO_MSG, "CA's certificate published to Certificate Store");
+            } catch (Exception e) {
+                log.error("Error while publishing CA's certificate to Certificate Store", e);
+                response.setRenderParameter(ERROR_MSG, "Error while publishing CA's certificate to Certificate Store. "+e);
+            }
+        }
+        return getMode()+BEFORE_ACTION;
+    }
+}

Added: geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/ca/ListRequestsIssueHandler.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/ca/ListRequestsIssueHandler.java?view=auto&rev=476229
==============================================================================
--- geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/ca/ListRequestsIssueHandler.java (added)
+++ geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/ca/ListRequestsIssueHandler.java Fri Nov 17 09:48:02 2006
@@ -0,0 +1,107 @@
+/**
+ *
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.console.ca;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.PortletException;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.console.MultiPageModel;
+import org.apache.geronimo.management.geronimo.CertificateRequestStore;
+import org.apache.geronimo.util.CaUtils;
+import org.apache.geronimo.util.asn1.x509.X509Name;
+
+/**
+ * Handler for "Requests to be fulfilled" screen.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ListRequestsIssueHandler extends BaseCAHandler {
+    private final static Log log = LogFactory.getLog(ListRequestsIssueHandler.class);
+    public ListRequestsIssueHandler() {
+        super(LIST_REQUESTS_ISSUE_MODE, "/WEB-INF/view/ca/listRequestsIssue.jsp");
+    }
+
+    public String actionBeforeView(ActionRequest request, ActionResponse response, MultiPageModel model) throws PortletException, IOException {
+        String[] params = {ERROR_MSG, INFO_MSG};
+        for(int i = 0; i < params.length; ++i) {
+            String value = request.getParameter(params[i]);
+            if(value != null) response.setRenderParameter(params[i], value);
+        }
+        return getMode();
+    }
+
+    public void renderView(RenderRequest request, RenderResponse response, MultiPageModel model) throws PortletException, IOException {
+        String[] params = {ERROR_MSG, INFO_MSG};
+        for(int i = 0; i < params.length; ++i) {
+            String value = request.getParameter(params[i]);
+            if(value != null) request.setAttribute(params[i], value);
+        }
+        CertificateRequestStore csrStore = getCertificateRequestStore(request);
+        String[] csrIds = csrStore.getVerifiedRequestIds();
+        request.setAttribute("csrIds", csrIds);
+    }
+
+    public String actionAfterView(ActionRequest request, ActionResponse response, MultiPageModel model) throws PortletException, IOException {
+        String errorMsg = null;
+        String requestId = request.getParameter("requestId");
+        try {
+            response.setRenderParameter("requestId", requestId);
+            // Retrieve the request info based on the requestId
+            String certreq = getCertificateRequestStore(request).getRequest(requestId);
+            if(certreq.startsWith(CaUtils.CERT_REQ_HEADER)) {
+                // This is a PKCS 10 Request
+                Map certReqMap = CaUtils.processPKCS10Request(certreq);
+                // Set the subject and publickey values to be displayed in subsequent screens
+                response.setRenderParameter("subject", certReqMap.get(CaUtils.CERT_REQ_SUBJECT).toString());
+                response.setRenderParameter("publickey", certReqMap.get(CaUtils.CERT_REQ_PUBLICKEY_OBJ).toString());
+            } else {
+                // This is a custom request containing SPKAC and X509Name attributes received through web browser
+                Properties csrProps = new Properties();
+                csrProps.load(new ByteArrayInputStream(certreq.getBytes()));
+                String spkac = csrProps.getProperty("SPKAC");
+                String cn = csrProps.getProperty("CN");
+                String ou = csrProps.getProperty("OU");
+                String o = csrProps.getProperty("O");
+                String l = csrProps.getProperty("L");
+                String st = csrProps.getProperty("ST");
+                String c = csrProps.getProperty("C");
+                X509Name subject = CaUtils.getX509Name(cn, ou, o, l, st, c);
+                Map certReqMap = CaUtils.processSPKAC(spkac);
+                // Set the subject and publickey values to be displayed in subsequent screens
+                response.setRenderParameter("subject", subject.toString());
+                response.setRenderParameter("publickey", certReqMap.get(CaUtils.CERT_REQ_PUBLICKEY_OBJ).toString());
+            }
+            return CERT_REQ_DETAILS_MODE+BEFORE_ACTION;
+        } catch(Exception e) {
+            errorMsg = e.toString();
+            log.error("Errors while processing a Certificate Request. id="+requestId, e);
+        }
+        response.setRenderParameter(ERROR_MSG, errorMsg);
+        return getMode()+BEFORE_ACTION;
+    }
+}

Added: geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/ca/ListRequestsVerifyHandler.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/ca/ListRequestsVerifyHandler.java?view=auto&rev=476229
==============================================================================
--- geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/ca/ListRequestsVerifyHandler.java (added)
+++ geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/ca/ListRequestsVerifyHandler.java Fri Nov 17 09:48:02 2006
@@ -0,0 +1,107 @@
+/**
+ *
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.console.ca;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.PortletException;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.console.MultiPageModel;
+import org.apache.geronimo.management.geronimo.CertificateRequestStore;
+import org.apache.geronimo.util.CaUtils;
+import org.apache.geronimo.util.asn1.x509.X509Name;
+
+/**
+ * Handler for "Requests to be verified" screen.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ListRequestsVerifyHandler extends BaseCAHandler {
+    private final static Log log = LogFactory.getLog(ListRequestsVerifyHandler.class);
+    public ListRequestsVerifyHandler() {
+        super(LIST_REQUESTS_VERIFY_MODE, "/WEB-INF/view/ca/listRequestsVerify.jsp");
+    }
+
+    public String actionBeforeView(ActionRequest request, ActionResponse response, MultiPageModel model) throws PortletException, IOException {
+        String[] params = {ERROR_MSG, INFO_MSG};
+        for(int i = 0; i < params.length; ++i) {
+            String value = request.getParameter(params[i]);
+            if(value != null) response.setRenderParameter(params[i], value);
+        }
+        return getMode();
+    }
+
+    public void renderView(RenderRequest request, RenderResponse response, MultiPageModel model) throws PortletException, IOException {
+        String[] params = {ERROR_MSG, INFO_MSG};
+        for(int i = 0; i < params.length; ++i) {
+            String value = request.getParameter(params[i]);
+            if(value != null) request.setAttribute(params[i], value);
+        }
+        CertificateRequestStore csrStore = getCertificateRequestStore(request);
+        String[] csrIds = csrStore.getVerificatonDueRequestIds();
+        request.setAttribute("csrIds", csrIds);
+    }
+
+    public String actionAfterView(ActionRequest request, ActionResponse response, MultiPageModel model) throws PortletException, IOException {
+        String errorMsg = null;
+        String requestId = request.getParameter("requestId");
+        try {
+            response.setRenderParameter("requestId", requestId);
+            // Retrieve the request info based on the requestId
+            String certreq = getCertificateRequestStore(request).getRequest(requestId);
+            if(certreq.startsWith(CaUtils.CERT_REQ_HEADER)) {
+                // This is a PKCS10 Request
+                Map certReqMap = CaUtils.processPKCS10Request(certreq);
+                // Set the subject and publickey values to be shown in subsequent screens
+                response.setRenderParameter("subject", certReqMap.get(CaUtils.CERT_REQ_SUBJECT).toString());
+                response.setRenderParameter("publickey", certReqMap.get(CaUtils.CERT_REQ_PUBLICKEY_OBJ).toString());
+            } else {
+                // This is a custom request containing SPKAC and X509Name attributes received through web browser
+                Properties csrProps = new Properties();
+                csrProps.load(new ByteArrayInputStream(certreq.getBytes()));
+                String spkac = csrProps.getProperty("SPKAC");
+                String cn = csrProps.getProperty("CN");
+                String ou = csrProps.getProperty("OU");
+                String o = csrProps.getProperty("O");
+                String l = csrProps.getProperty("L");
+                String st = csrProps.getProperty("ST");
+                String c = csrProps.getProperty("C");
+                X509Name subject = CaUtils.getX509Name(cn, ou, o, l, st, c);
+                Map certReqMap = CaUtils.processSPKAC(spkac);
+                // Set the subject and publickey values to be shown in subsequent screens
+                response.setRenderParameter("subject", subject.toString());
+                response.setRenderParameter("publickey", certReqMap.get(CaUtils.CERT_REQ_PUBLICKEY_OBJ).toString());
+            }
+            return CONFIRM_CERT_REQ_MODE+BEFORE_ACTION;
+        } catch(Exception e) {
+            errorMsg = e.toString();
+            log.error("Errors while verifying Certificate Request. id="+requestId, e);
+        }
+        response.setRenderParameter(ERROR_MSG, errorMsg);
+        return getMode()+BEFORE_ACTION;
+    }
+}

Added: geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/ca/ProcessCSRHandler.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/ca/ProcessCSRHandler.java?view=auto&rev=476229
==============================================================================
--- geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/ca/ProcessCSRHandler.java (added)
+++ geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/ca/ProcessCSRHandler.java Fri Nov 17 09:48:02 2006
@@ -0,0 +1,80 @@
+/**
+ *
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.console.ca;
+
+import java.io.IOException;
+import java.util.Map;
+
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.PortletException;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.console.MultiPageModel;
+import org.apache.geronimo.util.CaUtils;
+
+/**
+ * Handler for process CSR screen.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ProcessCSRHandler extends BaseCAHandler {
+    private final static Log log = LogFactory.getLog(ProcessCSRHandler.class);
+    public ProcessCSRHandler() {
+        super(PROCESS_CSR_MODE, "/WEB-INF/view/ca/processCSR.jsp");
+    }
+
+    public String actionBeforeView(ActionRequest request, ActionResponse response, MultiPageModel model) throws PortletException, IOException {
+        String[] params = {ERROR_MSG, INFO_MSG};
+        for(int i = 0; i < params.length; ++i) {
+            String value = request.getParameter(params[i]);
+            if(value != null) response.setRenderParameter(params[i], value);
+        }
+        return getMode();
+    }
+
+    public void renderView(RenderRequest request, RenderResponse response, MultiPageModel model) throws PortletException, IOException {
+        String[] params = {ERROR_MSG, INFO_MSG};
+        for(int i = 0; i < params.length; ++i) {
+            Object value = request.getParameter(params[i]);
+            if(value != null) request.setAttribute(params[i], value);
+        }
+    }
+
+    public String actionAfterView(ActionRequest request, ActionResponse response, MultiPageModel model) throws PortletException, IOException {
+        String errorMsg = null;
+        try {
+            // Process the PKCS10 Certificate Request
+            String pkcs10certreq = request.getParameter("pkcs10certreq");
+            Map certReqMap = CaUtils.processPKCS10Request(pkcs10certreq);
+            response.setRenderParameter("pkcs10certreq", pkcs10certreq);
+            // Set the subject and publickey values to be shown in subsequent screens
+            response.setRenderParameter("subject", certReqMap.get(CaUtils.CERT_REQ_SUBJECT).toString());
+            response.setRenderParameter("publickey", certReqMap.get(CaUtils.CERT_REQ_PUBLICKEY_OBJ).toString());
+            return CERT_REQ_DETAILS_MODE+BEFORE_ACTION;
+        } catch(Exception e) {
+            errorMsg = e.toString();
+            log.error("Errors while processing a CSR.", e);
+        }
+        response.setRenderParameter(ERROR_MSG, errorMsg);
+        return getMode()+BEFORE_ACTION;
+    }
+}



Mime
View raw message