Package org.libreplan.business.users.entities

Examples of org.libreplan.business.users.entities.User


    private boolean isDefaultAdmin(final User user) {
        return user.getLoginName().equals(PredefinedUsers.ADMIN.getLoginName());
    }

    private boolean isUserDefaultAdmin() {
        User user = userModel.getUser();
        if (user != null) {
            return isDefaultAdmin(user);
        }
        return false;
    }
View Full Code Here


    public boolean isLdapUserOrDefaultAdmin() {
        return isLdapUser() || isUserDefaultAdmin();
    }

    public UserAuthenticationType getAuthenticationType() {
        User user = getUser();
        if (user != null) {
            return user.getUserType();
        }
        return null;
    }
View Full Code Here

                    editWindow.getFellowIfAny("authenticationTypeCombo"),
                    _("cannot be empty"));
        }
        UserAuthenticationType authenticationType = (UserAuthenticationType) item
                .getValue();
        User user = getUser();
        if (user != null) {
            user.setLibrePlanUser(authenticationType
                    .equals(UserAuthenticationType.DATABASE));
        }
    }
View Full Code Here

    }

    @Override
    @Transactional(readOnly = true)
    public void initEditLoggedUser() {
        User user = findByLoginUser(SecurityUtils.getSessionUserLoginName());
        this.user = getFromDB(user);
    }
View Full Code Here

        return getFromDB(user.getId());
    }

    private User getFromDB(Long id) {
        try {
            User result = userDAO.find(id);
            forceLoadEntities(result);
            return result;
        } catch (InstanceNotFoundException e) {
            throw new RuntimeException(e);
        }
View Full Code Here

    @Override
    @Transactional(readOnly = true)
    public UserDetails loadUserByUsername(String loginName)
            throws UsernameNotFoundException, DataAccessException {

        User user;

        try {
            user = userDAO.findByLoginName(loginName);
        } catch (InstanceNotFoundException e) {
            throw new UsernameNotFoundException(MessageFormat.format(
                    "User with username {0}: not found", loginName));
        }

        Scenario scenario = user.getLastConnectedScenario();
        if (scenario == null) {
            scenario = PredefinedScenarios.MASTER.getScenario();
        }

        String password = user.getPassword();
        if (null == password)
            password = "foo";
        return new CustomUser(user.getLoginName(), password,
                !user.isDisabled(), true, // accountNonExpired
                true, // credentialsNonExpired
                true, // accountNonLocked
                getGrantedAuthorities(user.getAllRoles()), scenario);
    }
View Full Code Here

                    "Username and password can not be empty");
        }

        String encodedPassword = passwordEncoderService.encodePassword(
                clearPassword, username);
        User user = getUserFromDB(username);

        // If user != null then exists in LibrePlan
        if (null != user && user.isLibrePlanUser()) {
            // is a LibrePlan user, then we must authenticate against DB
            return authenticateInDatabase(username, user, encodedPassword);
        }

        // If it's a LDAP or null user, then we must authenticate against LDAP
        // Load LDAPConfiguration properties
        configuration = loadLDAPConfiguration();

        if (configuration.getLdapAuthEnabled()) {
            // Sets the new context to ldapTemplate
            ldapTemplate.setContextSource(loadLDAPContext());

            try {
                // Test authentication for user against LDAP
                if (authenticateAgainstLDAP(username, clearPassword)) {
                    // Authentication against LDAP was ok
                    if (null == user) {
                        // User does not exist in LibrePlan must be imported
                        user = createLDAPUserWithRoles(username, encodedPassword);
                    } else {
                        // Update password
                        if (configuration.isLdapSavePasswordsDB()) {
                            user.setPassword(encodedPassword);
                        }
                        // Update roles from LDAP
                        setRoles(user);
                    }
                    saveUserOnTransaction(user);
View Full Code Here

        return userDAO.list(User.class);
    }

    @Override
    public boolean entryMatchesText(Object obj, String text) {
        final User user = (User) obj;
        text = StringUtils.trim(text.toLowerCase());
        return checkContainsText(user.getLoginName(), text)
                || checkContainsText(user.getFirstName(), text)
                || checkContainsText(user.getLastName(), text);
    }
View Full Code Here

        return original.toLowerCase().contains(text);
    }

    @Override
    public String objectToString(Object obj) {
        User user = (User) obj;

        String fullName = user.getFullName();
        if (Strings.isBlank(fullName)) {
            return user.getLoginName();
        }

        return user.getLoginName() + " (" + fullName + ")";
    }
View Full Code Here

            }
        }
    }

    private User createLDAPUserWithRoles(String username, String encodedPassword) {
        User user = User.create();
        user.setLoginName(username);
        // we must check if it is needed to save LDAP
        // passwords in DB
        if (!configuration.isLdapSavePasswordsDB()) {
            encodedPassword = null;
        }
        user.setPassword(encodedPassword);
        user.setLibrePlanUser(false);
        user.setDisabled(false);
        setRoles(user);
        return user;
    }
View Full Code Here

TOP

Related Classes of org.libreplan.business.users.entities.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.