use of redis.clients.jedis.JedisShardInfo in project spring-security-oauth by spring-projects.
the class RedisTokenStoreTests method setup.
@Before
public void setup() throws Exception {
JedisShardInfo shardInfo = new JedisShardInfo("localhost");
JedisConnectionFactory connectionFactory = new JedisConnectionFactory(shardInfo);
tokenStore = new RedisTokenStore(connectionFactory);
}
use of redis.clients.jedis.JedisShardInfo in project jedis by xetorthio.
the class SSLJedisTest method connectWithShardInfoByIpAddress.
/**
* Tests opening an SSL/TLS connection to redis using the loopback address of
* 127.0.0.1. This test should fail because "127.0.0.1" does not match the
* certificate subject common name and there are no subject alternative names
* in the certificate.
*
* NOTE: This test relies on a feature that is only available as of Java 7 and later.
* It is commented out but not removed in case support for Java 6 is dropped or
* we find a way to have the CI run a specific set of tests on Java 7 and above.
*/
@Test
public void connectWithShardInfoByIpAddress() throws Exception {
final URI uri = URI.create("rediss://127.0.0.1:6390");
final SSLSocketFactory sslSocketFactory = createTrustStoreSslSocketFactory();
// These SSL parameters ensure that we use the same hostname verifier used
// for HTTPS.
// Note: this options is only available in Java 7.
final SSLParameters sslParameters = new SSLParameters();
sslParameters.setEndpointIdentificationAlgorithm("HTTPS");
JedisShardInfo shardInfo = new JedisShardInfo(uri, sslSocketFactory, sslParameters, null);
shardInfo.setPassword("foobared");
Jedis jedis = new Jedis(shardInfo);
try {
jedis.get("foo");
Assert.fail("The code did not throw the expected JedisConnectionException.");
} catch (JedisConnectionException e) {
Assert.assertEquals("Unexpected first inner exception.", SSLHandshakeException.class, e.getCause().getClass());
Assert.assertEquals("Unexpected second inner exception.", CertificateException.class, e.getCause().getCause().getClass());
}
try {
jedis.close();
} catch (Throwable e1) {
// Expected.
}
}
use of redis.clients.jedis.JedisShardInfo in project jedis by xetorthio.
the class SSLJedisTest method connectWithShardInfo.
/**
* Tests opening an SSL/TLS connection to redis.
* NOTE: This test relies on a feature that is only available as of Java 7 and later.
* It is commented out but not removed in case support for Java 6 is dropped or
* we find a way to have the CI run a specific set of tests on Java 7 and above.
*/
@Test
public void connectWithShardInfo() throws Exception {
final URI uri = URI.create("rediss://localhost:6390");
final SSLSocketFactory sslSocketFactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
// These SSL parameters ensure that we use the same hostname verifier used
// for HTTPS.
// Note: this options is only available in Java 7.
final SSLParameters sslParameters = new SSLParameters();
sslParameters.setEndpointIdentificationAlgorithm("HTTPS");
JedisShardInfo shardInfo = new JedisShardInfo(uri, sslSocketFactory, sslParameters, null);
shardInfo.setPassword("foobared");
Jedis jedis = new Jedis(shardInfo);
jedis.get("foo");
jedis.disconnect();
jedis.close();
}
use of redis.clients.jedis.JedisShardInfo in project jedis by xetorthio.
the class SSLJedisTest method connectWithShardInfoAndCustomHostnameVerifier.
/**
* Tests opening an SSL/TLS connection to redis with a custom hostname
* verifier.
*/
@Test
public void connectWithShardInfoAndCustomHostnameVerifier() {
final URI uri = URI.create("rediss://localhost:6390");
final SSLSocketFactory sslSocketFactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
final SSLParameters sslParameters = new SSLParameters();
HostnameVerifier hostnameVerifier = new BasicHostnameVerifier();
JedisShardInfo shardInfo = new JedisShardInfo(uri, sslSocketFactory, sslParameters, hostnameVerifier);
shardInfo.setPassword("foobared");
Jedis jedis = new Jedis(shardInfo);
jedis.get("foo");
jedis.disconnect();
jedis.close();
}
use of redis.clients.jedis.JedisShardInfo in project jedis by xetorthio.
the class SSLJedisTest method connectWithShardInfoAndCustomHostnameVerifierByIpAddress.
/**
* Tests opening an SSL/TLS connection to redis with a custom hostname
* verifier. This test should fail because "127.0.0.1" does not match the
* certificate subject common name and there are no subject alternative names
* in the certificate.
*/
@Test
public void connectWithShardInfoAndCustomHostnameVerifierByIpAddress() {
final URI uri = URI.create("rediss://127.0.0.1:6390");
final SSLSocketFactory sslSocketFactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
final SSLParameters sslParameters = new SSLParameters();
HostnameVerifier hostnameVerifier = new BasicHostnameVerifier();
JedisShardInfo shardInfo = new JedisShardInfo(uri, sslSocketFactory, sslParameters, hostnameVerifier);
shardInfo.setPassword("foobared");
Jedis jedis = new Jedis(shardInfo);
try {
jedis.get("foo");
Assert.fail("The code did not throw the expected JedisConnectionException.");
} catch (JedisConnectionException e) {
Assert.assertEquals("The JedisConnectionException does not contain the expected message.", "The connection to '127.0.0.1' failed ssl/tls hostname verification.", e.getMessage());
}
try {
jedis.close();
} catch (Throwable e1) {
// Expected.
}
}
Aggregations