Hello there. I'm having problems developing Authorization on my
webapplication. I have followed the steps of the chapter 12 of Wicket in
Action. When i try to access to a protected page, the page is renderend
instead of redirected to the Login page. Here is my code. I was wondering if
anyone knows what am i missing.

-->Application Base class

public class NetCasasApplication extends WebApplication{

    public NetCasasApplication() {
        addComponentInstantiationListener(new
IComponentInstantiationListener() {

            public void onInstantiation(Component component) {
               
if(!getSecuritySettings().getAuthorizationStrategy().isInstantiationAuthorized(component.getClass()))
{
                   
getSecuritySettings().getUnauthorizedComponentInstantiationListener().onUnauthorizedInstantiation(component);
                }
            }
        });
    }

    @Override
    public Class getHomePage() {
        return Index.class;
    }

    @Override
    public Session newSession(Request request, Response response) {
        return new NetCasasSession(request);
    }

}

--> The Protected page (NetCasas extends WebPage) each page that is suppose
to protected extends this class

package pt.msoftware.netcasas.wicket.security;
import pt.msoftware.netcasas.wicket.NetCasasBasePage;

public class ProtectedPage extends NetCasasBasePage {

}

-->The AuthorizationStrategy

public class NetCasasAuthorizationStrategy implements
IAuthorizationStrategy, IUnauthorizedComponentInstantiationListener {

    public boolean isInstantiationAuthorized(Class componentClass) {
        if(ProtectedPage.class.isAssignableFrom(componentClass)) {
            return NetCasasSession.get().isAuthenticated();
        }

        return true;
    }

    public boolean isActionAuthorized(Component component, Action action) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public void onUnauthorizedInstantiation(Component component) {
        throw new RestartResponseAtInterceptPageException(Login.class);
    }

}

On the constructor of the Application Base class (NetCasasApplication) an
interceptor is registered. when i try to access a protected page, the method
onInstantiation is executed. Inside the call
getSecuritySettings().getAuthorizationStrategy() always return a
IAuthorizationStrategy, never a NetCasasAuthorizationStrategy. So the method
NetCasasAuthorizationStrategy.isInstantiationAuthorized is never executed.
So i guess something is missing. Someone knows what?

Thanks for the help.

Os meus melhores cumprimenstos / Best Regards

Marco Santos

-- 
View this message in context: 
http://www.nabble.com/%21%21-Wicket-Authorization-Problem-%21%21-tp22318987p22318987.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to