Search in sources :

Example 21 with DummyCredentialGenerator

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));
    }
}
Also used : DummyCredentialGenerator(org.apache.geode.security.generator.DummyCredentialGenerator) LdapUserCredentialGenerator(org.apache.geode.security.generator.LdapUserCredentialGenerator) CredentialGenerator(org.apache.geode.security.generator.CredentialGenerator) ConfigurationProperties(org.apache.geode.distributed.ConfigurationProperties) Properties(java.util.Properties) DummyCredentialGenerator(org.apache.geode.security.generator.DummyCredentialGenerator) SecurityTest(org.apache.geode.test.junit.categories.SecurityTest) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 22 with DummyCredentialGenerator

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));
    }
}
Also used : DummyCredentialGenerator(org.apache.geode.security.generator.DummyCredentialGenerator) CredentialGenerator(org.apache.geode.security.generator.CredentialGenerator) Properties(java.util.Properties) DummyCredentialGenerator(org.apache.geode.security.generator.DummyCredentialGenerator)

Example 23 with DummyCredentialGenerator

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));
}
Also used : DummyCredentialGenerator(org.apache.geode.security.generator.DummyCredentialGenerator) CredentialGenerator(org.apache.geode.security.generator.CredentialGenerator) Properties(java.util.Properties) DummyCredentialGenerator(org.apache.geode.security.generator.DummyCredentialGenerator)

Example 24 with DummyCredentialGenerator

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));
    }
}
Also used : DummyCredentialGenerator(org.apache.geode.security.generator.DummyCredentialGenerator) LdapUserCredentialGenerator(org.apache.geode.security.generator.LdapUserCredentialGenerator) CredentialGenerator(org.apache.geode.security.generator.CredentialGenerator) ConfigurationProperties(org.apache.geode.distributed.ConfigurationProperties) Properties(java.util.Properties) SecurityTestUtils(org.apache.geode.security.SecurityTestUtils) DummyCredentialGenerator(org.apache.geode.security.generator.DummyCredentialGenerator) Category(org.junit.experimental.categories.Category) SecurityTest(org.apache.geode.test.junit.categories.SecurityTest) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Aggregations

DummyCredentialGenerator (org.apache.geode.security.generator.DummyCredentialGenerator)24 CredentialGenerator (org.apache.geode.security.generator.CredentialGenerator)22 Properties (java.util.Properties)20 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)13 Test (org.junit.Test)13 SecurityTest (org.apache.geode.test.junit.categories.SecurityTest)11 ConfigurationProperties (org.apache.geode.distributed.ConfigurationProperties)10 FlakyTest (org.apache.geode.test.junit.categories.FlakyTest)8 LdapUserCredentialGenerator (org.apache.geode.security.generator.LdapUserCredentialGenerator)7 SecurityTestUtils (org.apache.geode.security.SecurityTestUtils)4 ArrayList (java.util.ArrayList)3 AuthzCredentialGenerator (org.apache.geode.security.generator.AuthzCredentialGenerator)3 XmlAuthzCredentialGenerator (org.apache.geode.security.generator.XmlAuthzCredentialGenerator)3 Category (org.junit.experimental.categories.Category)3 Host (org.apache.geode.test.dunit.Host)2 VM (org.apache.geode.test.dunit.VM)2 Iterator (java.util.Iterator)1 List (java.util.List)1 Random (java.util.Random)1 Region (org.apache.geode.cache.Region)1