Commit 6914567940cf1e0f563c01a5f633755261caecf8
Committed by
GitHub
Merge pull request #494 from Posi-Paka/master
Removal of Joda-Time library.
Showing
3 changed files
with
11 additions
and
20 deletions
... | ... | @@ -126,10 +126,6 @@ |
126 | 126 | <artifactId>jjwt</artifactId> |
127 | 127 | </dependency> |
128 | 128 | <dependency> |
129 | - <groupId>joda-time</groupId> | |
130 | - <artifactId>joda-time</artifactId> | |
131 | - </dependency> | |
132 | - <dependency> | |
133 | 129 | <groupId>org.apache.velocity</groupId> |
134 | 130 | <artifactId>velocity</artifactId> |
135 | 131 | </dependency> | ... | ... |
... | ... | @@ -20,7 +20,6 @@ import io.jsonwebtoken.Jws; |
20 | 20 | import io.jsonwebtoken.Jwts; |
21 | 21 | import io.jsonwebtoken.SignatureAlgorithm; |
22 | 22 | import org.apache.commons.lang3.StringUtils; |
23 | -import org.joda.time.DateTime; | |
24 | 23 | import org.springframework.beans.factory.annotation.Autowired; |
25 | 24 | import org.springframework.stereotype.Component; |
26 | 25 | import org.thingsboard.server.common.data.id.CustomerId; |
... | ... | @@ -31,7 +30,9 @@ import org.thingsboard.server.config.JwtSettings; |
31 | 30 | import org.thingsboard.server.service.security.model.SecurityUser; |
32 | 31 | import org.thingsboard.server.service.security.model.UserPrincipal; |
33 | 32 | |
34 | -import java.util.Arrays; | |
33 | +import java.time.ZonedDateTime; | |
34 | +import java.util.Collections; | |
35 | +import java.util.Date; | |
35 | 36 | import java.util.List; |
36 | 37 | import java.util.UUID; |
37 | 38 | import java.util.stream.Collectors; |
... | ... | @@ -81,13 +82,13 @@ public class JwtTokenFactory { |
81 | 82 | claims.put(CUSTOMER_ID, securityUser.getCustomerId().getId().toString()); |
82 | 83 | } |
83 | 84 | |
84 | - DateTime currentTime = new DateTime(); | |
85 | + ZonedDateTime currentTime = ZonedDateTime.now(); | |
85 | 86 | |
86 | 87 | String token = Jwts.builder() |
87 | 88 | .setClaims(claims) |
88 | 89 | .setIssuer(settings.getTokenIssuer()) |
89 | - .setIssuedAt(currentTime.toDate()) | |
90 | - .setExpiration(currentTime.plusSeconds(settings.getTokenExpirationTime()).toDate()) | |
90 | + .setIssuedAt(Date.from(currentTime.toInstant())) | |
91 | + .setExpiration(Date.from(currentTime.plusSeconds(settings.getTokenExpirationTime()).toInstant())) | |
91 | 92 | .signWith(SignatureAlgorithm.HS512, settings.getTokenSigningKey()) |
92 | 93 | .compact(); |
93 | 94 | |
... | ... | @@ -129,11 +130,11 @@ public class JwtTokenFactory { |
129 | 130 | throw new IllegalArgumentException("Cannot create JWT Token without username/email"); |
130 | 131 | } |
131 | 132 | |
132 | - DateTime currentTime = new DateTime(); | |
133 | + ZonedDateTime currentTime = ZonedDateTime.now(); | |
133 | 134 | |
134 | 135 | UserPrincipal principal = securityUser.getUserPrincipal(); |
135 | 136 | Claims claims = Jwts.claims().setSubject(principal.getValue()); |
136 | - claims.put(SCOPES, Arrays.asList(Authority.REFRESH_TOKEN.name())); | |
137 | + claims.put(SCOPES, Collections.singletonList(Authority.REFRESH_TOKEN.name())); | |
137 | 138 | claims.put(USER_ID, securityUser.getId().getId().toString()); |
138 | 139 | claims.put(IS_PUBLIC, principal.getType() == UserPrincipal.Type.PUBLIC_ID); |
139 | 140 | |
... | ... | @@ -141,8 +142,8 @@ public class JwtTokenFactory { |
141 | 142 | .setClaims(claims) |
142 | 143 | .setIssuer(settings.getTokenIssuer()) |
143 | 144 | .setId(UUID.randomUUID().toString()) |
144 | - .setIssuedAt(currentTime.toDate()) | |
145 | - .setExpiration(currentTime.plusSeconds(settings.getRefreshTokenExpTime()).toDate()) | |
145 | + .setIssuedAt(Date.from(currentTime.toInstant())) | |
146 | + .setExpiration(Date.from(currentTime.plusSeconds(settings.getRefreshTokenExpTime()).toInstant())) | |
146 | 147 | .signWith(SignatureAlgorithm.HS512, settings.getTokenSigningKey()) |
147 | 148 | .compact(); |
148 | 149 | ... | ... |
... | ... | @@ -33,8 +33,7 @@ |
33 | 33 | <spring.version>4.3.4.RELEASE</spring.version> |
34 | 34 | <spring-security.version>4.2.0.RELEASE</spring-security.version> |
35 | 35 | <jjwt.version>0.7.0</jjwt.version> |
36 | - <joda-time.version>2.4</joda-time.version> | |
37 | - <json-path.version>2.2.0</json-path.version> | |
36 | + <json-path.version>2.2.0</json-path.version> | |
38 | 37 | <junit.version>4.12</junit.version> |
39 | 38 | <slf4j.version>1.7.7</slf4j.version> |
40 | 39 | <logback.version>1.2.3</logback.version> |
... | ... | @@ -484,11 +483,6 @@ |
484 | 483 | <version>${jjwt.version}</version> |
485 | 484 | </dependency> |
486 | 485 | <dependency> |
487 | - <groupId>joda-time</groupId> | |
488 | - <artifactId>joda-time</artifactId> | |
489 | - <version>${joda-time.version}</version> | |
490 | - </dependency> | |
491 | - <dependency> | |
492 | 486 | <groupId>org.apache.velocity</groupId> |
493 | 487 | <artifactId>velocity</artifactId> |
494 | 488 | <version>${velocity.version}</version> | ... | ... |