Class ApiTokenServiceImpl

java.lang.Object
org.genesys.blocks.tokenauth.service.impl.ApiTokenServiceImpl
All Implemented Interfaces:
ApiTokenService

@Service public class ApiTokenServiceImpl extends Object implements ApiTokenService
API Token services
  • Constructor Details

    • ApiTokenServiceImpl

      public ApiTokenServiceImpl()
  • Method Details

    • encodeToken

      @Cacheable(cacheNames="api.tokenauth.encoded", key="#token", unless="#result == null") public String encodeToken(@NonNull @NonNull String token)
      Description copied from interface: ApiTokenService
      Generate the encoded token string.
      Specified by:
      encodeToken in interface ApiTokenService
      Parameters:
      token - token value
      Returns:
      encoded token value
    • loadById

      @Transactional(readOnly=true) @PostAuthorize("hasRole(\'ADMINISTRATOR\') || returnObject.sid.id == principal.id") public ApiToken loadById(Long id)
      Specified by:
      loadById in interface ApiTokenService
    • getToken

      @Transactional(readOnly=true) @Cacheable(cacheNames="api.tokenauth.tokens", key="#encodedToken", unless="#result == null") public ApiToken getToken(String encodedToken)
      Description copied from interface: ApiTokenService
      Get token by its persisted value. This is used by the InvalidatedTokenFilter and ApiTokenDetailsService.
      Specified by:
      getToken in interface ApiTokenService
      Parameters:
      encodedToken - encoded token
      Returns:
      null if token not found
    • listTokensForSid

      @Transactional(readOnly=true) @PreAuthorize("hasRole(\'ADMINISTRATOR\') || (hasRole(\'VETTEDUSER\') && #sid.id == principal.id)") public List<ApiToken> listTokensForSid(AclSid sid)
      Specified by:
      listTokensForSid in interface ApiTokenService
    • listTokens

      @Transactional(readOnly=true) @PreAuthorize("hasRole(\'ADMINISTRATOR\')") public org.springframework.data.domain.Page<ApiToken> listTokens(org.springframework.data.domain.Pageable page)
      Specified by:
      listTokens in interface ApiTokenService
    • createToken

      @Transactional @PreAuthorize("hasRole(\'ADMINISTRATOR\') || (hasRole(\'VETTEDUSER\') && #sid.id == principal.id)") public ApiToken createToken(AclSid sid, String label, Instant expires)
      Description copied from interface: ApiTokenService
      Register a new API token for the specified sid with a label and expiration date.
      Specified by:
      createToken in interface ApiTokenService
      Parameters:
      sid - the SID represented by the token
      label - a token friendly name, unique to the sid
      expires - the expiration date of the token
      Returns:
      a new API token with token.token provided in plain-text
    • remove

      @Transactional @PostAuthorize("hasRole(\'ADMINISTRATOR\') || (hasRole(\'VETTEDUSER\') && returnObject.sid.id == principal.id)") @CacheEvict(cacheNames="api.tokenauth.tokens", key="#result.token", condition="#result != null") public ApiToken remove(ApiToken apiToken)
      Specified by:
      remove in interface ApiTokenService
    • update

      @Transactional @PostAuthorize("hasRole(\'ADMINISTRATOR\') || (hasRole(\'VETTEDUSER\') && returnObject.sid.id == principal.id)") @CacheEvict(cacheNames="api.tokenauth.tokens", key="#result.token", condition="#result != null") public ApiToken update(ApiToken apiToken)
      Specified by:
      update in interface ApiTokenService