Package org.candlepin.model

Examples of org.candlepin.model.User


        // TODO: test will fail, need to mock the permissions setup

        Set<OwnerPermission> permissions = new HashSet<OwnerPermission>();
        permissions.add(new OwnerPermission(owner, Access.ALL));

        when(userService.findByLogin("user")).thenReturn(new User());

        UserPrincipal expected = new UserPrincipal("user",
                new ArrayList<Permission>(permissions), false);
        assertEquals(expected, this.auth.getPrincipal(request));
    }
View Full Code Here



        Set<OwnerPermission> permissions = new HashSet<OwnerPermission>();
        permissions.add(new OwnerPermission(owner, Access.ALL));

        when(userService.findByLogin("user")).thenReturn(new User());

        UserPrincipal expected = new UserPrincipal("user",
                new ArrayList<Permission>(permissions), false);
        assertEquals(expected, this.auth.getPrincipal(request));
    }
View Full Code Here

    }

    @Test
    public void testUpdateUsersNoLogin() {
        try {
            User user = new User();
            user.setUsername("henri");
            user.setPassword("password");
            userResource.updateUser("JarJarIsMyCopilot", user);
        }
        catch (NotFoundException e) {
            // this is exptected
            return;
View Full Code Here


        Set<OwnerPermission> permissions = new HashSet<OwnerPermission>();
        permissions.add(new OwnerPermission(owner, Access.ALL));

        when(userService.findByLogin("user")).thenReturn(new User());

        UserPrincipal expected = new UserPrincipal("user",
                new ArrayList<Permission>(permissions), false);
        assertEquals(expected, this.auth.getPrincipal(request));
    }
View Full Code Here

    @Override
    public Role createRole(Role role) {
        Set<User> actualUsers = new HashSet<User>();

        for (User user : role.getUsers()) {
            User actualUser = findByLogin(user.getUsername());
            actualUsers.add(actualUser);
        }
        role.setUsers(actualUsers);

        for (PermissionBlueprint permission : role.getPermissions()) {
View Full Code Here

        return role;
    }

    @Override
    public boolean validateUser(String username, String password) {
        User user = this.userCurator.findByLogin(username);
        String hashedPassword = Util.hash(password);

        if (user != null && password != null && hashedPassword != null) {
            return hashedPassword.equals(user.getHashedPassword());
        }

        return false;
    }
View Full Code Here

        @Override
        public User lookup(String username) {
            /* WARNING: Semi-risky business here, we need a user object for the security
             * code to validate, but in this area we seem to only need the username.
             */
            return new User(username, null);
        }
View Full Code Here

        @Override
        public List<User> lookup(Collection<String> keys) {
            List<User> users = new ArrayList<User>();
            for (String username : keys) {
                users.add(new User(username, null));
            }

            return users;
        }
View Full Code Here

    @GET
    @Path("/{username}/roles")
    @Produces(MediaType.APPLICATION_JSON)
    public List<Role> getUserRoles(@PathParam("username")
        @Verify(User.class) String username) {
        User myUser = userService.findByLogin(username);
        List<Role> roles = new LinkedList<Role>();
        Set<User> s = new HashSet<User>();
        s.add(myUser);

        for (Role r : myUser.getRoles()) {
            // Copy onto a detached role object so we can omit users list, which could
            // technically leak information here.
            Role copy = new Role(r.getName());
            copy.setId(r.getId());
            copy.setPermissions(r.getPermissions());
View Full Code Here

     */
    @DELETE
    @Path("/{username}")
    @Produces(MediaType.APPLICATION_JSON)
    public void deleteUser(@PathParam("username") String username) {
        User user = userService.findByLogin(username);
        if (user == null) {
            throw new GoneException(i18n.tr("User {0} not found", username), username);
        }
        else {
            userService.deleteUser(user);
View Full Code Here

TOP

Related Classes of org.candlepin.model.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.