/** * Returns <code>true</code> if these Credentials and the specified instance are equal. For credentials to be equal, * their login (as returned by {@link #getLogin()} must be equal. If the password-sensitive parameter is enabled, * their passwords (as returned by {@link #getPassword()} must also match. * * <p> * Empty Credentials and <code>null</code> are considered equal: if a <code>null</code> instance is specified, * <code>true</code> is returned if these Credentials are {@link #isEmpty() empty}). * </p> * * @param o the Object to test for equality * @param passwordSensitive true if passwords need to be equal for credentials instanes to match * @return true if this and the specified instance are equal */ public boolean equals(Object o, boolean passwordSensitive) { // Empty Credentials and null are equivalent if(o==null) return isEmpty(); if(!(o instanceof Credentials)) // Note: this class is declared final so we don't need to worry about subclasses return false; Credentials credentials = (Credentials)o; return credentials.login.equals(this.login) && (!passwordSensitive || credentials.password.equals(this.password)); }
/** * Sets the login and password parts of this URL. Any credentials contained by this FileURL will be replaced. * <code>null</code> can be passed to discard existing credentials. * * <p>Credentials may or may not be of any use for the scheme's file protocol depending on the value * returned by {@link #getAuthenticationType()}.</p> * * @param credentials the new login and password parts, replacing any existing credentials. If null is passed, * existing credentials will be discarded. * @see #getCredentials() */ public void setCredentials(Credentials credentials) { if(credentials==null || credentials.isEmpty()) // Empty credentials are equivalent to null credentials this.credentials = null; else this.credentials = credentials; urlModified(); }
if(credentialsMapping.getCredentials().isEmpty()) return;