Package com.mossle.auth.domain

Examples of com.mossle.auth.domain.UserStatus


    public void onApplicationEvent(EntityEvent event) {
        if (!event.supportsEntityType(UserStatus.class)) {
            return;
        }

        UserStatus userStatus = event.getEntity();
        authCache.evictUserStatus(userStatus);
    }
View Full Code Here


            return null;
        }

        String userId = apiUserDto.getId();

        UserStatus userStatus = userStatusManager.findUnique(
                "from UserStatus where ref=? and localId=?", userId, localId);

        if (userStatus == null) {
            userStatus = new UserStatus();
            userStatus.setRef(userId);
            userStatus.setUsername(username);
            userStatus.setStatus(1);
            userStatus.setUserRepoRef(ScopeHolder.getUserRepoRef());
            userStatus.setScopeId(ScopeHolder.getScopeId());
            userStatusManager.save(userStatus);
        }

        UserDTO userDto = new UserDTO();

        userDto.setUserId(userStatus.getId());

        userDto.setUsername(apiUserDto.getUsername());

        List<String> roles = userStatusManager.find(HQL_ATTRIBUTE,
                userStatus.getId());
        logger.debug("roles : {}", roles);

        userDto.setAuthorities(roles);

        return userDto;
View Full Code Here

                if (str.length() == 0) {
                    continue;
                }

                UserStatus userStatus = userStatusManager.findUnique(
                        "from UserStatus where username=? and userRepoRef=?",
                        str, ScopeHolder.getUserRepoRef());

                if (userStatus == null) {
                    messageHelper.addFlashMessage(redirectAttributes, str
View Full Code Here

    private AccessManager accessManager;
    private PermManager permManager;

    public UserStatus createOrGetUserStatus(String username, String ref,
            String userRepoRef, String scopeId) {
        UserStatus userStatus = userStatusManager.findUnique(
                "from UserStatus where username=? and scopeId=?", username,
                scopeId);

        if (userStatus == null) {
            userStatus = new UserStatus();
            userStatus.setUsername(username);
            userStatus.setRef(ref);
            userStatus.setUserRepoRef(userRepoRef);
            userStatus.setScopeId(scopeId);
            // TODO: 考虑status同步的策略,目前是默认都设置成了有效
            userStatus.setStatus(1);
            userStatusManager.save(userStatus);
        }

        return userStatus;
    }
View Full Code Here

    public void configUserRole(Long userId, List<Long> roleIds,
            String userRepoRef, String scopeId, boolean clearRoles) {
        logger.debug("userId: {}, roleIds: {}", userId, roleIds);

        UserStatus userStatus = userStatusManager.get(userId);

        if (userStatus == null) {
            logger.warn("cannot find UserStatus : {}", userId);

            return;
        }

        if (clearRoles) {
            List<Role> roles = new ArrayList<Role>();

            roles.addAll(userStatus.getRoles());

            for (Role role : roles) {
                userStatus.getRoles().remove(role);
            }
        }

        if (roleIds == null) {
            roleIds = Collections.emptyList();
        }

        for (Long roleId : roleIds) {
            Role role = roleManager.get(roleId);
            boolean skip = false;

            if (role == null) {
                logger.warn("role is null, roleId : {}", roleId);

                continue;
            }

            for (Role r : userStatus.getRoles()) {
                logger.debug("r.getId() : {}, role.getId() : {}", r.getId(),
                        role.getId());

                if (r.getId().equals(role.getId())) {
                    skip = true;

                    break;
                }
            }

            if (skip) {
                continue;
            }

            userStatus.getRoles().add(role);
        }

        userStatusManager.save(userStatus);
    }
View Full Code Here

TOP

Related Classes of com.mossle.auth.domain.UserStatus

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.