aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/com/github/scribejava/apis/AppleClientSecretGenerator.java18
-rw-r--r--src/main/java/com/github/scribejava/apis/AppleSignInApi.java1
-rw-r--r--src/main/java/com/juick/server/configuration/SignInWithAppleConfig.java2
3 files changed, 11 insertions, 10 deletions
diff --git a/src/main/java/com/github/scribejava/apis/AppleClientSecretGenerator.java b/src/main/java/com/github/scribejava/apis/AppleClientSecretGenerator.java
index f8e10d97..f3406182 100644
--- a/src/main/java/com/github/scribejava/apis/AppleClientSecretGenerator.java
+++ b/src/main/java/com/github/scribejava/apis/AppleClientSecretGenerator.java
@@ -19,18 +19,20 @@ package com.github.scribejava.apis;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;
-import org.apache.commons.io.IOUtils;
import java.io.IOException;
-import java.io.InputStream;
import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
import java.security.Key;
import java.security.KeyFactory;
import java.security.NoSuchAlgorithmException;
import java.security.spec.EncodedKeySpec;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.PKCS8EncodedKeySpec;
-import java.time.*;
+import java.time.Instant;
+import java.time.ZoneId;
+import java.time.ZonedDateTime;
import java.util.Base64;
import java.util.Date;
@@ -41,16 +43,16 @@ public class AppleClientSecretGenerator {
private final Key signingKey;
- private final String pemData;
+ private final byte[] pemData;
- public AppleClientSecretGenerator(final String subject, final String teamId, final String keyId, final InputStream keyData)
+ public AppleClientSecretGenerator(final String subject, final String teamId, final String keyId, final Path keyFile)
throws IOException, NoSuchAlgorithmException, InvalidKeySpecException {
this.subject = subject;
this.keyId = keyId;
this.teamId = teamId;
- this.pemData = IOUtils.toString(keyData, StandardCharsets.UTF_8);
- String p8encodedData = getPemData()
+ this.pemData = Files.readAllBytes(keyFile);
+ String p8encodedData = new String(getPemData(), StandardCharsets.UTF_8)
.replace(
"-----BEGIN PRIVATE KEY-----\n", "")
.replace("\n", "")
@@ -85,7 +87,7 @@ public class AppleClientSecretGenerator {
return subject;
}
- public String getPemData() {
+ public byte[] getPemData() {
return pemData;
}
}
diff --git a/src/main/java/com/github/scribejava/apis/AppleSignInApi.java b/src/main/java/com/github/scribejava/apis/AppleSignInApi.java
index 14b7f0e6..7d960d35 100644
--- a/src/main/java/com/github/scribejava/apis/AppleSignInApi.java
+++ b/src/main/java/com/github/scribejava/apis/AppleSignInApi.java
@@ -18,7 +18,6 @@
package com.github.scribejava.apis;
import com.github.scribejava.core.builder.api.DefaultApi20;
-import com.github.scribejava.core.model.OAuth2AccessToken;
import com.github.scribejava.core.oauth2.clientauthentication.ClientAuthentication;
import com.nimbusds.jose.JOSEException;
import com.nimbusds.jose.JWSAlgorithm;
diff --git a/src/main/java/com/juick/server/configuration/SignInWithAppleConfig.java b/src/main/java/com/juick/server/configuration/SignInWithAppleConfig.java
index b55ba391..310c5899 100644
--- a/src/main/java/com/juick/server/configuration/SignInWithAppleConfig.java
+++ b/src/main/java/com/juick/server/configuration/SignInWithAppleConfig.java
@@ -40,6 +40,6 @@ public class SignInWithAppleConfig {
@Bean
public AppleClientSecretGenerator clientSecretGenerator() throws IOException, InvalidKeySpecException, NoSuchAlgorithmException {
- return new AppleClientSecretGenerator(appId, teamId, keyId, keyPath.getInputStream());
+ return new AppleClientSecretGenerator(appId, teamId, keyId, keyPath.getFile().toPath());
}
}