From a788a7c8f8d2e85bdbe379652de0ef5a9495ac29 Mon Sep 17 00:00:00 2001 From: Basil Crow Date: Mon, 22 Nov 2021 23:23:01 -0800 Subject: [PATCH] Reduce usages of Guava (#87) --- .../remote/UsernamePrivateKeyAuth.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/microsoft/jenkins/containeragents/remote/UsernamePrivateKeyAuth.java b/src/main/java/com/microsoft/jenkins/containeragents/remote/UsernamePrivateKeyAuth.java index 2b6904e..0806910 100644 --- a/src/main/java/com/microsoft/jenkins/containeragents/remote/UsernamePrivateKeyAuth.java +++ b/src/main/java/com/microsoft/jenkins/containeragents/remote/UsernamePrivateKeyAuth.java @@ -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 privateKeys; + private final List 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 privateKeys) { super(username); this.passPhrase = passPhrase; //noinspection unchecked - this.privateKeys = ImmutableList.copyOf(privateKeys); + List privateKeyList = new ArrayList<>(); + for (String privateKey : privateKeys) { + privateKeyList.add(privateKey); + } + this.privateKeys = Collections.unmodifiableList(privateKeyList); } byte[] getPassPhraseBytes() { @@ -35,7 +40,7 @@ byte[] getPassPhraseBytes() { return passPhrase.getBytes(StandardCharsets.UTF_8); } - ImmutableList getPrivateKeys() { + List getPrivateKeys() { return privateKeys; } }