Пример #1
0
 /** INTERNAL: Clone the login. This also clones the platform as it is internal to the login. */
 public Object clone() {
   DatasourceLogin clone = null;
   try {
     clone = (DatasourceLogin) super.clone();
   } catch (Exception exception) {
     // should not happen...do nothing
   }
   if (getConnector() != null) {
     clone.setConnector((Connector) getConnector().clone());
   }
   clone.setDatasourcePlatform((Platform) getDatasourcePlatform().clone());
   clone.setProperties((Properties) properties.clone());
   return clone;
 }
Пример #2
0
  /**
   * SECURE: The password in the login properties is encrypted. Return a clone of the properties
   * with the password decrypted.
   */
  private Properties prepareProperties(Properties properties) {
    Properties result = (Properties) properties.clone();
    String password = result.getProperty("password");
    if (password != null) {
      // Fix for bug # 2700529
      // The securable object is initialized on first call of
      // getSecurableObject. When setting an encrypted password
      // we don't make this call since it is already encrypted, hence,
      // we do not initialize the securable object on the holder.
      //
      // If neither setPassword or setEncryptedPassword is called
      // (example, user sets properties via the setProperties method),
      // when the user tries to connect they  will get a null pointer
      // exception. So if the holder does not hold
      // a securable object or the setEncryptedPassword flag is not true,
      // don't bother trying to decrypt.
      if (getSecurableObjectHolder().hasSecurableObject() || isEncryptedPasswordSet) {
        result.put(
            "password", getSecurableObjectHolder().getSecurableObject().decryptPassword(password));
      }
    }

    return result;
  }
Пример #3
0
 /**
  * PUBLIC: Some JDBC drivers require additional, driver-specific, properties. Add the specified
  * property to those to be passed to the JDBC driver.
  */
 public void setProperty(String propertyName, Object propertyValue) {
   properties.put(propertyName, propertyValue);
 }
Пример #4
0
 /** Return the password. It will be encrypted. */
 public String getPassword() {
   return properties.getProperty("password");
 }
Пример #5
0
 /**
  * PUBLIC: Some drivers don't like the "user" and "password" properties. They can be removed with
  * this method.
  */
 public void removeProperty(String propertyName) {
   properties.remove(propertyName);
 }
Пример #6
0
 /**
  * PUBLIC: The user name is the database login name. Some databases do not require a user name or
  * the user is obtained from the OS, in this case the user name not be specified.
  */
 public String getUserName() {
   return properties.getProperty("user");
 }