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();
}
}
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());
}
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));
}
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));
}
Aggregations