Search in sources :

Example 1 with ExpressionBasedPostInvocationAdvice

use of org.springframework.security.access.expression.method.ExpressionBasedPostInvocationAdvice in project spring-security by spring-projects.

the class PrePostSecured method configureForElAnnotations.

private void configureForElAnnotations() {
    DefaultMethodSecurityExpressionHandler eh = new DefaultMethodSecurityExpressionHandler();
    interceptor.setSecurityMetadataSource(new PrePostAnnotationSecurityMetadataSource(new ExpressionBasedAnnotationAttributeFactory(eh)));
    interceptor.setAccessDecisionManager(adm);
    AfterInvocationProviderManager aim = new AfterInvocationProviderManager();
    aim.setProviders(Arrays.asList(new PostInvocationAdviceProvider(new ExpressionBasedPostInvocationAdvice(eh))));
    interceptor.setAfterInvocationManager(aim);
}
Also used : PostInvocationAdviceProvider(org.springframework.security.access.prepost.PostInvocationAdviceProvider) AfterInvocationProviderManager(org.springframework.security.access.intercept.AfterInvocationProviderManager) ExpressionBasedAnnotationAttributeFactory(org.springframework.security.access.expression.method.ExpressionBasedAnnotationAttributeFactory) ExpressionBasedPostInvocationAdvice(org.springframework.security.access.expression.method.ExpressionBasedPostInvocationAdvice) DefaultMethodSecurityExpressionHandler(org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler) PrePostAnnotationSecurityMetadataSource(org.springframework.security.access.prepost.PrePostAnnotationSecurityMetadataSource)

Example 2 with ExpressionBasedPostInvocationAdvice

use of org.springframework.security.access.expression.method.ExpressionBasedPostInvocationAdvice in project spring-security by spring-projects.

the class GlobalMethodSecurityConfiguration method afterInvocationManager.

/**
	 * Provide a custom {@link AfterInvocationManager} for the default implementation of
	 * {@link #methodSecurityInterceptor()}. The default is null if pre post is not
	 * enabled. Otherwise, it returns a {@link AfterInvocationProviderManager}.
	 *
	 * <p>
	 * Subclasses should override this method to provide a custom
	 * {@link AfterInvocationManager}
	 * </p>
	 *
	 * @return
	 */
protected AfterInvocationManager afterInvocationManager() {
    if (prePostEnabled()) {
        AfterInvocationProviderManager invocationProviderManager = new AfterInvocationProviderManager();
        ExpressionBasedPostInvocationAdvice postAdvice = new ExpressionBasedPostInvocationAdvice(getExpressionHandler());
        PostInvocationAdviceProvider postInvocationAdviceProvider = new PostInvocationAdviceProvider(postAdvice);
        List<AfterInvocationProvider> afterInvocationProviders = new ArrayList<AfterInvocationProvider>();
        afterInvocationProviders.add(postInvocationAdviceProvider);
        invocationProviderManager.setProviders(afterInvocationProviders);
        return invocationProviderManager;
    }
    return null;
}
Also used : PostInvocationAdviceProvider(org.springframework.security.access.prepost.PostInvocationAdviceProvider) AfterInvocationProviderManager(org.springframework.security.access.intercept.AfterInvocationProviderManager) ArrayList(java.util.ArrayList) ExpressionBasedPostInvocationAdvice(org.springframework.security.access.expression.method.ExpressionBasedPostInvocationAdvice) AfterInvocationProvider(org.springframework.security.access.AfterInvocationProvider)

Aggregations

ExpressionBasedPostInvocationAdvice (org.springframework.security.access.expression.method.ExpressionBasedPostInvocationAdvice)2 AfterInvocationProviderManager (org.springframework.security.access.intercept.AfterInvocationProviderManager)2 PostInvocationAdviceProvider (org.springframework.security.access.prepost.PostInvocationAdviceProvider)2 ArrayList (java.util.ArrayList)1 AfterInvocationProvider (org.springframework.security.access.AfterInvocationProvider)1 DefaultMethodSecurityExpressionHandler (org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler)1 ExpressionBasedAnnotationAttributeFactory (org.springframework.security.access.expression.method.ExpressionBasedAnnotationAttributeFactory)1 PrePostAnnotationSecurityMetadataSource (org.springframework.security.access.prepost.PrePostAnnotationSecurityMetadataSource)1