|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.jboss.jsfunit.framework.SimpleInitialRequestStrategy org.jboss.jsfunit.framework.FormAuthenticationStrategy
public class FormAuthenticationStrategy
Performs FORM authentication for JEE container-managed security. Note that
the form-login-page and the form-error-page specified in web.xml don't have
to be JSF pages.
This class needs to know the user name and password to log in. It also
needs to know the name of a submit button or other component that can
submit the form containing the login credentials. Because this might not
be a JSF page, this class finds the "submit" component using the name
attribute.
For non-JEE login, there is a second constructor that allows username and
password components to have non-standard names.
Constructor Summary | |
---|---|
FormAuthenticationStrategy(String userName,
String password,
String submitComponent)
Create a new FormAuthenticationStrategy for JEE container-managed security. |
|
FormAuthenticationStrategy(String userName,
String password,
String submitComponent,
String userNameComponent,
String passwordComponent)
Create a new FormAuthenticationStrategy for non-JEE logins. |
Method Summary | |
---|---|
protected com.gargoylesoftware.htmlunit.Page |
clickSubmitComponent(com.gargoylesoftware.htmlunit.html.HtmlPage page)
Click the component needed to submit the form. |
com.gargoylesoftware.htmlunit.Page |
doInitialRequest(WebClientSpec wcSpec)
Perform the initial request and provide FORM authentication credentials when challenged. |
protected com.gargoylesoftware.htmlunit.html.HtmlElement |
getElement(com.gargoylesoftware.htmlunit.html.HtmlPage page,
String elementName)
Find an element by its name attribute. |
protected void |
setValue(com.gargoylesoftware.htmlunit.html.HtmlPage page,
String elementName,
String value)
Find an element by its name attribute and set its value. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public FormAuthenticationStrategy(String userName, String password, String submitComponent)
userName
- The user name.password
- The password.submitComponent
- The value of the name attribute for the submit component.public FormAuthenticationStrategy(String userName, String password, String submitComponent, String userNameComponent, String passwordComponent)
userName
- The user name.password
- The password.submitComponent
- The value of the name attribute for the submit component.userNameComponent
- The value of the name attribute for the user name input.passwordComponent
- The value of the name attribute for the password input.Method Detail |
---|
public com.gargoylesoftware.htmlunit.Page doInitialRequest(WebClientSpec wcSpec) throws IOException
doInitialRequest
in interface InitialRequestStrategy
doInitialRequest
in class SimpleInitialRequestStrategy
wcSpec
- The WebClient specification.
IOException
- if HtmlUnit encounters an error.protected com.gargoylesoftware.htmlunit.Page clickSubmitComponent(com.gargoylesoftware.htmlunit.html.HtmlPage page) throws IOException
page
- The page where credentials are entered.
IOException
- If the form can not be submitted.protected void setValue(com.gargoylesoftware.htmlunit.html.HtmlPage page, String elementName, String value)
page
- The page.elementName
- The value of the name attribute.value
- The value to set.protected com.gargoylesoftware.htmlunit.html.HtmlElement getElement(com.gargoylesoftware.htmlunit.html.HtmlPage page, String elementName)
page
- The page.elementName
- The value of the name attribute.
IllegalArgumentException
- if the element is not found or if more than
one element has that value for the name attribute.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |