Search code examples
javaspringcas

Is extending an existing webflowconfigurer (of the CAS webflow) feasible?


In this blog post, the subject of creating a new Webflowconfigurer to extend the web flow is covered.

In the examples provided this is done through classes that extend the AbstractCasWebflowConfigurer and introducing new actions that are appended to the webflow through the included process.

Is extending already existing configurers like for instance AcceptableUsagePolicyWebflowConfigurer and overriding some of its methods feasible or is that outside the scope of CAS web flow? If its feasible, what is the correct way to do this? p.s. currently on version 5.3.x


Solution

  • Is extending already existing configurers like for instance AcceptableUsagePolicyWebflowConfigurer and overriding some of its methods feasible or is that outside the scope of CAS web flow?

    Yes, that is feasible.

    If you examine this block, you will find that AcceptableUsagePolicyWebflowConfigurer is only created conditionally, if an existing bean is not already found in the context by the same name. So to provide your own, you just need to register a bean with the same name using your own @Configuration class. Something like this:

        @Bean
        @DependsOn("defaultWebflowConfigurer")
        public CasWebflowConfigurer acceptableUsagePolicyWebflowConfigurer() {
            return new MyAcceptableUsagePolicyWebflowConfigurer(...);
        }
    
        public class MyAcceptableUsagePolicyWebflowConfigurer extends 
                              AcceptableUsagePolicyWebflowConfigurer {}
    

    To learn about how @Configuration classes work in general, you can: