KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > cjdbc > common > users > DatabaseBackendUser


1 /**
2  * C-JDBC: Clustered JDBC.
3  * Copyright (C) 2002-2005 French National Institute For Research In Computer
4  * Science And Control (INRIA).
5  * Contact: c-jdbc@objectweb.org
6  *
7  * This library is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU Lesser General Public License as published by the
9  * Free Software Foundation; either version 2.1 of the License, or any later
10  * version.
11  *
12  * This library is distributed in the hope that it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
15  * for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with this library; if not, write to the Free Software Foundation,
19  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
20  *
21  * Initial developer(s): Emmanuel Cecchet.
22  * Contributor(s): Mathieu Peltier.
23  */

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

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

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

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

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

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

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