use of org.picketlink.idm.IdentityManager in project deltaspike by apache.
the class Initializer method create.
@PostConstruct
public void create() {
// Create user john
User john = new User("john");
john.setEmail("john@acme.com");
john.setFirstName("John");
john.setLastName("User");
IdentityManager identityManager = this.partitionManager.createIdentityManager();
identityManager.add(john);
identityManager.updateCredential(john, new Password("123456"));
}
use of org.picketlink.idm.IdentityManager 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));
}
use of org.picketlink.idm.IdentityManager 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());
}
use of org.picketlink.idm.IdentityManager in project wildfly by wildfly.
the class MultipleIdentityStoreConfigurationTestCase method testConfiguration.
@Test
public void testConfiguration() throws Exception {
Realm defaultRealm = this.partitionManager.getPartition(Realm.class, Realm.DEFAULT_REALM);
if (defaultRealm == null) {
defaultRealm = new Realm(Realm.DEFAULT_REALM);
this.partitionManager.add(defaultRealm);
}
IdentityManager identityManager = this.partitionManager.createIdentityManager();
User user = new User("mary");
identityManager.add(user);
assertNotNull(BasicModel.getUser(identityManager, user.getLoginName()));
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());
Role role = new Role("ruler");
identityManager.add(role);
assertNotNull(BasicModel.getRole(identityManager, role.getName()));
}
use of org.picketlink.idm.IdentityManager 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());
}
Aggregations