Search in sources :

Example 6 with PartitionManager

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

the class PartitionManagerAddHandler method createPartitionManagerService.

public void createPartitionManagerService(final OperationContext context, String partitionManagerName, final ModelNode partitionManager, boolean onlyValidate) throws OperationFailedException {
    String jndiName = PartitionManagerResourceDefinition.IDENTITY_MANAGEMENT_JNDI_URL.resolveModelAttribute(context, partitionManager).asString();
    IdentityConfigurationBuilder builder = new IdentityConfigurationBuilder();
    PartitionManagerService partitionManagerService = new PartitionManagerService(partitionManagerName, jndiName, builder);
    ServiceBuilder<PartitionManager> serviceBuilder = null;
    if (!onlyValidate) {
        serviceBuilder = context.getServiceTarget().addService(PartitionManagerService.createServiceName(partitionManagerName), partitionManagerService);
    }
    ModelNode identityConfigurationNode = partitionManager.get(IDENTITY_CONFIGURATION.getName());
    if (!identityConfigurationNode.isDefined()) {
        throw ROOT_LOGGER.idmNoIdentityConfigurationProvided();
    }
    for (Property identityConfiguration : identityConfigurationNode.asPropertyList()) {
        String configurationName = identityConfiguration.getName();
        NamedIdentityConfigurationBuilder namedIdentityConfigurationBuilder = builder.named(configurationName);
        if (!identityConfiguration.getValue().isDefined()) {
            throw ROOT_LOGGER.idmNoIdentityStoreProvided(configurationName);
        }
        List<ModelNode> identityStores = identityConfiguration.getValue().asList();
        for (ModelNode store : identityStores) {
            configureIdentityStore(context, serviceBuilder, partitionManagerService, configurationName, namedIdentityConfigurationBuilder, store);
        }
    }
    if (!onlyValidate) {
        ServiceController<PartitionManager> controller = serviceBuilder.setInitialMode(Mode.PASSIVE).install();
    }
}
Also used : PartitionManager(org.picketlink.idm.PartitionManager) PartitionManagerService(org.wildfly.extension.picketlink.idm.service.PartitionManagerService) IdentityConfigurationBuilder(org.picketlink.idm.config.IdentityConfigurationBuilder) NamedIdentityConfigurationBuilder(org.picketlink.idm.config.NamedIdentityConfigurationBuilder) ModelNode(org.jboss.dmr.ModelNode) NamedIdentityConfigurationBuilder(org.picketlink.idm.config.NamedIdentityConfigurationBuilder) Property(org.jboss.dmr.Property)

Example 7 with PartitionManager

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

the class AbstractBasicIdentityManagementTestCase method testCredentialManagement.

@Test
@InSequence(3)
public void testCredentialManagement() throws Exception {
    PartitionManager partitionManager = getPartitionManager();
    IdentityManager identityManager = partitionManager.createIdentityManager();
    User user = getUser(identityManager, "johny");
    Password password = new Password("abcd1234");
    identityManager.updateCredential(user, password);
    UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(user.getLoginName(), password);
    identityManager.validateCredentials(credentials);
    assertEquals(Credentials.Status.VALID, credentials.getStatus());
}
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) Password(org.picketlink.idm.credential.Password) UsernamePasswordCredentials(org.picketlink.idm.credential.UsernamePasswordCredentials) Test(org.junit.Test) InSequence(org.jboss.arquillian.junit.InSequence)

Example 8 with PartitionManager

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

the class AbstractBasicIdentityManagementTestCase method testRoleManagement.

@Test
@InSequence(4)
public void testRoleManagement() throws Exception {
    PartitionManager partitionManager = getPartitionManager();
    IdentityManager identityManager = partitionManager.createIdentityManager();
    String roleName = "admin";
    Role role = getRole(identityManager, roleName);
    if (role != null) {
        identityManager.remove(role);
    }
    identityManager.add(new Role(roleName));
    assertNotNull(getRole(identityManager, roleName));
}
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) PartitionManager(org.picketlink.idm.PartitionManager) Test(org.junit.Test) InSequence(org.jboss.arquillian.junit.InSequence)

Example 9 with PartitionManager

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

the class AbstractBasicIdentityManagementTestCase method testUserManagement.

@Test
@InSequence(2)
public void testUserManagement() throws Exception {
    PartitionManager partitionManager = getPartitionManager();
    IdentityManager identityManager = partitionManager.createIdentityManager();
    String loginName = "johny";
    User user = getUser(identityManager, loginName);
    if (user != null) {
        identityManager.remove(user);
    }
    identityManager.add(new User(loginName));
    assertNotNull(getUser(identityManager, loginName));
}
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