Class RemoteAPITokenServiceImpl
- java.lang.Object
-
- ca.corefacility.bioinformatics.irida.service.impl.RemoteAPITokenServiceImpl
-
- All Implemented Interfaces:
RemoteAPITokenService
@Service public class RemoteAPITokenServiceImpl extends java.lang.Object implements RemoteAPITokenService
Service implementation for storing and reading remote api tokens
-
-
Constructor Summary
Constructors Constructor Description RemoteAPITokenServiceImpl(RemoteApiTokenRepository tokenRepository, UserRepository userRepository, org.apache.oltu.oauth2.client.OAuthClient oauthClient)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RemoteAPIToken
create(RemoteAPIToken token)
Add a token to the store for a given serviceRemoteAPIToken
createTokenFromAuthCode(java.lang.String authcode, RemoteAPI remoteAPI, java.lang.String tokenRedirect)
Get a new token from the given auth codevoid
delete(RemoteAPI remoteAPI)
Delete a token for the logged in user and a givenRemoteAPI
protected RemoteAPIToken
getOldTokenId(RemoteAPIToken apiToken)
Remove any old token for this user from the databaseRemoteAPIToken
getToken(RemoteAPI remoteAPI)
Get a token for a given serviceRemoteAPIToken
updateTokenFromRefreshToken(RemoteAPI api)
Update a givenRemoteAPI
's OAuth token by refresh token if available
-
-
-
Constructor Detail
-
RemoteAPITokenServiceImpl
@Autowired public RemoteAPITokenServiceImpl(RemoteApiTokenRepository tokenRepository, UserRepository userRepository, org.apache.oltu.oauth2.client.OAuthClient oauthClient)
-
-
Method Detail
-
create
@Transactional public RemoteAPIToken create(RemoteAPIToken token)
Add a token to the store for a given service- Specified by:
create
in interfaceRemoteAPITokenService
- Parameters:
token
- The token to create- Returns:
- the created token
-
getToken
public RemoteAPIToken getToken(RemoteAPI remoteAPI) throws EntityNotFoundException
Get a token for a given service- Specified by:
getToken
in interfaceRemoteAPITokenService
- Parameters:
remoteAPI
- TheRemoteAPI
of the service root- Returns:
- A String OAuth2 token
- Throws:
EntityNotFoundException
- if the token could not be found
-
delete
@Transactional public void delete(RemoteAPI remoteAPI) throws EntityNotFoundException
Delete a token for the logged in user and a givenRemoteAPI
- Specified by:
delete
in interfaceRemoteAPITokenService
- Parameters:
remoteAPI
- theRemoteAPI
to delete a token for- Throws:
EntityNotFoundException
- if the token could not be found
-
updateTokenFromRefreshToken
@Transactional public RemoteAPIToken updateTokenFromRefreshToken(RemoteAPI api)
Update a givenRemoteAPI
's OAuth token by refresh token if available- Specified by:
updateTokenFromRefreshToken
in interfaceRemoteAPITokenService
- Parameters:
api
- the API to update- Returns:
- the most recent token if available
-
createTokenFromAuthCode
@Transactional public RemoteAPIToken createTokenFromAuthCode(java.lang.String authcode, RemoteAPI remoteAPI, java.lang.String tokenRedirect) throws org.apache.oltu.oauth2.common.exception.OAuthSystemException, org.apache.oltu.oauth2.common.exception.OAuthProblemException
Get a new token from the given auth code- Specified by:
createTokenFromAuthCode
in interfaceRemoteAPITokenService
- Parameters:
authcode
- the auth code to create a token forremoteAPI
- the remote api to get a token fortokenRedirect
- a redirect url to get the token from- Returns:
- a new token
- Throws:
org.apache.oltu.oauth2.common.exception.OAuthSystemException
- If building the token request failsorg.apache.oltu.oauth2.common.exception.OAuthProblemException
- If the token request fails
-
getOldTokenId
protected RemoteAPIToken getOldTokenId(RemoteAPIToken apiToken)
Remove any old token for this user from the database- Parameters:
apiToken
- the api token to remove.- Returns:
- the token that was found.
-
-