Search in sources :

Example 1 with ObjectPostProcessor

use of org.springframework.security.config.annotation.ObjectPostProcessor in project credhub by cloudfoundry-incubator.

the class Oauth2TestConfiguration method authenticationManagerBuilder.

@Bean
public AuthenticationManagerBuilder authenticationManagerBuilder() {
    final ObjectPostProcessor<Object> objectPostProcessor = new ObjectPostProcessor<Object>() {

        @Override
        public <O extends Object> O postProcess(O object) {
            return object;
        }
    };
    final AuthenticationManagerBuilder authenticationManagerBuilder = new AuthenticationManagerBuilder(objectPostProcessor);
    authenticationManagerBuilder.parentAuthenticationManager(authenticationManager());
    return authenticationManagerBuilder;
}
Also used : ObjectPostProcessor(org.springframework.security.config.annotation.ObjectPostProcessor) AuthenticationManagerBuilder(org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder) Bean(org.springframework.context.annotation.Bean)

Example 2 with ObjectPostProcessor

use of org.springframework.security.config.annotation.ObjectPostProcessor in project hub-alert by blackducksoftware.

the class AuthenticationHandler method createRoleProcessor.

private ObjectPostProcessor<AffirmativeBased> createRoleProcessor() {
    return new ObjectPostProcessor<>() {

        @Override
        public <O extends AffirmativeBased> O postProcess(O affirmativeBased) {
            WebExpressionVoter webExpressionVoter = new WebExpressionVoter();
            DefaultWebSecurityExpressionHandler expressionHandler = new DefaultWebSecurityExpressionHandler();
            expressionHandler.setRoleHierarchy(authorities -> {
                String[] allAlertRoles = retrieveAllowedRoles();
                return AuthorityUtils.createAuthorityList(allAlertRoles);
            });
            webExpressionVoter.setExpressionHandler(expressionHandler);
            affirmativeBased.getDecisionVoters().add(webExpressionVoter);
            return affirmativeBased;
        }
    };
}
Also used : DefaultWebSecurityExpressionHandler(org.springframework.security.web.access.expression.DefaultWebSecurityExpressionHandler) ObjectPostProcessor(org.springframework.security.config.annotation.ObjectPostProcessor) AffirmativeBased(org.springframework.security.access.vote.AffirmativeBased) WebExpressionVoter(org.springframework.security.web.access.expression.WebExpressionVoter)

Example 3 with ObjectPostProcessor

use of org.springframework.security.config.annotation.ObjectPostProcessor in project credhub by cloudfoundry-incubator.

the class OAuth2Configuration method authenticationManagerBuilder.

@Bean
public AuthenticationManagerBuilder authenticationManagerBuilder() {
    final ObjectPostProcessor<Object> objectPostProcessor = new ObjectPostProcessor<Object>() {

        @Override
        public <O extends Object> O postProcess(O object) {
            return object;
        }
    };
    final AuthenticationManagerBuilder authenticationManagerBuilder = new AuthenticationManagerBuilder(objectPostProcessor);
    authenticationManagerBuilder.parentAuthenticationManager(authenticationManager());
    return authenticationManagerBuilder;
}
Also used : ObjectPostProcessor(org.springframework.security.config.annotation.ObjectPostProcessor) AuthenticationManagerBuilder(org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder) Bean(org.springframework.context.annotation.Bean)

Aggregations

ObjectPostProcessor (org.springframework.security.config.annotation.ObjectPostProcessor)3 Bean (org.springframework.context.annotation.Bean)2 AuthenticationManagerBuilder (org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder)2 AffirmativeBased (org.springframework.security.access.vote.AffirmativeBased)1 DefaultWebSecurityExpressionHandler (org.springframework.security.web.access.expression.DefaultWebSecurityExpressionHandler)1 WebExpressionVoter (org.springframework.security.web.access.expression.WebExpressionVoter)1