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): Emmanuel Cecchet.
021: * Contributor(s): Mathieu Peltier.
022: */package org.continuent.sequoia.common.users;
023:
024: /**
025: * A <code>DatabaseBackendUser</code> is a login/password combination to
026: * represent a database backend user.
027: *
028: * @author <a href="mailto:Emmanuel.Cecchet@inria.fr">Emmanuel Cecchet </a>
029: * @author <a href="mailto:Mathieu.Peltier@inrialpes.fr">Mathieu Peltier </a>
030: * @version 1.0
031: */
032: public class DatabaseBackendUser extends AbstractDatabaseUser {
033: private static final long serialVersionUID = 92260597820622650L;
034:
035: /** Backend logical name. */
036: private String backendName;
037:
038: /**
039: * Creates a new <code>DatabaseBackendUser</code> instance. The caller must
040: * ensure that the parameters are not <code>null</code>.
041: *
042: * @param backendName the backend logical name.
043: * @param login the user name.
044: * @param password the password.
045: */
046: public DatabaseBackendUser(String backendName, String login,
047: String password) {
048: super (login, password);
049: this .backendName = backendName;
050: }
051:
052: /**
053: * Returns the backend logical name.
054: *
055: * @return the backend logical name.
056: */
057: public String getBackendName() {
058: return backendName;
059: }
060:
061: /**
062: * Tests if the login and password provided matches the login/password of this
063: * object.
064: *
065: * @param backendName backend logical name
066: * @param login a user name
067: * @param password a password
068: * @return <code>true</code> if it matches this object's login/password
069: */
070: public boolean matches(String backendName, String login,
071: String password) {
072: return (super .matches(login, password) && this .backendName
073: .equals(backendName));
074: }
075:
076: /**
077: * Two <code>DatabaseBackendUser</code> are equals if both objects have the
078: * same login & password.
079: *
080: * @param other the object to compare with.
081: * @return <code>true</code> if both objects have the same login & password.
082: */
083: public boolean equals(Object other) {
084: if ((other == null) || !(other instanceof DatabaseBackendUser))
085: return false;
086:
087: DatabaseBackendUser user = (DatabaseBackendUser) other;
088: return (super .matches(user.login, user.password) && backendName
089: .equals(user.backendName));
090: }
091:
092: /**
093: * @see org.continuent.sequoia.common.xml.XmlComponent#getXml()
094: */
095: public String getXml() {
096: return "";
097: // return "<"
098: // + DatabasesXmlTags.ELT_RealLogin
099: // + " "
100: // + DatabasesXmlTags.ATT_backendName
101: // + "=\""
102: // + getBackendName()
103: // + "\" "
104: // + DatabasesXmlTags.ATT_rLogin
105: // + "=\""
106: // + getLogin()
107: // + "\" "
108: // + DatabasesXmlTags.ATT_rPassword
109: // + "=\""
110: // + getPassword()
111: // + "\"/>";
112: }
113: }
|