增加jetbrains.annotations.NotNull注释
This commit is contained in:
@ -5,6 +5,7 @@ import io.jsonwebtoken.security.Keys;
|
|||||||
import io.jsonwebtoken.security.SignatureException;
|
import io.jsonwebtoken.security.SignatureException;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
@ -29,6 +30,7 @@ public class JwtService {
|
|||||||
@Value("${jwt.token-expiration-ms}")
|
@Value("${jwt.token-expiration-ms}")
|
||||||
private long tokenExpirationMs;
|
private long tokenExpirationMs;
|
||||||
|
|
||||||
|
@org.jetbrains.annotations.NotNull
|
||||||
private Key getSignKey() {
|
private Key getSignKey() {
|
||||||
byte[] keyBytes = Base64.getDecoder().decode(secretKey);
|
byte[] keyBytes = Base64.getDecoder().decode(secretKey);
|
||||||
return Keys.hmacShaKeyFor(keyBytes);
|
return Keys.hmacShaKeyFor(keyBytes);
|
||||||
@ -46,7 +48,7 @@ public class JwtService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T> T extractClaim(String token, Function<Claims, T> claimsResolver) {
|
public <T> T extractClaim(String token, @NotNull Function<Claims, T> claimsResolver) {
|
||||||
final Claims claims = extractAllClaims(token);
|
final Claims claims = extractAllClaims(token);
|
||||||
return claimsResolver.apply(claims);
|
return claimsResolver.apply(claims);
|
||||||
}
|
}
|
||||||
@ -60,7 +62,7 @@ public class JwtService {
|
|||||||
.getBody();
|
.getBody();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String generateToken(UserDetails userDetails) {
|
public String generateToken(@NotNull UserDetails userDetails) {
|
||||||
Map<String, Object> claims = new HashMap<>();
|
Map<String, Object> claims = new HashMap<>();
|
||||||
return createToken(claims, userDetails.getUsername());
|
return createToken(claims, userDetails.getUsername());
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user