KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > catalina > deploy > LoginConfig


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18
19 package org.apache.catalina.deploy;
20
21
22 import org.apache.catalina.util.RequestUtil;
23 import java.io.Serializable JavaDoc;
24
25
26 /**
27  * Representation of a login configuration element for a web application,
28  * as represented in a <code>&lt;login-config&gt;</code> element in the
29  * deployment descriptor.
30  *
31  * @author Craig R. McClanahan
32  * @version $Revision: 467222 $ $Date: 2006-10-24 05:17:11 +0200 (mar., 24 oct. 2006) $
33  */

34
35 public class LoginConfig implements Serializable JavaDoc {
36
37
38     // ----------------------------------------------------------- Constructors
39

40
41     /**
42      * Construct a new LoginConfig with default properties.
43      */

44     public LoginConfig() {
45
46         super();
47
48     }
49
50
51     /**
52      * Construct a new LoginConfig with the specified properties.
53      *
54      * @param authMethod The authentication method
55      * @param realmName The realm name
56      * @param loginPage The login page URI
57      * @param errorPage The error page URI
58      */

59     public LoginConfig(String JavaDoc authMethod, String JavaDoc realmName,
60                        String JavaDoc loginPage, String JavaDoc errorPage) {
61
62         super();
63         setAuthMethod(authMethod);
64         setRealmName(realmName);
65         setLoginPage(loginPage);
66         setErrorPage(errorPage);
67
68     }
69
70
71     // ------------------------------------------------------------- Properties
72

73
74     /**
75      * The authentication method to use for application login. Must be
76      * BASIC, DIGEST, FORM, or CLIENT-CERT.
77      */

78     private String JavaDoc authMethod = null;
79
80     public String JavaDoc getAuthMethod() {
81         return (this.authMethod);
82     }
83
84     public void setAuthMethod(String JavaDoc authMethod) {
85         this.authMethod = authMethod;
86     }
87
88
89     /**
90      * The context-relative URI of the error page for form login.
91      */

92     private String JavaDoc errorPage = null;
93
94     public String JavaDoc getErrorPage() {
95         return (this.errorPage);
96     }
97
98     public void setErrorPage(String JavaDoc errorPage) {
99         // if ((errorPage == null) || !errorPage.startsWith("/"))
100
// throw new IllegalArgumentException
101
// ("Error Page resource path must start with a '/'");
102
this.errorPage = RequestUtil.URLDecode(errorPage);
103     }
104
105
106     /**
107      * The context-relative URI of the login page for form login.
108      */

109     private String JavaDoc loginPage = null;
110
111     public String JavaDoc getLoginPage() {
112         return (this.loginPage);
113     }
114
115     public void setLoginPage(String JavaDoc loginPage) {
116         // if ((loginPage == null) || !loginPage.startsWith("/"))
117
// throw new IllegalArgumentException
118
// ("Login Page resource path must start with a '/'");
119
this.loginPage = RequestUtil.URLDecode(loginPage);
120     }
121
122
123     /**
124      * The realm name used when challenging the user for authentication
125      * credentials.
126      */

127     private String JavaDoc realmName = null;
128
129     public String JavaDoc getRealmName() {
130         return (this.realmName);
131     }
132
133     public void setRealmName(String JavaDoc realmName) {
134         this.realmName = realmName;
135     }
136
137
138     // --------------------------------------------------------- Public Methods
139

140
141     /**
142      * Return a String representation of this object.
143      */

144     public String JavaDoc toString() {
145
146         StringBuffer JavaDoc sb = new StringBuffer JavaDoc("LoginConfig[");
147         sb.append("authMethod=");
148         sb.append(authMethod);
149         if (realmName != null) {
150             sb.append(", realmName=");
151             sb.append(realmName);
152         }
153         if (loginPage != null) {
154             sb.append(", loginPage=");
155             sb.append(loginPage);
156         }
157         if (errorPage != null) {
158             sb.append(", errorPage=");
159             sb.append(errorPage);
160         }
161         sb.append("]");
162         return (sb.toString());
163
164     }
165
166
167 }
168
Popular Tags