@Test public void testGetAccessTokensByUserName() { Set<OAuth2AccessTokenEntity> tokens = repository.getAccessTokensByUserName("user1"); assertEquals(2, tokens.size()); assertEquals("user1", tokens.iterator().next().getAuthenticationHolder().getUserAuth().getName()); }
@Override public Set<OAuth2AccessTokenEntity> getAccessTokensByUserName(String name) { TypedQuery<OAuth2AccessTokenEntity> query = manager.createNamedQuery(OAuth2AccessTokenEntity.QUERY_BY_NAME, OAuth2AccessTokenEntity.class); query.setParameter(OAuth2AccessTokenEntity.PARAM_NAME, name); List<OAuth2AccessTokenEntity> results = query.getResultList(); return results != null ? new HashSet<>(results) : new HashSet<>(); }
JpaOAuth2TokenRepository implements OAuth2TokenRepository { @Override public Set<OAuth2AccessTokenEntity> getAccessTokensByUserName(String name) { TypedQuery<OAuth2AccessTokenEntity> query = manager.createNamedQuery(OAuth2AccessTokenEntity.QUERY_BY_NAME, OAuth2AccessTokenEntity.class); query.setParameter(OAuth2AccessTokenEntity.PARAM_NAME, name); List<OAuth2AccessTokenEntity> results = query.getResultList(); return results != null ? new HashSet<>(results) : new HashSet<>(); } }
JpaOAuth2TokenRepository implements OAuth2TokenRepository { @Override public Set<OAuth2AccessTokenEntity> getAccessTokensByUserName(String name) { TypedQuery<OAuth2AccessTokenEntity> query = manager.createNamedQuery(OAuth2AccessTokenEntity.QUERY_BY_NAME, OAuth2AccessTokenEntity.class); query.setParameter(OAuth2AccessTokenEntity.PARAM_NAME, name); List<OAuth2AccessTokenEntity> results = query.getResultList(); return results != null ? new HashSet<>(results) : new HashSet<>(); }  }
JpaOAuth2TokenRepository implements OAuth2TokenRepository { @Override public Set<OAuth2AccessTokenEntity> getAccessTokensByUserName(String name) { TypedQuery<OAuth2AccessTokenEntity> query = manager.createNamedQuery(OAuth2AccessTokenEntity.QUERY_BY_NAME, OAuth2AccessTokenEntity.class); query.setParameter(OAuth2AccessTokenEntity.PARAM_NAME, name); List<OAuth2AccessTokenEntity> results = query.getResultList(); return results != null ? new HashSet<>(results) : new HashSet<>(); }  @Override Set<OAuth2AccessTokenEntity> getAllAccessTokens(); @Override Set<OAuth2RefreshTokenEntity> getAllRefreshTokens(); @Override OAuth2AccessTokenEntity getAccessTokenByValue(String accessTokenValue); @Override OAuth2AccessTokenEntity getAccessTokenById(Long id); @Override @Transactional(value="defaultTransactionManager") OAuth2AccessTokenEntity saveAccessToken(OAuth2AccessTokenEntity token); @Override @Transactional(value="defaultTransactionManager") void removeAccessToken(OAuth2AccessTokenEntity accessToken); @Override @Transactional(value="defaultTransactionManager") void clearAccessTokensForRefreshToken(OAuth2RefreshTokenEntity refreshToken); @Override OAuth2RefreshTokenEntity getRefreshTokenByValue(String refreshTokenValue); @Override OAuth2RefreshTokenEntity getRefreshTokenById(Long id); @Override @Transactional(value="defaultTransactionManager") OAuth2RefreshTokenEntity saveRefreshToken(OAuth2RefreshTokenEntity refreshToken); @Override @Transactional(value="defaultTransactionManager") void removeRefreshToken(OAuth2RefreshTokenEntity refreshToken); @Override @Transactional(value="defaultTransactionManager") void clearTokensForClient(ClientDetailsEntity client); @Override List<OAuth2AccessTokenEntity> getAccessTokensForClient(ClientDetailsEntity client); @Override List<OAuth2RefreshTokenEntity> getRefreshTokensForClient(ClientDetailsEntity client); @Override Set<OAuth2AccessTokenEntity> getAccessTokensByUserName(String name); @Override Set<OAuth2RefreshTokenEntity> getRefreshTokensByUserName(String name); @Override Set<OAuth2AccessTokenEntity> getAllExpiredAccessTokens(); @Override Set<OAuth2AccessTokenEntity> getAllExpiredAccessTokens(PageCriteria pageCriteria); @Override Set<OAuth2RefreshTokenEntity> getAllExpiredRefreshTokens(); @Override Set<OAuth2RefreshTokenEntity> getAllExpiredRefreshTokens(PageCriteria pageCriteria); @Override Set<OAuth2AccessTokenEntity> getAccessTokensForResourceSet(ResourceSet rs); @Override @Transactional(value="defaultTransactionManager") void clearDuplicateAccessTokens(); @Override @Transactional(value="defaultTransactionManager") void clearDuplicateRefreshTokens(); @Override List<OAuth2AccessTokenEntity> getAccessTokensForApprovedSite(ApprovedSite approvedSite); }
JpaOAuth2TokenRepository implements OAuth2TokenRepository { @Override public Set<OAuth2AccessTokenEntity> getAccessTokensByUserName(String name) { TypedQuery<OAuth2AccessTokenEntity> query = manager.createNamedQuery(OAuth2AccessTokenEntity.QUERY_BY_NAME, OAuth2AccessTokenEntity.class); query.setParameter(OAuth2AccessTokenEntity.PARAM_NAME, name); List<OAuth2AccessTokenEntity> results = query.getResultList(); return results != null ? new HashSet<>(results) : new HashSet<>(); }  @Override Set<OAuth2AccessTokenEntity> getAllAccessTokens(); @Override Set<OAuth2RefreshTokenEntity> getAllRefreshTokens(); @Override OAuth2AccessTokenEntity getAccessTokenByValue(String accessTokenValue); @Override OAuth2AccessTokenEntity getAccessTokenById(Long id); @Override @Transactional(value="defaultTransactionManager") OAuth2AccessTokenEntity saveAccessToken(OAuth2AccessTokenEntity token); @Override @Transactional(value="defaultTransactionManager") void removeAccessToken(OAuth2AccessTokenEntity accessToken); @Override @Transactional(value="defaultTransactionManager") void clearAccessTokensForRefreshToken(OAuth2RefreshTokenEntity refreshToken); @Override OAuth2RefreshTokenEntity getRefreshTokenByValue(String refreshTokenValue); @Override OAuth2RefreshTokenEntity getRefreshTokenById(Long id); @Override @Transactional(value="defaultTransactionManager") OAuth2RefreshTokenEntity saveRefreshToken(OAuth2RefreshTokenEntity refreshToken); @Override @Transactional(value="defaultTransactionManager") void removeRefreshToken(OAuth2RefreshTokenEntity refreshToken); @Override @Transactional(value="defaultTransactionManager") void clearTokensForClient(ClientDetailsEntity client); @Override List<OAuth2AccessTokenEntity> getAccessTokensForClient(ClientDetailsEntity client); @Override List<OAuth2RefreshTokenEntity> getRefreshTokensForClient(ClientDetailsEntity client); @Override Set<OAuth2AccessTokenEntity> getAccessTokensByUserName(String name); @Override Set<OAuth2RefreshTokenEntity> getRefreshTokensByUserName(String name); @Override Set<OAuth2AccessTokenEntity> getAllExpiredAccessTokens(); @Override Set<OAuth2AccessTokenEntity> getAllExpiredAccessTokens(PageCriteria pageCriteria); @Override Set<OAuth2RefreshTokenEntity> getAllExpiredRefreshTokens(); @Override Set<OAuth2RefreshTokenEntity> getAllExpiredRefreshTokens(PageCriteria pageCriteria); @Override Set<OAuth2AccessTokenEntity> getAccessTokensForResourceSet(ResourceSet rs); @Override @Transactional(value="defaultTransactionManager") void clearDuplicateAccessTokens(); @Override @Transactional(value="defaultTransactionManager") void clearDuplicateRefreshTokens(); @Override List<OAuth2AccessTokenEntity> getAccessTokensForApprovedSite(ApprovedSite approvedSite);  }