Class JwtServiceImpl

java.lang.Object
tech.corefinance.common.service.JwtServiceImpl
All Implemented Interfaces:
JwtService

@Service @ConditionalOnProperty(prefix="tech.corefinance.security.jwt.enabled", name="common", matchIfMissing=true, havingValue="true") public class JwtServiceImpl extends Object implements JwtService
  • Constructor Details

  • Method Details

    • getJwtConfiguration

      public JwtConfiguration getJwtConfiguration()
      Specified by:
      getJwtConfiguration in interface JwtService
    • sign

      public String sign(Map<String,Serializable> data)
      Description copied from interface: JwtService
      Signing data.
      Specified by:
      sign in interface JwtService
      Parameters:
      data - Data to sign.
      Returns:
      JWT token
    • verfiy

      public com.auth0.jwt.interfaces.DecodedJWT verfiy(String token, String deviceId, String ipaddress)
      Description copied from interface: JwtService
      Verify JWT token.
      Specified by:
      verfiy in interface JwtService
      Parameters:
      token - JWT token
      deviceId - Login device ID
      ipaddress - Client IP Address
      Returns:
      True if token active
    • extractIpAddress

      public String extractIpAddress(jakarta.servlet.http.HttpServletRequest httpServletRequest) throws UnknownHostException
      Description copied from interface: JwtService
      Extract client IP Address from request.
      Specified by:
      extractIpAddress in interface JwtService
      Parameters:
      httpServletRequest - Request
      Returns:
      Client IP Address
      Throws:
      UnknownHostException - When cannot read ip address
    • retreiveTokenFromRequest

      public Map<String,tech.corefinance.common.dto.JwtTokenDto> retreiveTokenFromRequest(jakarta.servlet.http.HttpServletRequest httpServletRequest, jakarta.servlet.http.HttpServletResponse httpServletResponse) throws IOException
      Description copied from interface: JwtService
      Retreive JWT data from request.
      Specified by:
      retreiveTokenFromRequest in interface JwtService
      Parameters:
      httpServletRequest - HttpServletRequest
      httpServletResponse - HttpServletResponse
      Returns:
      JwtTokenDto Object
      Throws:
      IOException - When read fail
    • buildLoginDataMap

      public Map<String,Serializable> buildLoginDataMap(tech.corefinance.common.dto.JwtTokenDto jwtTokenDto) throws com.fasterxml.jackson.core.JsonProcessingException
      Specified by:
      buildLoginDataMap in interface JwtService
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException
    • buildRefreshTokenDataMap

      public Map<String,Serializable> buildRefreshTokenDataMap(tech.corefinance.common.dto.JwtTokenDto jwtTokenDto, String token) throws com.fasterxml.jackson.core.JsonProcessingException
      Specified by:
      buildRefreshTokenDataMap in interface JwtService
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException
    • additionalJwtVerifyStep

      protected tech.corefinance.common.dto.JwtTokenDto additionalJwtVerifyStep(tech.corefinance.common.dto.JwtTokenDto jwtTokenDto, String token, String deviceId, String ipaddress)
    • retrieveUserAsAttribute

      public tech.corefinance.common.dto.BasicUserDto retrieveUserAsAttribute(tech.corefinance.common.dto.JwtTokenDto jwtTokenDto)
      Description copied from interface: JwtService
      Retrieve user info from login token.
      Specified by:
      retrieveUserAsAttribute in interface JwtService
      Parameters:
      jwtTokenDto - Login token.
      Returns:
      User from token