diff options
3 files changed, 4 insertions, 15 deletions
diff --git a/src/main/java/com/github/scribejava/apis/AppleClientSecretGenerator.java b/src/main/java/com/github/scribejava/apis/AppleClientSecretGenerator.java index 2de9ea4a..c6bbf63d 100644 --- a/src/main/java/com/github/scribejava/apis/AppleClientSecretGenerator.java +++ b/src/main/java/com/github/scribejava/apis/AppleClientSecretGenerator.java @@ -37,15 +37,12 @@ public class AppleClientSecretGenerator { private final Key signingKey; - private final byte[] pemData; - 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 = pemData; this.signingKey = Keys.decode(pemData); } @@ -74,7 +71,7 @@ public class AppleClientSecretGenerator { return subject; } - public byte[] getPemData() { - return pemData; + public java.security.Key getPublicKey() { + return signingKey.getPublicKey().getKey(); } } diff --git a/src/main/java/com/juick/KeystoreManager.java b/src/main/java/com/juick/KeystoreManager.java index 5a2a98c1..d8355941 100644 --- a/src/main/java/com/juick/KeystoreManager.java +++ b/src/main/java/com/juick/KeystoreManager.java @@ -21,7 +21,6 @@ import com.juick.www.api.activity.model.objects.Actor; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.core.io.Resource; -import org.springframework.util.Base64Utils; import org.tomitribe.churchkey.Key; import org.tomitribe.churchkey.Keys; @@ -31,8 +30,6 @@ import java.io.InputStream; import java.security.*; import java.security.cert.Certificate; import java.security.cert.CertificateException; -import java.security.spec.X509EncodedKeySpec; -import java.util.Arrays; public class KeystoreManager { private static final Logger logger = LoggerFactory.getLogger("ActivityPub"); diff --git a/src/test/java/com/juick/server/tests/ServerTests.java b/src/test/java/com/juick/server/tests/ServerTests.java index 3edd4596..36483ce8 100644 --- a/src/test/java/com/juick/server/tests/ServerTests.java +++ b/src/test/java/com/juick/server/tests/ServerTests.java @@ -221,8 +221,6 @@ import org.springframework.web.client.RestTemplate; import org.springframework.web.util.UriComponents; import org.springframework.web.util.UriComponentsBuilder; import org.tomitribe.auth.signatures.Base64; -import org.tomitribe.churchkey.Key; -import org.tomitribe.churchkey.Keys; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NamedNodeMap; @@ -2481,12 +2479,9 @@ public class ServerTests { public void testAppleClientSecret() throws NoSuchAlgorithmException, IOException, InvalidKeySpecException, NoSuchProviderException { String secret = new String(clientSecretGenerator.getClientSecret().getBytes(), StandardCharsets.UTF_8); - final Key key = Keys.decode(clientSecretGenerator.getPemData()); - - // Get the public key - final Key publicKey = key.getPublicKey(); + final java.security.Key publicKey = clientSecretGenerator.getPublicKey(); - Jws<Claims> jwt = Jwts.parserBuilder().setSigningKey(publicKey.getKey()).build().parseClaimsJws(secret); + Jws<Claims> jwt = Jwts.parserBuilder().setSigningKey(publicKey).build().parseClaimsJws(secret); assertThat(jwt.getHeader().get("kid"), is("keyid")); assertThat(jwt.getHeader().get("alg"), is("ES256")); Claims claims = jwt.getBody(); |