KickJava   Java API By Example, From Geeks To Geeks.

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


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 import com.sun.enterprise.deployment.xml.ConnectorTagNames;
26
27 /**
28  * This class encapsulates the xml tags: description, auth-mech-type and
29  * credential-interface in the connector specification.
30  * @author Sheetal Vartak
31  */

32 public class AuthMechanism extends Descriptor{
33
34     private int authMechVal;
35     private String JavaDoc credInterface;
36
37     /**
38      * Default constructor.
39      */

40     public AuthMechanism(){}
41
42     /**
43      * Initializes the data members.
44      * @param description description
45      * @param authMechVal authentication mechanism type.
46      * @param credInterface credential interface type.
47      */

48     public AuthMechanism(String JavaDoc description, int authMechVal,
49                          String JavaDoc credInterface) {
50         super.setDescription(description);
51         this.authMechVal = authMechVal;
52         this.credInterface = credInterface;
53     }
54
55     /**
56      * Set the credential interface.
57      * @param cred the interface.
58      */

59     public void setCredentialInterface(String JavaDoc cred) {
60         credInterface = cred;
61     }
62
63     /**
64      * Get the credential interface.
65      * @return credInterface the interface.
66      */

67     public String JavaDoc getCredentialInterface() {
68         return credInterface;
69     }
70
71    /**
72     * Get the description
73     * @return description.
74     */

75     public String JavaDoc getDescription(){
76         return super.getDescription();
77     }
78
79     /**
80      * Sets the description
81      * @param description.
82      */

83     public void setDescription(String JavaDoc description){
84         super.setDescription(description);
85     }
86
87    /**
88     * Get the auth-mech-type
89     * @return authMechVal the authentication mechanism type
90     */

91     public String JavaDoc getAuthMechType() {
92         if(authMechVal == PoolManagerConstants.BASIC_PASSWORD)
93         return ConnectorTagNames.DD_BASIC_PASSWORD;
94         else
95             return ConnectorTagNames.DD_KERBEROS;
96     }
97     
98     /**
99      * Get the authentication mechanism value.
100      */

101     public int getAuthMechVal() {
102         return authMechVal;
103     }
104
105     /**
106      * Set the authentication mechanism value.
107      */

108     public void setAuthMechVal(int value) {
109         authMechVal = value;
110     }
111
112     /**
113      * Set the authentication mechanism value.
114      */

115     public void setAuthMechVal(String JavaDoc value) {
116         if((value.trim()).equals(ConnectorTagNames.DD_BASIC_PASSWORD))
117         authMechVal = PoolManagerConstants.BASIC_PASSWORD;
118         else if((value.trim()).equals(ConnectorTagNames.DD_KERBEROS))
119         authMechVal = PoolManagerConstants.KERBV5;
120     else throw new IllegalArgumentException JavaDoc("Invalid auth-mech-type");// put this in localStrings...
121
}
122 }
123
Popular Tags