KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > continuent > sequoia > common > users > DatabaseBackendUser


1 /**
2  * Sequoia: Database clustering technology.
3  * Copyright (C) 2002-2004 French National Institute For Research In Computer
4  * Science And Control (INRIA).
5  * Copyright (C) 2005 AmicoSoft, Inc. dba Emic Networks
6  * Contact: sequoia@continuent.org
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  * Initial developer(s): Emmanuel Cecchet.
21  * Contributor(s): Mathieu Peltier.
22  */

23
24 package org.continuent.sequoia.common.users;
25
26 /**
27  * A <code>DatabaseBackendUser</code> is a login/password combination to
28  * represent a database backend user.
29  *
30  * @author <a HREF="mailto:Emmanuel.Cecchet@inria.fr">Emmanuel Cecchet </a>
31  * @author <a HREF="mailto:Mathieu.Peltier@inrialpes.fr">Mathieu Peltier </a>
32  * @version 1.0
33  */

34 public class DatabaseBackendUser extends AbstractDatabaseUser
35 {
36   private static final long serialVersionUID = 92260597820622650L;
37
38   /** Backend logical name. */
39   private String JavaDoc backendName;
40
41   /**
42    * Creates a new <code>DatabaseBackendUser</code> instance. The caller must
43    * ensure that the parameters are not <code>null</code>.
44    *
45    * @param backendName the backend logical name.
46    * @param login the user name.
47    * @param password the password.
48    */

49   public DatabaseBackendUser(String JavaDoc backendName, String JavaDoc login, String JavaDoc password)
50   {
51     super(login, password);
52     this.backendName = backendName;
53   }
54
55   /**
56    * Returns the backend logical name.
57    *
58    * @return the backend logical name.
59    */

60   public String JavaDoc getBackendName()
61   {
62     return backendName;
63   }
64
65   /**
66    * Tests if the login and password provided matches the login/password of this
67    * object.
68    *
69    * @param backendName backend logical name
70    * @param login a user name
71    * @param password a password
72    * @return <code>true</code> if it matches this object's login/password
73    */

74   public boolean matches(String JavaDoc backendName, String JavaDoc login, String JavaDoc password)
75   {
76     return (super.matches(login, password) && this.backendName
77         .equals(backendName));
78   }
79
80   /**
81    * Two <code>DatabaseBackendUser</code> are equals if both objects have the
82    * same login & password.
83    *
84    * @param other the object to compare with.
85    * @return <code>true</code> if both objects have the same login & password.
86    */

87   public boolean equals(Object JavaDoc other)
88   {
89     if ((other == null) || !(other instanceof DatabaseBackendUser))
90       return false;
91
92     DatabaseBackendUser user = (DatabaseBackendUser) other;
93     return (super.matches(user.login, user.password) && backendName
94         .equals(user.backendName));
95   }
96
97   /**
98    * @see org.continuent.sequoia.common.xml.XmlComponent#getXml()
99    */

100   public String JavaDoc getXml()
101   {
102     return "";
103     // return "<"
104
// + DatabasesXmlTags.ELT_RealLogin
105
// + " "
106
// + DatabasesXmlTags.ATT_backendName
107
// + "=\""
108
// + getBackendName()
109
// + "\" "
110
// + DatabasesXmlTags.ATT_rLogin
111
// + "=\""
112
// + getLogin()
113
// + "\" "
114
// + DatabasesXmlTags.ATT_rPassword
115
// + "=\""
116
// + getPassword()
117
// + "\"/>";
118
}
119 }
120
Popular Tags