Package org.picketlink.idm.model.basic

Examples of org.picketlink.idm.model.basic.User


    @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


  @Inject Logger logger;

  @TransactionAttribute(TransactionAttributeType.REQUIRED)
  @Override
  public TodoListUser register(TodoListUser newTodoListUser, String password) throws RegistrationException {
    final User picketLinkUser = makePicketLinkUser(newTodoListUser);
    final String email = picketLinkUser.getEmail();

    //users login with their email address
    newTodoListUser.setLoginName(email);
    newTodoListUser.setEmail(email);
View Full Code Here

    return (TodoListUser) authService.login(email, password);
  }
 
  private User makePicketLinkUser(TodoListUser todoListUser) {
    final String email = todoListUser.getEmail().toLowerCase();
    final User picketLinkUser = new User(email);

    picketLinkUser.setEmail(email);
    picketLinkUser.setFirstName(todoListUser.getShortName());
    picketLinkUser.setLastName(todoListUser.getFullName());
   
    return picketLinkUser;
  }
View Full Code Here

    catch (RuntimeException ex) {
      throw new AuthenticationException("An error occurred during authentication.", ex);
    }

    if (result == Identity.AuthenticationResult.SUCCESS) {
      final User picketLinkUser = (User) identity.getAccount();
      final TodoListUser todoListUser = lookupTodoListUser(picketLinkUser.getEmail());

      return todoListUser;
    }
    else {
      throw new FailedAuthenticationException();
View Full Code Here

  @TransactionAttribute(TransactionAttributeType.REQUIRED)
  @Override
  public org.jboss.errai.security.shared.api.identity.User getUser() {
    if (identity.isLoggedIn()) {
      final User picketLinkUser = (User)identity.getAccount();
      return lookupTodoListUser(picketLinkUser.getEmail());
    }
    else {
      return org.jboss.errai.security.shared.api.identity.User.ANONYMOUS;
    }
  }
View Full Code Here

    @Before
    public void setUp() throws Exception {
        MockitoAnnotations.initMocks(this);

        List<User> list = new ArrayList<User>();
        list.add(new User("john"));

        when(identity.getAccount()).thenReturn(new User("john"));
        when(identity.isLoggedIn()).thenReturn(true);

        when(identityManager.createIdentityQuery(User.class)).thenReturn(defaultIdentityQuery);
        when(defaultIdentityQuery.getResultList()).thenReturn(list);
View Full Code Here

        when(defaultIdentityQuery.getResultList()).thenReturn(list);

    }

    private User buildUser(String username) {
        User user = mock(User.class);
        when(user.getLoginName()).thenReturn(username);
        when(user.getEmail()).thenReturn(username + "@doe.com");
        return user;
    }
View Full Code Here

    }

    @Test
    @Ignore
    public void testCreate() throws Exception {
        User user = buildUser("john");
        identityManagement.create(user, "123");
        User picketLinkUser = BasicModel.getUser(identityManager, "john");
        assertEquals("User should exist", picketLinkUser.getLoginName(), user.getLoginName());
    }
View Full Code Here

    }

    @Test(expected = RuntimeException.class)
    public void testRemove() throws Exception {
        identityManagement.remove("mike");
        User removedUser = (User) identityManagement.findByUsername("mike");
        assertNull("User should not exist", removedUser);
    }
View Full Code Here

    public Response enroll(Developer developer) {
        try {

            this.identityManager = partitionManager.createIdentityManager();
            this.relationshipManager = partitionManager.createRelationshipManager();
            User user = new User(developer.getLoginName());
            identityManager.add(user);
            Calendar calendar = expirationDate();
            Password password = new Password(developer.getPassword().toCharArray());

            identityManager.updateCredential(user, password, new Date(), calendar.getTime());

            Role developerRole = BasicModel.getRole(identityManager, UserRoles.DEVELOPER);

            grantRoles(user, developerRole);
            List<User> list = identityManager.createIdentityQuery(User.class)
                    .setParameter(User.LOGIN_NAME, user.getLoginName()).getResultList();
            user = list.get(0);
            developer.setId(user.getId());

        } catch (IdentityManagementException ime) {
            return Response.status(Response.Status.BAD_REQUEST).entity("Credential not available").build();
        }
View Full Code Here

TOP

Related Classes of org.picketlink.idm.model.basic.User

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.