Class TokenService

java.lang.Object
ntnu.idatt2016.v233.SmartMat.service.user.TokenService

@Service public class TokenService extends Object
This class is used to generate a JWT token.
Version:
1.0
Author:
Anders
  • Constructor Summary

    Constructors
    Constructor
    Description
    TokenService(org.springframework.security.oauth2.jwt.JwtEncoder encoder)
    Creates a new TokenService object.
  • Method Summary

    Modifier and Type
    Method
    Description
    generateToken(org.springframework.security.core.Authentication authentication)
    Generates a JWT token from an Authentication object.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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

      public String generateToken(org.springframework.security.core.Authentication authentication)
      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