Skip to content

Commit

Permalink
Making BaseSSHUser extend BaseStandardCredentials simplifies code and…
Browse files Browse the repository at this point in the history
… may be helpful for JENKINS-26099.
  • Loading branch information
jglick committed Jan 13, 2015
1 parent 4813642 commit 397bec7
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 77 deletions.
@@ -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;
}

/**
Expand All @@ -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);
}
}
Expand Up @@ -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());
}
Expand Down
Expand Up @@ -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}
*/
Expand Down

0 comments on commit 397bec7

Please sign in to comment.