package votorola.a.web.wic.authen; // Copyright 2012, Michael Allan. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Votorola Software"), to deal in the Votorola Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicence, and/or sell copies of the Votorola Software, and to permit persons to whom the Votorola Software is furnished to do so, subject to the following conditions: The preceding copyright notice and this permission notice shall be included in all copies or substantial portions of the Votorola Software. THE VOTOROLA SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE VOTOROLA SOFTWARE OR THE USE OR OTHER DEALINGS IN THE VOTOROLA SOFTWARE. import org.apache.wicket.Page; import org.apache.wicket.request.mapper.parameter.PageParameters; import votorola.a.web.wic.*; import votorola.g.lang.*; import votorola.g.web.wic.*; /** A facility to verify the identity of a user. */ public @ThreadSafe abstract class Authenticator { // /** A user identifier that might be that of the persistently authenticated user, or // * null if well-formed persistence data cannot be retrieved from the request cookies. // * The persistence data are not authenticated. // */ // abstract IDPair apparentlyPersistedUser( HttpServletRequest reqHS ); /** Removes "returnClass" from pP and returns the class it specifies. */ static Class extractReturnClass( final PageParameters pP ) { try { final String s = PageParametersX.getStringRequired( pP, "returnClass" ); pP.remove( "returnClass" ); return Class.forName(s).asSubclass( Page.class ); } catch( ClassNotFoundException x ) { throw new RuntimeException( x ); } } /** The class of login page for this authenticator. */ public abstract Class loginPageClass(); /** Ensures that the user is logged out. */ public abstract void logOut(); /** Constructs a login page that redirects to a newly constructed, bookmarkable, * return page if authentication succeeds. If the return page is a {@linkplain * votorola.a.voter.VoterPage voter page} without a specified voter, then pP is * altered to specify the newly authenticated user. * * @param pP The type and parameters of the return page to construct after the * login attempt. Parameter "returnClass" specifies the page type, while the * remainder of pP is passed to the page instance. */ public abstract VPageHTML newLoginPage( PageParameters pP ); /** The email address to automatically login for each session, as defined by the * system property "votorola.a.web.wic.authen.Authenticator.PRELOGIN_EMAIL", or null * if there is none. This is intended for testing in private deployments. */ public static final String PRELOGIN_EMAIL = System.getProperty( "votorola.a.web.wic.authen.Authenticator.PRELOGIN_EMAIL" ); }