Class TokenService
java.lang.Object
ntnu.idatt2016.v233.SmartMat.service.user.TokenService
This class is used to generate a JWT token.
- Version:
- 1.0
- Author:
- Anders
-
Constructor Summary
ConstructorsConstructorDescriptionTokenService
(org.springframework.security.oauth2.jwt.JwtEncoder encoder) Creates a new TokenService object. -
Method Summary
Modifier and TypeMethodDescriptiongenerateToken
(org.springframework.security.core.Authentication authentication) Generates a JWT token from an Authentication object.
-
Constructor Details
-
TokenService
public TokenService(org.springframework.security.oauth2.jwt.JwtEncoder encoder) Creates a new TokenService object.- Parameters:
encoder
- the JwtEncoder object to use
-
-
Method Details
-
generateToken
Generates a JWT token from an Authentication object. Generated tokens are self-signed and expire after one hour.- Parameters:
authentication
- the Authentication object to generate the token from- Returns:
- the generated token
-