Package org.springframework.security.access

Examples of org.springframework.security.access.AccessDeniedException


        JCUser editorUser = getUser();
        user.setId(USER_ID);
        editorUser.setId(USER_ID + 1);

        when(userService.getCurrentUser()).thenReturn(editorUser);
        doThrow(new AccessDeniedException(StringUtils.EMPTY))
                .when(userService).checkPermissionToEditOtherProfiles(editorUser.getId());

        ModelAndView mav = profileController.showUserSecuritySettings(USER_ID);

        assertViewName(mav, "editProfile");
View Full Code Here


        user.setId(USER_ID);
        EditUserProfileDto userDto = getEditUserProfileDto();
        userDto.setUserProfileDto(new UserProfileDto(user));
        MockHttpServletResponse response = new MockHttpServletResponse();
        when(userService.getCurrentUser()).thenReturn(user);
        doThrow(new AccessDeniedException(StringUtils.EMPTY)).when(userService)
                .checkPermissionToEditOwnProfile(user.getId());
        BindingResult bindingResult = new BeanPropertyBindingResult(userDto, "editedUser");

        profileController.saveEditedProfile(userDto, bindingResult, response);
    }
View Full Code Here

        EditUserProfileDto userDto = getEditUserProfileDto(user);
        userDto.setUserContactsDto(new UserContactsDto(user));

        MockHttpServletResponse response = new MockHttpServletResponse();
        when(userService.getCurrentUser()).thenReturn(user);
        doThrow(new AccessDeniedException(StringUtils.EMPTY)).when(userService)
                .checkPermissionToEditOwnProfile(user.getId());

        BindingResult bindingResult = new BeanPropertyBindingResult(userDto, "editedUser");

        profileController.saveEditedContacts(userDto, bindingResult, response);
View Full Code Here

        editorUser.setId(USER_ID + 1);
        EditUserProfileDto userDto = getEditUserProfileDto(editedUser);
        userDto.setUserProfileDto(new UserProfileDto(editedUser));

        when(userService.getCurrentUser()).thenReturn(editorUser);
        doThrow(new AccessDeniedException(StringUtils.EMPTY)).when(userService)
                .checkPermissionToEditOtherProfiles(editorUser.getId());

        BindingResult bindingResult = new BeanPropertyBindingResult(userDto, "editedUser");

        profileController.saveEditedProfile(userDto, bindingResult, null);
View Full Code Here

        editorUser.setId(USER_ID + 1);
        EditUserProfileDto userDto = getEditUserProfileDto(editedUser);
        userDto.setUserNotificationsDto(new UserNotificationsDto(editedUser));

        when(userService.getCurrentUser()).thenReturn(editorUser);
        doThrow(new AccessDeniedException(StringUtils.EMPTY))
                .when(userService).checkPermissionToEditOtherProfiles(editorUser.getId());

        BindingResult bindingResult = new BeanPropertyBindingResult(userDto, "editedUser");

        profileController.saveEditedNotifications(userDto, bindingResult, null);
View Full Code Here

        editorUser.setId(USER_ID + 1);
        EditUserProfileDto userDto = getEditUserProfileDto(editedUser);
        userDto.setUserSecurityDto(new UserSecurityDto(editedUser));

        when(userService.getCurrentUser()).thenReturn(editorUser);
        doThrow(new AccessDeniedException(StringUtils.EMPTY))
                .when(userService).checkPermissionToEditOtherProfiles(editorUser.getId());

        BindingResult bindingResult = new BeanPropertyBindingResult(userDto, "editedUser");

        profileController.saveEditedSecurity(userDto, bindingResult, null, redirectAttributes);
View Full Code Here

        editorUser.setId(USER_ID + 1);
        EditUserProfileDto userDto = getEditUserProfileDto(editedUser);
        userDto.setUserContactsDto(new UserContactsDto(editedUser));

        when(userService.getCurrentUser()).thenReturn(editorUser);
        doThrow(new AccessDeniedException(StringUtils.EMPTY))
                .when(userService).checkPermissionToEditOtherProfiles(editorUser.getId());

        BindingResult bindingResult = new BeanPropertyBindingResult(userDto, "editedUser");

        profileController.saveEditedContacts(userDto, bindingResult, null);
View Full Code Here

    public void testAddCommentAccessDenied() throws AccessDeniedException, NotFoundException {
        BindingResult bindingResult = mock(BindingResult.class);

        when(bindingResult.hasErrors()).thenReturn(false);
        when(codeReviewService.addComment(anyLong(), anyInt(), anyString()))
            .thenThrow(new AccessDeniedException(null));

        controller.addComment(new CodeReviewCommentDto(), bindingResult, 1L);
    }
View Full Code Here

    public void testEditCommentAccessDenied() throws AccessDeniedException, NotFoundException {
        BindingResult bindingResult = mock(BindingResult.class);

        when(bindingResult.hasErrors()).thenReturn(false);
        when(codeReviewCommentService.updateComment(anyLong(), anyString(), anyLong()))
            .thenThrow(new AccessDeniedException(null));

        controller.editComment(new CodeReviewCommentDto(), bindingResult, BRANCH_ID);
    }
View Full Code Here

    }

    @Test
    public void testLogExceptionWithIncomingAccessDeniedException() throws Exception {
        Log mockLog = replaceLoggerWithMock(prettyLogExceptionResolver);
        AccessDeniedException accessDeniedException = new AccessDeniedException("Access denied");

        MockHttpServletRequest request = new MockHttpServletRequest("POST", "/testing/url/42");
        request.setServerName("testserver.com");
        request.setServerPort(8080);
        request.setContent("12345".getBytes());
View Full Code Here

TOP

Related Classes of org.springframework.security.access.AccessDeniedException

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.