Java Examples for org.skife.config.ConfigSource
The following java examples will help you to understand the usage of org.skife.config.ConfigSource. These source code samples are taken from different open source projects.
Example 1
Project: killbill-master File: TestKillBillJndiLdapRealm.java View source code |
@Test(groups = "external", enabled = false)
public void testCheckLDAPConnection() throws Exception {
// Convenience method to verify your LDAP connectivity
final Properties props = new Properties();
props.setProperty("org.killbill.security.ldap.userDnTemplate", "uid={0},ou=users,dc=mycompany,dc=com");
props.setProperty("org.killbill.security.ldap.searchBase", "ou=groups,dc=mycompany,dc=com");
props.setProperty("org.killbill.security.ldap.groupSearchFilter", "memberOf=uid={0},ou=users,dc=mycompany,dc=com");
props.setProperty("org.killbill.security.ldap.groupNameId", "cn");
props.setProperty("org.killbill.security.ldap.url", "ldap://ldap:389");
props.setProperty("org.killbill.security.ldap.disableSSLCheck", "true");
props.setProperty("org.killbill.security.ldap.systemUsername", "cn=root");
props.setProperty("org.killbill.security.ldap.systemPassword", "password");
props.setProperty("org.killbill.security.ldap.authenticationMechanism", "simple");
props.setProperty("org.killbill.security.ldap.permissionsByGroup", "support-group: entitlement:*\n" + "finance-group: invoice:*, payment:*\n" + "ops-group: *:*");
final ConfigSource customConfigSource = new SimplePropertyConfigSource(props);
final SecurityConfig securityConfig = new ConfigurationObjectFactory(customConfigSource).build(SecurityConfig.class);
final KillBillJndiLdapRealm ldapRealm = new KillBillJndiLdapRealm(securityConfig);
final String username = "pierre";
final String password = "password";
// Check authentication
final UsernamePasswordToken token = new UsernamePasswordToken(username, password);
final AuthenticationInfo authenticationInfo = ldapRealm.getAuthenticationInfo(token);
System.out.println(authenticationInfo);
// Check permissions
final SimplePrincipalCollection principals = new SimplePrincipalCollection(username, username);
final AuthorizationInfo authorizationInfo = ldapRealm.queryForAuthorizationInfo(principals, ldapRealm.getContextFactory());
System.out.println("Roles: " + authorizationInfo.getRoles());
System.out.println("Permissions: " + authorizationInfo.getStringPermissions());
}
Example 2
Project: killbill-commons-master File: TestSetup.java View source code |
@BeforeClass(groups = "slow")
public void beforeClass() throws Exception {
loadSystemPropertiesFromClasspath("/queue.properties");
clock = new ClockMock();
// See also PlatformDBTestingHelper
if ("true".equals(System.getProperty(TEST_DB_PROPERTY_PREFIX + "h2"))) {
embeddedDB = new H2EmbeddedDB("killbillq", "killbillq", "killbillq");
} else if ("true".equals(System.getProperty(TEST_DB_PROPERTY_PREFIX + "postgresql"))) {
embeddedDB = new PostgreSQLEmbeddedDB("killbillq", "killbillq");
} else {
embeddedDB = new MySQLEmbeddedDB("killbillq", "killbillq", "killbillq");
}
embeddedDB.initialize();
embeddedDB.start();
if (embeddedDB.getDBEngine() == EmbeddedDB.DBEngine.POSTGRESQL) {
embeddedDB.executeScript("CREATE DOMAIN datetime AS timestamp without time zone;" + "CREATE OR REPLACE FUNCTION last_insert_id() RETURNS BIGINT AS $$\n" + " DECLARE\n" + " result BIGINT;\n" + " BEGIN\n" + " SELECT lastval() INTO result;\n" + " RETURN result;\n" + " EXCEPTION WHEN OTHERS THEN\n" + " SELECT NULL INTO result;\n" + " RETURN result;\n" + " END;\n" + "$$ LANGUAGE plpgsql VOLATILE;");
}
final String ddl = toString(Resources.getResource("org/killbill/queue/ddl.sql").openStream());
embeddedDB.executeScript(ddl);
embeddedDB.refreshTableNames();
databaseTransactionNotificationApi = new DatabaseTransactionNotificationApi();
dbi = new DBI(embeddedDB.getDataSource());
dbi.registerArgumentFactory(new UUIDArgumentFactory());
dbi.registerArgumentFactory(new DateTimeZoneArgumentFactory());
dbi.registerArgumentFactory(new DateTimeArgumentFactory());
dbi.registerArgumentFactory(new LocalDateArgumentFactory());
dbi.registerMapper(new UUIDMapper());
dbi.setTransactionHandler(new NotificationTransactionHandler(databaseTransactionNotificationApi));
final ConfigSource configSource = new SimplePropertyConfigSource(System.getProperties());
persistentBusConfig = new ConfigurationObjectFactory(configSource).buildWithReplacements(PersistentBusConfig.class, ImmutableMap.<String, String>of("instanceName", "main"));
notificationQueueConfig = new ConfigurationObjectFactory(configSource).buildWithReplacements(NotificationQueueConfig.class, ImmutableMap.<String, String>of("instanceName", "main"));
}
Example 3
Project: ning-service-skeleton-master File: ServerModuleBuilder.java View source code |
public ServerModuleBuilder setConfigSource(final ConfigSource configSource) {
this.configSource = configSource;
return this;
}