Package se.gu.fire.core

Examples of se.gu.fire.core.FireUser


    public void assignmentAndGrading() {
        UserManager um = new UserManager();
        um.setEntityManager(em);

        // Skapa ny grader
        FireUser u = TestUtil.createRandomUser();
        u.setRole(UserRole.GRADER);
       
        em.getTransaction().begin();
        um.create(u);
        em.getTransaction().commit();
       
        assertTrue(um.isGrader(u.getId()));
        assertTrue(um.isGrader(u));

        // Skapa en ny admin
        u = TestUtil.createRandomUser();
        u.setRole(UserRole.ADMIN);
       
        em.getTransaction().begin();
        um.create(u);
        em.getTransaction().commit();
       
        assertTrue(um.isAdmin(u.getId()));
        assertTrue(um.isAdmin(u));
    }
View Full Code Here


        userMan.setEntityManager(em);
       
        GroupManager groupMan = new GroupManager();
        groupMan.setEntityManager(em);
       
        FireUser user1 = TestUtil.createRandomUser();

        StudentGroup sg = new StudentGroup();

        sg.addGroupMember(user1);

        em.getTransaction().begin();
        userMan.create(user1);
        groupMan.create(sg);
        em.getTransaction().commit();

        FireUser user2 = userMan.read(user1.getId());
        assertNotNull(user2);

        StudentGroup group = groupMan.read(sg.getId());
        assertNotNull(group);
View Full Code Here

     * Test of doFinishRegistration method, of class ConfirmRegistrationBean.
     */
    @Test
    public void testDoFinishRegistration() {

        FireUser user = TestUtil.createRandomUser();
        String password = "haxx";

        interSessionContextBean.addRegistrationSessionData(user, password);
        confirmRegistrationBean.setPasswordManager(null);
       
View Full Code Here

        if (userEmail == null || userEmail.isEmpty()) {
            FireFaces.addErrorMessage("unable to retrieve an associated user for this session");
            return null;
        }

        FireUser user = userManager.findUser(userEmail);
        if (user == null) {
            FireFaces.addErrorMessage("Error when retrieving user for this session, please contact your administrator");
            return null;
        }
View Full Code Here

        return succeded ? "index?faces-redirect=true" : null;
    }

    private void debugCreateTestUser() {

        FireUser newUser = userManager.findUser("christopher.svanefalk@gmail.com");

        if (newUser == null) {
            newUser = new FireUser.Builder()
                    .email("christopher.svanefalk@gmail.com")
                    .firstName("Oscar")
                    .lastName("Utbult")
                    .personNummer("1231231231")
                    .userRole(UserRole.ADMIN)
                    .build();

            userManager.create(newUser);

            RandomNumberGenerator numberGenerator = new SecureRandomNumberGenerator();
            ByteSource salt = numberGenerator.nextBytes();

            String hashedPassword = new Sha256Hash("haxx", salt, 1024).toBase64();

            Password newPassword = new Password(newUser.getId(), hashedPassword, salt.getBytes());

            passwordManager.create(newPassword);

            FireLogger.logInfo(
                    "Created debug user "
                    + newUser.getEmail()
                    + " with password "
                    + newPassword.getPassword()
                    + " and salt "
                    + newPassword.getSalt());
        }
View Full Code Here

        pm.setEntityManager(em);
       
        UserManager um = new UserManager();
        um.setEntityManager(em);
       
        FireUser oscar = TestUtil.createRandomUser();

        em.getTransaction().begin();
        um.create(oscar);
        em.getTransaction().commit();
       
        FireUser u5 = um.read(oscar.getId());
        assertNotNull(u5);

        String smart = "haxx";
        Password oscarsPassword = new Password(oscar.getId(), smart);
        em.getTransaction().begin();
View Full Code Here

        if (userEmail == null) {
            FireFaces.addErrorMessage("Email not found in system {0}", userEmail);
        }

        FireUser targetUser = userManager.findUser(userEmail);

        if (targetUser == null) {
            FireLogger.logInfo("Could not find email: {0}", userEmail);
            FireFaces.addWarningMessage("Email not found in system");
            return;
        }

        String sessionKey = interSessionContextBean.addPasswordRecoverySessionData(userEmail);

        StringBuilder toSend = new StringBuilder()
                .append("Hello there ")
                .append(targetUser.getFullName())
                .append("!\n\nPlease follow this url in order to reset your password for the Fire system:\n\nlocalhost:8080/PrimeFire/faces/resetPassword.xhtml?sessionKey=")
                .append(sessionKey)
                .append("\n\nhugs,\n\nthe Fire team");

        try {
View Full Code Here

    public void tearDown() {
    }

    @Test
    public void testBuilder() {
        FireUser user = new FireUser.Builder()
                .firstName("Malin")
                .lastName("Bergsten")
                .email("malin@chalmers.se")
                .personNummer("8301012345")
                .userRole(UserRole.GRADER)
View Full Code Here

        um.setEntityManager(em);
       
        String email = "notUnique@hotmail.com";
       
          // Test getting same item back!
        FireUser user = TestUtil.createRandomUser();
        user.setEmail(email);

        em.getTransaction().begin();
        um.create(user);
        em.getTransaction().commit();
       
        user = TestUtil.createRandomUser();
        user.setEmail(email);
       
        em.getTransaction().begin();
        um.create(user);
        em.getTransaction().commit();
       
View Full Code Here

        userMan.setEntityManager(em);
       
          // Test getting same item back using email!
        String johnEmail = "aa@a.com";
       
        FireUser user1 =  TestUtil.createRandomUser();
        user1.setEmail(johnEmail);
       
        List<FireUser> us = userMan.getAll();
        for (FireUser u : us) System.out.println("User: " + u.getEmail());
       
        em.getTransaction().begin();
        userMan.create(user1);
        em.getTransaction().commit();

        // Lets find per email
        FireUser user = userMan.findUser(johnEmail);
        assertNotNull(user);
       
        List<FireUser> users = userMan.findUsersByFirstName(user1.getFname());
        assertTrue(users.contains(user1));
       
        users = userMan.findUsersByLastName(user1.getLname());
        assertTrue(users.contains(user1));
       
        FireUser user2 = userMan.read(user1.getId());

        assertNotNull(user2);
        assertTrue(user1.equals(user2));

        // Add 10 users to ensure we have enought
        // users for following tests
        em.getTransaction().begin();
        for(int i = 0; i < 10; i++) {
            userMan.create(new FireUser());
        }
        em.getTransaction().commit();
       
        // Get all
        List<FireUser> all = userMan.getAll();
        assertTrue(all.size() >= 10);

        // Get range tests
        all = userMan.getRange(0, 5);
        assertTrue(all.size() == 5);

        all = userMan.getRange(5, 5);
        assertTrue(all.size() == 5);

        // Test update
        String name = user1.getFname();
        user2.setFname("Another");
        em.getTransaction().begin();
        userMan.update(user2);
        em.getTransaction().commit();
       
        user2 = userMan.read(user1.getId());
        assertFalse(name.equals(user2.getFname()));

        // Test remove
        em.getTransaction().begin();
        userMan.delete(user2);
        em.getTransaction().commit();
View Full Code Here

TOP

Related Classes of se.gu.fire.core.FireUser

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.