KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > deployment > LoginConfigurationImpl


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23  package com.sun.enterprise.deployment;
24
25
26 import com.sun.enterprise.deployment.web.LoginConfiguration;
27 import com.sun.enterprise.util.LocalStringManagerImpl;
28
29 //START OF IASRI 4660482
30
import java.util.logging.*;
31 import com.sun.enterprise.deployment.util.LogDomains;
32 //END OF IASRI 4660482
33

34
35     /**
36     * I dictate how the web app I belong to should be logged into.
37     * @author Danny Coward
38      */

39
40 public class LoginConfigurationImpl extends Descriptor implements LoginConfiguration {
41     /** teh client authenticates using http basic authentication. */
42     public static final String JavaDoc AUTHENTICATION_METHOD_BASIC = LoginConfiguration.BASIC_AUTHENTICATION;
43     /** Digest authentication. */
44     public static final String JavaDoc AUTHENTICATION_METHOD_DIGEST = LoginConfiguration.DIGEST_AUTHENTICATION;
45     /** FOrm authentication. */
46     public static final String JavaDoc AUTHENTICATION_METHOD_FORM = LoginConfiguration.FORM_AUTHENTICATION;
47     /** The client sends a certificate. */
48     public static final String JavaDoc AUTHENTICATION_METHOD_CLIENT_CERTIFICATE = LoginConfiguration.CLIENT_CERTIFICATION_AUTHENTICATION;
49
50     //START OF IASRI 4660482
51
static Logger _logger = LogDomains.getLogger(LogDomains.DPL_LOGGER);
52     //END OF IASRI 4660482
53

54     private String JavaDoc authenticationMethod;
55     private String JavaDoc realmName = "";
56     private String JavaDoc formLoginPage = "";
57     private String JavaDoc formErrorPage = "";
58     private static LocalStringManagerImpl localStrings =
59         new LocalStringManagerImpl(LoginConfigurationImpl.class);
60
61     /** Return my authentication method. */
62     public String JavaDoc getAuthenticationMethod() {
63     if (this.authenticationMethod == null) {
64             //START OF IASRI 4660482 - warning log if authentication method isn't defined in descriptor
65
_logger.log(Level.WARNING,"enterprise.deployment_no_auth_method_dfnd");
66             //END OF IASRI 4660482
67
this.authenticationMethod = AUTHENTICATION_METHOD_BASIC;
68     }
69     return this.authenticationMethod;
70     }
71
72     /** Sets my authentication method. */
73     public void setAuthenticationMethod(String JavaDoc authenticationMethod) {
74     
75     if ( this.isBoundsChecking() ) {
76     
77         if (!LoginConfiguration.BASIC_AUTHENTICATION.equals(authenticationMethod)
78         && !LoginConfiguration.DIGEST_AUTHENTICATION.equals(authenticationMethod)
79             && !LoginConfiguration.FORM_AUTHENTICATION.equals(authenticationMethod)
80             && !LoginConfiguration.CLIENT_CERTIFICATION_AUTHENTICATION.equals(authenticationMethod) ) {
81                 
82         throw new IllegalArgumentException JavaDoc(localStrings.getLocalString(
83                                            "enterprise.deployment..exceptionauthenticationmethod",
84                                            "{0} is not a valid authentication method", new Object JavaDoc[] {authenticationMethod}));
85         
86         }
87     }
88     this.authenticationMethod = authenticationMethod;
89     
90     }
91
92     /** Obtain the realm the server should use for basic authentication. */
93     public String JavaDoc getRealmName() {
94     if (this.realmName == null) {
95         this.realmName = "";
96     }
97     return this.realmName;
98     }
99     
100     /** Set the realm the server should use for basic authentication. */
101     public void setRealmName(String JavaDoc realmName) {
102     this.realmName = realmName;
103     }
104     
105     /** Get the name of the login page for form login. */
106     public String JavaDoc getFormLoginPage() {
107     if (this.formLoginPage == null) {
108         this.formLoginPage = "";
109     }
110     return this.formLoginPage;
111     }
112      /** Set the name of the login page for form login. */
113     public void setFormLoginPage(String JavaDoc formLoginPage) {
114     this.formLoginPage = formLoginPage;
115     }
116     
117     /** Get the name of the error page for form login. */
118     public String JavaDoc getFormErrorPage() {
119     if (this.formErrorPage == null) {
120         this.formErrorPage = "";
121     }
122     return this.formErrorPage;
123     }
124     /** Set the name of the error page for form login. */
125     public void setFormErrorPage(String JavaDoc formErrorPage) {
126     this.formErrorPage = formErrorPage;
127     }
128     /** My representation as a formatted String.*/
129     public void print(StringBuffer JavaDoc toStringBuffer) {
130     toStringBuffer.append("LoginConfig:(").append(authenticationMethod).append(" ").append(
131             realmName).append(" ").append(formLoginPage).append(" ").append(formErrorPage).append(")");
132     }
133
134 }
135
Popular Tags