Class ApiTokenServiceImpl
java.lang.Object
org.genesys.blocks.tokenauth.service.impl.ApiTokenServiceImpl
- All Implemented Interfaces:
ApiTokenService
API Token services
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateToken(AclSid sid, String label, Instant expires) Register a new API token for the specifiedsidwith a label and expiration date.encodeToken(@NonNull String token) Generate the encoded token string.Get token by its persisted value.org.springframework.data.domain.Page<ApiToken>listTokens(org.springframework.data.domain.Pageable page) listTokensForSid(AclSid sid)
-
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:ApiTokenServiceGenerate the encoded token string.- Specified by:
encodeTokenin interfaceApiTokenService- 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:
loadByIdin interfaceApiTokenService
-
getToken
@Transactional(readOnly=true) @Cacheable(cacheNames="api.tokenauth.tokens", key="#encodedToken", unless="#result == null") public ApiToken getToken(String encodedToken) Description copied from interface:ApiTokenServiceGet token by its persisted value. This is used by theInvalidatedTokenFilterandApiTokenDetailsService.- Specified by:
getTokenin interfaceApiTokenService- Parameters:
encodedToken- encoded token- Returns:
nullif token not found
-
listTokensForSid
@Transactional(readOnly=true) @PreAuthorize("hasRole(\'ADMINISTRATOR\') || (hasRole(\'VETTEDUSER\') && #sid.id == principal.id)") public List<ApiToken> listTokensForSid(AclSid sid) - Specified by:
listTokensForSidin interfaceApiTokenService
-
listTokens
@Transactional(readOnly=true) @PreAuthorize("hasRole(\'ADMINISTRATOR\')") public org.springframework.data.domain.Page<ApiToken> listTokens(org.springframework.data.domain.Pageable page) - Specified by:
listTokensin interfaceApiTokenService
-
createToken
@Transactional @PreAuthorize("hasRole(\'ADMINISTRATOR\') || (hasRole(\'VETTEDUSER\') && #sid.id == principal.id)") public ApiToken createToken(AclSid sid, String label, Instant expires) Description copied from interface:ApiTokenServiceRegister a new API token for the specifiedsidwith a label and expiration date.- Specified by:
createTokenin interfaceApiTokenService- Parameters:
sid- the SID represented by the tokenlabel- a token friendly name, unique to thesidexpires- the expiration date of the token- Returns:
- a new API token with
token.tokenprovided 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:
removein interfaceApiTokenService
-
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:
updatein interfaceApiTokenService
-