Search in sources :

Example 1 with DefaultSecurityManager

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);
}
Also used : DefaultNonEntityDao(org.killbill.billing.util.dao.DefaultNonEntityDao) DefaultTenant(org.killbill.billing.tenant.api.DefaultTenant) HikariDataSource(com.zaxxer.hikari.HikariDataSource) TenantModelDao(org.killbill.billing.tenant.dao.TenantModelDao) HikariConfig(com.zaxxer.hikari.HikariConfig) DefaultSecurityManager(org.apache.shiro.mgt.DefaultSecurityManager) InternalCallContextFactory(org.killbill.billing.util.callcontext.InternalCallContextFactory) DefaultTenantDao(org.killbill.billing.tenant.dao.DefaultTenantDao) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 2 with DefaultSecurityManager

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);
}
Also used : DefaultSecurityManager(org.apache.shiro.mgt.DefaultSecurityManager) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 3 with DefaultSecurityManager

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;
}
Also used : CustomAuthRealm(org.apache.geode.internal.security.shiro.CustomAuthRealm) DefaultSecurityManager(org.apache.shiro.mgt.DefaultSecurityManager) Realm(org.apache.shiro.realm.Realm) CustomAuthRealm(org.apache.geode.internal.security.shiro.CustomAuthRealm)

Example 4 with DefaultSecurityManager

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);
}
Also used : ArrayList(java.util.ArrayList) PrincipalCollection(org.apache.shiro.subject.PrincipalCollection) SimplePrincipalCollection(org.apache.shiro.subject.SimplePrincipalCollection) SimplePrincipalCollection(org.apache.shiro.subject.SimplePrincipalCollection) DefaultSecurityManager(org.apache.shiro.mgt.DefaultSecurityManager) AuthorizingRealm(org.apache.shiro.realm.AuthorizingRealm) CollectionPermission(ddf.security.permission.CollectionPermission) Permission(org.apache.shiro.authz.Permission) KeyValueCollectionPermission(ddf.security.permission.KeyValueCollectionPermission) Realm(org.apache.shiro.realm.Realm) AuthorizingRealm(org.apache.shiro.realm.AuthorizingRealm) Principal(java.security.Principal) Before(org.junit.Before)

Example 5 with DefaultSecurityManager

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);
}
Also used : Permission(org.apache.shiro.authz.Permission) ArrayList(java.util.ArrayList) PrincipalCollection(org.apache.shiro.subject.PrincipalCollection) SimplePrincipalCollection(org.apache.shiro.subject.SimplePrincipalCollection) SimplePrincipalCollection(org.apache.shiro.subject.SimplePrincipalCollection) Matchers.anyString(org.mockito.Matchers.anyString) DefaultSecurityManager(org.apache.shiro.mgt.DefaultSecurityManager) AuthorizingRealm(org.apache.shiro.realm.AuthorizingRealm) Realm(org.apache.shiro.realm.Realm) AuthorizingRealm(org.apache.shiro.realm.AuthorizingRealm) Principal(java.security.Principal)

Aggregations

DefaultSecurityManager (org.apache.shiro.mgt.DefaultSecurityManager)14 SimplePrincipalCollection (org.apache.shiro.subject.SimplePrincipalCollection)7 PrincipalCollection (org.apache.shiro.subject.PrincipalCollection)6 Realm (org.apache.shiro.realm.Realm)5 Principal (java.security.Principal)3 ArrayList (java.util.ArrayList)3 Permission (org.apache.shiro.authz.Permission)3 AuthorizingRealm (org.apache.shiro.realm.AuthorizingRealm)3 SimpleSession (org.apache.shiro.session.mgt.SimpleSession)3 Before (org.junit.Before)3 Test (org.junit.Test)3 CollectionPermission (ddf.security.permission.CollectionPermission)2 KeyValueCollectionPermission (ddf.security.permission.KeyValueCollectionPermission)2 BeforeMethod (org.testng.annotations.BeforeMethod)2 HikariConfig (com.zaxxer.hikari.HikariConfig)1 HikariDataSource (com.zaxxer.hikari.HikariDataSource)1 Metacard (ddf.catalog.data.Metacard)1 ResultImpl (ddf.catalog.data.impl.ResultImpl)1 DeleteRequest (ddf.catalog.operation.DeleteRequest)1 ResourceRequest (ddf.catalog.operation.ResourceRequest)1