Skip to content

Commit 4a55c30

Browse files
jimmyjameslbalmaceda
authored andcommitted
review feedback - whitespace and optimized imports
1 parent 938f1a5 commit 4a55c30

File tree

3 files changed

+19
-18
lines changed

3 files changed

+19
-18
lines changed

lib/src/test/java/com/auth0/jwt/JWTCreatorTest.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -158,41 +158,40 @@ public void shouldNotOverwriteKeyIdIfAddedFromRSAAlgorithms() throws Exception {
158158
String headerJson = new String(Base64.decodeBase64(parts[0]), StandardCharsets.UTF_8);
159159
assertThat(headerJson, JsonMatcher.hasEntry("kid", "my-key-id"));
160160
}
161-
161+
162162
@Test
163163
public void shouldAddKeyIdIfAvailableFromECDSAKAlgorithms() throws Exception {
164-
ECPrivateKey privateKey = (ECPrivateKey) PemUtils.readPrivateKeyFromFile(PRIVATE_KEY_FILE_EC_256K
165-
, "EC");
164+
ECPrivateKey privateKey = (ECPrivateKey) PemUtils.readPrivateKeyFromFile(PRIVATE_KEY_FILE_EC_256K, "EC");
166165
ECDSAKeyProvider provider = mock(ECDSAKeyProvider.class);
167166
when(provider.getPrivateKeyId()).thenReturn("my-key-id");
168167
when(provider.getPrivateKey()).thenReturn(privateKey);
169-
168+
170169
String signed = JWTCreator.init()
171170
.sign(Algorithm.ECDSA256K(provider));
172-
171+
173172
assertThat(signed, is(notNullValue()));
174173
String[] parts = signed.split("\\.");
175174
String headerJson = new String(Base64.decodeBase64(parts[0]), StandardCharsets.UTF_8);
176175
assertThat(headerJson, JsonMatcher.hasEntry("kid", "my-key-id"));
177176
}
178-
177+
179178
@Test
180179
public void shouldNotOverwriteKeyIdIfAddedFromECDSAKAlgorithms() throws Exception {
181180
ECPrivateKey privateKey = (ECPrivateKey) PemUtils.readPrivateKeyFromFile(PRIVATE_KEY_FILE_EC_256K, "EC");
182181
ECDSAKeyProvider provider = mock(ECDSAKeyProvider.class);
183182
when(provider.getPrivateKeyId()).thenReturn("my-key-id");
184183
when(provider.getPrivateKey()).thenReturn(privateKey);
185-
184+
186185
String signed = JWTCreator.init()
187186
.withKeyId("real-key-id")
188187
.sign(Algorithm.ECDSA256(provider));
189-
188+
190189
assertThat(signed, is(notNullValue()));
191190
String[] parts = signed.split("\\.");
192191
String headerJson = new String(Base64.decodeBase64(parts[0]), StandardCharsets.UTF_8);
193192
assertThat(headerJson, JsonMatcher.hasEntry("kid", "my-key-id"));
194193
}
195-
194+
196195
@Test
197196
public void shouldAddKeyIdIfAvailableFromECDSAAlgorithms() throws Exception {
198197
ECPrivateKey privateKey = (ECPrivateKey) PemUtils.readPrivateKeyFromFile(PRIVATE_KEY_FILE_EC_256, "EC");

lib/src/test/java/com/auth0/jwt/JWTTest.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ public void shouldVerifyDecodedToken() throws Exception {
8686
DecodedJWT decodedJWT = JWT.decode(token);
8787
RSAKey key = (RSAKey) PemUtils.readPublicKeyFromFile(PUBLIC_KEY_FILE_RSA, "RSA");
8888
DecodedJWT jwt = JWT.require(Algorithm.RSA512(key))
89-
.build()
90-
.verify(decodedJWT);
89+
.build()
90+
.verify(decodedJWT);
9191

9292
assertThat(jwt, is(notNullValue()));
9393
}
@@ -498,26 +498,26 @@ public void shouldCreateAnEmptyECDSA256SignedToken() throws Exception {
498498
.build();
499499
assertThat(verified, is(notNullValue()));
500500
}
501-
501+
502502
@Test
503503
public void shouldCreateAnEmptyECDSA256KSignedToken() throws Exception {
504504
ECPublicKey publicKey = (ECPublicKey) PemUtils.readPublicKeyFromFile(PUBLIC_KEY_FILE_EC_256K, "EC");
505505
ECPrivateKey privateKey = (ECPrivateKey) PemUtils.readPrivateKeyFromFile(PRIVATE_KEY_FILE_EC_256K, "EC");
506506

507-
String signed = JWT.create().sign(Algorithm.ECDSA256K(publicKey, privateKey) );
507+
String signed = JWT.create().sign(Algorithm.ECDSA256K(publicKey, privateKey));
508508
assertThat(signed, is(notNullValue()));
509-
509+
510510
String[] parts = signed.split("\\.");
511511
String headerJson = new String(Base64.decodeBase64(parts[0]), StandardCharsets.UTF_8);
512512
assertThat(headerJson, JsonMatcher.hasEntry("alg", "ES256K"));
513513
assertThat(headerJson, JsonMatcher.hasEntry("typ", "JWT"));
514514
assertThat(parts[1], is("e30"));
515-
515+
516516
JWTVerifier verified = JWT.require(Algorithm.ECDSA256K(publicKey, privateKey))
517517
.build();
518518
assertThat(verified, is(notNullValue()));
519519
}
520-
520+
521521
@Test
522522
public void shouldCreateAnEmptyECDSA384SignedToken() throws Exception {
523523
String signed = JWT.create().sign(Algorithm.ECDSA384((ECKey) PemUtils.readPrivateKeyFromFile(PRIVATE_KEY_FILE_EC_384, "EC")));

lib/src/test/java/com/auth0/jwt/PemUtils.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.auth0.jwt;
22

3-
import org.bouncycastle.jce.provider.PEMUtil;
43
import org.bouncycastle.util.io.pem.PemObject;
54
import org.bouncycastle.util.io.pem.PemReader;
65

@@ -12,7 +11,10 @@
1211
import java.security.NoSuchAlgorithmException;
1312
import java.security.PrivateKey;
1413
import java.security.PublicKey;
15-
import java.security.spec.*;
14+
import java.security.spec.EncodedKeySpec;
15+
import java.security.spec.InvalidKeySpecException;
16+
import java.security.spec.PKCS8EncodedKeySpec;
17+
import java.security.spec.X509EncodedKeySpec;
1618

1719
public class PemUtils {
1820

0 commit comments

Comments
 (0)