Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d
with:
flags: unittests
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: Reports
path: lib/build/reports
17 changes: 8 additions & 9 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {

dependencies {
// https://github.com/melix/japicmp-gradle-plugin/issues/36
classpath 'com.google.guava:guava:31.1-jre'
classpath 'com.google.guava:guava:32.0.1-jre'
}
}

Expand Down Expand Up @@ -121,21 +121,20 @@ test {

dependencies {
implementation 'javax.servlet:javax.servlet-api:3.1.0'
implementation 'org.apache.commons:commons-lang3:3.12.0'
implementation 'com.google.guava:guava-annotations:r03'
implementation 'org.apache.commons:commons-lang3:3.13.0'
implementation 'com.google.guava:guava:32.0.1-jre'
implementation 'commons-codec:commons-codec:1.15'

api 'com.auth0:auth0:1.45.1'
api 'com.auth0:java-jwt:3.19.4'
api 'com.auth0:java-jwt:4.5.0'
api 'com.auth0:jwks-rsa:0.22.1'

testImplementation 'org.bouncycastle:bcprov-jdk15on:1.64'
testImplementation 'org.hamcrest:java-hamcrest:2.0.0.0'
testImplementation 'org.hamcrest:hamcrest-core:1.3'
testImplementation 'org.mockito:mockito-core:2.8.9'
testImplementation 'org.hamcrest:hamcrest:2.2'
testImplementation 'org.mockito:mockito-core:4.8.1'
testImplementation 'org.junit.jupiter:junit-jupiter:5.8.1'
testImplementation 'org.springframework:spring-test:4.3.14.RELEASE'
testImplementation 'com.squareup.okhttp3:okhttp:4.11.0'
testImplementation 'com.squareup.okhttp3:okhttp:4.12.0'
testImplementation "com.squareup.okio:okio:3.5.0"
}

apply from: rootProject.file('gradle/maven-publish.gradle')
20 changes: 14 additions & 6 deletions src/test/java/com/auth0/SignatureVerifierTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import com.auth0.jwk.JwkException;
import com.auth0.jwk.JwkProvider;
import com.auth0.jwt.interfaces.DecodedJWT;
import org.bouncycastle.util.io.pem.PemReader;
import org.junit.jupiter.api.Test;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.IOException;
Expand All @@ -18,6 +18,7 @@
import java.security.interfaces.RSAPublicKey;
import java.security.spec.EncodedKeySpec;
import java.security.spec.X509EncodedKeySpec;
import java.util.Base64;
import java.util.Scanner;

import static org.hamcrest.CoreMatchers.notNullValue;
Expand Down Expand Up @@ -146,7 +147,7 @@ private JwkProvider getRSProvider(String rsaPath) throws Exception {

private static RSAPublicKey readPublicKeyFromFile(final String path) throws IOException {
Scanner scanner = null;
PemReader pemReader = null;
BufferedReader reader = null;
try {
scanner = new Scanner(Paths.get(path));
if (scanner.hasNextLine() && scanner.nextLine().startsWith("-----BEGIN CERTIFICATE-----")) {
Expand All @@ -157,8 +158,15 @@ private static RSAPublicKey readPublicKeyFromFile(final String path) throws IOEx
fs.close();
return (RSAPublicKey) key;
} else {
pemReader = new PemReader(new FileReader(path));
byte[] keyBytes = pemReader.readPemObject().getContent();
reader = new BufferedReader(new FileReader(path));
StringBuilder pemContent = new StringBuilder();
String line;
while ((line = reader.readLine()) != null) {
if (!line.startsWith("-----BEGIN") && !line.startsWith("-----END")) {
pemContent.append(line);
}
}
byte[] keyBytes = Base64.getDecoder().decode(pemContent.toString());
KeyFactory kf = KeyFactory.getInstance("RSA");
EncodedKeySpec keySpec = new X509EncodedKeySpec(keyBytes);
return (RSAPublicKey) kf.generatePublic(keySpec);
Expand All @@ -169,8 +177,8 @@ private static RSAPublicKey readPublicKeyFromFile(final String path) throws IOEx
if (scanner != null) {
scanner.close();
}
if (pemReader != null) {
pemReader.close();
if (reader != null) {
reader.close();
}
}
}
Expand Down
Loading