// Path: social-redis-spring-boot-starter/src/main/java/be/ordina/jworks/social/redis/connection/data/SocialRedisConnection.java
// @Getter
// @Setter
// @AllArgsConstructor
// @RedisHash("socialRedisConnection")
// public class SocialRedisConnection {
// 
//     @Id
//     @Indexed
//     private String providerUserId;
// 
//     @Indexed
//     private String userId;
// 
//     @Indexed
//     private String providerId;
// 
//     private String displayName;
// 
//     private String profileUrl;
// 
//     private String imageUrl;
// 
//     private String accessToken;
// 
//     private String secret;
// 
//     private String refreshToken;
// 
//     private Long expireTime;
// }
// 
// Path: social-redis-spring-boot-starter/src/main/java/be/ordina/jworks/social/redis/connection/data/SocialRedisConnectionRepository.java
// @Repository
// public interface SocialRedisConnectionRepository extends CrudRepository<SocialRedisConnection, String> {
// 
//     Iterable<SocialRedisConnection> findByProviderId(final String providerId);
// 
//     Iterable<SocialRedisConnection> findByUserIdAndProviderId(final String userId, final String providerId);
// 
//     SocialRedisConnection findOneByUserIdAndProviderIdAndProviderUserId(String userId, String providerId, String providerUserId);
// 
//     // TODO: will be available once DATAKV-135 is finished
//     void deleteByUserIdAndProviderIdAndProviderUserId(final String userId, final String providerId, final String providerUserId);
// 
//     Iterable<SocialRedisConnection> findByUserId(final String userId);
// 
//     Iterable<SocialRedisConnection> findByProviderIdAndProviderUserId(final String providerId, final String providerUserId);
// }


import be.ordina.jworks.social.redis.connection.data.SocialRedisConnection;
import be.ordina.jworks.social.redis.connection.data.SocialRedisConnectionRepository;
import org.springframework.security.crypto.encrypt.TextEncryptor;
import org.springframework.social.connect.Connection;
import org.springframework.social.connect.ConnectionFactoryLocator;
import org.springframework.social.connect.ConnectionRepository;
import org.springframework.social.connect.UsersConnectionRepository;
import org.springframework.util.Assert;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
package be.ordina.jworks.social.redis.connection;



public class RedisUsersConnectionRepository implements UsersConnectionRepository {

    private final ConnectionFactoryLocator connectionFactoryLocator;
    private final TextEncryptor textEncryptor;
    private final SocialRedisConnectionRepository socialRedisConnectionRepository;

    public RedisUsersConnectionRepository(ConnectionFactoryLocator connectionFactoryLocator, TextEncryptor textEncryptor, SocialRedisConnectionRepository socialRedisConnectionRepository) {
        Assert.notNull(connectionFactoryLocator);
        Assert.notNull(textEncryptor);
        Assert.notNull(socialRedisConnectionRepository);

        this.connectionFactoryLocator = connectionFactoryLocator;
        this.textEncryptor = textEncryptor;
        this.socialRedisConnectionRepository = socialRedisConnectionRepository;
    }

    public List<String> findUserIdsWithConnection(final Connection<?> connection) {
// Path: social-redis-spring-boot-starter/src/main/java/be/ordina/jworks/social/redis/connection/data/SocialRedisConnection.java
// @Getter
// @Setter
// @AllArgsConstructor
// @RedisHash("socialRedisConnection")
// public class SocialRedisConnection {
// 
//     @Id
//     @Indexed
//     private String providerUserId;
// 
//     @Indexed
//     private String userId;
// 
//     @Indexed
//     private String providerId;
// 
//     private String displayName;
// 
//     private String profileUrl;
// 
//     private String imageUrl;
// 
//     private String accessToken;
// 
//     private String secret;
// 
//     private String refreshToken;
// 
//     private Long expireTime;
// }
// 
// Path: social-redis-spring-boot-starter/src/main/java/be/ordina/jworks/social/redis/connection/data/SocialRedisConnectionRepository.java
// @Repository
// public interface SocialRedisConnectionRepository extends CrudRepository<SocialRedisConnection, String> {
// 
//     Iterable<SocialRedisConnection> findByProviderId(final String providerId);
// 
//     Iterable<SocialRedisConnection> findByUserIdAndProviderId(final String userId, final String providerId);
// 
//     SocialRedisConnection findOneByUserIdAndProviderIdAndProviderUserId(String userId, String providerId, String providerUserId);
// 
//     // TODO: will be available once DATAKV-135 is finished
//     void deleteByUserIdAndProviderIdAndProviderUserId(final String userId, final String providerId, final String providerUserId);
// 
//     Iterable<SocialRedisConnection> findByUserId(final String userId);
// 
//     Iterable<SocialRedisConnection> findByProviderIdAndProviderUserId(final String providerId, final String providerUserId);
// }


// Path: social-redis-spring-boot-starter/src/main/java/be/ordina/jworks/social/redis/connection/RedisUsersConnectionRepository.java
import be.ordina.jworks.social.redis.connection.data.SocialRedisConnection;
import be.ordina.jworks.social.redis.connection.data.SocialRedisConnectionRepository;
import org.springframework.security.crypto.encrypt.TextEncryptor;
import org.springframework.social.connect.Connection;
import org.springframework.social.connect.ConnectionFactoryLocator;
import org.springframework.social.connect.ConnectionRepository;
import org.springframework.social.connect.UsersConnectionRepository;
import org.springframework.util.Assert;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

package be.ordina.jworks.social.redis.connection;



public class RedisUsersConnectionRepository implements UsersConnectionRepository {

    private final ConnectionFactoryLocator connectionFactoryLocator;
    private final TextEncryptor textEncryptor;
    private final SocialRedisConnectionRepository socialRedisConnectionRepository;

    public RedisUsersConnectionRepository(ConnectionFactoryLocator connectionFactoryLocator, TextEncryptor textEncryptor, SocialRedisConnectionRepository socialRedisConnectionRepository) {
        Assert.notNull(connectionFactoryLocator);
        Assert.notNull(textEncryptor);
        Assert.notNull(socialRedisConnectionRepository);

        this.connectionFactoryLocator = connectionFactoryLocator;
        this.textEncryptor = textEncryptor;
        this.socialRedisConnectionRepository = socialRedisConnectionRepository;
    }

    public List<String> findUserIdsWithConnection(final Connection<?> connection) {
        String providerId = connection.getKey().getProviderId();