List of usage examples for org.apache.commons.configuration Configuration getBoolean
Boolean getBoolean(String key, Boolean defaultValue);
From source file:org.apache.atlas.hook.AtlasTopicCreatorTest.java
@Test public void shouldNotProcessTopicCreationIfSecurityFails() { Configuration configuration = mock(Configuration.class); when(configuration.getBoolean(AtlasTopicCreator.ATLAS_NOTIFICATION_CREATE_TOPICS_KEY, true)) .thenReturn(true);/*from www. j av a2s. co m*/ final ZkUtils zookeeperUtils = mock(ZkUtils.class); final Map<String, Boolean> createdTopics = new HashMap<>(); createdTopics.put("ATLAS_HOOK", false); createdTopics.put("ATLAS_ENTITIES", 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) { createdTopics.put(topicName, true); } @Override protected boolean handleSecurity(Configuration atlasProperties) { return false; } }; atlasTopicCreator.createAtlasTopic(configuration, "ATLAS_HOOK", "ATLAS_ENTITIES"); assertFalse(createdTopics.get("ATLAS_HOOK")); assertFalse(createdTopics.get("ATLAS_ENTITIES")); }
From source file:org.apache.atlas.notification.AbstractNotification.java
public AbstractNotification(Configuration applicationProperties) throws AtlasException { this.embedded = applicationProperties.getBoolean(PROPERTY_EMBEDDED, false); this.isHAEnabled = HAConfiguration.isHAEnabled(applicationProperties); }
From source file:org.apache.atlas.notification.NotificationInterface.java
public NotificationInterface(Configuration applicationProperties) throws AtlasException { this.embedded = applicationProperties.getBoolean(PROPERTY_EMBEDDED, false); }
From source file:org.apache.atlas.repository.graph.FullTextMapperV2.java
@Inject public FullTextMapperV2(AtlasTypeRegistry typeRegistry) { entityGraphRetriever = new EntityGraphRetriever(typeRegistry); Configuration configuration = null; try {/* ww w .java2 s .com*/ configuration = ApplicationProperties.get(); } catch (Throwable e) { if (LOG.isDebugEnabled()) { LOG.debug("AtlasApplication properties couldn't be loaded", e); } } finally { followReferences = configuration != null && configuration.getBoolean(FULL_TEXT_FOLLOW_REFERENCES, false); } }
From source file:org.apache.atlas.utils.AuthenticationUtil.java
public static boolean isKerberosAuthenticationEnabled(Configuration atlasConf) { return atlasConf.getBoolean("atlas.authentication.method.kerberos", false); }
From source file:org.apache.atlas.web.filters.AtlasAuthenticationFilter.java
@Override protected Properties getConfiguration(String configPrefix, FilterConfig filterConfig) throws ServletException { Configuration configuration; try {/*from ww w. jav a2s . co m*/ 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; }
From source file:org.apache.atlas.web.listeners.TestGuiceServletConfig.java
@Override protected void startServices() { try {/*from w ww . ja v a2s. c om*/ Configuration conf = ApplicationProperties.get(); servicesEnabled = conf.getBoolean("atlas.services.enabled", true); if (servicesEnabled) { super.startServices(); } } catch (AtlasException e) { throw new RuntimeException(e); } }
From source file:org.apache.atlas.web.security.AtlasADAuthenticationProvider.java
private void setADProperties() { try {//w w w.ja va 2 s . c o m Configuration configuration = ApplicationProperties.get(); Properties properties = ConfigurationConverter .getProperties(configuration.subset("atlas.authentication.method.ldap.ad")); this.adDomain = properties.getProperty("domain"); this.adURL = properties.getProperty("url"); this.adBindDN = properties.getProperty("bind.dn"); this.adBindPassword = properties.getProperty("bind.password"); this.adUserSearchFilter = properties.getProperty("user.searchfilter"); this.adBase = properties.getProperty("base.dn"); this.adReferral = properties.getProperty("referral"); this.adDefaultRole = properties.getProperty("default.role"); this.groupsFromUGI = configuration.getBoolean("atlas.authentication.method.ldap.ugi-groups", true); if (LOG.isDebugEnabled()) { LOG.debug("AtlasADAuthenticationProvider{" + "adURL='" + adURL + '\'' + ", adDomain='" + adDomain + '\'' + ", adBindDN='" + adBindDN + '\'' + ", adUserSearchFilter='" + adUserSearchFilter + '\'' + ", adBase='" + adBase + '\'' + ", adReferral='" + adReferral + '\'' + ", adDefaultRole='" + adDefaultRole + '\'' + ", groupsFromUGI=" + groupsFromUGI + '}'); } } catch (Exception e) { LOG.error("Exception while setADProperties", e); } }
From source file:org.apache.atlas.web.security.AtlasAuthenticationProvider.java
@PostConstruct void setAuthenticationMethod() { try {//from ww w . j a v a2s . co m Configuration configuration = ApplicationProperties.get(); this.fileAuthenticationMethodEnabled = configuration.getBoolean(FILE_AUTH_METHOD, true); this.pamAuthenticationEnabled = configuration.getBoolean(PAM_AUTH_METHOD, false); boolean ldapAuthenticationEnabled = configuration.getBoolean(LDAP_AUTH_METHOD, false); if (ldapAuthenticationEnabled) { this.ldapType = configuration.getString(LDAP_TYPE, "NONE"); } else { this.ldapType = "NONE"; } } catch (Exception e) { LOG.error("Error while getting atlas.login.method application properties", e); } }
From source file:org.apache.atlas.web.security.AtlasLdapAuthenticationProvider.java
private void setLdapProperties() { try {/*from www . j ava 2 s.com*/ Configuration configuration = ApplicationProperties.get(); Properties properties = ConfigurationConverter .getProperties(configuration.subset("atlas.authentication.method.ldap")); ldapURL = properties.getProperty("url"); ldapUserDNPattern = properties.getProperty("userDNpattern"); ldapGroupSearchBase = properties.getProperty("groupSearchBase"); ldapGroupSearchFilter = properties.getProperty("groupSearchFilter"); ldapGroupRoleAttribute = properties.getProperty("groupRoleAttribute"); ldapBindDN = properties.getProperty("bind.dn"); ldapBindPassword = properties.getProperty("bind.password"); ldapDefaultRole = properties.getProperty("default.role"); ldapUserSearchFilter = properties.getProperty("user.searchfilter"); ldapReferral = properties.getProperty("referral"); ldapBase = properties.getProperty("base.dn"); groupsFromUGI = configuration.getBoolean("atlas.authentication.method.ldap.ugi-groups", true); if (LOG.isDebugEnabled()) { LOG.debug("AtlasLdapAuthenticationProvider{" + "ldapURL='" + ldapURL + '\'' + ", ldapUserDNPattern='" + ldapUserDNPattern + '\'' + ", ldapGroupSearchBase='" + ldapGroupSearchBase + '\'' + ", ldapGroupSearchFilter='" + ldapGroupSearchFilter + '\'' + ", ldapGroupRoleAttribute='" + ldapGroupRoleAttribute + '\'' + ", ldapBindDN='" + ldapBindDN + '\'' + ", ldapDefaultRole='" + ldapDefaultRole + '\'' + ", ldapUserSearchFilter='" + ldapUserSearchFilter + '\'' + ", ldapReferral='" + ldapReferral + '\'' + ", ldapBase='" + ldapBase + '\'' + ", groupsFromUGI=" + groupsFromUGI + '}'); } } catch (Exception e) { LOG.error("Exception while setLdapProperties", e); } }