diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/com/github/scribejava/apis/AppleClientSecretGenerator.java | 6 | ||||
-rw-r--r-- | src/main/java/com/juick/config/SignInWithAppleConfig.java | 6 |
2 files changed, 7 insertions, 5 deletions
diff --git a/src/main/java/com/github/scribejava/apis/AppleClientSecretGenerator.java b/src/main/java/com/github/scribejava/apis/AppleClientSecretGenerator.java index f3406182..be2c30cf 100644 --- a/src/main/java/com/github/scribejava/apis/AppleClientSecretGenerator.java +++ b/src/main/java/com/github/scribejava/apis/AppleClientSecretGenerator.java @@ -45,13 +45,13 @@ public class AppleClientSecretGenerator { private final byte[] pemData; - public AppleClientSecretGenerator(final String subject, final String teamId, final String keyId, final Path keyFile) - throws IOException, NoSuchAlgorithmException, InvalidKeySpecException { + public AppleClientSecretGenerator(final String subject, final String teamId, final String keyId, final byte[] pemData) + throws NoSuchAlgorithmException, InvalidKeySpecException { this.subject = subject; this.keyId = keyId; this.teamId = teamId; - this.pemData = Files.readAllBytes(keyFile); + this.pemData = pemData; String p8encodedData = new String(getPemData(), StandardCharsets.UTF_8) .replace( "-----BEGIN PRIVATE KEY-----\n", "") diff --git a/src/main/java/com/juick/config/SignInWithAppleConfig.java b/src/main/java/com/juick/config/SignInWithAppleConfig.java index 0b41cb7e..bbd58aed 100644 --- a/src/main/java/com/juick/config/SignInWithAppleConfig.java +++ b/src/main/java/com/juick/config/SignInWithAppleConfig.java @@ -18,6 +18,7 @@ package com.juick.config; import com.github.scribejava.apis.AppleClientSecretGenerator; +import org.apache.commons.io.IOUtils; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -35,11 +36,12 @@ public class SignInWithAppleConfig { private String teamId; @Value("${apple_key_id:keyid}") private String keyId; - @Value("${apple_key_path:classpath:testkey.p8}") + @Value("${apple_key_path:classpath:/testkey.p8}") private Resource keyPath; @Bean public AppleClientSecretGenerator clientSecretGenerator() throws IOException, InvalidKeySpecException, NoSuchAlgorithmException { - return new AppleClientSecretGenerator(appId, teamId, keyId, keyPath.getFile().toPath()); + byte[] pemData = IOUtils.toByteArray(keyPath.getInputStream()); + return new AppleClientSecretGenerator(appId, teamId, keyId, pemData); } } |