Main Page | Packages | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

DatabaseBackendUser.java

00001 /**
00002  * C-JDBC: Clustered JDBC.
00003  * Copyright (C) 2002-2004 French National Institute For Research In Computer
00004  * Science And Control (INRIA).
00005  * Contact: c-jdbc@objectweb.org
00006  * 
00007  * This library is free software; you can redistribute it and/or modify it
00008  * under the terms of the GNU Lesser General Public License as published by the
00009  * Free Software Foundation; either version 2.1 of the License, or any later
00010  * version.
00011  * 
00012  * This library is distributed in the hope that it will be useful, but WITHOUT
00013  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00014  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
00015  * for more details.
00016  * 
00017  * You should have received a copy of the GNU Lesser General Public License
00018  * along with this library; if not, write to the Free Software Foundation,
00019  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
00020  *
00021  * Initial developer(s): Emmanuel Cecchet.
00022  * Contributor(s): Mathieu Peltier.
00023  */
00024 
00025 package org.objectweb.cjdbc.common.users;
00026 
00027 
00028 
00029 /**
00030  * A <code>DatabaseBackendUser</code> is a login/password combination to
00031  * represent a database backend user.
00032  * 
00033  * @author <a href="mailto:Emmanuel.Cecchet@inria.fr">Emmanuel Cecchet </a>
00034  * @author <a href="mailto:Mathieu.Peltier@inrialpes.fr">Mathieu Peltier </a>
00035  * @version 1.0
00036  */
00037 public class DatabaseBackendUser extends AbstractDatabaseUser
00038 {
00039   /** Backend logical name. */
00040   private String backendName;
00041 
00042   /**
00043    * Creates a new <code>DatabaseBackendUser</code> instance. The caller must
00044    * ensure that the parameters are not <code>null</code>.
00045    * 
00046    * @param backendName the backend logical name.
00047    * @param login the user name.
00048    * @param password the password.
00049    */
00050   public DatabaseBackendUser(String backendName, String login, String password)
00051   {
00052     super(login, password);
00053     this.backendName = backendName;
00054   }
00055 
00056   /**
00057    * Returns the backend logical name.
00058    * 
00059    * @return the backend logical name.
00060    */
00061   public String getBackendName()
00062   {
00063     return backendName;
00064   }
00065 
00066   /**
00067    * Tests if the login and password provided matches the login/password of
00068    * this object.
00069    * 
00070    * @param backendName backend logical name
00071    * @param login a user name
00072    * @param password a password
00073    * @return <code>true</code> if it matches this object's login/password
00074    */
00075   public boolean matches(String backendName, String login, String password)
00076   {
00077     return (super.matches(login, password) && this.backendName
00078         .equals(backendName));
00079   }
00080 
00081   /**
00082    * Two <code>DatabaseBackendUser</code> are equals if both objects have the
00083    * same login & password.
00084    * 
00085    * @param other the object to compare with.
00086    * @return <code>true</code> if both objects have the same login &
00087    *         password.
00088    */
00089   public boolean equals(Object other)
00090   {
00091     if ((other == null) || !(other instanceof DatabaseBackendUser))
00092       return false;
00093 
00094     DatabaseBackendUser user = (DatabaseBackendUser) other;
00095     return (super.matches(user.login, user.password) && backendName
00096         .equals(user.backendName));
00097   }
00098 
00099   /**
00100    * @see org.objectweb.cjdbc.common.xml.XmlComponent#getXml()
00101    */
00102   public String getXml()
00103   {
00104     return "";
00105     //    return "<"
00106     //      + DatabasesXmlTags.ELT_RealLogin
00107     //      + " "
00108     //      + DatabasesXmlTags.ATT_backendName
00109     //      + "=\""
00110     //      + getBackendName()
00111     //      + "\" "
00112     //      + DatabasesXmlTags.ATT_rLogin
00113     //      + "=\""
00114     //      + getLogin()
00115     //      + "\" "
00116     //      + DatabasesXmlTags.ATT_rPassword
00117     //      + "=\""
00118     //      + getPassword()
00119     //      + "\"/>";
00120   }
00121 }

Generated on Mon Apr 11 22:01:31 2005 for C-JDBC by  doxygen 1.3.9.1