Skip to content

Commit

Permalink
Reduce usages of Guava (#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
basil authored Nov 23, 2021
1 parent 2402b93 commit a788a7c
Showing 1 changed file with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,32 @@

package com.microsoft.jenkins.containeragents.remote;

import com.google.common.collect.ImmutableList;

import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

/**
* SSH authentication credentials with username and private keys.
*/
class UsernamePrivateKeyAuth extends UsernameAuth {
private final String passPhrase;
private final ImmutableList<String> privateKeys;
private final List<String> privateKeys;

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

UsernamePrivateKeyAuth(String username, String passPhrase, Iterable privateKeys) {
UsernamePrivateKeyAuth(String username, String passPhrase, Iterable<String> privateKeys) {
super(username);
this.passPhrase = passPhrase;
//noinspection unchecked
this.privateKeys = ImmutableList.<String>copyOf(privateKeys);
List<String> privateKeyList = new ArrayList<>();
for (String privateKey : privateKeys) {
privateKeyList.add(privateKey);
}
this.privateKeys = Collections.unmodifiableList(privateKeyList);
}

byte[] getPassPhraseBytes() {
Expand All @@ -35,7 +40,7 @@ byte[] getPassPhraseBytes() {
return passPhrase.getBytes(StandardCharsets.UTF_8);
}

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

0 comments on commit a788a7c

Please sign in to comment.