KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sslexplorer > install > actions > SelectCertificateSourceAction


1 /*
2  * SSL-Explorer
3  *
4  * Copyright (C) 2003-2006 3SP LTD. All Rights Reserved
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2 of
9  * the License, or (at your option) any later version.
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public
16  * License along with this program; if not, write to the Free Software
17  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */

19             
20 package com.sslexplorer.install.actions;
21
22 import javax.servlet.http.HttpServletRequest JavaDoc;
23 import javax.servlet.http.HttpServletResponse JavaDoc;
24
25 import org.apache.commons.logging.Log;
26 import org.apache.commons.logging.LogFactory;
27 import org.apache.struts.Globals;
28 import org.apache.struts.action.ActionForm;
29 import org.apache.struts.action.ActionForward;
30 import org.apache.struts.action.ActionMapping;
31 import org.apache.struts.action.ActionMessage;
32 import org.apache.struts.action.ActionMessages;
33
34 import com.sslexplorer.boot.KeyStoreManager;
35 import com.sslexplorer.install.forms.SelectCertificateSourceForm;
36 import com.sslexplorer.install.forms.SetKeyStorePasswordForm;
37 import com.sslexplorer.keystore.actions.ShowKeyStoreDispatchAction;
38 import com.sslexplorer.wizard.AbstractWizardSequence;
39 import com.sslexplorer.wizard.DefaultWizardSequence;
40 import com.sslexplorer.wizard.WizardStep;
41
42
43 /**
44  * Implementatation of a {@link AbstractInstallWizardAction} that allows a
45  * source of SSL-Explorers main certificate to be chosed. This is the first
46  * page in the installation wizard.
47  *
48  * @author Brett Smith <a HREF="mailto: brett@3sp.com">&lt;brett@3sp.com&gt;</a>
49  * @see com.sslexplorer.install.forms.ConfigureUserDatabaseForm
50  */

51 public class SelectCertificateSourceAction extends AbstractInstallWizardAction {
52
53     static Log log = LogFactory.getLog(ShowKeyStoreDispatchAction.class);
54
55     /* (non-Javadoc)
56      * @see com.sslexplorer.wizard.actions.AbstractWizardAction#next(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
57      */

58     public ActionForward next(ActionMapping mapping, ActionForm form, HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response)
59                     throws Exception JavaDoc {
60         super.next(mapping, form, request, response);
61         SelectCertificateSourceForm wizardForm = (SelectCertificateSourceForm)form;
62         if(SelectCertificateSourceForm.CREATE_NEW_CERTIFICATE.equals(wizardForm.getCertificateSource())) {
63             return mapping.findForward("setKeyStorePassword");
64         }
65         else if(SelectCertificateSourceForm.IMPORT_EXISTING_CERTIFICATE.equals(wizardForm.getCertificateSource())) {
66             getWizardSequence(request).removeAttribute(SetKeyStorePasswordForm.ATTR_KEY_STORE_PASSWORD);
67             return mapping.findForward("importExistingCertificate");
68         }
69         else if(SelectCertificateSourceForm.USE_CURRENT_CERTIFICATE.equals(wizardForm.getCertificateSource())) {
70             getWizardSequence(request).removeAttribute(SetKeyStorePasswordForm.ATTR_KEY_STORE_PASSWORD);
71             return mapping.findForward("useCurrentCertificate");
72         }
73         return unspecified(mapping, form, request, response);
74     }
75     
76
77     /* (non-Javadoc)
78      * @see com.sslexplorer.wizard.actions.AbstractWizardAction#unspecified(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
79      */

80     public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response) throws Exception JavaDoc {
81         
82         /* If there was an exception loading the keystore, display it as an error */
83         ActionMessages errs = new ActionMessages();
84         Throwable JavaDoc ex = KeyStoreManager.getInstance(KeyStoreManager.DEFAULT_KEY_STORE).getKeyStoreException();
85         if(ex != null) {
86             errs.add(Globals.ERROR_KEY, new ActionMessage("installation.selectCertificateSource.error.couldNotLoadKeystore", ex.getMessage()));
87             saveErrors(request, errs);
88         }
89         return super.unspecified(mapping, form, request, response);
90     }
91
92     /* (non-Javadoc)
93      * @see com.sslexplorer.wizard.actions.AbstractWizardAction#previous(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
94      */

95     public ActionForward previous(ActionMapping mapping, ActionForm form, HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response)
96                     throws Exception JavaDoc {
97         throw new Exception JavaDoc("No previous steps.");
98     }
99
100     /* (non-Javadoc)
101      * @see com.sslexplorer.wizard.actions.AbstractWizardAction#createWizardSequence(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
102      */

103     protected AbstractWizardSequence createWizardSequence(ActionMapping mapping, ActionForm form, HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response) throws Exception JavaDoc {
104         ActionForward fwd = mapping.findForward("finish");
105         DefaultWizardSequence seq = new DefaultWizardSequence(fwd, "install", "installation", "/shutdown.do?actionTarget=installShutdown", "installWizard", this.getSessionInfo(request));
106         seq.addStep(new WizardStep("/selectCertificateSource.do", true));
107         seq.addStep(new WizardStep("/selectUserDatabase.do"));
108         seq.addStep(new WizardStep("/configureSuperUser.do"));
109         seq.addStep(new WizardStep("/webServer.do"));
110         seq.addStep(new WizardStep("/configureProxies.do"));
111         seq.addStep(new WizardStep("/installXtra.do"));
112         seq.addStep(new WizardStep("/installationSummary.do"));
113         return seq;
114     }
115 }
116
Popular Tags