Announcement Announcement Module
Collapse
No announcement yet.
Create beans only if multiple profiles are activated Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Create beans only if multiple profiles are activated

    In my webapp I have two profiles as follows:

    I needs to define a single <security:authentication-manager> that includes appropriate <security:authentication-provider> elements depending upon which profiles are active.

    The following works when either ldap or saml profile is active (good):

    Code:
        <beans profile="saml, !ldap">
            <security:authentication-manager alias="authenticationManager">
                <security:authentication-provider ref="samlAuthenticationProvider"/>
            </security:authentication-manager>
        </beans>
        
        <beans profile="ldap, !saml">
            <security:authentication-manager alias="authenticationManager">
                <security:authentication-provider ref="LdapAuthenticationProvider"/>
            </security:authentication-manager>
        </beans>
    However I need to define a 3rd <security:authentication-manager> for the scenario where both profiles are active. I cannot determine how to to that. Specifying profile="ldap, saml" does not work as it creates bean when either ldap or saml mode is active.

    Code:
        <beans profile="ldap, saml">
            <security:authentication-manager alias="authenticationManager">
                <security:authentication-provider ref="LdapAuthenticationProvider"/>
                <security:authentication-provider ref="samlAuthenticationProvider"/>
            </security:authentication-manager>
        </beans>
    I needs to only create the bean if both ldap or saml mode are active. Is this possible? Seems like we need syntax that supports more complex logic like profile="ldap & saml". More generally we need to support parenthesizing, boolean AND as well as OR to allow profile expressions like profile="(((A & B) | C) & !D)

    If this is not supported then what are my options for workaround and shall I file and RFE "Support arbitrary boolean predicates for profile expression"?

    Thank you for your kind help.

  • #2
    I found a workaround here.

    Logical AND can be achieved by nested <beans> element. So if a bean is created on when profile x and y are both active then this is specified as:

    Code:
    <beans profile="x">
        <beans profile="y">
            <bean id="beanOnlyRegisteredIfXandYActive" ... />
        </beans>
    </beans
    
    This addressed my immediate need. I will file an RFE for the more general requirement. Thanks.

    Comment

    Working...
    X