Class ServletSecurityAnnotationHandler

All Implemented Interfaces:
AnnotationIntrospector.IntrospectableAnnotationHandler

public class ServletSecurityAnnotationHandler extends AnnotationIntrospector.AbstractIntrospectableAnnotationHandler

Inspect a class to see if it has an @ServletSecurity annotation on it, setting up the <security-constraint>s.

A servlet can be defined in:

  • web.xml
  • web-fragment.xml
  • @WebServlet annotation discovered
  • ServletContext.createServlet

The ServletSecurity annotation for a servlet should only be processed iff metadata-complete == false.

  • Constructor Details

    • ServletSecurityAnnotationHandler

      public ServletSecurityAnnotationHandler(WebAppContext wac)
  • Method Details

    • doHandle

      public void doHandle(Class<?> clazz)
      Specified by:
      doHandle in class AnnotationIntrospector.AbstractIntrospectableAnnotationHandler
    • getServletMappings

      protected List<ServletMapping> getServletMappings(String className)
      Get the ServletMappings for the servlet's class.
      Parameters:
      className - the class name
      Returns:
      the servlet mappings for the class
    • constraintsExist

      protected boolean constraintsExist(List<ServletMapping> servletMappings, List<ConstraintMapping> constraintMappings)
      Check if there are already <security-constraint> elements defined that match the url-patterns for the servlet.
      Parameters:
      servletMappings - the servlet mappings
      constraintMappings - the constraint mappings
      Returns:
      true if constraint exists