use of org.skife.config.ConfigSource in project killbill by killbill.
the class KillBillShiroWebModule method configureShiroWeb.
@Override
protected void configureShiroWeb() {
final RedisCacheConfig redisCacheConfig = new ConfigurationObjectFactory(new ConfigSource() {
@Override
public String getString(final String propertyName) {
return configSource.getString(propertyName);
}
}).build(RedisCacheConfig.class);
// Magic provider to configure the cache manager
if (redisCacheConfig.isRedisCachingEnabled()) {
bind(CacheManager.class).toProvider(RedisShiroManagerProvider.class).asEagerSingleton();
} else {
bind(CacheManager.class).toProvider(EhcacheShiroManagerProvider.class).asEagerSingleton();
}
final SecurityConfig securityConfig = new ConfigurationObjectFactory(configSource).build(SecurityConfig.class);
final Collection<Realm> realms = defaultSecurityManager.getRealms() != null ? defaultSecurityManager.getRealms() : // Mainly for testing
ImmutableSet.<Realm>of(new IniRealm(securityConfig.getShiroResourcePath()));
for (final Realm realm : realms) {
bindRealm().toInstance(realm);
}
configureShiroForRBAC();
configureShiroForTenants();
expose(new TypeLiteral<Set<Realm>>() {
});
}
use of org.skife.config.ConfigSource in project killbill by killbill.
the class KillBillShiroModule method bindSecurityManager.
@Override
protected void bindSecurityManager(final AnnotatedBindingBuilder<? super SecurityManager> bind) {
// super.bindSecurityManager(bind);
bind.toInstance(defaultSecurityManager);
final RedisCacheConfig redisCacheConfig = new ConfigurationObjectFactory(new ConfigSource() {
@Override
public String getString(final String propertyName) {
return configSource.getString(propertyName);
}
}).build(RedisCacheConfig.class);
// Magic provider to configure the cache manager
if (redisCacheConfig.isRedisCachingEnabled()) {
bind(CacheManager.class).toProvider(RedisShiroManagerProvider.class).asEagerSingleton();
} else {
bind(CacheManager.class).toProvider(EhcacheShiroManagerProvider.class).asEagerSingleton();
}
}
use of org.skife.config.ConfigSource in project killbill by killbill.
the class TestKillBillJndiLdapRealm method testCheckLDAPConnection.
@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());
}
use of org.skife.config.ConfigSource in project killbill by killbill.
the class TestKillBillOktaRealm method testCheckOktaConnection.
@Test(groups = "external", enabled = false)
public void testCheckOktaConnection() throws Exception {
// Convenience method to verify your Okta connectivity
final Properties props = new Properties();
props.setProperty("org.killbill.security.okta.url", "https://dev-XXXXXX.oktapreview.com");
props.setProperty("org.killbill.security.okta.apiToken", "YYYYYY");
props.setProperty("org.killbill.security.okta.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 KillBillOktaRealm oktaRealm = new KillBillOktaRealm(securityConfig);
final String username = "pierre";
final String password = "password";
// Check authentication
final UsernamePasswordToken token = new UsernamePasswordToken(username, password);
final AuthenticationInfo authenticationInfo = oktaRealm.getAuthenticationInfo(token);
System.out.println(authenticationInfo);
// Check permissions
final SimplePrincipalCollection principals = new SimplePrincipalCollection(username, username);
final AuthorizationInfo authorizationInfo = oktaRealm.doGetAuthorizationInfo(principals);
System.out.println("Roles: " + authorizationInfo.getRoles());
System.out.println("Permissions: " + authorizationInfo.getStringPermissions());
}
use of org.skife.config.ConfigSource in project killbill by killbill.
the class GuicyKillbillTestSuite method globalBeforeTest.
@BeforeClass(alwaysRun = true)
public void globalBeforeTest() {
configSource = getConfigSource(extraPropertiesForTestSuite);
skifeConfigSource = new ConfigSource() {
@Override
public String getString(final String propertyName) {
return configSource.getString(propertyName);
}
};
// We need to set the instance variable in each subsequent class instantiated in the suite
clock = Mockito.mock(ClockMock.class, new Answer() {
@Override
public Object answer(final InvocationOnMock invocation) throws Throwable {
final Object answer = invocation.getMethod().invoke(theRealClock, invocation.getArguments());
final DateTime utcNow = theRealClock.getUTCNow();
if (callContext != null) {
callContext.setCreatedDate(utcNow);
}
if (internalCallContext != null) {
internalCallContext.setCreatedDate(utcNow);
internalCallContext.setUpdatedDate(utcNow);
}
return answer;
}
});
}
Aggregations