From 8a32b359eed27ab1d4e054ffed99b6602fa18acf Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Wed, 21 Dec 2022 02:23:44 +0300 Subject: Sign in with Apple: adopt records --- .../scribejava/apis/AppleClientAuthentication.java | 2 +- .../apis/AppleClientSecretGenerator.java | 37 ++-------------------- 2 files changed, 4 insertions(+), 35 deletions(-) (limited to 'src/main/java/com/github/scribejava') 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(); } -- cgit v1.2.3