use of org.apache.shiro.mgt.DefaultSecurityManager in project killbill by killbill.
the class TestKillbillJdbcTenantRealm method beforeMethod.
@Override
@BeforeMethod(groups = "slow")
public void beforeMethod() throws Exception {
super.beforeMethod();
// Create the tenant
final DefaultTenantDao tenantDao = new DefaultTenantDao(dbi, clock, cacheControllerDispatcher, new DefaultNonEntityDao(dbi), Mockito.mock(InternalCallContextFactory.class), securityConfig);
tenant = new DefaultTenant(UUID.randomUUID(), null, null, UUID.randomUUID().toString(), UUID.randomUUID().toString(), UUID.randomUUID().toString());
tenantDao.create(new TenantModelDao(tenant), internalCallContext);
// Setup the security manager
final HikariConfig dbConfig = new HikariConfig();
dbConfig.setJdbcUrl(helper.getJdbcConnectionString());
dbConfig.setUsername(helper.getUsername());
dbConfig.setPassword(helper.getPassword());
final KillbillJdbcTenantRealm jdbcRealm = new KillbillJdbcTenantRealm(shiroDataSource, securityConfig);
jdbcRealm.setDataSource(new HikariDataSource(dbConfig));
securityManager = new DefaultSecurityManager(jdbcRealm);
}
use of org.apache.shiro.mgt.DefaultSecurityManager in project killbill by killbill.
the class TestKillBillJdbcRealm method beforeMethod.
@Override
@BeforeMethod(groups = "slow")
public void beforeMethod() throws Exception {
super.beforeMethod();
final KillBillJdbcRealm realm = new KillBillJdbcRealm(helper.getDataSource(), securityConfig);
securityManager = new DefaultSecurityManager(realm);
SecurityUtils.setSecurityManager(securityManager);
}
use of org.apache.shiro.mgt.DefaultSecurityManager in project geode by apache.
the class IntegratedSecurityService method setSecurityManager.
public void setSecurityManager(SecurityManager securityManager) {
if (securityManager == null) {
return;
}
this.securityManager = securityManager;
Realm realm = new CustomAuthRealm(securityManager);
DefaultSecurityManager shiroManager = new DefaultSecurityManager(realm);
SecurityUtils.setSecurityManager(shiroManager);
increaseShiroGlobalSessionTimeout(shiroManager);
isIntegratedSecurity = true;
isClientAuthenticator = false;
isPeerAuthenticator = false;
}
use of org.apache.shiro.mgt.DefaultSecurityManager in project ddf by codice.
the class OperationPluginTest method setup.
@Before
public void setup() {
plugin = new OperationPlugin();
AuthorizingRealm realm = mock(AuthorizingRealm.class);
when(realm.getName()).thenReturn("mockRealm");
when(realm.isPermitted(any(PrincipalCollection.class), any(Permission.class))).then(makeDecision());
Collection<Realm> realms = new ArrayList<Realm>();
realms.add(realm);
DefaultSecurityManager manager = new DefaultSecurityManager();
manager.setRealms(realms);
SimplePrincipalCollection principalCollection = new SimplePrincipalCollection(new Principal() {
@Override
public String getName() {
return "testuser";
}
}, realm.getName());
subject = new MockSubject(manager, principalCollection);
}
use of org.apache.shiro.mgt.DefaultSecurityManager in project ddf by codice.
the class TestResourceUsagePlugin method setSubject.
private void setSubject(String expectedUsername) {
AuthorizingRealm realm = mock(AuthorizingRealm.class);
when(realm.getName()).thenReturn("mockRealm");
when(realm.isPermitted(any(PrincipalCollection.class), any(Permission.class))).thenReturn(true);
Collection<Realm> realms = new ArrayList<>();
realms.add(realm);
DefaultSecurityManager manager = new DefaultSecurityManager();
manager.setRealms(realms);
SimplePrincipalCollection principalCollection = new SimplePrincipalCollection(new Principal() {
@Override
public String getName() {
return expectedUsername;
}
@Override
public String toString() {
return expectedUsername;
}
}, realm.getName());
subject = new MockSubject(manager, principalCollection);
}
Aggregations