use of org.apache.geode.security.generator.DummyCredentialGenerator in project geode by apache.
the class P2PAuthenticationDUnitTest method testP2PAuthenticationWithValidCredentials.
@Test
public void testP2PAuthenticationWithValidCredentials() throws Exception {
int locatorPort = getRandomAvailablePort(SOCKET);
CredentialGenerator gen = new DummyCredentialGenerator();
assertNotNull(gen.getAuthenticator());
assertNotNull(gen.getAuthInit());
assertNull(gen.getJavaProperties());
assertNull(gen.getSystemProperties());
assertNotNull(gen.getValidCredentials(1));
Properties props = new Properties();
props.setProperty(MCAST_PORT, "0");
props.setProperty(LOCATORS, getIPLiteral() + "[" + locatorPort + "]");
props.setProperty(SECURITY_PEER_AUTH_INIT, gen.getAuthInit());
props.setProperty(SECURITY_PEER_AUTHENTICATOR, gen.getAuthenticator());
props.putAll(gen.getValidCredentials(1));
startTheLocator(props, gen.getJavaProperties(), locatorPort);
try {
createDS(props, gen.getJavaProperties());
verifyMembers(2);
disconnectFromDS();
} finally {
locatorVM.invoke(() -> stopLocator(locatorPort, ignoredExceptions));
}
}
use of org.apache.geode.security.generator.DummyCredentialGenerator in project geode by apache.
the class ClientAuthenticationTestCase method doTestNoCredentials.
protected void doTestNoCredentials(final boolean multiUser) throws Exception {
CredentialGenerator gen = new DummyCredentialGenerator();
Properties extraProps = gen.getSystemProperties();
Properties javaProps = gen.getJavaProperties();
String authenticator = gen.getAuthenticator();
String authInit = gen.getAuthInit();
getLogWriter().info("testNoCredentials: Using scheme: " + gen.classCode());
getLogWriter().info("testNoCredentials: Using authenticator: " + authenticator);
getLogWriter().info("testNoCredentials: Using authinit: " + authInit);
// Start the servers
int locPort1 = getLocatorPort();
int locPort2 = getLocatorPort();
String locString = getAndClearLocatorString();
int port1 = createServer1(extraProps, javaProps, authenticator, locPort1, locString);
int port2 = server2.invoke(() -> createCacheServer(locPort2, locString, authenticator, extraProps, javaProps));
// Start first client with valid credentials
Properties credentials1 = gen.getValidCredentials(1);
Properties javaProps1 = gen.getJavaProperties();
getLogWriter().info("testNoCredentials: For first client credentials: " + credentials1 + " : " + javaProps1);
createClient1NoException(multiUser, authInit, port1, port2, credentials1, javaProps1);
// Perform some put operations from client1
client1.invoke(() -> doPuts(2));
// Trying to create the region on client2
if (gen.classCode().equals(CredentialGenerator.ClassCode.SSL)) {
// For SSL the exception may not come since the server can close socket
// before handshake message is sent from client. However exception
// should come in any region operations.
client2.invoke(() -> createCacheClient(null, null, null, port1, port2, 0, multiUser, NO_EXCEPTION));
client2.invoke(() -> doPuts(2, OTHER_EXCEPTION));
} else {
client2.invoke(() -> createCacheClient(null, null, null, port1, port2, 0, multiUser, AUTHREQ_EXCEPTION));
}
}
use of org.apache.geode.security.generator.DummyCredentialGenerator in project geode by apache.
the class ClientAuthenticationTestCase method doTestNoAuthInitWithCredentials.
protected void doTestNoAuthInitWithCredentials(final boolean multiUser) throws Exception {
CredentialGenerator gen = new DummyCredentialGenerator();
Properties extraProps = gen.getSystemProperties();
Properties javaProps = gen.getJavaProperties();
String authenticator = gen.getAuthenticator();
getLogWriter().info("testNoAuthInitWithCredentials: Using scheme: " + gen.classCode());
getLogWriter().info("testNoAuthInitWithCredentials: Using authenticator: " + authenticator);
// Start the servers
int locPort1 = getLocatorPort();
int locPort2 = getLocatorPort();
String locString = getAndClearLocatorString();
int port1 = createServer1(extraProps, javaProps, authenticator, locPort1, locString);
int port2 = server2.invoke(() -> createCacheServer(locPort2, locString, authenticator, extraProps, javaProps));
// Start the clients with valid credentials
Properties credentials1 = gen.getValidCredentials(1);
Properties javaProps1 = gen.getJavaProperties();
getLogWriter().info("testNoAuthInitWithCredentials: For first client credentials: " + credentials1 + " : " + javaProps1);
Properties credentials2 = gen.getValidCredentials(2);
Properties javaProps2 = gen.getJavaProperties();
getLogWriter().info("testNoAuthInitWithCredentials: For second client credentials: " + credentials2 + " : " + javaProps2);
client1.invoke(() -> createCacheClient(null, credentials1, javaProps1, port1, port2, 0, multiUser, AUTHREQ_EXCEPTION));
client2.invoke(() -> createCacheClient(null, credentials2, javaProps2, port1, port2, 0, multiUser, AUTHREQ_EXCEPTION));
client2.invoke(() -> closeCache());
// Now also try with invalid credentials
Properties credentials3 = gen.getInvalidCredentials(5);
Properties javaProps3 = gen.getJavaProperties();
client2.invoke(() -> createCacheClient(null, credentials3, javaProps3, port1, port2, 0, multiUser, AUTHREQ_EXCEPTION));
}
use of org.apache.geode.security.generator.DummyCredentialGenerator in project geode by apache.
the class P2PAuthenticationDUnitTest method testP2PAuthenticationWithNoCredentials.
// GEODE-1091: random port
@Category(FlakyTest.class)
@Test
public void testP2PAuthenticationWithNoCredentials() throws Exception {
int locatorPort = getRandomAvailablePort(SOCKET);
CredentialGenerator gen = new DummyCredentialGenerator();
assertNotNull(gen.getAuthenticator());
assertNotNull(gen.getAuthInit());
assertNull(gen.getJavaProperties());
assertNull(gen.getSystemProperties());
Properties props = new Properties();
props.setProperty(MCAST_PORT, "0");
props.setProperty(LOCATORS, getIPLiteral() + "[" + locatorPort + "]");
props.setProperty(SECURITY_PEER_AUTH_INIT, gen.getAuthInit());
props.setProperty(SECURITY_PEER_AUTHENTICATOR, gen.getAuthenticator());
startTheLocator(props, null, locatorPort);
try {
new SecurityTestUtils("tmp").createSystem(props, null);
fail("AuthenticationFailedException was expected as no credentials are set");
} catch (GemFireSecurityException expected) {
// success
} finally {
locatorVM.invoke(() -> stopLocator(locatorPort, ignoredExceptions));
}
}
Aggregations