Package com.sparc.knappsack.components.entities

Examples of com.sparc.knappsack.components.entities.User


        User user = userService.getUserFromSecurityContext();
        return user != null && user.isOrganizationAdmin();
    }

    public boolean isSystemOrOrganizationAdmin() {
        User user = userService.getUserFromSecurityContext();
        return user != null && user.isSystemOrOrganizationAdmin();
    }
View Full Code Here


        User user = userService.getUserFromSecurityContext();
        return user != null && user.isSystemOrOrganizationAdmin();
    }

    public boolean isOrganizationOrGroupAdmin() {
        User user = userService.getUserFromSecurityContext();
        return user != null && user.isOrganizationOrGroupAdmin();
    }
View Full Code Here

        User user = userService.getUserFromSecurityContext();
        return user != null && user.isOrganizationOrGroupAdmin();
    }

    public boolean isAnyAdmin() {
        User user = userService.getUserFromSecurityContext();
        return user != null && user.isAnyAdmin();
    }
View Full Code Here

        userDetailsDao.update((User) user);
    }

    @Override
    public void deleteUser(String username) {
        User user = userDetailsDao.findByUserName(username);
        if (user != null) {
            userDetailsDao.delete(user);
        }
    }
View Full Code Here

            authenticationManager.authenticate(new UsernamePasswordAuthenticationToken(username, oldPassword));
        } else {
            logger.info("No authentication manager set. Password won't be re-checked.");
        }

        User user = userDetailsDao.findByUserName(username);

        if (user == null) {
            throw new IllegalStateException("Current user doesn't exist in database.");
        }

        user.setPassword(newPassword);
        userDetailsDao.update(user);
    }
View Full Code Here

        return user;
    }

    protected void setActiveOrganizationOnUserInSecurityContext(Organization organization) {
        User securityContextUser = getUserWithSecurityContext();
        securityContextUser.setActiveOrganization(organization);
        userService.update(securityContextUser);
        userService.updateSecurityContext(securityContextUser);

        user = securityContextUser;
    }
View Full Code Here

        user = securityContextUser;
    }

    protected User createUser(String email, boolean activated, boolean passwordExpired) {
        MessageDigestPasswordEncoder passwordEncoder = new MessageDigestPasswordEncoder("SHA-256", true);
        User user = new User();
        user.setEmail(email);
        user.setFirstName("John");
        user.setLastName("Doe");
        user.setUsername(email);
        user.setPassword(passwordEncoder.encodePassword("1234", user.getEmail()));
        user.setActivationCode(UUID.randomUUID().toString());
        user.setActivated(activated);
        user.setPasswordExpired(passwordExpired);
        user.getUuid();

        userService.add(user);
        assertTrue(userService.doesEntityExist(user.getId()));

        return user;
    }
View Full Code Here

    @Autowired(required = true)
    private UserService userService;

    @Test
    public void loadUserByUsernameTest() {
        User user = getUserWithSecurityContext();
        userService.add(user);

        user = userDetailsService.loadUserByUsername(user.getEmail());
        assertNotNull(user);
    }
View Full Code Here

//        assertTrue(userDetails.getUsername().equals(user.getEmail()));
//    }

    @Test
    public void loadUserDetailsByEmailTest() {
        User user = getUserWithSecurityContext();
        userService.add(user);
        Set<String> openIdIdentifiers = new HashSet<String>();
        openIdIdentifiers.add("oldOpenIdIdentifier");
        user.setOpenIdIdentifiers(openIdIdentifiers);

        OpenIDAuthenticationToken token = mock(OpenIDAuthenticationToken.class);
        when(token.getName()).thenReturn("newOpenIdIdentifier");
        List<OpenIDAttribute> attributes = new ArrayList<OpenIDAttribute>();
        List<String> attributeValues = new ArrayList<String>();
        attributeValues.add(user.getEmail());
        OpenIDAttribute attribute = new OpenIDAttribute("email", "", attributeValues);
        attributes.add(attribute);
        when(token.getAttributes()).thenReturn(attributes);

        UserDetails userDetails = userDetailsService.loadUserDetails(token);
        assertNotNull(userDetails);
        assertTrue(userDetails.getUsername().equals(user.getEmail()));
    }
View Full Code Here

    }

    @Override
    public void removeUserDomainFromDomain(Long domainId, Long userId) {
        if (domainId != null && domainId > 0 && userId != null && userId > 0) {
            User user = userService.get(userId);
            if (user != null && user.getUserDomains() != null) {
                UserDomain userDomain = userDomainDao.getUserDomain(user, domainId);

                if (userDomain != null) {
                    if (user.getUserDomains().contains(userDomain)) {
                        user.getUserDomains().remove(userDomain);
                    }

                    userDomainDao.delete(userDomain);
                }
            }
View Full Code Here

TOP

Related Classes of com.sparc.knappsack.components.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.