Skip to content
Permalink
Browse files

Making BaseSSHUser extend BaseStandardCredentials simplifies code and…

… may be helpful for JENKINS-26099.
  • Loading branch information
jglick committed Jan 13, 2015
1 parent 4813642 commit 397bec75840835c953708f006d4ad74a7f9b5926
@@ -1,50 +1,31 @@
package com.cloudbees.jenkins.plugins.sshcredentials.impl;

import com.cloudbees.jenkins.plugins.sshcredentials.SSHUser;
import com.cloudbees.plugins.credentials.BaseCredentials;
import com.cloudbees.plugins.credentials.CredentialsScope;
import com.cloudbees.plugins.credentials.common.IdCredentials;
import com.cloudbees.plugins.credentials.common.StandardUsernameCredentials;
import com.cloudbees.plugins.credentials.impl.BaseStandardCredentials;
import edu.umd.cs.findbugs.annotations.NonNull;
import org.apache.commons.lang.StringUtils;

/**
* @author stephenc
* @since 28/02/2012 13:44
*/
public class BaseSSHUser extends BaseCredentials implements SSHUser, StandardUsernameCredentials {
public class BaseSSHUser extends BaseStandardCredentials implements SSHUser, StandardUsernameCredentials {

/**
* Ensure consistent serialization.
*/
private static final long serialVersionUID = 1L;

/**
* The id.
*/
protected final String id;
/**
* The description.
*/
protected final String description;
/**
* The username.
*/
protected final String username;

public BaseSSHUser(CredentialsScope scope, String id, String username, String description) {
super(scope);
this.id = IdCredentials.Helpers.fixEmptyId(id);
super(scope, id, description);
this.username = username;
this.description = description;
}

/**
* {@inheritDoc}
*/
@NonNull
public String getId() {
return id;
}

/**
@@ -55,27 +36,4 @@ public String getUsername() {
return StringUtils.isEmpty(username) ? System.getProperty("user.name") : username;
}

/**
* {@inheritDoc}
*/
@NonNull
public String getDescription() {
return StringUtils.isNotEmpty(description) ? description : "";
}

/**
* {@inheritDoc}
*/
@Override
public boolean equals(Object o) {
return IdCredentials.Helpers.equals(this, o);
}

/**
* {@inheritDoc}
*/
@Override
public int hashCode() {
return IdCredentials.Helpers.hashCode(this);
}
}
@@ -73,22 +73,6 @@ public Secret getPassword() {
return password;
}

/**
* {@inheritDoc}
*/
@Override
public int hashCode() {
return super.hashCode();
}

/**
* {@inheritDoc}
*/
@Override
public boolean equals(Object o) {
return super.equals(o);
}

private Object readResolve() {
return new UsernamePasswordCredentialsImpl(getScope(), getId(), getDescription(), getUsername(), getPassword().getEncryptedValue());
}
@@ -162,22 +162,6 @@ public Secret getPassphrase() {
return passphrase;
}

/**
* {@inheritDoc}
*/
@Override
public int hashCode() {
return super.hashCode();
}

/**
* {@inheritDoc}
*/
@Override
public boolean equals(Object o) {
return super.equals(o);
}

/**
* {@inheritDoc}
*/

0 comments on commit 397bec7

Please sign in to comment.
You can’t perform that action at this time.