Package org.springframework.security.access

Examples of org.springframework.security.access.AccessDeniedException


        MockHttpServletRequest request = new MockHttpServletRequest();
        request.setServletPath("/secure/page.html");

        // Setup the FilterChain to thrown an access denied exception
        FilterChain fc = mock(FilterChain.class);
        doThrow(new AccessDeniedException("")).when(fc).doFilter(any(HttpServletRequest.class), any(HttpServletResponse.class));

        // Setup SecurityContextHolder, as filter needs to check if user is
        // anonymous
        SecurityContextHolder.clearContext();
View Full Code Here


    @Test
    public void deniesAccessIfAccessDecisionMangerDoes() throws Exception {
        Authentication token = new TestingAuthenticationToken("test", "Password", "MOCK_INDEX");
        DefaultWebInvocationPrivilegeEvaluator wipe = new DefaultWebInvocationPrivilegeEvaluator(interceptor);

        doThrow(new AccessDeniedException("")).when(adm).decide(any(Authentication.class), anyObject(), anyList());

        assertFalse(wipe.isAllowed("/foo/index.jsp", token));
    }
View Full Code Here

    }

    @SuppressWarnings("unchecked")
    @Test
    public void callbackIsNotInvokedWhenPermissionDenied() throws Exception {
        doThrow(new AccessDeniedException("denied")).when(adm).decide(any(Authentication.class), any(), any(Collection.class));

        SecurityContextHolder.getContext().setAuthentication(token);
        try {
            interceptor.invoke(joinPoint, aspectJCallback);
            fail("Expected AccessDeniedException");
View Full Code Here

        Object object = new TargetObject();
        final MethodInvocation mi = MethodInvocationUtils.create(object, "makeLowerCase", "foobar");
        MethodInvocationPrivilegeEvaluator mipe = new MethodInvocationPrivilegeEvaluator();
        mipe.setSecurityInterceptor(interceptor);
        when(mds.getAttributes(mi)).thenReturn(role);
        doThrow(new AccessDeniedException("rejected")).when(adm).decide(token, mi, role);

        assertFalse(mipe.isAllowed(mi, token));
    }
View Full Code Here

                new Class[] {String.class}, new Object[] {"helloWorld"});

        MethodInvocationPrivilegeEvaluator mipe = new MethodInvocationPrivilegeEvaluator();
        mipe.setSecurityInterceptor(interceptor);
        when(mds.getAttributes(mi)).thenReturn(role);
        doThrow(new AccessDeniedException("rejected")).when(adm).decide(token, mi, role);

        assertFalse(mipe.isAllowed(mi, token));
    }
View Full Code Here

        SecurityContextHolder.getContext().setAuthentication(token);
        // Use mocked target to make sure invocation doesn't happen (not in expectations so test would fail)
        createTarget(true);
        mdsReturnsUserRole();
        when(authman.authenticate(token)).thenReturn(token);
        doThrow(new AccessDeniedException("rejected")).when(adm).decide(any(Authentication.class), any(MethodInvocation.class), any(List.class));

        try {
            advisedTarget.makeUpperCase("HELLO");
            fail();
        } catch (AccessDeniedException expected) {
View Full Code Here

    }

    @Test(expected = AccessDeniedException.class)
    public void preSendDeny() throws Exception {
        when(source.getAttributes(message)).thenReturn(attrs);
        doThrow(new AccessDeniedException("")).when(accessDecisionManager).decide(any(Authentication.class), eq(message), eq(attrs));

        interceptor.preSend(message, channel);
    }
View Full Code Here

        }

        // Validate user access (if logged in)
        String remoteUser = request.getRemoteUser();
        if (remoteUser != null && !username.equals(remoteUser)) {
            throw new AccessDeniedException("You do not have permission to modify other users password.");
        }


        // Ensure new password is not empty
        if (StringUtils.isEmpty(newPassword)) {
View Full Code Here

//                          break;
//                      }
//                  }
                  if(!shouldAllow) {
                      // fail the request
                      throw new AccessDeniedException("Access has been denied for your IP address: "+req.getRemoteAddr());
                  }
              }
         } else {
             logger.warn("The IPRoleAuthenticationFilter should be placed after the user has been authenticated in the filter chain.");
         }
View Full Code Here

            chain.doFilter(request, response);
            return;
        }
       
    //process ZkAccessDeniedHandler iframe in errorTemplate
        final AccessDeniedException accessDeniedException =
          (AccessDeniedExceptionsess.getAttribute(WebAttributes.ACCESS_DENIED_403);
       
        if (accessDeniedException != null) {
            //FireFox will fire iframe src request twice.
            //1st on Executions.createComponents, 2nd on doHighlighted (see ZkAccessDeniedHandler)
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.