diff --git a/src/main/java/com/datapipe/jenkins/vault/credentials/VaultTokenFileCredential.java b/src/main/java/com/datapipe/jenkins/vault/credentials/VaultTokenFileCredential.java index 7b32d445..4286bbf4 100644 --- a/src/main/java/com/datapipe/jenkins/vault/credentials/VaultTokenFileCredential.java +++ b/src/main/java/com/datapipe/jenkins/vault/credentials/VaultTokenFileCredential.java @@ -6,12 +6,10 @@ import edu.umd.cs.findbugs.annotations.CheckForNull; import edu.umd.cs.findbugs.annotations.NonNull; import hudson.Extension; -import hudson.FilePath; -import hudson.remoting.VirtualChannel; import java.io.File; import java.io.IOException; +import java.nio.charset.StandardCharsets; import org.apache.commons.io.FileUtils; -import org.jenkinsci.remoting.RoleChecker; import org.kohsuke.stapler.DataBoundConstructor; public class VaultTokenFileCredential extends AbstractVaultTokenCredential { @@ -28,24 +26,9 @@ public VaultTokenFileCredential(@CheckForNull CredentialsScope scope, @CheckForN @Override public String getToken(Vault vault) { - FilePath file = new FilePath(new File(filepath)); try { - return file.act(new FilePath.FileCallable() { - @Override - public void checkRoles(RoleChecker roleChecker) throws SecurityException { - //not needed - } - - @Override - public String invoke(File f, VirtualChannel channel) { - try { - return FileUtils.readFileToString(f); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - }).trim(); - } catch (IOException | InterruptedException e) { + return FileUtils.readFileToString(new File(filepath), StandardCharsets.UTF_8); + } catch (IOException e) { throw new VaultPluginException("Failed to read token from file", e); } }