I need to overload the ServiceValidateController Bean by my own 
configuration bean, but it seems Spring Boot is first using my bean, then 
again the original one and I don't know why.

My bean is called CasOverlayedValidationConfiguration:

@Configuration("casOverlayedValidationConfiguration")
@EnableConfigurationProperties(CasConfigurationProperties.class)
@Order(value = 50000)
public class CasOverlayedValidationConfiguration {

@Autowired
private CasConfigurationProperties casProperties;

@Autowired
@Qualifier("casAttributeEncoder")
private CasAttributeEncoder casAttributeEncoder;

@Autowired
@Qualifier("cas3SuccessView")
private View cas3SuccessView;

@Autowired
@Qualifier("authenticationContextValidator")
private AuthenticationContextValidator authenticationContextValidator;

@Autowired
@Qualifier("defaultAuthenticationSystemSupport")
private AuthenticationSystemSupport authenticationSystemSupport;

@Autowired
@Qualifier("cas20WithoutProxyProtocolValidationSpecification")
private ValidationSpecification 
cas20WithoutProxyProtocolValidationSpecification;

@Autowired
@Qualifier("cas2ServiceFailureView")
private View cas2ServiceFailureView;

@Autowired
@Qualifier("proxy20Handler")
private ProxyHandler proxy20Handler;

@Autowired
@Qualifier("servicesManager")
private ServicesManager servicesManager;

@Autowired
@Qualifier("centralAuthenticationService")
private CentralAuthenticationService centralAuthenticationService;

@Autowired
@Qualifier("defaultArgumentExtractor")
private ArgumentExtractor argumentExtractor;

@Autowired
@Qualifier("defaultMultifactorTriggerSelectionStrategy")
private MultifactorTriggerSelectionStrategy 
multifactorTriggerSelectionStrategy;

@Autowired
private View cas3ServiceSuccessView;

@Autowired
private View cas3ServiceJsonView;


/* 
 Use cas3ServiceSuccessView to be able to release attributes in CAS 2.0 
serviceValidate
 until all CAS Clients are migrated
 */
@Bean
public ServiceValidateController serviceValidateController() {
 final ServiceValidateController c = new ServiceValidateController();
 c.setValidationSpecification(this.
cas20WithoutProxyProtocolValidationSpecification);
 c.setSuccessView(cas3ServiceSuccessView);
 c.setFailureView(cas2ServiceFailureView);
 c.setProxyHandler(proxy20Handler);
 c.setAuthenticationSystemSupport(authenticationSystemSupport);
 c.setServicesManager(servicesManager);
 c.setCentralAuthenticationService(centralAuthenticationService);
 c.setArgumentExtractor(argumentExtractor);
 c.setMultifactorTriggerSelectionStrategy(
multifactorTriggerSelectionStrategy);
 c.setAuthenticationContextValidator(authenticationContextValidator);
 c.setJsonView(cas3ServiceJsonView);
 c.setAuthnContextAttribute(casProperties.getAuthn().getMfa().
getAuthenticationContextAttribute());
 return c;
}

}



The logs show this:


1. First, my bean definition overwrites the one from 


2017-05-04 15:53:22,312 INFO [org.apereo.cas.web.CasWebApplication] - <The 
> following profiles are active: native>
> 2017-05-04 15:53:22,341 INFO 
> [org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext]
>  
> - <Refreshing 
> org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@5e25a92e:
>  
> startup date [Thu May 04 15:53:22 CEST 2017]; parent: 
> org.springframework.context.annotation.AnnotationConfigApplicationContext@387c703b>
> 2017-05-04 15:53:23,372 INFO 
> [org.springframework.beans.factory.support.DefaultListableBeanFactory] -
> <*Overriding bean definition for bean 'serviceValidateController'* with a 
> different definition:
> replacing

[Generic bean: class [org.apereo.cas.web.ServiceValidateController];
> scope=singleton; abstract=false; lazyInit=false; autowireMode=0; 
> dependencyCheck=0; autowireCandidate=true; primary=false; 
> factoryBeanName=null; factoryMethodName=null; initMethodName=null; 
> destroyMethodName=null;
>
> * defined in URL 
> [jar:file:/projects/cas5/cas/build/libs/cas.war!/WEB-INF/lib/cas-server-support-validation-5.0.4.jar!/org/apereo/cas/web/ServiceValidateController.class]]*
> with
> [Root bean: class [null]; scope=; abstract=false; lazyInit=false; 
> autowireMode=3;
> dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=
> *casOverlayedValidationConfiguration*; 
> factoryMethodName=serviceValidateController; initMethodName=null; 
> destroyMethodName=(inferred);
> * defined in class path resource 
> [org/apereo/cas/web/config/CasOverlayedValidationConfiguration.class*]]>



This would be fine.
BUT a second later, it again overwrites my bean with the one from 
"*CasValidationConfiguration.class*", but as Classpath resource:



2017-05-04 15:53:23,380 INFO 
> [org.springframework.beans.factory.support.DefaultListableBeanFactory] -
> <Overriding bean definition for bean 'serviceValidateController' with a 
> different definition:
> replacing [Root bean: class [null];
> scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; 
> autowireCandidate=true; primary=false; 
> factoryBeanName=CasOverlayedValidationConfiguration; 
> factoryMethodName=serviceValidateController;
> initMethodName=null; destroyMethodName=(inferred);
>
> * defined in   class path resource 
> [org/apereo/cas/web/config/CasOverlayedValidationConfiguration.class]]*
> * with*
>   [Root bean: class [null]; scope=; abstract=false; lazyInit=false; 
> autowireMode=3;
>   dependencyCheck=0; autowireCandidate=true; primary=false; 
> factoryBeanName=*casValidationConfiguration*; 
>   factoryMethodName=serviceValidateController; initMethodName=null; 
> destroyMethodName=(inferred); 
>   *defined in class path resource 
> [org/apereo/cas/web/config/CasValidationConfiguration.class*]]>



My overlay is based on the gradle overlay template. It doesn't matter if I 
start the application as a standalone war application using "java -jar 
cas.war", or in Intellij using a local Tomcat 8 Server.

Any ideas?

Thanks Robert

 

-- 
- CAS gitter chatroom: https://gitter.im/apereo/cas
- CAS mailing list guidelines: https://apereo.github.io/cas/Mailing-Lists.html
- CAS documentation website: https://apereo.github.io/cas
- CAS project website: https://github.com/apereo/cas
--- 
You received this message because you are subscribed to the Google Groups "CAS 
Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cas-user+unsubscr...@apereo.org.
To view this discussion on the web visit 
https://groups.google.com/a/apereo.org/d/msgid/cas-user/a06acd49-1dd1-4089-8d68-410e0396a6b8%40apereo.org.

Reply via email to