Skip to content

Commit 6e80ea1

Browse files
CodeDeadjimmyjames
andauthored
Feature/cleanup (#642)
* GIT compliance * Simpler HashMap declaration * Replaced usage of deprecated JsonMapper methods, removed unneeded null check * Removed unused import * Removed unused imports Co-authored-by: Jim Anderson <jim.anderson@auth0.com>
1 parent b4fae64 commit 6e80ea1

File tree

9 files changed

+11
-15
lines changed

9 files changed

+11
-15
lines changed

EXAMPLES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,4 +127,4 @@ RSAKeyProvider keyProvider = new RSAKeyProvider() {
127127

128128
Algorithm algorithm = Algorithm.RSA256(keyProvider);
129129
//Use the Algorithm to create and verify JWTs.
130-
```
130+
```

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1818
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1919
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2020
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21-
SOFTWARE.
21+
SOFTWARE.

lib/src/main/java/com/auth0/jwt/JWTCreator.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import com.fasterxml.jackson.core.JsonProcessingException;
88
import com.fasterxml.jackson.databind.MapperFeature;
99
import com.fasterxml.jackson.databind.ObjectMapper;
10+
import com.fasterxml.jackson.databind.json.JsonMapper;
1011
import com.fasterxml.jackson.databind.module.SimpleModule;
1112

1213
import java.nio.charset.StandardCharsets;
@@ -31,12 +32,14 @@ public final class JWTCreator {
3132
private static final SimpleModule module;
3233

3334
static {
34-
mapper = new ObjectMapper();
3535
module = new SimpleModule();
3636
module.addSerializer(PayloadClaimsHolder.class, new PayloadSerializer());
3737
module.addSerializer(HeaderClaimsHolder.class, new HeaderSerializer());
38-
mapper.registerModule(module);
39-
mapper.configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true);
38+
39+
mapper = JsonMapper.builder()
40+
.configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true)
41+
.build()
42+
.registerModule(module);
4043
}
4144

4245
private JWTCreator(Algorithm algorithm, Map<String, Object> headerClaims, Map<String, Object> payloadClaims)
@@ -489,7 +492,7 @@ private static boolean validateClaim(Map<?, ?> map) {
489492
return false;
490493
}
491494

492-
if (entry.getKey() == null || !(entry.getKey() instanceof String)) {
495+
if (!(entry.getKey() instanceof String)) {
493496
return false;
494497
}
495498
}

lib/src/main/java/com/auth0/jwt/algorithms/RSAAlgorithm.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import com.auth0.jwt.interfaces.DecodedJWT;
66
import com.auth0.jwt.interfaces.RSAKeyProvider;
77

8-
import java.nio.charset.StandardCharsets;
98
import java.security.InvalidKeyException;
109
import java.security.NoSuchAlgorithmException;
1110
import java.security.SignatureException;

lib/src/main/java/com/auth0/jwt/impl/BasicHeader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class BasicHeader implements Header, Serializable {
3737
this.type = type;
3838
this.contentType = contentType;
3939
this.keyId = keyId;
40-
this.tree = Collections.unmodifiableMap(tree == null ? new HashMap<String, JsonNode>() : tree);
40+
this.tree = Collections.unmodifiableMap(tree == null ? new HashMap<>() : tree);
4141
this.objectReader = objectReader;
4242
}
4343

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,11 @@
1010
import org.junit.rules.ExpectedException;
1111

1212
import java.security.interfaces.ECKey;
13-
import java.security.interfaces.ECPrivateKey;
14-
import java.security.interfaces.ECPublicKey;
1513
import java.security.interfaces.RSAKey;
1614
import java.util.Collections;
1715
import java.util.List;
1816
import java.util.concurrent.*;
1917

20-
import static com.auth0.jwt.PemUtils.readPrivateKeyFromFile;
2118
import static com.auth0.jwt.PemUtils.readPublicKeyFromFile;
2219

2320
//@Ignore("Skipping concurrency tests")

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@
1616

1717
import static org.hamcrest.MatcherAssert.assertThat;
1818
import static org.hamcrest.Matchers.*;
19-
import static org.junit.Assert.assertNull;
2019
import static org.junit.Assert.assertTrue;
21-
import static org.mockito.ArgumentMatchers.eq;
2220
import static org.mockito.Mockito.mock;
2321
import static org.mockito.Mockito.when;
2422

lib/src/test/java/com/auth0/jwt/algorithms/HMACAlgorithmTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import java.nio.charset.StandardCharsets;
1414
import java.security.InvalidKeyException;
1515
import java.security.NoSuchAlgorithmException;
16-
import java.util.Arrays;
1716

1817
import static com.auth0.jwt.algorithms.CryptoTestHelper.asJWT;
1918
import static com.auth0.jwt.algorithms.CryptoTestHelper.assertSignaturePresent;

settings.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ pluginManagement {
88
}
99

1010
include ':java-jwt'
11-
project(':java-jwt').projectDir = new File(rootProject.projectDir, '/lib')
11+
project(':java-jwt').projectDir = new File(rootProject.projectDir, '/lib')

0 commit comments

Comments
 (0)