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 RemoteAPITokencreate(RemoteAPIToken token)Add a token to the store for a given serviceRemoteAPITokencreateTokenFromAuthCode(java.lang.String authcode, RemoteAPI remoteAPI, java.lang.String tokenRedirect)Get a new token from the given auth codevoiddelete(RemoteAPI remoteAPI)Delete a token for the logged in user and a givenRemoteAPIprotected RemoteAPITokengetOldTokenId(RemoteAPIToken apiToken)Remove any old token for this user from the databaseRemoteAPITokengetToken(RemoteAPI remoteAPI)Get a token for a given serviceRemoteAPITokenupdateTokenFromRefreshToken(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:
createin 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:
getTokenin interfaceRemoteAPITokenService- Parameters:
remoteAPI- TheRemoteAPIof 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:
deletein interfaceRemoteAPITokenService- Parameters:
remoteAPI- theRemoteAPIto 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:
updateTokenFromRefreshTokenin 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:
createTokenFromAuthCodein 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.
-
-