开发者

GWT and SpringSecurity

I've created two modules

  1. GWTAppAuth
  2. GWTApp

when I try posting form from GWTAppAuth to j_spring_securit开发者_C百科y_check nothing happened.

Firebug shows in console

"Failed to load source for:http://127.0.0.1:8888/j_spring_security_check"

But if I try after that manually access to GWTApp it works. Anybody knows what a matter?

Looks like Spring Security just doesn't redirect to second (GWTApp).

How do I check it?

  1. Run application in hosted mode
  2. Try to access to GWTApp.html
  3. Spring security redirects me to GWTAppAuth.html
  4. Press login button

In this place if we check firebug log we can see

"POST //127.0.0.1:8888/j_spring_security_check"

and response -

"Failed to load source for: http://127.0.0.1:8888/j_spring_security_check"

then next record -

"GET //127.0.0.1:8888/GWT/GWTApp.html?gwt.codesvr=127.0.0.1:9997"

and fetching all needed resources

Now I can manually input

"//127.0.0.1:8888/GWT/GWTApp.html" 

and now I have access to GWTApp.html


I found out solution.
You should use html form and submit button instead widgets provided by GWT for instance:

<form action="/j_spring_security_check" method="post">
   <g:Label>
       login
   </g:Label>
   <g:TextBox name="j_username" width="200" />
       <g:Label>
           password
       </g:Label>
       <g:PasswordTextBox name="j_password" width="200" />
       <input name="submit" type="submit" value="Login" />
</form>

or catch on form submit completed event in case you are using GWT FormPanel widget:

public class LoginFormB extends Composite {

  private static LoginFormBUiBinder uiBinder = GWT.create(LoginFormBUiBinder.class);

  interface LoginFormBUiBinder extends UiBinder<Widget, LoginFormB> {}

  @UiField
  FormPanel formPanel;

  public LoginFormB() {
    formPanel.addSubmitCompleteHandler(new SubmitCompleteHandler() {

        @Override
        public void onSubmitComplete(SubmitCompleteEvent arg0) {
            // Redirect to needed page
            redirect("needed url");
        }
    });
    initWidget(uiBinder.createAndBindUi(this));
  }

  public static native void redirect(String url)/*-{
    $wnd.location = url;
  }-*/;
}


I don't think you can directly integrate Spring Security and GWT in the same app. You'll need something in-between to glue them.

Try checking these tutorials: http://krams915.blogspot.com/2011/01/spring-and-gwt-integration-using-maven.html

http://krams915.blogspot.com/2011/01/spring-and-gwt-security-via-spring.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜