001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package org.apache.cocoon.webapps.authentication.user;
018:
019: import org.apache.avalon.framework.configuration.Configuration;
020: import org.apache.cocoon.ProcessingException;
021: import org.apache.cocoon.webapps.authentication.configuration.ApplicationConfiguration;
022: import org.apache.excalibur.source.SourceResolver;
023:
024: /**
025: * The state of the user for the current request.
026: * This object holds the information which handler and application
027: * is currently used for this request.
028: *
029: * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
030: * @deprecated This block is deprecated and will be removed in future versions.
031: * @version CVS $Id: RequestState.java 433543 2006-08-22 06:22:54Z crossley $
032: */
033: public final class RequestState implements java.io.Serializable {
034:
035: /** The handlers */
036: private UserHandler handler;
037:
038: /** The application */
039: private String application;
040:
041: /**
042: * Create a new handler object.
043: */
044: public RequestState(UserHandler handler, String app) {
045: this .handler = handler;
046: this .application = app;
047: }
048:
049: /**
050: * Initialize
051: */
052: public void initialize(SourceResolver resolver)
053: throws ProcessingException {
054: if (this .application != null
055: && !this .handler.getApplicationsLoaded()) {
056: ApplicationConfiguration conf = (ApplicationConfiguration) this .handler
057: .getHandlerConfiguration().getApplications().get(
058: this .application);
059: if (!this .handler.isApplicationLoaded(conf)) {
060: this .handler.getContext().loadApplicationXML(conf,
061: resolver);
062: }
063: }
064: }
065:
066: public String getApplicationName() {
067: return this .application;
068: }
069:
070: public UserHandler getHandler() {
071: return this .handler;
072: }
073:
074: public String getHandlerName() {
075: return this .handler.getHandlerName();
076: }
077:
078: public ApplicationConfiguration getApplicationConfiguration() {
079: if (this .application != null) {
080: return (ApplicationConfiguration) this .handler
081: .getHandlerConfiguration().getApplications().get(
082: this .application);
083: }
084: return null;
085: }
086:
087: /**
088: * Get the configuration if available
089: */
090: public Configuration getModuleConfiguration(String name) {
091: Configuration conf = null;
092:
093: if (this.handler != null && this.application != null) {
094: conf = this.getApplicationConfiguration().getConfiguration(
095: name);
096: }
097: if (this.handler != null && conf == null) {
098: conf = this.handler.getHandlerConfiguration()
099: .getConfiguration(name);
100: }
101:
102: return conf;
103: }
104: }
|