Search in sources :

Example 6 with User

use of org.picketlink.idm.model.basic.User 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 7 with User

use of org.picketlink.idm.model.basic.User 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)

Example 8 with User

use of org.picketlink.idm.model.basic.User in project wildfly by wildfly.

the class MultipleIdentityConfigurationTestCase 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()));
}
Also used : Role(org.picketlink.idm.model.basic.Role) IdentityManager(org.picketlink.idm.IdentityManager) User(org.picketlink.idm.model.basic.User) Realm(org.picketlink.idm.model.basic.Realm) Password(org.picketlink.idm.credential.Password) UsernamePasswordCredentials(org.picketlink.idm.credential.UsernamePasswordCredentials) Test(org.junit.Test)

Aggregations

User (org.picketlink.idm.model.basic.User)8 Test (org.junit.Test)7 IdentityManager (org.picketlink.idm.IdentityManager)7 InSequence (org.jboss.arquillian.junit.InSequence)5 Password (org.picketlink.idm.credential.Password)5 PartitionManager (org.picketlink.idm.PartitionManager)4 BasicModel.getUser (org.picketlink.idm.model.basic.BasicModel.getUser)4 Role (org.picketlink.idm.model.basic.Role)4 UsernamePasswordCredentials (org.picketlink.idm.credential.UsernamePasswordCredentials)3 Realm (org.picketlink.idm.model.basic.Realm)2 PostConstruct (javax.annotation.PostConstruct)1 RelationshipManager (org.picketlink.idm.RelationshipManager)1 BasicModel.getRole (org.picketlink.idm.model.basic.BasicModel.getRole)1 BasicModel.hasRole (org.picketlink.idm.model.basic.BasicModel.hasRole)1