Search in sources :

Example 1 with Realm

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

use of org.picketlink.idm.model.basic.Realm 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()));
}
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)

Example 3 with Realm

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

Test (org.junit.Test)3 Realm (org.picketlink.idm.model.basic.Realm)3 IdentityManager (org.picketlink.idm.IdentityManager)2 Password (org.picketlink.idm.credential.Password)2 UsernamePasswordCredentials (org.picketlink.idm.credential.UsernamePasswordCredentials)2 Role (org.picketlink.idm.model.basic.Role)2 User (org.picketlink.idm.model.basic.User)2 InSequence (org.jboss.arquillian.junit.InSequence)1 PartitionManager (org.picketlink.idm.PartitionManager)1