Class SecurityHandler.PathMethodMapped

java.lang.Object
org.eclipse.jetty.util.component.AbstractLifeCycle
org.eclipse.jetty.util.component.ContainerLifeCycle
org.eclipse.jetty.server.Handler.Abstract
org.eclipse.jetty.server.Handler.AbstractContainer
org.eclipse.jetty.server.Handler.Wrapper
org.eclipse.jetty.security.SecurityHandler
org.eclipse.jetty.security.SecurityHandler.PathMethodMapped
All Implemented Interfaces:
Authenticator.Configuration, org.eclipse.jetty.server.Handler, org.eclipse.jetty.server.Handler.Container, org.eclipse.jetty.server.Handler.Singleton, org.eclipse.jetty.server.Request.Handler, org.eclipse.jetty.util.component.Container, org.eclipse.jetty.util.component.Destroyable, org.eclipse.jetty.util.component.Dumpable, org.eclipse.jetty.util.component.Dumpable.DumpableContainer, org.eclipse.jetty.util.component.LifeCycle, org.eclipse.jetty.util.thread.Invocable
Enclosing class:
SecurityHandler

public static class SecurityHandler.PathMethodMapped extends SecurityHandler

A concrete implementation of SecurityHandler that uses a PathMappings to match request paths to a map of an HTTP method to a Constraint.

The token * is used to indicate all HTTP methods.

Request path matches are sorted from the least significant to the most significant, and the associated constraints are combined in order.

For example:

SecurityHandler.PathMethodMapped handler = new SecurityHandler.PathMethodMapped();
handler.put(PathSpec.from("/*"), "*", Constraint.combine(Constraint.FORBIDDEN, Constraint.SECURE_TRANSPORT));
handler.put(PathSpec.from("/releases/*"), "GET", Constraint.from("read"));
handler.put(PathSpec.from("/releases/*"), "PUT", Constraint.from("write"));

For these request paths:

If there is no match for the request path, then the constraint is assumed to be Constraint.ALLOWED.

If there is no match for the request URI, or no match for the HTTP method, then the constraint is assumed to be Constraint.ALLOWED.

It is therefore good practice to always explicitly configure a constraint for path /* or / and HTTP method *.

  • Nested Class Summary

    Nested classes/interfaces inherited from class org.eclipse.jetty.server.Handler.Abstract

    org.eclipse.jetty.server.Handler.Abstract.NonBlocking

    Nested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle

    org.eclipse.jetty.util.component.AbstractLifeCycle.AbstractLifeCycleListener, org.eclipse.jetty.util.component.AbstractLifeCycle.StopException

    Nested classes/interfaces inherited from interface Authenticator.Configuration

    Authenticator.Configuration.Wrapper

    Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Container

    org.eclipse.jetty.util.component.Container.InheritedListener, org.eclipse.jetty.util.component.Container.Listener

    Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Dumpable

    org.eclipse.jetty.util.component.Dumpable.DumpableContainer, org.eclipse.jetty.util.component.Dumpable.DumpAppendable

    Nested classes/interfaces inherited from interface org.eclipse.jetty.server.Handler

    org.eclipse.jetty.server.Handler.Abstract, org.eclipse.jetty.server.Handler.AbstractContainer, org.eclipse.jetty.server.Handler.Collection, org.eclipse.jetty.server.Handler.Container, org.eclipse.jetty.server.Handler.Sequence, org.eclipse.jetty.server.Handler.Singleton, org.eclipse.jetty.server.Handler.Wrapper

    Nested classes/interfaces inherited from interface org.eclipse.jetty.util.thread.Invocable

    org.eclipse.jetty.util.thread.Invocable.Callable, org.eclipse.jetty.util.thread.Invocable.InvocationType, org.eclipse.jetty.util.thread.Invocable.ReadyTask, org.eclipse.jetty.util.thread.Invocable.Task

    Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle

    org.eclipse.jetty.util.component.LifeCycle.Listener

    Nested classes/interfaces inherited from interface org.eclipse.jetty.server.Request.Handler

    org.eclipse.jetty.server.Request.Handler.AbortException
  • Field Summary

    Fields inherited from class SecurityHandler

    SESSION_AUTHENTICATED_ATTRIBUTE

    Fields inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle

    FAILED, STARTED, STARTING, STOPPED, STOPPING

    Fields inherited from interface org.eclipse.jetty.util.component.Dumpable

    LEGEND

    Fields inherited from interface org.eclipse.jetty.util.thread.Invocable

    __nonBlocking, NOOP
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    PathMethodMapped(org.eclipse.jetty.server.Handler handler)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected Constraint
    getConstraint(String pathInContext, org.eclipse.jetty.server.Request request)
     
    protected Set<String>
     
    put(String pathSpec, String method, Constraint constraint)
    Associates the given Constraint to the given request path patten and HTTP method.
    put(org.eclipse.jetty.http.pathmap.PathSpec pathSpec, String method, Constraint constraint)
    Associates the given Constraint to the given request path pattern and HTTP method.
    void
    put(org.eclipse.jetty.http.pathmap.PathSpec pathSpec, List<String> methods, Constraint constraint)
    Associates the given Constraint to the given request path pattern and HTTP methods.

    Methods inherited from class org.eclipse.jetty.server.Handler.Wrapper

    getHandler, getInvocationType, setHandler

    Methods inherited from class org.eclipse.jetty.server.Handler.AbstractContainer

    findContainerOf, getDescendant, getDescendants, isDynamic, setDynamic, setServer

    Methods inherited from class org.eclipse.jetty.server.Handler.Abstract

    destroy, getServer

    Methods inherited from class org.eclipse.jetty.util.component.ContainerLifeCycle

    addBean, addBean, addEventListener, addManaged, contains, dump, dump, dump, dumpObjects, dumpStdErr, getBean, getBeans, getBeans, getContainedBeans, getContainedBeans, installBean, installBean, isAuto, isManaged, isUnmanaged, manage, removeBean, removeBeans, removeEventListener, setBeans, start, stop, unmanage, updateBean, updateBean, updateBeans, updateBeans

    Methods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle

    getEventListeners, getState, getState, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, setEventListeners, start, stop, toString

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.eclipse.jetty.util.component.Container

    getCachedBeans, getEventListeners

    Methods inherited from interface org.eclipse.jetty.util.component.Destroyable

    destroy

    Methods inherited from interface org.eclipse.jetty.util.component.Dumpable

    dumpSelf

    Methods inherited from interface org.eclipse.jetty.util.component.Dumpable.DumpableContainer

    isDumpable

    Methods inherited from interface org.eclipse.jetty.server.Handler

    getServer, setServer

    Methods inherited from interface org.eclipse.jetty.server.Handler.Container

    getContainer, getDescendant, getDescendants, getDescendants

    Methods inherited from interface org.eclipse.jetty.server.Handler.Singleton

    getHandlers, getTail, insertHandler, setHandler

    Methods inherited from interface org.eclipse.jetty.util.component.LifeCycle

    addEventListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeEventListener, start, stop
  • Constructor Details

    • PathMethodMapped

      public PathMethodMapped()
    • PathMethodMapped

      public PathMethodMapped(org.eclipse.jetty.server.Handler handler)
  • Method Details

    • put

      public Constraint put(String pathSpec, String method, Constraint constraint)

      Associates the given Constraint to the given request path patten and HTTP method.

      Parameters:
      pathSpec - the PathSpec associated to the given constraint
      method - the HTTP method associated to the given constraint, or null or * to indicate all HTTP methods
      constraint - the constraint to associate
      Returns:
      the previous constraint associated with the given path and HTTP method, or null is there was no association
    • put

      public Constraint put(org.eclipse.jetty.http.pathmap.PathSpec pathSpec, String method, Constraint constraint)

      Associates the given Constraint to the given request path pattern and HTTP method.

      Parameters:
      pathSpec - the PathSpec associated to the given constraint
      method - the HTTP method associated to the given constraint, or null or * to indicate all HTTP methods
      constraint - the constraint to associate
      Returns:
      the previous constraint associated with the given path and HTTP method, or null is there was no association
    • put

      public void put(org.eclipse.jetty.http.pathmap.PathSpec pathSpec, List<String> methods, Constraint constraint)

      Associates the given Constraint to the given request path pattern and HTTP methods.

      Parameters:
      pathSpec - the PathSpec associated to the given constraint
      methods - the list of HTTP methods associated to the given constraint
      constraint - the constraint to associate
    • getConstraint

      protected Constraint getConstraint(String pathInContext, org.eclipse.jetty.server.Request request)
      Specified by:
      getConstraint in class SecurityHandler
    • getKnownRoles

      protected Set<String> getKnownRoles()
      Overrides:
      getKnownRoles in class SecurityHandler