001: /*
002: * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/deploy/LoginConfig.java,v 1.6 2001/07/22 20:25:10 pier Exp $
003: * $Revision: 1.6 $
004: * $Date: 2001/07/22 20:25:10 $
005: *
006: * ====================================================================
007: *
008: * The Apache Software License, Version 1.1
009: *
010: * Copyright (c) 1999 The Apache Software Foundation. All rights
011: * reserved.
012: *
013: * Redistribution and use in source and binary forms, with or without
014: * modification, are permitted provided that the following conditions
015: * are met:
016: *
017: * 1. Redistributions of source code must retain the above copyright
018: * notice, this list of conditions and the following disclaimer.
019: *
020: * 2. Redistributions in binary form must reproduce the above copyright
021: * notice, this list of conditions and the following disclaimer in
022: * the documentation and/or other materials provided with the
023: * distribution.
024: *
025: * 3. The end-user documentation included with the redistribution, if
026: * any, must include the following acknowlegement:
027: * "This product includes software developed by the
028: * Apache Software Foundation (http://www.apache.org/)."
029: * Alternately, this acknowlegement may appear in the software itself,
030: * if and wherever such third-party acknowlegements normally appear.
031: *
032: * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
033: * Foundation" must not be used to endorse or promote products derived
034: * from this software without prior written permission. For written
035: * permission, please contact apache@apache.org.
036: *
037: * 5. Products derived from this software may not be called "Apache"
038: * nor may "Apache" appear in their names without prior written
039: * permission of the Apache Group.
040: *
041: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
042: * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
043: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
044: * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
045: * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
046: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
047: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
048: * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
049: * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
050: * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
051: * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
052: * SUCH DAMAGE.
053: * ====================================================================
054: *
055: * This software consists of voluntary contributions made by many
056: * individuals on behalf of the Apache Software Foundation. For more
057: * information on the Apache Software Foundation, please see
058: * <http://www.apache.org/>.
059: *
060: * [Additional notices, if required by prior licensing conditions]
061: *
062: */
063:
064: package org.apache.catalina.deploy;
065:
066: import org.apache.catalina.util.RequestUtil;
067:
068: /**
069: * Representation of a login configuration element for a web application,
070: * as represented in a <code><login-config></code> element in the
071: * deployment descriptor.
072: *
073: * @author Craig R. McClanahan
074: * @version $Revision: 1.6 $ $Date: 2001/07/22 20:25:10 $
075: */
076:
077: public final class LoginConfig {
078:
079: // ----------------------------------------------------------- Constructors
080:
081: /**
082: * Construct a new LoginConfig with default properties.
083: */
084: public LoginConfig() {
085:
086: super ();
087:
088: }
089:
090: /**
091: * Construct a new LoginConfig with the specified properties.
092: *
093: * @param authMethod The authentication method
094: * @param realmName The realm name
095: * @param loginPage The login page URI
096: * @param errorPage The error page URI
097: */
098: public LoginConfig(String authMethod, String realmName,
099: String loginPage, String errorPage) {
100:
101: super ();
102: setAuthMethod(authMethod);
103: setRealmName(realmName);
104: setLoginPage(loginPage);
105: setErrorPage(errorPage);
106:
107: }
108:
109: // ------------------------------------------------------------- Properties
110:
111: /**
112: * The authentication method to use for application login. Must be
113: * BASIC, DIGEST, FORM, or CLIENT-CERT.
114: */
115: private String authMethod = null;
116:
117: public String getAuthMethod() {
118: return (this .authMethod);
119: }
120:
121: public void setAuthMethod(String authMethod) {
122: this .authMethod = authMethod;
123: }
124:
125: /**
126: * The context-relative URI of the error page for form login.
127: */
128: private String errorPage = null;
129:
130: public String getErrorPage() {
131: return (this .errorPage);
132: }
133:
134: public void setErrorPage(String errorPage) {
135: // if ((errorPage == null) || !errorPage.startsWith("/"))
136: // throw new IllegalArgumentException
137: // ("Error Page resource path must start with a '/'");
138: this .errorPage = RequestUtil.URLDecode(errorPage);
139: }
140:
141: /**
142: * The context-relative URI of the login page for form login.
143: */
144: private String loginPage = null;
145:
146: public String getLoginPage() {
147: return (this .loginPage);
148: }
149:
150: public void setLoginPage(String loginPage) {
151: // if ((loginPage == null) || !loginPage.startsWith("/"))
152: // throw new IllegalArgumentException
153: // ("Login Page resource path must start with a '/'");
154: this .loginPage = RequestUtil.URLDecode(loginPage);
155: }
156:
157: /**
158: * The realm name used when challenging the user for authentication
159: * credentials.
160: */
161: private String realmName = null;
162:
163: public String getRealmName() {
164: return (this .realmName);
165: }
166:
167: public void setRealmName(String realmName) {
168: this .realmName = realmName;
169: }
170:
171: // --------------------------------------------------------- Public Methods
172:
173: /**
174: * Return a String representation of this object.
175: */
176: public String toString() {
177:
178: StringBuffer sb = new StringBuffer("LoginConfig[");
179: sb.append("authMethod=");
180: sb.append(authMethod);
181: if (realmName != null) {
182: sb.append(", realmName=");
183: sb.append(realmName);
184: }
185: if (loginPage != null) {
186: sb.append(", loginPage=");
187: sb.append(loginPage);
188: }
189: if (errorPage != null) {
190: sb.append(", errorPage=");
191: sb.append(errorPage);
192: }
193: sb.append("]");
194: return (sb.toString());
195:
196: }
197:
198: }
|