Package com.rupertjones.globalcron.common.domain

Examples of com.rupertjones.globalcron.common.domain.User


        return new ForwardResolution(PROFILE_JSP);
    }

    @HandlesEvent("SaveOrUpdate")
    public Resolution onSave() {
        User user = userService.findUser(sessionUser);

        boolean passwordMatch = this.formUser.isPasswordMatch();
        boolean compliant = this.formUser.isPasswordPolicyCompliant();
        ValidationErrors errors = new ValidationErrors();

        if (!passwordMatch) {
            errors.add("password", new LocalizableError("password.nomatch"));
        }

        if (!compliant) {
            errors.add("password", new SimpleError(passwordPolicy.getDescription()));
        }

        if (errors.size() == 0) {
            user.setFullName(this.formUser.getFullName());
            userService.saveWithPassword(user, this.formUser.getPassword());
            return new ForwardResolution(HOME_ACTION);
        } else {
            getContext().setValidationErrors(errors);
            return getContext().getSourcePageResolution();
View Full Code Here


    @Override
    public Authentication authenticate(Authentication authentication) {
        String username = (String) authentication.getPrincipal();
        String password = (String) authentication.getCredentials();
        User user = userDAO.login(username, password);

        if (user == null) {
            LOG.warn("Could not authenticate user with username: " + username);
            throw new GlobalCronAuthenticationException("Authentication failed");
        }

        Collection<GrantedAuthority> auth = new ArrayList<GrantedAuthority>();
        for (Role role : user.getRoles()) {
            auth.add(new Authority(role.getName()));
        }
        user.registerLogin();
        userDAO.upsert(user);

        AuditLog auditLog = new AuditLog();
        auditLog.setMessage("User logged in");
        auditLog.setUser(user.getUsername());
        auditLog.setType(AuditLogType.LOGIN);
        auditLogDAO.upsert(auditLog);

        LOG.info(format("User %s successfully logged in with roles [%s]", username, auth));
        return new UsernamePasswordAuthenticationToken(user.getUsername(), user.getPassword(), auth);
    }
View Full Code Here

        if (!compliant) {
            errors.add("password", new SimpleError(passwordPolicy.getDescription()));
        }

        User otherUser = getUserService().findUser(this.formUser.getUsername());
        if (otherUser != null) {
            errors.add("username", new SimpleError("That username is not available"));
        }

        if (formUser.getRoles().isEmpty()) {
            errors.add("roles", new SimpleError("You must select one role"));
        }

        if (errors.size() == 0) {
            User user = new User();
            user.setFullName(this.formUser.getFullName());
            user.setUsername(this.formUser.getUsername());

            user.clearRoles();
            for (FormRole thisRole : formUser.getRoles()) {
                if (thisRole.isAssigned()) {
                    user.addRole(getUserService().findRole(thisRole.getName()));
                }
            }

            getUserService().saveWithPassword(user, this.formUser.getPassword());
            return new ForwardResolution(INFO_USERS_ACTION);
View Full Code Here

TOP

Related Classes of com.rupertjones.globalcron.common.domain.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.