Search in sources :

Example 1 with BusinessService

use of org.springframework.security.access.annotation.BusinessService in project spring-security by spring-projects.

the class SecuredAnnotationDrivenBeanDefinitionParserTests method targetIsSerializableAfterUse.

@Test(expected = AccessDeniedException.class)
public void targetIsSerializableAfterUse() throws Exception {
    try {
        target.someAdminMethod();
    } catch (AuthenticationCredentialsNotFoundException expected) {
    }
    SecurityContextHolder.getContext().setAuthentication(new TestingAuthenticationToken("u", "p", "ROLE_A"));
    BusinessService chompedTarget = (BusinessService) serializeAndDeserialize(target);
    chompedTarget.someAdminMethod();
}
Also used : BusinessService(org.springframework.security.access.annotation.BusinessService) AuthenticationCredentialsNotFoundException(org.springframework.security.authentication.AuthenticationCredentialsNotFoundException) TestingAuthenticationToken(org.springframework.security.authentication.TestingAuthenticationToken) Test(org.junit.Test)

Example 2 with BusinessService

use of org.springframework.security.access.annotation.BusinessService in project spring-security by spring-projects.

the class SecuredAnnotationDrivenBeanDefinitionParserTests method targetIsSerializableBeforeUse.

// SEC-1387
@Test(expected = AuthenticationCredentialsNotFoundException.class)
public void targetIsSerializableBeforeUse() throws Exception {
    BusinessService chompedTarget = (BusinessService) serializeAndDeserialize(target);
    chompedTarget.someAdminMethod();
}
Also used : BusinessService(org.springframework.security.access.annotation.BusinessService) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 BusinessService (org.springframework.security.access.annotation.BusinessService)2 AuthenticationCredentialsNotFoundException (org.springframework.security.authentication.AuthenticationCredentialsNotFoundException)1 TestingAuthenticationToken (org.springframework.security.authentication.TestingAuthenticationToken)1