use of org.springframework.security.access.intercept.aopalliance.MethodSecurityInterceptor in project spring-security by spring-projects.
the class GlobalMethodSecurityConfiguration method methodSecurityInterceptor.
/**
* Creates the default MethodInterceptor which is a MethodSecurityInterceptor using
* the following methods to construct it.
* <ul>
* <li>{@link #accessDecisionManager()}</li>
* <li>{@link #afterInvocationManager()}</li>
* <li>{@link #authenticationManager()}</li>
* <li>{@link #methodSecurityMetadataSource()}</li>
* <li>{@link #runAsManager()}</li>
*
* </ul>
*
* <p>
* Subclasses can override this method to provide a different
* {@link MethodInterceptor}.
* </p>
*
* @return
* @throws Exception
*/
@Bean
public MethodInterceptor methodSecurityInterceptor() throws Exception {
this.methodSecurityInterceptor = isAspectJ() ? new AspectJMethodSecurityInterceptor() : new MethodSecurityInterceptor();
methodSecurityInterceptor.setAccessDecisionManager(accessDecisionManager());
methodSecurityInterceptor.setAfterInvocationManager(afterInvocationManager());
methodSecurityInterceptor.setSecurityMetadataSource(methodSecurityMetadataSource());
RunAsManager runAsManager = runAsManager();
if (runAsManager != null) {
methodSecurityInterceptor.setRunAsManager(runAsManager);
}
return this.methodSecurityInterceptor;
}
use of org.springframework.security.access.intercept.aopalliance.MethodSecurityInterceptor in project spring-security by spring-projects.
the class MethodInvocationPrivilegeEvaluatorTests method setUp.
@BeforeEach
public final void setUp() {
SecurityContextHolder.clearContext();
this.interceptor = new MethodSecurityInterceptor();
this.token = new TestingAuthenticationToken("Test", "Password", "ROLE_SOMETHING");
this.adm = mock(AccessDecisionManager.class);
AuthenticationManager authman = mock(AuthenticationManager.class);
this.mds = mock(MethodSecurityMetadataSource.class);
this.interceptor.setAccessDecisionManager(this.adm);
this.interceptor.setAuthenticationManager(authman);
this.interceptor.setSecurityMetadataSource(this.mds);
}
use of org.springframework.security.access.intercept.aopalliance.MethodSecurityInterceptor in project spring-security by spring-projects.
the class GlobalMethodSecurityConfiguration method methodSecurityInterceptor.
/**
* Creates the default MethodInterceptor which is a MethodSecurityInterceptor using
* the following methods to construct it.
* <ul>
* <li>{@link #accessDecisionManager()}</li>
* <li>{@link #afterInvocationManager()}</li>
* <li>{@link #authenticationManager()}</li>
* <li>{@link #runAsManager()}</li>
*
* </ul>
*
* <p>
* Subclasses can override this method to provide a different
* {@link MethodInterceptor}.
* </p>
* @param methodSecurityMetadataSource the default
* {@link MethodSecurityMetadataSource}.
* @return the {@link MethodInterceptor}.
*/
@Bean
public MethodInterceptor methodSecurityInterceptor(MethodSecurityMetadataSource methodSecurityMetadataSource) {
this.methodSecurityInterceptor = isAspectJ() ? new AspectJMethodSecurityInterceptor() : new MethodSecurityInterceptor();
this.methodSecurityInterceptor.setAccessDecisionManager(accessDecisionManager());
this.methodSecurityInterceptor.setAfterInvocationManager(afterInvocationManager());
this.methodSecurityInterceptor.setSecurityMetadataSource(methodSecurityMetadataSource);
RunAsManager runAsManager = runAsManager();
if (runAsManager != null) {
this.methodSecurityInterceptor.setRunAsManager(runAsManager);
}
return this.methodSecurityInterceptor;
}
use of org.springframework.security.access.intercept.aopalliance.MethodSecurityInterceptor in project spring-security by spring-projects.
the class GlobalMethodSecurityConfigurationTests method methodSecurityInterceptorUsesMetadataSourceBeanWhenProxyingDisabled.
@Test
public void methodSecurityInterceptorUsesMetadataSourceBeanWhenProxyingDisabled() {
this.spring.register(CustomMetadataSourceBeanProxyEnabledConfig.class).autowire();
MethodSecurityInterceptor methodInterceptor = (MethodSecurityInterceptor) this.spring.getContext().getBean(MethodInterceptor.class);
MethodSecurityMetadataSource methodSecurityMetadataSource = this.spring.getContext().getBean(MethodSecurityMetadataSource.class);
assertThat(methodInterceptor.getSecurityMetadataSource()).isSameAs(methodSecurityMetadataSource);
}
Aggregations