KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > connectors > authentication > EisBackendPrincipal


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

24
25 package com.sun.enterprise.connectors.authentication;
26
27 import java.io.Serializable JavaDoc;
28
29 /**
30  * This a javabean class thatabstracts the backend principal.
31  * The backend principal consist of the userName and password
32  * which is used for authenticating/getting connection from
33  * the backend.
34  * @author Srikanth P
35  */

36
37 public class EisBackendPrincipal implements Serializable JavaDoc{
38
39
40     private String JavaDoc userName;
41     private String JavaDoc password;
42
43     /** Default constructor
44      */

45
46     public EisBackendPrincipal() {
47
48     }
49
50     /**
51      * Constructor
52      * @param userName UserName
53      * @param password Password
54      * @credential Credential
55      */

56
57     public EisBackendPrincipal(String JavaDoc userName, String JavaDoc password) {
58         this.userName = userName;
59         this.password = password;
60     }
61
62     /**
63      * Setter method for UserName property
64      * @param userName UserName
65      */

66
67     public void setUserName(String JavaDoc userName) {
68         this.userName = userName;
69     }
70
71     /**
72      * Setter method for password property
73      * @param password Password
74      */

75
76     public void setPassword(String JavaDoc password) {
77         this.password = password;
78     }
79
80     /**
81      * Getter method for UserName property
82      * @return UserName
83      */

84
85     public String JavaDoc getUserName() {
86         return userName;
87     }
88
89     /**
90      * Getter method for Password property
91      * @return Password
92      */

93
94     public String JavaDoc getPassword() {
95         return password;
96     }
97
98     /**
99      * Overloaded method from "Object" class
100      * Checks the equality.
101      * @param backendPrincipal Backend principal against which equality has to
102      * be tested.
103      * @return true if they are equal
104      * false if hey are not equal.
105      */

106
107     public boolean equals(Object JavaDoc backendPrincipal) {
108
109         if(backendPrincipal == null ||
110                  !(backendPrincipal instanceof EisBackendPrincipal)) {
111             return false;
112         }
113         EisBackendPrincipal eisBackendPrincipal =
114                            (EisBackendPrincipal)backendPrincipal;
115         
116         if(isEqual(eisBackendPrincipal.userName,this.userName) &&
117                 isEqual(eisBackendPrincipal.password,this.password)) {
118             return true;
119         } else {
120             return false;
121
122         }
123     }
124
125     /** Checks whether two strings are equal including the null string
126      * cases.
127      */

128
129     private boolean isEqual(String JavaDoc in, String JavaDoc out) {
130         if(in == null && out == null) {
131             return true;
132         }
133         if(in == null || out == null) {
134             return false;
135         }
136         return (out.equals(in));
137     }
138 }
139
Popular Tags