use of org.skife.config.ConfigSource in project killbill by killbill.
the class TestJaxrsBase method beforeSuite.
@BeforeSuite(groups = "slow")
public void beforeSuite() throws Exception {
if (hasFailed()) {
return;
}
super.beforeSuite();
// We need to setup these earlier than other tests because the server is started once in @BeforeSuite
final KillbillConfigSource configSource = getConfigSource(extraPropertiesForTestSuite);
final ConfigSource skifeConfigSource = new ConfigSource() {
@Override
public String getString(final String propertyName) {
return configSource.getString(propertyName);
}
};
final KillbillServerConfig serverConfig = new ConfigurationObjectFactory(skifeConfigSource).build(KillbillServerConfig.class);
listener = new TestKillbillGuiceListener(serverConfig, configSource);
config = new ConfigurationObjectFactory(System.getProperties()).build(HttpServerConfig.class);
server = new HttpServer();
server.configure(config, getListeners(), getFilters());
server.start();
callbackServlet = new CallbackServlet();
callbackServer = new CallbackServer(callbackServlet);
callbackServer.startServer();
}
use of org.skife.config.ConfigSource in project killbill by killbill.
the class KillBillShiroModule method configureShiro.
protected void configureShiro() {
final RbacConfig config = new ConfigurationObjectFactory(new ConfigSource() {
@Override
public String getString(final String propertyName) {
return configSource.getString(propertyName);
}
}).build(RbacConfig.class);
bind(RbacConfig.class).toInstance(config);
bind(RbacConfig.class).toInstance(config);
final SecurityConfig securityConfig = new ConfigurationObjectFactory(skifeConfigSource).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);
}
configureJDBCRealm();
configureLDAPRealm();
configureOktaRealm();
configureAuth0Realm();
expose(new TypeLiteral<Set<Realm>>() {
});
}
use of org.skife.config.ConfigSource in project killbill by killbill.
the class TestKillBillAuth0Realm method testCheckAuth0Connection.
@Test(groups = "external", enabled = false)
public void testCheckAuth0Connection() throws Exception {
// Convenience method to verify your Auth0 connectivity
final Properties props = new Properties();
props.setProperty("org.killbill.security.auth0.url", "https://XXX.us.auth0.com");
props.setProperty("org.killbill.security.auth0.clientId", "YYY");
props.setProperty("org.killbill.security.auth0.clientSecret", "ZZZ");
props.setProperty("org.killbill.security.auth0.apiIdentifier", "WWW");
props.setProperty("org.killbill.security.auth0.databaseConnectionName", "Username-Password-Authentication");
props.setProperty("org.killbill.security.auth0.allowedClockSkew", "2000s");
final ConfigSource customConfigSource = new SimplePropertyConfigSource(props);
final SecurityConfig securityConfig = new ConfigurationObjectFactory(customConfigSource).build(SecurityConfig.class);
final KillBillAuth0Realm auth0Realm = new KillBillAuth0Realm(securityConfig, clock);
final String username = "test@example.com";
final String password = "password";
// Check authentication
final AuthenticationToken token = new UsernamePasswordToken(username, password);
final AuthenticationInfo authenticationInfo = auth0Realm.getAuthenticationInfo(token);
System.out.println(authenticationInfo);
// Check permissions
final PrincipalCollection principals = new SimplePrincipalCollection(username, username);
final AuthorizationInfo authorizationInfo = auth0Realm.doGetAuthorizationInfo(principals);
System.out.println("Roles: " + authorizationInfo.getRoles());
System.out.println("Permissions: " + authorizationInfo.getStringPermissions());
// Check JWT
final Claims claims = auth0Realm.verifyJWT("JWT");
System.out.println("Token claims: " + claims);
}
Aggregations