Package se.gu.fire.core

Examples of se.gu.fire.core.FireUser


        }

        /*
         * Persist the user
         */
        FireUser newUser = credentials.getUser();
        String password = credentials.getPassword();

        userManager.create(newUser);
        newUser = userManager.findUser(newUser.getEmail());

        /*
         * Persist the password
         */
        passwordManager.create(newUser.getId(), password);

        /*
         * Finally, if everything went well, notify user of success.
         */
        FireLogger.logInfo("Succesfully registered new user: {0}", newUser);
        FireFaces.addInfoMessage(new StringBuilder()
                .append("Welcome ")
                .append(newUser.getFullName())
                .append("!\n\n")
                .append("We hope you will enjoy using Fire2!")
                .toString());

        return;
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

        /*
         * Create the new FireUser. The actual allocation of an ID
         * and persistence to the database will be done when the user confirms
         * his/her registration
         */
        FireUser user = new FireUser.Builder()
                .firstName(fname)
                .lastName(lname)
                .email(email)
                .personNummer(personNummer)
                .userRole(UserRole.STUDENT)
View Full Code Here

        // Extract user credentials
        UsernamePasswordToken token = (UsernamePasswordToken) at;
        String username = token.getUsername();

        // Extract user from the database
        FireUser resolvedUser;
        try {
            resolvedUser = userManager.findUser(username);

        } catch (PersistenceException e) {
            FireLogger.logSevere("Realm {0} has encountered a database problem: {1}", getName(), e.getClass());
            throw new AuthenticationException("Database error: " + e.getMessage());
        }

        if (resolvedUser == null) {
            FireLogger.logSevere("Realm {0} found no match for user {1}", getName(), username);
            throw new UnknownAccountException("Unable to locate user: " + username);
        }

        // Extract password and check for match
        Password resolvedPassword;
        try {
            resolvedPassword = passwordManager.findPassword(resolvedUser);

        } catch (Exception e) {
            FireLogger.logSevere("Realm {0} has encountered a database problem: {1}", getName(), e.getClass());
            throw new AuthenticationException("Database error: " + e.getMessage());
        }

         // If the password does not exist, the user will have to create a new one
        if (resolvedPassword == null) {
            FireLogger.logSevere("Realm {0} found no matching password for user {1}", getName(), username);
            throw new UnknownAccountException("Password for account could not be found. New password must be created");
        }

        FireLogger.logInfo("Realm {0} generated SimpleAuthenticationToken for user {1}", getName(), username);

        return new SimpleAuthenticationInfo(resolvedUser.getEmail(),
                resolvedPassword.getPassword(),
                new SimpleByteSource(resolvedPassword.getSalt()),
                getName());
    }
View Full Code Here

        am.create(assign);
        em.getTransaction().commit();


        // Fix users
        FireUser u = TestUtil.createRandomUser();
       
        em.getTransaction().begin();
        um.create(u);
        em.getTransaction().commit();


        FireUser u2 = TestUtil.createRandomUser();
       
        em.getTransaction().begin();
        um.create(u2);
        em.getTransaction().commit();
View Full Code Here

            FireLogger.logSevere("WARNING: possible masquerader. Authorizing user is {0} but logged in user is {1}",
                    currentUserEmail,
                    FireUtil.getLoggedinUserEmail());
        }
       
        FireUser currentUser = userManager.findUser(currentUserEmail);
       
        if (currentUser == null) {
            FireLogger.logSevere("FATAL: attempting to find authorization info for non-existen user: {0}", FireUtil.getLoggedinUserEmail());
            return new SimpleAuthorizationInfo();
        }
       
        userRoles.add(currentUser.getRole().toString());
        FireLogger.logInfo("Returning authorization info for user {0}, with role {1}",
                currentUser.getEmail(),
                currentUser.getRole().toString());
       
        /*
        Collection<FireUser> users = pc.byType(FireUser.class);

View Full Code Here

    public void testAddAndGetRegistrationSessionData() {
       
        /*
         * Add user data to context
         */
        FireUser user = TestUtil.createRandomUser();
        String password = "superhaxx";
        String sessionKey = interSessionContextBean.addRegistrationSessionData(user, password);
       
        /*
         * Assert it is present
View Full Code Here

    }

    @Override
    public boolean isAdmin(Long userId) {
        FireUser user = read(userId);
        if (user == null) {
            FireLogger.logInfo("No user found {0}", userId);
            return false;
        }

        return user.getRole() == UserRole.ADMIN;

    }
View Full Code Here

        return user.getRole() == UserRole.GRADER;
    }

    @Override
    public boolean isGrader(Long userId) {
        FireUser user = read(userId);
        if (user == null) {
            FireLogger.logInfo("No user found {0}", userId);
            return false;
        }

        return user.getRole() == UserRole.GRADER;
    }
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.