/***
 * Excerpted from "Domain-Driven Design Using Naked Objects",
 * published by The Pragmatic Bookshelf.
 * Copyrights apply to this code. It may not be used to create training material, 
 * courses, books, articles, and the like. Contact us if you are in doubt.
 * We make no guarantees that this code is fit for any purpose. 
 * Visit http://www.pragmaticprogrammer.com/titles/dhnako for more book information.
***/
import org.apache.wicket.authentication.AuthenticatedWebSession;
import org.nakedobjects.metamodel.authentication.AuthenticationSession;
import org.nakedobjects.runtime.authentication.AuthenticationManager;
...
public class NakedObjectsAuthenticatedWebSession 
        extends AuthenticatedWebSession {
    ...
    private AuthenticationSession authenticationSession;
    public boolean authenticate(
            final String username, final String password) {
        AuthenticationRequestPassword authenticationRequest = 
            new AuthenticationRequestPassword(username, password);
        authenticationSession = 
            getAuthenticationManager().authenticate(
                    authenticationRequest);
        return authenticationSession != null;
    }
    private static AuthenticationManager getAuthenticationManager() {
        return NakedObjectsContext.getAuthenticationManager();
    }
    ...
}
