Class BaseFilterParser

All Implemented Interfaces:
BeanDefinitionParser
Direct Known Subclasses:
AndMatcherParser, AnyParser, AttributeFilterPolicyParser, AttributeRuleParser, BaseAttributeValueMatcherParser, BasePolicyRuleParser, NotMatcherParser, OrMatcherParser, ScriptedMatcherParser

public abstract class BaseFilterParser extends AbstractCustomBeanDefinitionParser
Base class for Spring bean definition parsers within the filter engine configuration.

This base class is responsible for generating an ID for the Spring bean that is unique within all the policy components loaded. This in turn underpins our implementation of referencing in the language.

  • Field Details

    • NAMESPACE

      public static final String NAMESPACE
      Namespace The Top level filters.
      See Also:
    • AFP_ELEMENT_NAME

      public static final QName AFP_ELEMENT_NAME
      Element name.
    • POLICY_REQUIREMENT_RULE

      public static final QName POLICY_REQUIREMENT_RULE
      The PolicyRequirementRule QName.
    • PERMIT_VALUE_RULE

      public static final QName PERMIT_VALUE_RULE
      PermitValueRule.
    • DENY_VALUE_RULE

      public static final QName DENY_VALUE_RULE
      DenyValueRule.
    • QUALIFIED_ID

      public static final String QUALIFIED_ID
      The attribute name for the qualified id.
      See Also:
    • idGen

      private static IdentifierGenerationStrategy idGen
      Generator of unique IDs.
    • LOG

      private static final org.slf4j.Logger LOG
      Class logger.
  • Constructor Details

    • BaseFilterParser

      public BaseFilterParser()
  • Method Details

    • getQualifiedId

      @Nonnull @NotEmpty protected String getQualifiedId(@Nonnull Element configElement, @Nonnull String componentNamespace, @Nullable String localId)
      Generates an ID for a filter engine component. If the given localId is null a random one will be generated.
      Parameters:
      configElement - component configuration element
      componentNamespace - namespace for the component
      localId - local id or null
      Returns:
      unique ID for the component
    • getAbsoluteReference

      @Nonnull @NotEmpty protected String getAbsoluteReference(@Nonnull Element configElement, @Nonnull @NotEmpty String componentNamespace, @Nonnull @NotEmpty String reference)
      Gets the absolute reference given a possibly relative reference.
      Parameters:
      configElement - component configuration element
      componentNamespace - namespace for the component
      reference - Reference to convert into an absolute
      Returns:
      absolute form of the reference
    • doParse

      protected void doParse(@Nonnull Element element, @Nonnull ParserContext parserContext, @Nonnull BeanDefinitionBuilder builder)

      Calculate the qualified id once, and set both the id property as well as a qualified id metadata attribute used by the resolveId(Element, AbstractBeanDefinition, ParserContext) method.

      If we auto-generate a name then we issue a warning so users can (1) correct this, but also so they can make sense of the logging in the filters which uses the id extensively.

      Overrides:
      doParse in class AbstractSingleBeanDefinitionParser
    • resolveId

      @Nonnull @NotEmpty protected String resolveId(@Nonnull Element configElement, @Nonnull AbstractBeanDefinition beanDefinition, @Nonnull ParserContext parserContext)
      Overrides:
      resolveId in class AbstractBeanDefinitionParser
    • isPolicyRule

      protected boolean isPolicyRule(@Nonnull Element element)
      Is this inside a <PolicyRequirementRule> or an permit or deny rule?.

      This is used when parsing the various rules (<MatchFunctorType>) since the bean we summon up depends on where we find ourselves.

      Parameters:
      element - the element under question
      Returns:
      true if it is inside a policy requirement rule, false otherwise.
    • parseCustomElements

      @Nullable public static ManagedList<BeanDefinition> parseCustomElements(@Nullable @NonnullElements Collection<Element> elements, @Nonnull ParserContext parserContext, @Nonnull BeanDefinitionBuilder parentBuilder)
      Parse list of elements into bean definitions. This is like {SpringSupport.parseCustomElements(Collection, ParserContext, BeanDefinitionBuilder) but with qualifiedName warnings.
      Parameters:
      elements - list of elements to parse
      parserContext - current parsing context
      parentBuilder - the builder we are going to insert into
      Returns:
      list of bean definitions