KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sslexplorer > webforwards > webforwardwizard > forms > WebForwardAuthenticationDetailsForm


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.webforwards.webforwardwizard.forms;
21
22 import java.util.List JavaDoc;
23
24 import javax.servlet.http.HttpServletRequest JavaDoc;
25
26 import org.apache.commons.logging.Log;
27 import org.apache.commons.logging.LogFactory;
28 import org.apache.struts.action.ActionErrors;
29 import org.apache.struts.action.ActionMapping;
30
31 import com.maverick.http.HttpAuthenticatorFactory;
32 import com.sslexplorer.core.forms.AbstractResourceDetailsWizardForm;
33 import com.sslexplorer.webforwards.WebForwardPlugin;
34 import com.sslexplorer.webforwards.WebForwardTypes;
35 import com.sslexplorer.wizard.AbstractWizardSequence;
36
37 /**
38  * <p>
39  * The form for all other attributes associated with the TunneledSite resource.
40  *
41  * @author James D Robinson <a HREF="mailto:james@3sp.com">&lt;james@3sp.com&gt;</a>
42  *
43  */

44 public class WebForwardAuthenticationDetailsForm extends AbstractResourceDetailsWizardForm {
45
46     final static Log log = LogFactory.getLog(WebForwardAuthenticationDetailsForm.class);
47
48     private int type = -1;
49
50     // Authenticating web forward
51
static final String JavaDoc ATTR_NO_AUTHENTICATION = "none";
52     static final String JavaDoc ATTR_FORM_BASED_AUTHENTICATION = "form";
53     static final String JavaDoc ATTR_HTTP_AUTHENTICATION = "http";
54     public final static String JavaDoc ATTR_AUTHENTICATION_USERNAME = "authenticationUsername";
55     public final static String JavaDoc ATTR_AUTHENTICATION_PASSWORD = "authenticationPassword";
56     public final static String JavaDoc ATTR_PREFERRED_AUTHENTICATION_SCHEME = "preferredAuthenticationScheme";
57     
58     private String JavaDoc authenticationType = ATTR_NO_AUTHENTICATION;
59     private String JavaDoc authenticationUsername;
60     private String JavaDoc authenticationPassword;
61     private String JavaDoc preferredAuthenticationScheme;
62
63     public final static String JavaDoc ATTR_FORM_PARAMETERS = "formParameters";
64     public final static String JavaDoc ATTR_FORM_TYPE = "formType";
65
66     // Form parameters
67
private String JavaDoc formParameters;
68     private String JavaDoc formType;
69
70     /**
71      * Construtor
72      */

73     public WebForwardAuthenticationDetailsForm() {
74         // Autocomplete must be false because this page contains passwords
75
super(true, true, "/WEB-INF/jsp/content/webforward/webforwardwizard/webForwardAuthenticationDetails.jspf",
76                         "authenticationUsername", false, false, "webForwardAuthenticationDetails", "webForwards",
77                         "webForwardWizard.webForwardAuthenticationDetails", 4, WebForwardPlugin.WEBFORWARD_RESOURCE_TYPE);
78     }
79
80     /*
81      * (non-Javadoc)
82      *
83      * @see com.sslexplorer.wizard.forms.AbstractWizardForm#init(com.sslexplorer.wizard.AbstractWizardSequence,
84      * javax.servlet.http.HttpServletRequest)
85      */

86     public void init(AbstractWizardSequence sequence, HttpServletRequest JavaDoc request) throws Exception JavaDoc {
87         super.init(sequence, request);
88         type = ((Integer JavaDoc) sequence.getAttribute(WebForwardTypeSelectionForm.ATTR_TYPE, new Integer JavaDoc(0))).intValue();
89
90         this.authenticationUsername = (String JavaDoc) sequence.getAttribute(ATTR_AUTHENTICATION_USERNAME, "");
91         this.authenticationPassword = (String JavaDoc) sequence.getAttribute(ATTR_AUTHENTICATION_PASSWORD, "");
92         this.preferredAuthenticationScheme = (String JavaDoc) sequence.getAttribute(ATTR_PREFERRED_AUTHENTICATION_SCHEME,
93                         HttpAuthenticatorFactory.NONE);
94
95         this.formParameters = (String JavaDoc) sequence.getAttribute(ATTR_FORM_PARAMETERS, "");
96         this.formType = (String JavaDoc) sequence.getAttribute(ATTR_FORM_TYPE, "");
97     }
98
99     /*
100      * (non-Javadoc)
101      *
102      * @see com.sslexplorer.wizard.forms.AbstractWizardForm#apply(com.sslexplorer.wizard.AbstractWizardSequence)
103      */

104     public void apply(AbstractWizardSequence sequence) throws Exception JavaDoc {
105         super.apply(sequence);
106         sequence.putAttribute(ATTR_AUTHENTICATION_USERNAME, this.authenticationUsername);
107         sequence.putAttribute(ATTR_AUTHENTICATION_PASSWORD, this.authenticationPassword);
108         sequence.putAttribute(ATTR_PREFERRED_AUTHENTICATION_SCHEME, this.preferredAuthenticationScheme);
109         sequence.putAttribute(ATTR_FORM_PARAMETERS, this.formParameters);
110         sequence.putAttribute(ATTR_FORM_TYPE, this.formType);
111
112     }
113
114     /*
115      * (non-Javadoc)
116      *
117      * @see org.apache.struts.action.ActionForm#validate(org.apache.struts.action.ActionMapping,
118      * javax.servlet.http.HttpServletRequest)
119      */

120     public ActionErrors validate(ActionMapping mapping, HttpServletRequest JavaDoc request) {
121         if (getResourceName() != null && isCommiting()) {
122             ActionErrors errs = super.validate(mapping, request);
123             return errs;
124         }
125         return null;
126     }
127
128     /**
129      * @return
130      */

131     public int getType() {
132         return type;
133     }
134
135     /**
136      * @param type
137      */

138     public void setType(int type) {
139         this.type = type;
140     }
141
142     public void reset(ActionMapping mapping, HttpServletRequest JavaDoc request) {
143         super.reset(mapping, request);
144     }
145     
146     public boolean isNoAuthentication() {
147         return ATTR_NO_AUTHENTICATION.equals(getAuthenticationType());
148     }
149     
150     public boolean isFormBasedAuthentication() {
151         return ATTR_FORM_BASED_AUTHENTICATION.equals(getAuthenticationType());
152     }
153     
154     public boolean isHttpAuthentication() {
155         return ATTR_HTTP_AUTHENTICATION.equals(getAuthenticationType());
156     }
157     
158     public String JavaDoc getAuthenticationType() {
159         return authenticationType;
160     }
161
162     public void setAuthenticationType(String JavaDoc authenticationType) {
163         this.authenticationType = authenticationType;
164     }
165
166     public String JavaDoc getAuthenticationPassword() {
167         return authenticationPassword;
168     }
169
170     public void setAuthenticationPassword(String JavaDoc authenticationPassword) {
171         this.authenticationPassword = authenticationPassword;
172     }
173
174     public String JavaDoc getAuthenticationUsername() {
175         return authenticationUsername;
176     }
177
178     public void setAuthenticationUsername(String JavaDoc authenticationUsername) {
179         this.authenticationUsername = authenticationUsername;
180     }
181
182     public String JavaDoc getPreferredAuthenticationScheme() {
183         return preferredAuthenticationScheme;
184     }
185
186     public void setPreferredAuthenticationScheme(String JavaDoc preferredAuthenticationScheme) {
187         this.preferredAuthenticationScheme = preferredAuthenticationScheme;
188     }
189
190     public List JavaDoc getPreferredAuthenticationSchemeList() {
191         return WebForwardTypes.PREFERED_SCHEMES;
192     }
193
194     public String JavaDoc getFormType() {
195         return formType;
196     }
197
198     public void setFormType(String JavaDoc formType) {
199         this.formType = formType;
200     }
201
202     public String JavaDoc getFormParameters() {
203         return formParameters;
204     }
205
206     public void setFormParameters(String JavaDoc formParameters) {
207         this.formParameters = formParameters;
208     }
209
210     public List JavaDoc getFormTypeList() {
211         return WebForwardTypes.FORM_SUBMIT_TYPES;
212     }
213
214     public List JavaDoc getEncodeingTypeList() {
215         return WebForwardTypes.ENCODING_TYPES;
216     }
217 }
Popular Tags