Skip to content
This repository was archived by the owner on Nov 23, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Mark SSHClient Auth helper classes package accessible
  • Loading branch information
allxiao committed Nov 2, 2017
commit 1733ec2b2dba4d357561353217f55521bb19986f
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@
/**
* Abstract SSH authentication credentials with username.
*/
public abstract class UsernameAuth {
abstract class UsernameAuth {
private final String username;

public UsernameAuth(String username) {
UsernameAuth(String username) {
this.username = username;
}

public String getUsername() {
String getUsername() {
return username;
}

public static UsernameAuth fromCredentials(StandardUsernameCredentials credentials) {
static UsernameAuth fromCredentials(StandardUsernameCredentials credentials) {
if (credentials instanceof StandardUsernamePasswordCredentials) {
StandardUsernamePasswordCredentials userPass = (StandardUsernamePasswordCredentials) credentials;
return new UsernamePasswordAuth(userPass.getUsername(), userPass.getPassword().getPlainText());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
/**
* SSH authentication credentials with username and password.
*/
public class UsernamePasswordAuth extends UsernameAuth {
class UsernamePasswordAuth extends UsernameAuth {
private final String password;

public UsernamePasswordAuth(String username, String password) {
UsernamePasswordAuth(String username, String password) {
super(username);
this.password = password;
}

public String getPassword() {
String getPassword() {
return password;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,29 @@
/**
* SSH authentication credentials with username and private keys.
*/
public class UsernamePrivateKeyAuth extends UsernameAuth {
class UsernamePrivateKeyAuth extends UsernameAuth {
private final String passPhrase;
private final ImmutableList<String> privateKeys;

public UsernamePrivateKeyAuth(String username, String passPhrase, String... privateKeys) {
UsernamePrivateKeyAuth(String username, String passPhrase, String... privateKeys) {
this(username, passPhrase, Arrays.asList(privateKeys));
}

public UsernamePrivateKeyAuth(String username, String passPhrase, Iterable privateKeys) {
UsernamePrivateKeyAuth(String username, String passPhrase, Iterable privateKeys) {
super(username);
this.passPhrase = passPhrase;
//noinspection unchecked
this.privateKeys = ImmutableList.<String>copyOf(privateKeys);
}

public byte[] getPassPhraseBytes() {
byte[] getPassPhraseBytes() {
if (passPhrase == null) {
return null;
}
return passPhrase.getBytes(Constants.UTF8);
}

public ImmutableList<String> getPrivateKeys() {
ImmutableList<String> getPrivateKeys() {
return privateKeys;
}
}