Search in sources :

Example 1 with PartitionManager

use of org.picketlink.idm.PartitionManager in project wildfly by wildfly.

the class PartitionManagerService method publishPartitionManager.

private void publishPartitionManager(StartContext context) {
    BindInfo bindInfo = createPartitionManagerBindInfo();
    ServiceName serviceName = bindInfo.getBinderServiceName();
    final BinderService binderService = new BinderService(serviceName.getCanonicalName());
    final ServiceBuilder<ManagedReferenceFactory> builder = context.getController().getServiceContainer().addService(serviceName, binderService).addAliases(ContextNames.JAVA_CONTEXT_SERVICE_NAME.append(this.jndiName));
    builder.addDependency(ContextNames.JAVA_CONTEXT_SERVICE_NAME, ServiceBasedNamingStore.class, binderService.getNamingStoreInjector());
    builder.addDependency(createServiceName(this.alias), PartitionManager.class, new Injector<PartitionManager>() {

        @Override
        public void inject(final PartitionManager value) throws InjectionException {
            binderService.getManagedObjectInjector().inject(new ValueManagedReferenceFactory(new ImmediateValue<Object>(value)));
        }

        @Override
        public void uninject() {
            binderService.getManagedObjectInjector().uninject();
        }
    });
    builder.setInitialMode(Mode.PASSIVE).install();
    ROOT_LOGGER.boundToJndi("PartitionManager " + this.alias, bindInfo.getAbsoluteJndiName());
}
Also used : BinderService(org.jboss.as.naming.service.BinderService) InjectionException(org.jboss.msc.inject.InjectionException) DefaultPartitionManager(org.picketlink.idm.internal.DefaultPartitionManager) PartitionManager(org.picketlink.idm.PartitionManager) ServiceName(org.jboss.msc.service.ServiceName) ValueManagedReferenceFactory(org.jboss.as.naming.ValueManagedReferenceFactory) ManagedReferenceFactory(org.jboss.as.naming.ManagedReferenceFactory) ValueManagedReferenceFactory(org.jboss.as.naming.ValueManagedReferenceFactory) BindInfo(org.jboss.as.naming.deployment.ContextNames.BindInfo)

Example 2 with PartitionManager

use of org.picketlink.idm.PartitionManager in project wildfly by wildfly.

the class AbstractBasicIdentityManagementTestCase method testPartitionManagement.

@Test
@InSequence(1)
public void testPartitionManagement() throws Exception {
    PartitionManager partitionManager = getPartitionManager();
    Realm partition = partitionManager.getPartition(Realm.class, Realm.DEFAULT_REALM);
    if (partition != null) {
        partitionManager.remove(partition);
    }
    partitionManager.add(new Realm(Realm.DEFAULT_REALM));
    assertNotNull(partitionManager.getPartition(Realm.class, Realm.DEFAULT_REALM));
}
Also used : PartitionManager(org.picketlink.idm.PartitionManager) Realm(org.picketlink.idm.model.basic.Realm) Test(org.junit.Test) InSequence(org.jboss.arquillian.junit.InSequence)

Example 3 with PartitionManager

use of org.picketlink.idm.PartitionManager in project wildfly by wildfly.

the class AbstractBasicIdentityManagementTestCase method testRelationshipManagement.

@Test
@InSequence(5)
public void testRelationshipManagement() throws Exception {
    PartitionManager partitionManager = getPartitionManager();
    IdentityManager identityManager = partitionManager.createIdentityManager();
    User user = getUser(identityManager, "johny");
    Role role = getRole(identityManager, "admin");
    RelationshipManager relationshipManager = partitionManager.createRelationshipManager();
    BasicModel.grantRole(relationshipManager, user, role);
    assertTrue(hasRole(relationshipManager, user, role));
}
Also used : BasicModel.hasRole(org.picketlink.idm.model.basic.BasicModel.hasRole) Role(org.picketlink.idm.model.basic.Role) BasicModel.getRole(org.picketlink.idm.model.basic.BasicModel.getRole) IdentityManager(org.picketlink.idm.IdentityManager) User(org.picketlink.idm.model.basic.User) BasicModel.getUser(org.picketlink.idm.model.basic.BasicModel.getUser) PartitionManager(org.picketlink.idm.PartitionManager) RelationshipManager(org.picketlink.idm.RelationshipManager) Test(org.junit.Test) InSequence(org.jboss.arquillian.junit.InSequence)

Example 4 with PartitionManager

use of org.picketlink.idm.PartitionManager in project wildfly by wildfly.

the class CustomCredentialHandlerTestCase method testCustomCredential.

@InSequence(99)
@Test
public void testCustomCredential() {
    PartitionManager partitionManager = getPartitionManager();
    IdentityManager identityManager = partitionManager.createIdentityManager();
    CustomCredential credentials = new CustomCredential("valid_token");
    identityManager.validateCredentials(credentials);
    assertEquals(Credentials.Status.VALID, credentials.getStatus());
    credentials = new CustomCredential("invalid_token");
    identityManager.validateCredentials(credentials);
    assertEquals(Credentials.Status.INVALID, credentials.getStatus());
}
Also used : IdentityManager(org.picketlink.idm.IdentityManager) PartitionManager(org.picketlink.idm.PartitionManager) CustomCredential(org.wildfly.test.integration.security.picketlink.idm.credentials.CustomCredential) InSequence(org.jboss.arquillian.junit.InSequence) Test(org.junit.Test)

Example 5 with PartitionManager

use of org.picketlink.idm.PartitionManager in project wildfly by wildfly.

the class AbstractBasicIdentityManagementTestCase method testAttributeManagement.

@Test
@InSequence(6)
public void testAttributeManagement() throws Exception {
    PartitionManager partitionManager = getPartitionManager();
    IdentityManager identityManager = partitionManager.createIdentityManager();
    User user = getUser(identityManager, "johny");
    assertNull(user.getAttribute("testAttribute"));
    user.setAttribute(new Attribute<String>("testAttribute", "value"));
    identityManager.update(user);
    assertNotNull(user.getAttribute("testAttribute"));
    assertEquals("value", user.getAttribute("testAttribute").getValue());
}
Also used : IdentityManager(org.picketlink.idm.IdentityManager) User(org.picketlink.idm.model.basic.User) BasicModel.getUser(org.picketlink.idm.model.basic.BasicModel.getUser) PartitionManager(org.picketlink.idm.PartitionManager) Test(org.junit.Test) InSequence(org.jboss.arquillian.junit.InSequence)

Aggregations

PartitionManager (org.picketlink.idm.PartitionManager)9 InSequence (org.jboss.arquillian.junit.InSequence)7 Test (org.junit.Test)7 IdentityManager (org.picketlink.idm.IdentityManager)6 BasicModel.getUser (org.picketlink.idm.model.basic.BasicModel.getUser)4 User (org.picketlink.idm.model.basic.User)4 BasicModel.getRole (org.picketlink.idm.model.basic.BasicModel.getRole)2 BasicModel.hasRole (org.picketlink.idm.model.basic.BasicModel.hasRole)2 Role (org.picketlink.idm.model.basic.Role)2 ManagedReferenceFactory (org.jboss.as.naming.ManagedReferenceFactory)1 ValueManagedReferenceFactory (org.jboss.as.naming.ValueManagedReferenceFactory)1 BindInfo (org.jboss.as.naming.deployment.ContextNames.BindInfo)1 BinderService (org.jboss.as.naming.service.BinderService)1 ModelNode (org.jboss.dmr.ModelNode)1 Property (org.jboss.dmr.Property)1 InjectionException (org.jboss.msc.inject.InjectionException)1 ServiceName (org.jboss.msc.service.ServiceName)1 RelationshipManager (org.picketlink.idm.RelationshipManager)1 IdentityConfigurationBuilder (org.picketlink.idm.config.IdentityConfigurationBuilder)1 NamedIdentityConfigurationBuilder (org.picketlink.idm.config.NamedIdentityConfigurationBuilder)1