Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
robotdan committed Sep 27, 2023
1 parent 2a3d644 commit 1c0005f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
11 changes: 4 additions & 7 deletions src/main/java/io/fusionauth/jwt/JWTEncoder.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016-2019, FusionAuth, All Rights Reserved
* Copyright (c) 2016-2023, FusionAuth, All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -51,12 +51,9 @@ public String encode(JWT jwt, Signer signer) {
* @return the encoded JWT string.
*/
public String encode(JWT jwt, Signer signer, Supplier<Header> supplier) {
final Header header;
if (supplier != null) {
header = supplier.get();
} else {
header = new Header();
}
Header header = supplier != null
? supplier.get()
: new Header();
return encode(jwt, signer, header);
}

Expand Down
9 changes: 3 additions & 6 deletions src/test/java/io/fusionauth/jwt/JWTTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -563,12 +563,9 @@ public void test_complexPayload() {
Signer signer = HMACSigner.newSHA256Signer("secret");
Verifier verifier = HMACVerifier.newVerifier("secret");

String encodedJWT = JWT.getEncoder().encode(expectedJWT, signer, () -> {
final Header header = new Header();
header.set("gty", Collections.singletonList("client_credentials"));
header.set("kid", "1234");
return header;
});
String encodedJWT = JWT.getEncoder().encode(expectedJWT, signer, () -> new Header()
.set("gty", Collections.singletonList("client_credentials"))
.set("kid", "1234"));
JWT actualJwt = JWT.getDecoder().decode(encodedJWT, verifier);

assertEquals(actualJwt.header.algorithm, Algorithm.HS256);
Expand Down

0 comments on commit 1c0005f

Please sign in to comment.