Example #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;
 }
Example #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;
  }