我有一個從網頁繼承和下方類保護的網頁上:當我進入該頁面它是確定,一切工作重定向問題
public final class WiaAuthorizationStrategy implements
IAuthorizationStrategy,
IUnauthorizedComponentInstantiationListener {
private RealmPolicy roleManager;
private static WiaAuthorizationStrategy instance;
private WiaAuthorizationStrategy() {
roleManager = RealmPolicy.getInstance();
}
public static WiaAuthorizationStrategy getInstance() {
if(instance == null)
instance = new WiaAuthorizationStrategy();
return instance;
}
public boolean isInstantiationAuthorized(Class componentClass) {
if (ProtectedPage.class.isAssignableFrom(componentClass)) {
if (WiaSession.get().getUser() == null) {
return false;
}
if(!roleManager.isAuthorized(WiaSession.get().getUser().getRole(), componentClass.getName()))//WiaSession.get().isAuthenticated();
{
WiaSession.get().setAccess(false);
return false;
}
else
return true;
}
return true;
}
public void onUnauthorizedInstantiation(Component component) {
throw new RestartResponseAtInterceptPageException(
Login.class);
}
public boolean isActionAuthorized(Component component, Action action) {
//System.out.println("Name:" + component.getClass().getName() + "\n Action:" + action.getName() + "\nUser:" + WiaSession.get().getUser());
if (action.equals(Component.RENDER)) {
if (roleManager.containClass(component.getClass().getName()))
{
if (WiaSession.get().getUser() != null) {
if(!roleManager.isAuthorized(WiaSession.get().getUser().getRole(), component.getClass().getName()))
{
WiaSession.get().setAccess(false);
return false;
}
return true;
}
return false;
}
}
return true;
}
}
但是當我按下Ctrl + F5頁面重定向到登錄頁面,該頁面默認用於訪問受保護的頁面。 我試圖調試代碼,我發現ProtectedPage類中的super()函數執行此操作,並且在調試中我無法輸入這部分代碼。此類存在如下:
public abstract class ProtectedPage extends WebPage {
public ProtectedPage() {
---- >>> super(); verifyAccess(); }
protected void verifyAccess() {
// Redirect to Login page on invalid access.
if (!isUserLoggedIn()) {
throw new RestartResponseAtInterceptPageException(Login.class);
}
}
protected boolean isUserLoggedIn() {
return ((WiaSession) getSession()).isAuthenticated();
}
}
我已經簽署了由---- >>>登錄的代碼。 任何人都可以幫我解決這個問題嗎?
很高興見到你在這裏Eelco,真的喜歡Wicket in Action! – Tim 2009-08-02 00:58:17