001: /**
002: * Sequoia: Database clustering technology.
003: * Copyright (C) 2002-2004 French National Institute For Research In Computer
004: * Science And Control (INRIA).
005: * Copyright (C) 2005 AmicoSoft, Inc. dba Emic Networks
006: * Contact: sequoia@continuent.org
007: *
008: * Licensed under the Apache License, Version 2.0 (the "License");
009: * you may not use this file except in compliance with the License.
010: * You may obtain a copy of the License at
011: *
012: * http://www.apache.org/licenses/LICENSE-2.0
013: *
014: * Unless required by applicable law or agreed to in writing, software
015: * distributed under the License is distributed on an "AS IS" BASIS,
016: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: * See the License for the specific language governing permissions and
018: * limitations under the License.
019: *
020: * Initial developer(s): Julie Marguerite.
021: * Contributor(s): Mathieu Peltier.
022: */package org.continuent.sequoia.driver;
023:
024: import java.io.Serializable;
025:
026: /**
027: * A <code>DatabaseUser</code> is just a login/password combination to
028: * represent database user.
029: *
030: * @author <a href="mailto:Julie.Marguerite@inria.fr">Julie Marguerite</a>
031: * @author <a href="Mathieu.Peltier@inrialpes.fr">Mathieu Peltier</a>
032: * @version 1.0
033: */
034: public class DatabaseUser implements Serializable {
035: private static final long serialVersionUID = 4733183236454586066L;
036:
037: /** Virtual database name. */
038: private String dbName;
039:
040: /** User name. */
041: private String login;
042:
043: /** Password. */
044: private String password;
045:
046: /**
047: * Creates a new <code>DatabaseUser</code> instance.
048: *
049: * @param dbName The virtual database name
050: * @param login User name
051: * @param password Password
052: */
053: public DatabaseUser(String dbName, String login, String password) {
054: this .dbName = dbName;
055: this .login = login;
056: this .password = password;
057: }
058:
059: /**
060: * Tests if the virtual database name login and password provided matches the
061: * virtual database name/login/password of this object.
062: *
063: * @param dbName virtual database name
064: * @param login a user name
065: * @param password a password
066: * @return <code>true</code> if it matches this object's virtual database
067: * name/login/password
068: */
069: public boolean matches(String dbName, String login, String password) {
070: return (this .dbName.equals(dbName) && this .login.equals(login) && this .password
071: .equals(password));
072: }
073:
074: /**
075: * Compares an object with this object.
076: *
077: * @param other an <code>Object</code>
078: * @return <code>true</code> if both objects have same virtual database
079: * name, login and password
080: */
081: public boolean equals(Object other) {
082: if (!(other instanceof DatabaseUser))
083: return false;
084:
085: DatabaseUser castOther = (DatabaseUser) other;
086: return matches(castOther.dbName, castOther.login,
087: castOther.password);
088: }
089:
090: /**
091: * Returns the virtual database name.
092: *
093: * @return database name
094: */
095: public String getDbName() {
096: return dbName;
097: }
098:
099: /**
100: * Gets the login name.
101: *
102: * @return login name
103: */
104: public String getLogin() {
105: return login;
106: }
107:
108: /**
109: * Gets the password.
110: *
111: * @return password
112: */
113: public String getPassword() {
114: return password;
115: }
116: }
|