2014-01-25 37 views
0

我有一個Wicket應用程序(網址是:localhost:7001/myWicketApp),它以ask中的登錄開頭。這工作正常。在我的主頁上,我有一個Sign Out鏈接。如何永久登出檢票口?

我想要什麼:如果我點擊這個鏈接,就應該從會話註銷,並進入一個又一個網頁等www.google.com 我寫了這個java代碼日誌出:

private AjaxLink createSignOutLink() { 
    return new AjaxLink("signOutLink") { 
     private static final long serialVersionUID = 1L; 

     @Override 
     public void onClick(AjaxRequestTarget target) { 
      S2rtSession.get().invalidate(); 
      S2rtSession.get().logout(); 
      throw new RedirectToUrlException("http://www.google.com"); 
     } 
    }; 
} 

什麼情況發生:當我點擊它,它進入新的頁面(www.google.com),所以看起來它工作正常。 但是:當我點擊瀏覽器的BACK按鈕(或者我再次輸入我的網址而不關閉瀏覽器並按ENTER鍵),它會返回到我的頁面,不詢問用戶名和密碼。所以退出沒有發生。

缺什麼?有沒有辦法,永久註銷,或瀏覽器緩存用戶名和密碼,並且沒有關閉瀏覽器,它將無法工作?

我希望有一種方法,從緩存和會話中刪除所有內容。

謝謝!

回答

1

此代碼適用於我,但在1.5.8的檢票中。但可能是它有助於

public class MyAppSession extends AuthenticatedWebSession implements IClusterable 

我的註銷鏈接是:

logOut = new Link<Page>("logOut") { 
    private static final long serialVersionUID = 1L; 

    @Override 
    public void onClick() { 
     //MyAppSession.get().invalidate(); - **I do not remember why, but in sources i have this line an it is commented!!!** 
     MyAppSession.get().signOut(); 
     setResponsePage(WebApplication.get().getHomePage()); 
    } 
}; 
+0

不爲我工作。也許問題是我沒有自己的登錄頁面,它在開始時使用瀏覽器的身份驗證,而不是主頁。 – victorio

+2

是的。您的問題在於使用基本身份驗證。 http://stackoverflow.com/questions/233507/how-to-log-out-user-from-web-site-using-basic-authentication – cache

1

也許憑據保存在cookie中,請嘗試以下代碼:

private AjaxLink createSignOutLink() { 
     return new AjaxLink("signOutLink") { 
      private static final long serialVersionUID = 1L; 

      @Override 
      public void onClick(AjaxRequestTarget target) { 
       IAuthenticationStrategy strategy = WebApplication.get().getSecuritySettings() 
          .getAuthenticationStrategy(); 
        strategy.remove(); 
       S2rtSession.get().logout(); 
       throw new RedirectToUrlException("http://www.google.com"); 
      } 
     }; 
    } 
+0

不起作用。問題是我正在使用基本身份驗證。但是謝謝你。 – victorio