aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/com/github/scribejava/apis/AppleClientAuthentication.java2
-rw-r--r--src/main/java/com/github/scribejava/apis/AppleClientSecretGenerator.java37
-rw-r--r--src/main/java/com/juick/config/SignInWithAppleConfig.java7
3 files changed, 7 insertions, 39 deletions
diff --git a/src/main/java/com/github/scribejava/apis/AppleClientAuthentication.java b/src/main/java/com/github/scribejava/apis/AppleClientAuthentication.java
index b4198af1..919cbafe 100644
--- a/src/main/java/com/github/scribejava/apis/AppleClientAuthentication.java
+++ b/src/main/java/com/github/scribejava/apis/AppleClientAuthentication.java
@@ -27,7 +27,7 @@ public class AppleClientAuthentication implements ClientAuthentication {
}
@Override
public void addClientAuthentication(OAuthRequest request, String apiKey, String apiSecret) {
- request.addBodyParameter("client_id", generator.getApplicationId());
+ request.addBodyParameter("client_id", generator.subject());
request.addBodyParameter("client_secret", generator.getClientSecret());
}
}
diff --git a/src/main/java/com/github/scribejava/apis/AppleClientSecretGenerator.java b/src/main/java/com/github/scribejava/apis/AppleClientSecretGenerator.java
index c6bbf63d..21254550 100644
--- a/src/main/java/com/github/scribejava/apis/AppleClientSecretGenerator.java
+++ b/src/main/java/com/github/scribejava/apis/AppleClientSecretGenerator.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008-2020, Juick
+ * Copyright (C) 2008-2022, Juick
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
@@ -19,33 +19,14 @@ package com.github.scribejava.apis;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;
+import org.tomitribe.churchkey.Key;
-import java.security.NoSuchAlgorithmException;
-import java.security.spec.InvalidKeySpecException;
import java.time.Instant;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.Date;
-import org.tomitribe.churchkey.Key;
-import org.tomitribe.churchkey.Keys;
-
-public class AppleClientSecretGenerator {
- private final String subject;
- private final String teamId;
- private final String keyId;
-
- private final Key signingKey;
-
- 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.signingKey = Keys.decode(pemData);
- }
-
+public record AppleClientSecretGenerator(String subject, String teamId, String keyId, Key signingKey) {
public String getClientSecret() {
Instant now = Instant.now();
return Jwts.builder()
@@ -59,18 +40,6 @@ public class AppleClientSecretGenerator {
.compact();
}
- public String getTeamId() {
- return teamId;
- }
-
- public String getKeyId() {
- return keyId;
- }
-
- public String getApplicationId() {
- return subject;
- }
-
public java.security.Key getPublicKey() {
return signingKey.getPublicKey().getKey();
}
diff --git a/src/main/java/com/juick/config/SignInWithAppleConfig.java b/src/main/java/com/juick/config/SignInWithAppleConfig.java
index 85e2bdd1..2b0d3698 100644
--- a/src/main/java/com/juick/config/SignInWithAppleConfig.java
+++ b/src/main/java/com/juick/config/SignInWithAppleConfig.java
@@ -23,10 +23,9 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.Resource;
+import org.tomitribe.churchkey.Keys;
import java.io.IOException;
-import java.security.NoSuchAlgorithmException;
-import java.security.spec.InvalidKeySpecException;
@Configuration
public class SignInWithAppleConfig {
@@ -40,8 +39,8 @@ public class SignInWithAppleConfig {
private Resource keyPath;
@Bean
- AppleClientSecretGenerator clientSecretGenerator() throws IOException, InvalidKeySpecException, NoSuchAlgorithmException {
+ AppleClientSecretGenerator clientSecretGenerator() throws IOException {
byte[] pemData = IOUtils.toByteArray(keyPath.getInputStream());
- return new AppleClientSecretGenerator(appId, teamId, keyId, pemData);
+ return new AppleClientSecretGenerator(appId, teamId, keyId, Keys.decode(pemData));
}
}