Search in sources :

Example 1 with Role

use of com.gmoon.springsecurityjwt.user.Role in project Toy by gmoon92.

the class JwtUtil method decode.

public User decode(String tokenOfIncludeSchema) {
    String token = obtainTokenWithoutSchema(tokenOfIncludeSchema);
    verify(token);
    DecodedJWT jwt = JWT.decode(token);
    String username = jwt.getClaim("username").asString();
    Role role = Role.valueOf(jwt.getClaim("role").asString());
    return User.create(username, "", role);
}
Also used : Role(com.gmoon.springsecurityjwt.user.Role) DecodedJWT(com.auth0.jwt.interfaces.DecodedJWT)

Example 2 with Role

use of com.gmoon.springsecurityjwt.user.Role in project toy by gmoon92.

the class JwtUtil method decode.

public User decode(String tokenOfIncludeSchema) {
    String token = obtainTokenWithoutSchema(tokenOfIncludeSchema);
    verify(token);
    DecodedJWT jwt = JWT.decode(token);
    String username = jwt.getClaim("username").asString();
    Role role = Role.valueOf(jwt.getClaim("role").asString());
    return User.create(username, "", role);
}
Also used : Role(com.gmoon.springsecurityjwt.user.Role) DecodedJWT(com.auth0.jwt.interfaces.DecodedJWT)

Aggregations

DecodedJWT (com.auth0.jwt.interfaces.DecodedJWT)2 Role (com.gmoon.springsecurityjwt.user.Role)2