Package org.picketlink.idm

Examples of org.picketlink.idm.IdentityManager


            setup();
        }
    }

    private void setup() {
        final IdentityManager identityManager = partitionManager.createIdentityManager();
        final RelationshipManager relationshipManager = partitionManager.createRelationshipManager();

        final User admin = new User( "admin" );
        final User director = new User( "director" );
        final User user = new User( "user" );
        final User guest = new User( "guest" );

        identityManager.add( admin );
        identityManager.add( director );
        identityManager.add( user );
        identityManager.add( guest );

        identityManager.updateCredential( admin, new Password( "admin" ) );
        identityManager.updateCredential( director, new Password( "director" ) );
        identityManager.updateCredential( user, new Password( "user" ) );
        identityManager.updateCredential( guest, new Password( "guest" ) );

        final Role roleAdmin = new Role( "admin" );
        final Role roleAnalyst = new Role( "analyst" );

        identityManager.add( roleAdmin );
        identityManager.add( roleAnalyst );

        relationshipManager.add( new Grant( admin, roleAnalyst ) );
        relationshipManager.add( new Grant( admin, roleAdmin ) );

        relationshipManager.add( new Grant( director, roleAnalyst ) );
View Full Code Here


            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()));
    }
View Full Code Here

    @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());
    }
View Full Code Here

            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()));
    }
View Full Code Here

    @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));
    }
View Full Code Here

    @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());
    }
View Full Code Here

    @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));
    }
View Full Code Here

    @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();
View Full Code Here

    @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());
    }
View Full Code Here

public class LDAPKeycloakCredentialHandler extends LDAPPlainTextPasswordCredentialHandler {

    // Overridden as in Keycloak, we don't have Agents
    @Override
    protected User getAccount(IdentityContext context, String loginName) {
        IdentityManager identityManager = getIdentityManager(context);

        if (CREDENTIAL_LOGGER.isDebugEnabled()) {
            CREDENTIAL_LOGGER.debugf("Trying to find account [%s] using default account type [%s]", loginName, User.class);
        }
View Full Code Here

TOP

Related Classes of org.picketlink.idm.IdentityManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.