1 19 20 package com.sslexplorer.webforwards.webforwardwizard.forms; 21 22 import java.util.List ; 23 24 import javax.servlet.http.HttpServletRequest ; 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 44 public class WebForwardAuthenticationDetailsForm extends AbstractResourceDetailsWizardForm { 45 46 final static Log log = LogFactory.getLog(WebForwardAuthenticationDetailsForm.class); 47 48 private int type = -1; 49 50 static final String ATTR_NO_AUTHENTICATION = "none"; 52 static final String ATTR_FORM_BASED_AUTHENTICATION = "form"; 53 static final String ATTR_HTTP_AUTHENTICATION = "http"; 54 public final static String ATTR_AUTHENTICATION_USERNAME = "authenticationUsername"; 55 public final static String ATTR_AUTHENTICATION_PASSWORD = "authenticationPassword"; 56 public final static String ATTR_PREFERRED_AUTHENTICATION_SCHEME = "preferredAuthenticationScheme"; 57 58 private String authenticationType = ATTR_NO_AUTHENTICATION; 59 private String authenticationUsername; 60 private String authenticationPassword; 61 private String preferredAuthenticationScheme; 62 63 public final static String ATTR_FORM_PARAMETERS = "formParameters"; 64 public final static String ATTR_FORM_TYPE = "formType"; 65 66 private String formParameters; 68 private String formType; 69 70 73 public WebForwardAuthenticationDetailsForm() { 74 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 86 public void init(AbstractWizardSequence sequence, HttpServletRequest request) throws Exception { 87 super.init(sequence, request); 88 type = ((Integer ) sequence.getAttribute(WebForwardTypeSelectionForm.ATTR_TYPE, new Integer (0))).intValue(); 89 90 this.authenticationUsername = (String ) sequence.getAttribute(ATTR_AUTHENTICATION_USERNAME, ""); 91 this.authenticationPassword = (String ) sequence.getAttribute(ATTR_AUTHENTICATION_PASSWORD, ""); 92 this.preferredAuthenticationScheme = (String ) sequence.getAttribute(ATTR_PREFERRED_AUTHENTICATION_SCHEME, 93 HttpAuthenticatorFactory.NONE); 94 95 this.formParameters = (String ) sequence.getAttribute(ATTR_FORM_PARAMETERS, ""); 96 this.formType = (String ) sequence.getAttribute(ATTR_FORM_TYPE, ""); 97 } 98 99 104 public void apply(AbstractWizardSequence sequence) throws Exception { 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 120 public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { 121 if (getResourceName() != null && isCommiting()) { 122 ActionErrors errs = super.validate(mapping, request); 123 return errs; 124 } 125 return null; 126 } 127 128 131 public int getType() { 132 return type; 133 } 134 135 138 public void setType(int type) { 139 this.type = type; 140 } 141 142 public void reset(ActionMapping mapping, HttpServletRequest 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 getAuthenticationType() { 159 return authenticationType; 160 } 161 162 public void setAuthenticationType(String authenticationType) { 163 this.authenticationType = authenticationType; 164 } 165 166 public String getAuthenticationPassword() { 167 return authenticationPassword; 168 } 169 170 public void setAuthenticationPassword(String authenticationPassword) { 171 this.authenticationPassword = authenticationPassword; 172 } 173 174 public String getAuthenticationUsername() { 175 return authenticationUsername; 176 } 177 178 public void setAuthenticationUsername(String authenticationUsername) { 179 this.authenticationUsername = authenticationUsername; 180 } 181 182 public String getPreferredAuthenticationScheme() { 183 return preferredAuthenticationScheme; 184 } 185 186 public void setPreferredAuthenticationScheme(String preferredAuthenticationScheme) { 187 this.preferredAuthenticationScheme = preferredAuthenticationScheme; 188 } 189 190 public List getPreferredAuthenticationSchemeList() { 191 return WebForwardTypes.PREFERED_SCHEMES; 192 } 193 194 public String getFormType() { 195 return formType; 196 } 197 198 public void setFormType(String formType) { 199 this.formType = formType; 200 } 201 202 public String getFormParameters() { 203 return formParameters; 204 } 205 206 public void setFormParameters(String formParameters) { 207 this.formParameters = formParameters; 208 } 209 210 public List getFormTypeList() { 211 return WebForwardTypes.FORM_SUBMIT_TYPES; 212 } 213 214 public List getEncodeingTypeList() { 215 return WebForwardTypes.ENCODING_TYPES; 216 } 217 } | Popular Tags |