use of org.picketlink.idm.credential.Password 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.credential.Password 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.credential.Password in project wildfly by wildfly.
the class PartitionManagerProducerTestCase method testAuthentication.
@Test
@InSequence(2)
public void testAuthentication() {
User user = new User("johny");
this.identityManager.add(user);
Password password = new Password("abcd1234");
this.identityManager.updateCredential(user, password);
Role role = new Role("admin");
this.identityManager.add(role);
BasicModel.grantRole(this.relationshipManager, user, role);
this.credentials.setUserId("johny");
this.credentials.setPassword("abcd1234");
this.identity.login();
assertTrue(this.identity.isLoggedIn());
user = BasicModel.getUser(this.identityManager, "johny");
role = BasicModel.getRole(this.identityManager, "admin");
assertTrue(BasicModel.hasRole(this.relationshipManager, user, role));
}
use of org.picketlink.idm.credential.Password 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.credential.Password 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()));
}
Aggregations