I am trying to create a login page using SmartGWT and trying to get authentication using the Jetty server form embedded in the GWT plugin for Eclipse. I have a page that takes a username and password using TextItems, and then when the login button is pressed, I need authentication.
I installed my jetty-web.xml file to create a user kingdom that currently does nothing, but tell me that its methods are called, so that I know that it works as soon as I get there, I'm pretty sure that I can understand what's next.
moles-web.xml
<Configure class="org.mortbay.jetty.webapp.WebAppContext">
<Get name="SecurityHandler">
<Call name="setUserRealm">
<Arg>
<New class="custom.realm.CustomRealm">
<Set name="name">CustomRealm</Set>
</New>
</Arg>
</Call>
<Call name="setAuthenticator">
<Arg>
<New class="org.mortbay.jetty.security.FormAuthenticator">
<Set name="loginPage">/login.html</Set>
<Set name="errorPage">/login.html</Set>
</New>
</Arg>
</Call>
</Get>
</Configure>
[edit 05/18 1:16 pm]
My CustomRealm extends Jetty HashUserRealm, I don’t know if this might be a problem, btu decided that I also mentioned this.
web.xml
web.xml
<security-constraint>
<web-resource-collection>
<web-resource-name>Login</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
</security-constraint>
<login-config>
<auth-method>FORM</auth-method>
<realm-name>CustomRealm</realm-name>
<form-login-config>
<form-login-page>/login.html</form-login-page>
<form-error-page>/login.html</form-login-page>
</form-login-config>
</login-config>
, tbh. , . , , , .
, , , Jetty . , , , . , .
RequestBuilder GWT, , , . , - . , ? , , , .
.
[ 05/18 8:56 ]
, RequestBuilder
RequestBuilder rb = new RequestBuilder(RequestBuilder.POST, "login.html");
StringBuilder postData = new StringBuilder();
postData.append(URL.encode("j_username")).append("=").append(URL.encode(getUsername()));
postData.append("&");
postData.append(URL.encode("j_password")).append("=").append(URL.encode(getPassword()));
rb.setRequestData(postData.toString());
rb.setHeader("Content-type", "application/x-www-form-urlencoded");
rb.setCallback(new RequestCallback() {
@Override
public void onResponseReceived(Request request, Response response)
{
if (response.getStatusCode() != Response.SC_OK)
{
onError(request, new RequestException(response.getStatusText() + ":\n" + response.getText()));
return;
}
if (response.getText().contains("Access Denied"))
{
Window.alert("Incorrect username or password entered. Please try again.");
}
else
{
System.out.println("IT WORKED!!!");
}
}
@Override
public void onError(Request request, Throwable exception)
{
Window.alert(exception.getMessage());
}
});
try
{
rb.send();
}
catch (RequestException e)
{
SC.say(e.getMessage());
}
[ ]
auth , onModuleLoad . - , ?