Search in sources :

Example 66 with Configuration

use of org.apache.commons.configuration.Configuration in project incubator-atlas by apache.

the class HBaseBasedAuditRepository method start.

@Override
public void start() throws AtlasException {
    Configuration configuration = ApplicationProperties.get();
    startInternal(configuration, getHBaseConfiguration(configuration));
}
Also used : Configuration(org.apache.commons.configuration.Configuration) HAConfiguration(org.apache.atlas.ha.HAConfiguration) HBaseConfiguration(org.apache.hadoop.hbase.HBaseConfiguration)

Example 67 with Configuration

use of org.apache.commons.configuration.Configuration in project incubator-atlas by apache.

the class HBaseBasedAuditRepositoryHATest method testShouldCreateTableWhenReactingToActive.

@Test
public void testShouldCreateTableWhenReactingToActive() throws AtlasException, IOException {
    when(configuration.containsKey(HAConfiguration.ATLAS_SERVER_HA_ENABLED_KEY)).thenReturn(true);
    when(configuration.getBoolean(HAConfiguration.ATLAS_SERVER_HA_ENABLED_KEY)).thenReturn(true);
    when(configuration.getString(HBaseBasedAuditRepository.CONFIG_TABLE_NAME, HBaseBasedAuditRepository.DEFAULT_TABLE_NAME)).thenReturn(HBaseBasedAuditRepository.DEFAULT_TABLE_NAME);
    TableName tableName = TableName.valueOf(HBaseBasedAuditRepository.DEFAULT_TABLE_NAME);
    Admin admin = mock(Admin.class);
    when(connection.getAdmin()).thenReturn(admin);
    when(admin.tableExists(tableName)).thenReturn(true);
    HBaseBasedAuditRepository auditRepository = new HBaseBasedAuditRepository() {

        @Override
        protected Connection createConnection(org.apache.hadoop.conf.Configuration hbaseConf) {
            return connection;
        }
    };
    auditRepository.startInternal(configuration, hbaseConf);
    auditRepository.instanceIsActive();
    verify(connection).getAdmin();
    verify(admin).tableExists(tableName);
}
Also used : TableName(org.apache.hadoop.hbase.TableName) Configuration(org.apache.commons.configuration.Configuration) HAConfiguration(org.apache.atlas.ha.HAConfiguration) Admin(org.apache.hadoop.hbase.client.Admin) Test(org.testng.annotations.Test)

Example 68 with Configuration

use of org.apache.commons.configuration.Configuration in project incubator-atlas by apache.

the class AtlasAuthenticationFilter method getConfiguration.

@Override
protected Properties getConfiguration(String configPrefix, FilterConfig filterConfig) throws ServletException {
    Configuration configuration;
    try {
        configuration = ApplicationProperties.get();
    } catch (Exception e) {
        throw new ServletException(e);
    }
    Properties config = new Properties();
    String kerberosAuthEnabled = configuration != null ? configuration.getString("atlas.authentication.method.kerberos") : null;
    // getString may return null, and would like to log the nature of the default setting
    String authMethod = "";
    if (kerberosAuthEnabled == null || kerberosAuthEnabled.equalsIgnoreCase("false")) {
        LOG.info("No authentication method configured.  Defaulting to simple authentication");
        authMethod = "simple";
    } else if (kerberosAuthEnabled.equalsIgnoreCase("true")) {
        authMethod = "kerberos";
    }
    if (configuration.getString("atlas.authentication.method.kerberos.name.rules") != null) {
        config.put("kerberos.name.rules", configuration.getString("atlas.authentication.method.kerberos.name.rules"));
    }
    if (configuration.getString("atlas.authentication.method.kerberos.keytab") != null) {
        config.put("kerberos.keytab", configuration.getString("atlas.authentication.method.kerberos.keytab"));
    }
    if (configuration.getString("atlas.authentication.method.kerberos.principal") != null) {
        config.put("kerberos.principal", configuration.getString("atlas.authentication.method.kerberos.principal"));
    }
    config.put(AuthenticationFilter.AUTH_TYPE, authMethod);
    config.put(AuthenticationFilter.COOKIE_PATH, "/");
    // add any config passed in as init parameters
    Enumeration<String> enumeration = filterConfig.getInitParameterNames();
    while (enumeration.hasMoreElements()) {
        String name = enumeration.nextElement();
        config.put(name, filterConfig.getInitParameter(name));
    }
    //Resolve _HOST into bind address
    String bindAddress = configuration.getString(SecurityProperties.BIND_ADDRESS);
    if (bindAddress == null) {
        LOG.info("No host name configured.  Defaulting to local host name.");
        try {
            bindAddress = InetAddress.getLocalHost().getHostName();
        } catch (UnknownHostException e) {
            throw new ServletException("Unable to obtain host name", e);
        }
    }
    String principal = config.getProperty(KerberosAuthenticationHandler.PRINCIPAL);
    if (principal != null) {
        try {
            principal = SecurityUtil.getServerPrincipal(principal, bindAddress);
        } catch (IOException ex) {
            throw new RuntimeException("Could not resolve Kerberos principal name: " + ex.toString(), ex);
        }
        config.put(KerberosAuthenticationHandler.PRINCIPAL, principal);
    }
    LOG.debug(" AuthenticationFilterConfig: {}", config);
    supportKeyTabBrowserLogin = configuration.getBoolean("atlas.authentication.method.kerberos.support.keytab.browser.login", false);
    String agents = configuration.getString(AtlasCSRFPreventionFilter.BROWSER_USER_AGENT_PARAM, AtlasCSRFPreventionFilter.BROWSER_USER_AGENTS_DEFAULT);
    if (agents == null) {
        agents = AtlasCSRFPreventionFilter.BROWSER_USER_AGENTS_DEFAULT;
    }
    parseBrowserUserAgents(agents);
    return config;
}
Also used : ServletException(javax.servlet.ServletException) Configuration(org.apache.commons.configuration.Configuration) UnknownHostException(java.net.UnknownHostException) IOException(java.io.IOException) SecurityProperties(org.apache.atlas.security.SecurityProperties) ApplicationProperties(org.apache.atlas.ApplicationProperties) AuthenticationException(org.apache.hadoop.security.authentication.client.AuthenticationException) ServletException(javax.servlet.ServletException) SignerException(org.apache.hadoop.security.authentication.util.SignerException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException)

Example 69 with Configuration

use of org.apache.commons.configuration.Configuration in project incubator-atlas by apache.

the class AtlasTopicCreatorTest method shouldNotFailIfExceptionOccursDuringCreatingTopic.

@Test
public void shouldNotFailIfExceptionOccursDuringCreatingTopic() {
    Configuration configuration = mock(Configuration.class);
    when(configuration.getBoolean(AtlasTopicCreator.ATLAS_NOTIFICATION_CREATE_TOPICS_KEY, true)).thenReturn(true);
    when(configuration.getString("atlas.authentication.method.kerberos")).thenReturn("false");
    final ZkUtils zookeeperUtils = mock(ZkUtils.class);
    final boolean[] createTopicCalled = new boolean[] { false };
    AtlasTopicCreator atlasTopicCreator = new AtlasTopicCreator() {

        @Override
        protected boolean ifTopicExists(String topicName, ZkUtils zkUtils) {
            return false;
        }

        @Override
        protected ZkUtils createZkUtils(Configuration atlasProperties) {
            return zookeeperUtils;
        }

        @Override
        protected void createTopic(Configuration atlasProperties, String topicName, ZkUtils zkUtils) {
            createTopicCalled[0] = true;
            throw new RuntimeException("Simulating failure during creating topic");
        }
    };
    atlasTopicCreator.createAtlasTopic(configuration, "ATLAS_HOOK");
    assertTrue(createTopicCalled[0]);
}
Also used : Configuration(org.apache.commons.configuration.Configuration) ZkUtils(kafka.utils.ZkUtils) Test(org.testng.annotations.Test)

Example 70 with Configuration

use of org.apache.commons.configuration.Configuration in project incubator-atlas by apache.

the class AtlasTopicCreatorTest method shouldNotCreateAtlasTopicIfNotConfiguredToDoSo.

@Test
public void shouldNotCreateAtlasTopicIfNotConfiguredToDoSo() {
    Configuration configuration = mock(Configuration.class);
    when(configuration.getBoolean(AtlasTopicCreator.ATLAS_NOTIFICATION_CREATE_TOPICS_KEY, true)).thenReturn(false);
    when(configuration.getString("atlas.authentication.method.kerberos")).thenReturn("false");
    final boolean[] topicExistsCalled = new boolean[] { false };
    AtlasTopicCreator atlasTopicCreator = new AtlasTopicCreator() {

        @Override
        protected boolean ifTopicExists(String topicName, ZkUtils zkUtils) {
            topicExistsCalled[0] = true;
            return false;
        }
    };
    atlasTopicCreator.createAtlasTopic(configuration, "ATLAS_HOOK");
    assertFalse(topicExistsCalled[0]);
}
Also used : Configuration(org.apache.commons.configuration.Configuration) ZkUtils(kafka.utils.ZkUtils) Test(org.testng.annotations.Test)

Aggregations

Configuration (org.apache.commons.configuration.Configuration)185 Test (org.junit.Test)51 PropertiesConfiguration (org.apache.commons.configuration.PropertiesConfiguration)44 ZapXmlConfiguration (org.zaproxy.zap.utils.ZapXmlConfiguration)23 Test (org.testng.annotations.Test)22 File (java.io.File)14 AbstractConfiguration (org.apache.commons.configuration.AbstractConfiguration)13 MidpointConfiguration (com.evolveum.midpoint.common.configuration.api.MidpointConfiguration)11 Properties (java.util.Properties)10 HashMap (java.util.HashMap)9 AtlasException (org.apache.atlas.AtlasException)9 CompositeConfiguration (org.apache.commons.configuration.CompositeConfiguration)9 ArrayList (java.util.ArrayList)8 ZkUtils (kafka.utils.ZkUtils)8 ConfigurationException (org.apache.commons.configuration.ConfigurationException)8 IndexLoadingConfigMetadata (com.linkedin.pinot.common.metadata.segment.IndexLoadingConfigMetadata)7 AtlasClient (org.apache.atlas.AtlasClient)6 BeforeClass (org.testng.annotations.BeforeClass)6 MockResponse (com.github.bordertech.wcomponents.util.mock.MockResponse)5 IOException (java.io.IOException)5