Class ServletSecurityAnnotationHandler

All Implemented Interfaces:

public class ServletSecurityAnnotationHandler extends AnnotationIntrospector.AbstractIntrospectableAnnotationHandler
ServletSecurityAnnotationHandler 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
    • makeConstraint

      protected Constraint makeConstraint(Class servlet, String[] rolesAllowed, javax.servlet.annotation.ServletSecurity.EmptyRoleSemantic permitOrDeny, javax.servlet.annotation.ServletSecurity.TransportGuarantee transport)
      Make a jetty Constraint object, which represents the <auth-constraint> and <user-data-constraint> elements, based on the security annotation.
      servlet - the servlet
      rolesAllowed - the roles allowed
      permitOrDeny - the role / permission semantic
      transport - the transport guarantee
      the constraint
    • getServletMappings

      protected List<ServletMapping> getServletMappings(String className)
      Get the ServletMappings for the servlet's class.
      className - the class name
      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.
      servletMappings - the servlet mappings
      constraintMappings - the constraint mappings
      true if constraint exists