@CacheConfig(cacheManager="auth2RedisHashCacheManager") public class Auth2JdbcUsersConnectionRepository extends Object implements UsersConnectionRepository
RepositoryProperties,
更便于用户自定义。USER_CONNECTION_HASH_CACHE_NAME: 'hs:' + providerId + '__' + providerUserId USER_CONNECTION_HASH_CACHE_NAME: 'h:' + userId + ':' + providerId + '__' + providerUserId USER_CONNECTION_HASH_CACHE_NAME: 'h:' + userId + '__' + providerId USER_CONNECTION_HASH_CACHE_NAME: 'hs:' + userId + '__' + providerId USER_CONNECTION_HASH_ALL_CLEAR_CACHE_NAME: 'hm:' + providerId + '__' + providerUserIds USER_CONNECTION_HASH_ALL_CLEAR_CACHE_NAME: 'hm:' + userId + '__' + methodName(findAllConnections,findAllListConnections) USER_CONNECTION_HASH_ALL_CLEAR_CACHE_NAME: 'hm:' + userId + '__' + providerUsers USER_CONNECTION_HASH_ALL_CLEAR_CACHE_NAME: 'hm:' + userId + '__' + parameters
| 构造器和说明 |
|---|
Auth2JdbcUsersConnectionRepository(org.springframework.jdbc.core.JdbcTemplate auth2UserConnectionJdbcTemplate,
org.springframework.security.crypto.encrypt.TextEncryptor textEncryptor,
RepositoryProperties repositoryProperties) |
| 限定符和类型 | 方法和说明 |
|---|---|
ConnectionData |
addConnection(ConnectionData connection)
绑定.
|
org.springframework.util.MultiValueMap<String,ConnectionData> |
findAllConnections(String userId)
获取 userId 的所有绑定信息.
|
List<ConnectionData> |
findAllListConnections(String userId)
根据 userId 获取 ConnectionData list.
|
List<ConnectionData> |
findConnectionByProviderIdAndProviderUserId(String providerId,
String providerUserId)
根据 providerId 与 providerUserId 获取 ConnectionData list.
|
ConnectionData |
findConnectionByTokenId(Long tokenId)
根据 tokenId 查找
ConnectionData注意: 这里不做 spring cache 缓存处理, 这个接口主要用于 refreshToken 的定时任务, 只调用一次, 缓存无意义 |
List<ConnectionData> |
findConnections(String userId,
String providerId)
获取 userId 和 providerId 的所以绑定信息.
|
List<ConnectionData> |
findConnectionsToUsers(org.springframework.jdbc.core.namedparam.MapSqlParameterSource parameters,
String providerUsersCriteriaSql,
String userId)
根据 userId 通过指定 providerUsersCriteriaSql 与 parameters 的 sql 获取 ConnectionData list
|
org.springframework.util.MultiValueMap<String,ConnectionData> |
findConnectionsToUsers(String userId,
org.springframework.util.MultiValueMap<String,String> providerUsers)
获取 userId 和 providerUserIds 的所以绑定信息.
|
ConnectionData |
findPrimaryConnection(String userId,
String providerId)
根据 userId 与 providerId 获取 ConnectionData.
|
Set<String> |
findUserIdsConnectedTo(String providerId,
Set<String> providerUserIds)
Find the ids of the users who are connected to the specific provider user accounts.
|
ConnectionData |
getConnection(String userId,
top.dcenter.ums.security.core.api.oauth.entity.ConnectionKey connectionKey)
根据 userId 和 connectionKey 获取 ConnectionData.
|
ConnectionData |
getPrimaryConnection(String userId,
String providerId)
获取 userId 和 providerId 的所以 rank 值最小的绑定信息.
|
void |
removeConnection(String userId,
top.dcenter.ums.security.core.api.oauth.entity.ConnectionKey connectionKey)
解除绑定.
|
void |
removeConnections(String userId,
String providerId)
解除绑定.
|
ConnectionData |
updateConnection(ConnectionData connection)
Update a Connection already added to this repository.
|
ConnectionData |
updateConnectionByTokenId(AuthTokenPo token)
根据
AuthTokenPo#getId() 更新 ConnectionData. |
public Auth2JdbcUsersConnectionRepository(org.springframework.jdbc.core.JdbcTemplate auth2UserConnectionJdbcTemplate,
org.springframework.security.crypto.encrypt.TextEncryptor textEncryptor,
RepositoryProperties repositoryProperties)
@Cacheable(cacheNames="UCHC",
key="\'hs:\' + #providerId + \'__\' + #providerUserId")
public List<ConnectionData> findConnectionByProviderIdAndProviderUserId(String providerId,
String providerUserId)
UsersConnectionRepositoryfindConnectionByProviderIdAndProviderUserId 在接口中 UsersConnectionRepositoryproviderId - 第三方服务商, 如: qq, githubproviderUserId - 第三方用户 Id@Cacheable(cacheNames="UCHACC",
key="\'hm:\' + #providerId + \'__\' + #providerUserIds")
public Set<String> findUserIdsConnectedTo(String providerId,
Set<String> providerUserIds)
UsersConnectionRepositoryfindUserIdsConnectedTo 在接口中 UsersConnectionRepositoryproviderId - 第三方服务商, 如: qq, githubproviderUserIds - the set of provider user ids e.g. ("987665", "435796", "584444").@Cacheable(cacheNames="UCHACC",
key="\'hm:\' + #userId + \'__\' + #root.methodName")
public org.springframework.util.MultiValueMap<String,ConnectionData> findAllConnections(String userId)
UsersConnectionRepositoryConnectionDatas that exist between the user and that provider.
For example, if the user is connected once to Facebook and twice to Twitter, the returned map would contain two entries with the following structure:
{
"qq" -> Connection("Jack") ,
"github" -> Connection("Tomas"), Connection("Jessica")
}
The returned map is sorted by providerId and entry values are ordered by rank.
Returns an empty map if the user has no connections.findAllConnections 在接口中 UsersConnectionRepositoryuserId - the userId@Cacheable(cacheNames="UCHC",
key="\'hs:\' + #userId + \'__\' + #providerId")
public List<ConnectionData> findConnections(String userId,
String providerId)
UsersConnectionRepositoryfindConnections 在接口中 UsersConnectionRepositoryuserId - 本地账户用户 IdproviderId - the provider id e.g. "qq"@Cacheable(cacheNames="UCHACC",
key="\'hm:\' + #userId + \'__\' + #providerUsers")
public org.springframework.util.MultiValueMap<String,ConnectionData> findConnectionsToUsers(String userId,
org.springframework.util.MultiValueMap<String,String> providerUsers)
UsersConnectionRepositoryfindConnectionsToUsers 在接口中 UsersConnectionRepositoryuserId - 本地账户用户 IdproviderUsers - 第三方用户 Id@Cacheable(cacheNames="UCHC",
key="\'h:\' + #userId + \':\' + #connectionKey.providerId + \'__\' + #connectionKey.providerUserId")
public ConnectionData getConnection(String userId,
top.dcenter.ums.security.core.api.oauth.entity.ConnectionKey connectionKey)
throws NoSuchConnectionException
UsersConnectionRepositorygetConnection 在接口中 UsersConnectionRepositoryuserId - 本地账户用户 IdconnectionKey - connectionKeyNoSuchConnectionException - no such connection exception@Cacheable(cacheNames="UCHC",
key="\'h:\' + #userId + \'__\' + #providerId")
public ConnectionData findPrimaryConnection(String userId,
String providerId)
UsersConnectionRepositoryfindPrimaryConnection 在接口中 UsersConnectionRepositoryuserId - 本地账户用户 IdproviderId - the provider id e.g. "qq"@Cacheable(cacheNames="UCHC",
key="\'h:\' + #userId + \'__\' + #providerId")
public ConnectionData getPrimaryConnection(String userId,
String providerId)
throws NotConnectedException
UsersConnectionRepositorygetPrimaryConnection 在接口中 UsersConnectionRepositoryuserId - 本地账户用户 IdproviderId - the provider id e.g. "qq"NotConnectedException - if the user is not connected to the provider of the API@Caching(evict={@CacheEvict(cacheNames="UCHACC",key="\'hm:\' + #connection.userId",beforeInvocation=true),@CacheEvict(cacheNames="UCHACC",key="\'hm:\' + #connection.providerId",beforeInvocation=true),@CacheEvict(cacheNames="UCHC",key="\'h:\' + #connection.userId + \':\' + #connection.providerId + \'__\' + #connection.providerUserId",beforeInvocation=true),@CacheEvict(cacheNames="UCHC",key="\'h:\' + #connection.userId + \'__\' + #connection.providerId",beforeInvocation=true),@CacheEvict(cacheNames="UCHC",key="\'hs:\' + #connection.userId + \'__\' + #connection.providerId",beforeInvocation=true),@CacheEvict(cacheNames="UCHC",key="\'hs:\' + #connection.providerId + \'__\' + #connection.providerUserId",beforeInvocation=true)},put={@CachePut(cacheNames="UCHC",key="\'h:\' + #connection.userId + \'__\' + #connection.providerId"),@CachePut(cacheNames="UCHC",key="\'h:\' + #connection.userId + \':\' + #connection.providerId + \'__\' + #connection.providerUserId")})
@Transactional(rollbackFor=java.lang.Exception.class,
propagation=REQUIRED)
public ConnectionData addConnection(ConnectionData connection)
UsersConnectionRepositoryaddConnection 在接口中 UsersConnectionRepositoryconnection - the new connection to add to this repository@Caching(evict={@CacheEvict(cacheNames="UCHACC",key="\'hm:\' + #connection.userId",beforeInvocation=true),@CacheEvict(cacheNames="UCHACC",key="\'hm:\' + #connection.providerId",beforeInvocation=true),@CacheEvict(cacheNames="UCHC",key="\'h:\' + #connection.userId + \':\' + #connection.providerId + \'__\' + #connection.providerUserId",beforeInvocation=true),@CacheEvict(cacheNames="UCHC",key="\'h:\' + #connection.userId + \'__\' + #connection.providerId",beforeInvocation=true),@CacheEvict(cacheNames="UCHC",key="\'hs:\' + #connection.userId + \'__\' + #connection.providerId",beforeInvocation=true),@CacheEvict(cacheNames="UCHC",key="\'hs:\' + #connection.providerId + \'__\' + #connection.providerUserId",beforeInvocation=true)},put={@CachePut(cacheNames="UCHC",key="\'h:\' + #connection.userId + \'__\' + #connection.providerId"),@CachePut(cacheNames="UCHC",key="\'h:\' + #connection.userId + \':\' + #connection.providerId + \'__\' + #connection.providerUserId")})
@Transactional(rollbackFor=java.lang.Exception.class,
propagation=REQUIRED)
public ConnectionData updateConnection(ConnectionData connection)
UsersConnectionRepositoryupdateConnection 在接口中 UsersConnectionRepositoryconnection - the existing connection to update in this repository@Caching(evict={@CacheEvict(cacheNames="UCHACC",key="\'hm:\' + #result.userId"),@CacheEvict(cacheNames="UCHACC",key="\'hm:\' + #result.providerId"),@CacheEvict(cacheNames="UCHC",key="\'hs:\' + #result.userId + \'__\' + #result.providerId"),@CacheEvict(cacheNames="UCHC",key="\'hs:\' + #result.providerId + \'__\' + #result.providerUserId")},put={@CachePut(cacheNames="UCHC",key="\'h:\' + #result.userId + \'__\' + #result.providerId"),@CachePut(cacheNames="UCHC",key="\'h:\' + #result.userId + \':\' + #result.providerId + \'__\' + #result.providerUserId")})
@Transactional(rollbackFor=java.lang.Exception.class,
propagation=REQUIRED)
public ConnectionData updateConnectionByTokenId(AuthTokenPo token)
UsersConnectionRepositoryAuthTokenPo#getId() 更新 ConnectionData.updateConnectionByTokenId 在接口中 UsersConnectionRepositorytoken - AuthTokenPoConnectionData, 还可以顺便更新 spring cachepublic ConnectionData findConnectionByTokenId(Long tokenId)
UsersConnectionRepositoryConnectionDatafindConnectionByTokenId 在接口中 UsersConnectionRepositorytokenId - AuthTokenPo#getId()@CacheEvict(cacheNames="UCHACC",key="\'hm:\' + #userId",beforeInvocation=true) @CacheEvict(cacheNames="UCHACC",key="\'hm:\' + #providerId",beforeInvocation=true) @CacheEvict(cacheNames="UCHC",key="\'h:\' + #userId + \':\' + #providerId",beforeInvocation=true) @CacheEvict(cacheNames="UCHC",key="\'h:\' + #userId + \'__\' + #providerId",beforeInvocation=true) @CacheEvict(cacheNames="UCHC",key="\'hs:\' + #userId + \':\' + #providerId",beforeInvocation=true) @CacheEvict(cacheNames="UCHC",key="\'hs:\' + #providerId",beforeInvocation=true) @Transactional(rollbackFor=java.lang.Exception.class, propagation=REQUIRED) public void removeConnections(String userId, String providerId)
UsersConnectionRepositoryremoveConnections 在接口中 UsersConnectionRepositoryuserId - 本地账户用户 IdproviderId - the provider id e.g. "qq"@CacheEvict(cacheNames="UCHACC",key="\'hm:\' + #userId",beforeInvocation=true) @CacheEvict(cacheNames="UCHACC",key="\'hm:\' + #connectionKey.providerId",beforeInvocation=true) @CacheEvict(cacheNames="UCHC",keyGenerator="removeConnectionsByConnectionKeyWithUserIdKeyGenerator",beforeInvocation=true) @CacheEvict(cacheNames="UCHC",key="\'h:\' + #userId + \'__\' + #connectionKey.providerId",beforeInvocation=true) @CacheEvict(cacheNames="UCHC",key="\'hs:\' + #userId + \'__\' + #connectionKey.providerId",beforeInvocation=true) @CacheEvict(cacheNames="UCHC",key="\'hs:\' + #connectionKey.providerId + \'__\' + #connectionKey.providerUserId",beforeInvocation=true) @Transactional(rollbackFor=java.lang.Exception.class, propagation=REQUIRED) public void removeConnection(String userId, top.dcenter.ums.security.core.api.oauth.entity.ConnectionKey connectionKey)
UsersConnectionRepositoryremoveConnection 在接口中 UsersConnectionRepositoryuserId - 本地账户用户 IdconnectionKey - the connection key@Cacheable(cacheNames="UCHACC",
key="\'hm:\' + #userId + \'__\' + #root.methodName")
public List<ConnectionData> findAllListConnections(String userId)
UsersConnectionRepositoryfindAllListConnections 在接口中 UsersConnectionRepositoryuserId - 本地账户用户 Id@Cacheable(cacheNames="UCHACC",
key="\'hm:\' + #userId + \'__\' + #parameters")
public List<ConnectionData> findConnectionsToUsers(org.springframework.jdbc.core.namedparam.MapSqlParameterSource parameters,
String providerUsersCriteriaSql,
String userId)
UsersConnectionRepositoryfindConnectionsToUsers 在接口中 UsersConnectionRepositoryparameters - sql 的 where 条件 与 对应参数providerUsersCriteriaSql - providerUsersCriteriaSqluserId - 本地账户用户 IdCopyright © 2021. All rights reserved.