From 15419fe34b6dd92223eff7c9f64b34f044eb0133 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Wed, 25 Dec 2019 15:47:15 +0300 Subject: Fix tests --- .../scribejava/apis/AppleClientSecretGenerator.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src/main/java/com/github/scribejava') diff --git a/src/main/java/com/github/scribejava/apis/AppleClientSecretGenerator.java b/src/main/java/com/github/scribejava/apis/AppleClientSecretGenerator.java index 3af6bc7a..f8e10d97 100644 --- a/src/main/java/com/github/scribejava/apis/AppleClientSecretGenerator.java +++ b/src/main/java/com/github/scribejava/apis/AppleClientSecretGenerator.java @@ -19,10 +19,10 @@ package com.github.scribejava.apis; import io.jsonwebtoken.Jwts; import io.jsonwebtoken.SignatureAlgorithm; -import org.apache.commons.io.FileUtils; +import org.apache.commons.io.IOUtils; -import java.io.File; import java.io.IOException; +import java.io.InputStream; import java.nio.charset.StandardCharsets; import java.security.Key; import java.security.KeyFactory; @@ -41,14 +41,16 @@ public class AppleClientSecretGenerator { private final Key signingKey; - public AppleClientSecretGenerator(final String subject, final String teamId, final String keyId, final String keyPath) + private final String pemData; + + public AppleClientSecretGenerator(final String subject, final String teamId, final String keyId, final InputStream keyData) throws IOException, NoSuchAlgorithmException, InvalidKeySpecException { this.subject = subject; this.keyId = keyId; this.teamId = teamId; - String pemData = FileUtils.readFileToString(new File(keyPath), StandardCharsets.UTF_8); - String p8encodedData = pemData + this.pemData = IOUtils.toString(keyData, StandardCharsets.UTF_8); + String p8encodedData = getPemData() .replace( "-----BEGIN PRIVATE KEY-----\n", "") .replace("\n", "") @@ -82,4 +84,8 @@ public class AppleClientSecretGenerator { public String getApplicationId() { return subject; } + + public String getPemData() { + return pemData; + } } -- cgit v1.2.3