Return-Path: Delivered-To: apmail-cocoon-cvs-archive@www.apache.org Received: (qmail 28666 invoked from network); 4 Oct 2004 19:19:24 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 4 Oct 2004 19:19:24 -0000 Received: (qmail 11986 invoked by uid 500); 4 Oct 2004 19:19:23 -0000 Delivered-To: apmail-cocoon-cvs-archive@cocoon.apache.org Received: (qmail 11876 invoked by uid 500); 4 Oct 2004 19:19:22 -0000 Mailing-List: contact cvs-help@cocoon.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@cocoon.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list cvs@cocoon.apache.org Received: (qmail 11864 invoked by uid 99); 4 Oct 2004 19:19:22 -0000 X-ASF-Spam-Status: No, hits=-10.0 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.28) with SMTP; Mon, 04 Oct 2004 12:19:21 -0700 Received: (qmail 28614 invoked by uid 65534); 4 Oct 2004 19:19:20 -0000 Date: 4 Oct 2004 19:19:20 -0000 Message-ID: <20041004191920.28610.qmail@minotaur.apache.org> From: vgritsenko@apache.org To: cvs@cocoon.apache.org Subject: svn commit: rev 53739 - in cocoon/branches/BRANCH_2_1_X/src/blocks/authentication-fw/java/org/apache/cocoon/webapps/authentication: . components X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Author: vgritsenko Date: Mon Oct 4 12:19:19 2004 New Revision: 53739 Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/authentication-fw/java/org/apache/cocoon/webapps/authentication/AuthenticationManager.java cocoon/branches/BRANCH_2_1_X/src/blocks/authentication-fw/java/org/apache/cocoon/webapps/authentication/components/DefaultAuthenticationManager.java cocoon/branches/BRANCH_2_1_X/src/blocks/authentication-fw/java/org/apache/cocoon/webapps/authentication/components/PipelineAuthenticator.java Log: tab hunt Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/authentication-fw/java/org/apache/cocoon/webapps/authentication/AuthenticationManager.java ============================================================================== --- cocoon/branches/BRANCH_2_1_X/src/blocks/authentication-fw/java/org/apache/cocoon/webapps/authentication/AuthenticationManager.java (original) +++ cocoon/branches/BRANCH_2_1_X/src/blocks/authentication-fw/java/org/apache/cocoon/webapps/authentication/AuthenticationManager.java Mon Oct 4 12:19:19 2004 @@ -1,12 +1,12 @@ /* * Copyright 1999-2004 The Apache Software Foundation. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -24,8 +24,6 @@ import org.apache.cocoon.webapps.session.context.SessionContext; import org.apache.excalibur.source.SourceParameters; - - /** * This is the authentication manager. * It is used to authenticate (login, logout) a user. Usually, this @@ -33,7 +31,7 @@ * actions perform all required tasks. * * @author Carsten Ziegeler - * @version CVS $Id: AuthenticationManager.java,v 1.7 2004/03/05 13:01:40 bdelacretaz Exp $ + * @version CVS $Id$ */ public interface AuthenticationManager { @@ -73,7 +71,7 @@ void logout(String handlerName, int mode) throws ProcessingException; - + /** * Get the current state of authentication */ Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/authentication-fw/java/org/apache/cocoon/webapps/authentication/components/DefaultAuthenticationManager.java ============================================================================== --- cocoon/branches/BRANCH_2_1_X/src/blocks/authentication-fw/java/org/apache/cocoon/webapps/authentication/components/DefaultAuthenticationManager.java (original) +++ cocoon/branches/BRANCH_2_1_X/src/blocks/authentication-fw/java/org/apache/cocoon/webapps/authentication/components/DefaultAuthenticationManager.java Mon Oct 4 12:19:19 2004 @@ -1,12 +1,12 @@ /* * Copyright 1999-2004 The Apache Software Foundation. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -65,42 +65,42 @@ * This is the basis authentication component. * * @author Carsten Ziegeler - * @version CVS $Id: DefaultAuthenticationManager.java,v 1.25 2004/03/19 14:16:55 cziegeler Exp $ + * @version CVS $Id$ */ public class DefaultAuthenticationManager -extends AbstractLogEnabled -implements AuthenticationManager, - SitemapConfigurable, - Serviceable, - Disposable, - ThreadSafe, - Contextualizable, - Component { + extends AbstractLogEnabled + implements AuthenticationManager, + SitemapConfigurable, + Serviceable, + Disposable, + ThreadSafe, + Contextualizable, + Component { /** The name of the session attribute storing the user status */ public final static String SESSION_ATTRIBUTE_USER_STATUS = DefaultAuthenticationManager.class.getName() + "/UserStatus"; /** The manager for the authentication handlers */ protected SitemapConfigurationHolder holder; - + /** The Service Manager */ protected ServiceManager manager; - + /** The Source Resolver */ protected SourceResolver resolver; - + /** The context */ protected Context context; - + /** Instantiated authenticators */ protected Map authenticators = new HashMap(); - + /** The xpath processor */ protected XPathProcessor xpathProcessor; /** This is the key used to store the current request state in the request object */ private static final String REQUEST_STATE_KEY = RequestState.class.getName(); - + /** * Set the sitemap configuration containing the handlers */ @@ -112,12 +112,12 @@ /** * Get the handler configuration for the current sitemap */ - private Map getHandlerConfigurations() + private Map getHandlerConfigurations() throws ProcessingException { Map configs = (Map) this.holder.getPreparedConfiguration(); if ( null == configs ) { - try { - configs = DefaultHandlerManager.prepareHandlerConfiguration(ContextHelper.getObjectModel(this.context), + try { + configs = DefaultHandlerManager.prepareHandlerConfiguration(ContextHelper.getObjectModel(this.context), this.holder); } catch (ConfigurationException ce) { throw new ProcessingException("Configuration error.", ce); @@ -131,24 +131,24 @@ * @param name The handler name * @return The configuration or null. */ - private HandlerConfiguration getHandlerConfiguration(String name) - throws ProcessingException { + private HandlerConfiguration getHandlerConfiguration(String name) + throws ProcessingException { final Map configs = this.getHandlerConfigurations(); HandlerConfiguration c = null; if ( configs != null) { - c = (HandlerConfiguration)configs.get( name ); + c = (HandlerConfiguration)configs.get( name ); } return c; } - + private Request getRequest() { return ContextHelper.getRequest(this.context); } - - private Session getSession(boolean create) { + + private Session getSession(boolean create) { return this.getRequest().getSession(create); } - + private UserState getUserState() { final Session session = this.getSession( false ); UserState status = null; @@ -167,7 +167,7 @@ } return status; } - + private UserHandler getUserHandler(String name) { final UserState status = this.getUserState(); if ( status != null ) { @@ -175,17 +175,17 @@ } return null; } - + private void updateUserState() { final Session session = this.getSession(true); Object status = session.getAttribute(SESSION_ATTRIBUTE_USER_STATUS); session.setAttribute(SESSION_ATTRIBUTE_USER_STATUS, status); } - - /* (non-Javadoc) - * @see org.apache.cocoon.webapps.authentication.components.Manager#authenticate(java.lang.String, java.lang.String, org.apache.excalibur.source.SourceParameters) - */ - public UserHandler login(String handlerName, + + /* (non-Javadoc) + * @see org.apache.cocoon.webapps.authentication.components.Manager#authenticate(java.lang.String, java.lang.String, org.apache.excalibur.source.SourceParameters) + */ + public UserHandler login(String handlerName, String applicationName, SourceParameters parameters) throws ProcessingException { @@ -198,7 +198,7 @@ if ( handler != null ) { throw new ProcessingException("User is already authenticated using handler: " + handlerName); } - + Authenticator authenticator = this.lookupAuthenticator( config ); try { Authenticator.AuthenticationResult result = authenticator.authenticate( config, parameters ); @@ -213,7 +213,7 @@ try { contextManager = (ContextManager) this.manager.lookup( ContextManager.ROLE ); SessionContext temp = contextManager.getContext( SessionConstants.TEMPORARY_CONTEXT ); - + final DocumentFragment fragment = result.result.createDocumentFragment(); final Node root = result.result.getDocumentElement(); root.normalize(); @@ -236,25 +236,25 @@ } finally { this.manager.release( contextManager ); } - + } - + } finally { this.releaseAuthenticator( authenticator, config ); } - + if ( handler != null ) { // create UserStatus final UserState status = this.createUserState(); - - status.addHandler( handler ); + + status.addHandler( handler ); this.updateUserState(); - + // update RequestState RequestState state = new RequestState( handler, applicationName); this.setState( state ); state.initialize( this.resolver ); - + // And now load applications Iterator applications = handler.getHandlerConfiguration().getApplications().values().iterator(); @@ -265,11 +265,11 @@ } } } - - return handler; - } - /** + return handler; + } + + /** * Release the used authenticator */ protected void releaseAuthenticator(Authenticator authenticator, HandlerConfiguration config) { @@ -277,9 +277,9 @@ } /** - * The authenticator used to authenticate a user + * The authenticator used to authenticate a user */ - protected Authenticator lookupAuthenticator(HandlerConfiguration config) + protected Authenticator lookupAuthenticator(HandlerConfiguration config) throws ProcessingException { final String name = config.getAuthenticatorClassName(); Authenticator authenticator = (Authenticator) this.authenticators.get(name); @@ -294,7 +294,7 @@ ContainerUtil.service( authenticator, this.manager ); ContainerUtil.initialize( authenticator ); this.authenticators.put(name, authenticator); - + } catch (Exception e ) { throw new ProcessingException("Unable to initialize authenticator from class " + name, e); } @@ -305,12 +305,12 @@ } /* (non-Javadoc) - * @see org.apache.cocoon.webapps.authentication.components.Manager#checkAuthentication(org.apache.cocoon.environment.Redirector, java.lang.String, java.lang.String) - */ - public boolean checkAuthentication(Redirector redirector, - String handlerName, - String applicationName) - throws IOException, ProcessingException { + * @see org.apache.cocoon.webapps.authentication.components.Manager#checkAuthentication(org.apache.cocoon.environment.Redirector, java.lang.String, java.lang.String) + */ + public boolean checkAuthentication(Redirector redirector, + String handlerName, + String applicationName) + throws IOException, ProcessingException { HandlerConfiguration config = this.getHandlerConfiguration( handlerName ); if ( config == null ) { throw new ProcessingException("Unknown handler to check: " + handlerName); @@ -328,7 +328,7 @@ if (request.getQueryString() != null) { resource += '?' + request.getQueryString(); } - + parameters.setSingleParameterValue("resource", resource); final String redirectURI = config.getRedirectURI(); redirector.globalRedirect(false, SourceUtil.appendParameters(redirectURI, parameters)); @@ -339,9 +339,9 @@ this.setState( state ); state.initialize( this.resolver ); } - - return authenticated; - } + + return authenticated; + } public String getForwardingURI(String handlerName) throws ProcessingException { HandlerConfiguration config = this.getHandlerConfiguration( handlerName ); @@ -352,24 +352,24 @@ if (request.getQueryString() != null) { resource += '?' + request.getQueryString(); } - + parameters.setSingleParameterValue("resource", resource); final String redirectURI = config.getRedirectURI(); return SourceUtil.appendParameters(redirectURI, parameters); } - - /* (non-Javadoc) - * @see org.apache.cocoon.webapps.authentication.components.Manager#isAuthenticated(java.lang.String) - */ - public UserHandler isAuthenticated(String handlerName) + + /* (non-Javadoc) + * @see org.apache.cocoon.webapps.authentication.components.Manager#isAuthenticated(java.lang.String) + */ + public UserHandler isAuthenticated(String handlerName) throws ProcessingException { return this.getUserHandler( handlerName ); - } + } - /* (non-Javadoc) - * @see org.apache.cocoon.webapps.authentication.components.Manager#logout(java.lang.String, java.lang.String) - */ - public void logout(String handlerName, int mode) + /* (non-Javadoc) + * @see org.apache.cocoon.webapps.authentication.components.Manager#logout(java.lang.String, java.lang.String) + */ + public void logout(String handlerName, int mode) throws ProcessingException { HandlerConfiguration config = this.getHandlerConfiguration( handlerName ); if ( config == null ) { @@ -379,18 +379,18 @@ UserHandler handler = this.getUserHandler( handlerName ); // we don't throw an exception if we are already logged out! if ( handler != null ) { - + // Do we save something on logout? /* - - if ( config.saveOnLogout() + + if ( config.saveOnLogout() && config.getSaveResource() != null) { final AuthenticationContext authContext = handler.getContext(); try { // This might not work, because of the missing state - authContext.saveXML("/authentication", - null, - ContextHelper.getObjectModel(this.context), + authContext.saveXML("/authentication", + null, + ContextHelper.getObjectModel(this.context), this.resolver, this.manager); } catch (Exception ignore) { // we don't want to stop the logout process @@ -414,7 +414,7 @@ } catch (Exception ignore) { // we really ignore any exception! } - + List applicationContexts = handler.getApplicationContexts(); if ( applicationContexts != null ) { ContextManager contextManager = null; @@ -433,7 +433,7 @@ this.manager.release( contextManager); } } - + UserState status = this.getUserState(); status.removeHandler( handlerName ); this.updateUserState(); @@ -442,45 +442,44 @@ SessionManager sessionManager = null; try { sessionManager = (SessionManager)this.manager.lookup( SessionManager.ROLE ); - + if ( mode == AuthenticationConstants.LOGOUT_MODE_IMMEDIATELY ) { sessionManager.terminateSession(true); } else if ( mode == AuthenticationConstants.LOGOUT_MODE_IF_UNUSED ) { if ( !status.hasHandler()) { - sessionManager.terminateSession( false ); + sessionManager.terminateSession( false ); } - + } else if ( mode == AuthenticationConstants.LOGOUT_MODE_IF_NOT_AUTHENTICATED) { if ( !status.hasHandler()) { - sessionManager.terminateSession( true ); + sessionManager.terminateSession( true ); } } else { throw new ProcessingException("Unknown logout mode: " + mode); } - + } catch (ServiceException se) { throw new ProcessingException("Unable to lookup session manager.", se); } finally { this.manager.release( sessionManager ); } } - - } + } - /** + /** * Serviceable - */ - public void service(ServiceManager manager) + */ + public void service(ServiceManager manager) throws ServiceException { this.manager = manager; this.resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE); this.xpathProcessor = (XPathProcessor)this.manager.lookup(XPathProcessor.ROLE); - } + } - /* (non-Javadoc) - * @see org.apache.avalon.framework.activity.Disposable#dispose() - */ - public void dispose() { + /* (non-Javadoc) + * @see org.apache.avalon.framework.activity.Disposable#dispose() + */ + public void dispose() { Iterator iter = this.authenticators.values().iterator(); while ( iter.hasNext() ) { final Authenticator authenticator = (Authenticator) iter.next(); @@ -493,7 +492,7 @@ this.xpathProcessor = null; this.manager = null; } - } + } /** * Get the current state of authentication @@ -506,7 +505,7 @@ final Request req = ContextHelper.getRequest(context); return (RequestState)req.getAttribute( REQUEST_STATE_KEY); } - + /* (non-Javadoc) * @see org.apache.avalon.framework.context.Contextualizable#contextualize(org.apache.avalon.framework.context.Context) */ @@ -522,7 +521,7 @@ req.removeAttribute( REQUEST_STATE_KEY ); } } - + /** * Create Application Context. * This context is destroyed when the user logs out of the handler @@ -533,7 +532,7 @@ throws ProcessingException { RequestState state = this.getState(); UserHandler handler = state.getHandler(); - + SessionContext context = null; if ( handler != null ) { @@ -559,7 +558,4 @@ return context; } - } - - Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/authentication-fw/java/org/apache/cocoon/webapps/authentication/components/PipelineAuthenticator.java ============================================================================== --- cocoon/branches/BRANCH_2_1_X/src/blocks/authentication-fw/java/org/apache/cocoon/webapps/authentication/components/PipelineAuthenticator.java (original) +++ cocoon/branches/BRANCH_2_1_X/src/blocks/authentication-fw/java/org/apache/cocoon/webapps/authentication/components/PipelineAuthenticator.java Mon Oct 4 12:19:19 2004 @@ -48,8 +48,8 @@ * @version CVS $Id$ */ public class PipelineAuthenticator - extends AbstractLogEnabled - implements Serviceable, ThreadSafe, Disposable, Authenticator { + extends AbstractLogEnabled + implements Serviceable, ThreadSafe, Disposable, Authenticator { /** The service manager */ protected ServiceManager manager; @@ -149,7 +149,7 @@ throw SourceUtil.handle(se); } catch (IOException e) { throw new ProcessingException(e); - } finally { + } finally { this.resolver.release(source); } } catch (ProcessingException local) { @@ -256,24 +256,24 @@ } - /* (non-Javadoc) - * @see org.apache.avalon.framework.service.Serviceable#service(ServiceManager) - */ - public void service(ServiceManager manager) throws ServiceException { - this.manager = manager; + /* (non-Javadoc) + * @see org.apache.avalon.framework.service.Serviceable#service(ServiceManager) + */ + public void service(ServiceManager manager) throws ServiceException { + this.manager = manager; this.resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE); - } + } - /* (non-Javadoc) - * @see org.apache.avalon.framework.activity.Disposable#dispose() - */ - public void dispose() { - if ( this.manager != null ){ + /* (non-Javadoc) + * @see org.apache.avalon.framework.activity.Disposable#dispose() + */ + public void dispose() { + if ( this.manager != null ){ this.manager.release( this.resolver ); this.manager = null; this.resolver = null; - } - } + } + } /* (non-Javadoc) * @see org.apache.cocoon.webapps.authentication.components.Authenticator#logout(UserHandler)