Ejemplo n.º 1
0
 @Override
 public void removeAccessToken(OAuth2AccessToken accessToken) {
   /*Query query = new Query();
   query.addCriteria(Criteria.where("tokenId").is(accessToken.getValue()));
   OAuth2AuthenticationAccessToken token = mongoTemplate.findOne(query, OAuth2AuthenticationAccessToken.class, "oauth2_access_token");*/
   OAuth2AuthenticationAccessToken token =
       oAuth2AccessTokenDao.findByTokenId(accessToken.getValue());
   if (token != null) {
     oAuth2AccessTokenDao.delete(token);
   }
 }
Ejemplo n.º 2
0
 @Override
 public void storeAccessToken(OAuth2AccessToken token, OAuth2Authentication authentication) {
   OAuth2AuthenticationAccessToken oAuth2AuthenticationAccessToken =
       new OAuth2AuthenticationAccessToken(
           token, authentication, authenticationKeyGenerator.extractKey(authentication));
   oAuth2AccessTokenDao.save(oAuth2AuthenticationAccessToken);
 }
Ejemplo n.º 3
0
 @Override
 public OAuth2Authentication readAuthentication(String tokenId) {
   /*
   Query query = new Query();
   query.addCriteria(Criteria.where("tokenId").is(tokenId));
   OAuth2AuthenticationAccessToken token = mongoTemplate.findOne(query, OAuth2AuthenticationAccessToken.class, "oauth2_access_token"); */
   OAuth2AuthenticationAccessToken token = oAuth2AccessTokenDao.findByTokenId(tokenId);
   return null == token ? null : token.getAuthentication();
 }
Ejemplo n.º 4
0
 @Override
 public Collection<OAuth2AccessToken> findTokensByClientId(String clientId) {
   /*Query query = new Query();
   query.addCriteria(Criteria.where("clientId").is(clientId));
   List<OAuth2AuthenticationAccessToken> accessTokens = mongoTemplate.find(query, OAuth2AuthenticationAccessToken.class, "oauth2_access_token");*/
   List<OAuth2AuthenticationAccessToken> accessTokens =
       oAuth2AccessTokenDao.findByClientId(clientId);
   return extractAccessTokens(accessTokens);
 }
Ejemplo n.º 5
0
 @Override
 public OAuth2AccessToken readAccessToken(String tokenId) {
   /* Query query = new Query();
   query.addCriteria(Criteria.where("tokenId").is(tokenId));
   OAuth2AuthenticationAccessToken token = mongoTemplate.findOne(query, OAuth2AuthenticationAccessToken.class, "oauth2_access_token"); */
   OAuth2AuthenticationAccessToken token = oAuth2AccessTokenDao.findByTokenId(tokenId);
   if (null == token) {
     throw new InvalidTokenException("Token not valid");
   }
   return token.getoAuth2AccessToken();
 }
Ejemplo n.º 6
0
 @Override
 public OAuth2AccessToken getAccessToken(OAuth2Authentication authentication) {
   String authenticationId = authenticationKeyGenerator.extractKey(authentication);
   if (null == authenticationId) {
     return null;
   }
   /*Query query = new Query();
   query.addCriteria(Criteria.where("authenticationId").is(authenticationId));
   OAuth2AuthenticationAccessToken token = mongoTemplate.findOne(query, OAuth2AuthenticationAccessToken.class, "oauth2_access_token"); */
   OAuth2AuthenticationAccessToken token =
       oAuth2AccessTokenDao.findByAuthenticationId(authenticationId);
   return token == null ? null : token.getoAuth2AccessToken();
 }