Hi,

thanks for your feedback, Isammoc and Zilvinas.

But I don't get your point. In fact I would assume I already did everything
like the example you provided but still I get a login page even if the user
already authenticated successfully before.

@ Isammoc: You told me that I don't have to create two xxxApplication files
that extend WebApplication.
But if there a two separat pages that both would need authentication first
how can I ensure that this login will take place if I configure only one
xxxApplication which extends AthenticatedWebApplication with the relevant
methods getWebSessionClass() and getSignInPageClass()?

This is my code:
-----------------------------
MyAuthenticatedWebSession
public class MyAuthenticatedWebSession extends AuthenticatedWebSession {

        public MyAuthenticatedWebSession( Request request ) {
        super(request);
    }

    @Override
    public boolean authenticate( final String username, final String
password ) {
        
        PersistenceManager pm = PMF.getPersistenceManager();
        List listUser = new ArrayList();
        
        try {
                
                         Query query = pm.newQuery( User.class, "password == 
\""+
password +"\" && username == "+ username );
                listUser = (List) query.execute();
                
                return listUser.isEmpty()? false : true;
                
        } 
        catch( Exception e ){
            info( "Es ist ein technischer Fehler aufgetreten...bitte
versuchen Sie es später noch einmal." );
        }
        finally {
            pm.close();
        }
        
        return false;
        
    }

    @Override
    public Roles getRoles() {
        return isSignedIn() ? new Roles( Roles.ADMIN ) : null;
    }
}

Page A (A_Application.java)
public class A_Application extends AuthenticatedWebApplication {
        
    public A_Application() {}

    @Override
    public Class< ? extends Page> getHomePage() {
        return Uebersicht.class;
    }
    
    @Override
    protected Class<? extends AuthenticatedWebSession> getWebSessionClass()
{
        return MyAuthenticatedWebSession.class;
    }
    
    @Override
    protected Class<? extends WebPage> getSignInPageClass() {
        return Login.class;
    }
    
    @Override
    protected void init() {
        super.init();
        getResourceSettings().setResourcePollFrequency(null); 
    }
    
}

corresponding class to page A 
@AuthorizeInstantiation("ADMIN")
public class Uebersicht extends WebPage {
      ...
}


Page B (B_Application.java)
public class B_Application extends AuthenticatedWebApplication {
        
    public B_Application() {}
    
    @Override
    public Class< ? extends Page> getHomePage() {
        return Fragen.class;
    }
    
    @Override
    protected Class<? extends AuthenticatedWebSession> getWebSessionClass()
{
        return MyAuthenticatedWebSession.class;
    }
    
    @Override
    protected Class<? extends WebPage> getSignInPageClass() {
        return Login.class;
    }
    
    protected void init() {
        super.init();
        getResourceSettings().setResourcePollFrequency(null);  
    }
    
}

corresponding class to page B 
@AuthorizeInstantiation("ADMIN")
public class Frage extends WebPage {
      ...
}
-----------------------------

At the moment if I click on a link which call's page A I get redirected to
my login page. After a successfully login I get redirected to my markup of
page A. If I click again on the link no login is necessary. But there is the
exact same scenario if I click on a link which call's page B - even if I
already logged in successfully.

How can I achieve that a user don't need to authenticate for each page which
requires authentication? I would like to share these information over all
pages once a user is already logged in successfully.

I think I still need some assistance :(

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/dynamic-navigation-side-content-depending-on-login-status-tp3384641p3402193.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to