Class SecurityHandler.PathMethodMapped
- All Implemented Interfaces:
Authenticator.Configuration,Handler,Handler.Container,Handler.Singleton,Request.Handler,Container,Destroyable,Dumpable,Dumpable.DumpableContainer,LifeCycle,Invocable
- Enclosing class:
- 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:
/foomatches/*; any HTTP method results in a constraint withConstraint.Authorization.FORBIDDENandConstraint.Transport.SECURE/releases/jetty-12.1.0.tar.gzmatches both/*and/releases/*; methodGETresults in a constraint withConstraint.Authorization.SPECIFIC_ROLEwith rolereadandConstraint.Transport.SECURE; methodPUTresults in a constraint withConstraint.Authorization.SPECIFIC_ROLEwith rolewriteandConstraint.Transport.SECURE; any other HTTP method results in a constraint withConstraint.Authorization.FORBIDDENandConstraint.Transport.SECURE
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.security.SecurityHandler
SecurityHandler.NotChecked, SecurityHandler.PathMapped, SecurityHandler.PathMethodMappedNested classes/interfaces inherited from class org.eclipse.jetty.server.Handler.Abstract
Handler.Abstract.NonBlockingNested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
AbstractLifeCycle.AbstractLifeCycleListener, AbstractLifeCycle.StopExceptionNested classes/interfaces inherited from interface org.eclipse.jetty.security.Authenticator.Configuration
Authenticator.Configuration.WrapperNested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Container
Container.InheritedListener, Container.ListenerNested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Dumpable
Dumpable.DumpableContainer, Dumpable.DumpAppendableNested classes/interfaces inherited from interface org.eclipse.jetty.server.Handler
Handler.Abstract, Handler.AbstractContainer, Handler.Collection, Handler.Container, Handler.Sequence, Handler.Singleton, Handler.WrapperNested classes/interfaces inherited from interface org.eclipse.jetty.util.thread.Invocable
Invocable.Callable, Invocable.InvocationType, Invocable.ReadyTask, Invocable.TaskNested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle
LifeCycle.ListenerNested classes/interfaces inherited from interface org.eclipse.jetty.server.Request.Handler
Request.Handler.AbortException -
Field Summary
Fields inherited from class org.eclipse.jetty.security.SecurityHandler
SESSION_AUTHENTICATED_ATTRIBUTEFields inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
FAILED, STARTED, STARTING, STOPPED, STOPPINGFields inherited from interface org.eclipse.jetty.util.thread.Invocable
__nonBlocking, NOOP -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected ConstraintgetConstraint(String pathInContext, Request request) put(String pathSpec, String method, Constraint constraint) Associates the givenConstraintto the given request path patten and HTTP method.put(PathSpec pathSpec, String method, Constraint constraint) Associates the givenConstraintto the given request path pattern and HTTP method.voidput(PathSpec pathSpec, List<String> methods, Constraint constraint) Associates the givenConstraintto the given request path pattern and HTTP methods.Methods inherited from class org.eclipse.jetty.security.SecurityHandler
doStart, doStop, findIdentityService, findLoginService, getAuthenticationType, getAuthenticator, getAuthenticatorFactory, getCurrentSecurityHandler, getIdentityService, getKnownAuthenticatorFactories, getLoginService, getParameter, getParameterNames, getRealmName, getSessionMaxInactiveIntervalOnAuthentication, handle, isAuthorized, isSessionRenewedOnAuthentication, redirectToSecure, setAuthenticationType, setAuthenticator, setAuthenticatorFactory, setIdentityService, setLoginService, setParameter, setRealmName, setSessionMaxInactiveIntervalOnAuthentication, setSessionRenewedOnAuthenticationMethods inherited from class org.eclipse.jetty.server.Handler.Wrapper
getHandler, getInvocationType, setHandlerMethods inherited from class org.eclipse.jetty.server.Handler.AbstractContainer
findContainerOf, getDescendant, getDescendants, isDynamic, setDynamic, setServerMethods inherited from class org.eclipse.jetty.server.Handler.Abstract
destroy, getServerMethods 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, updateBeansMethods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
getEventListeners, getState, getState, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, setEventListeners, start, stop, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.eclipse.jetty.util.component.Container
getCachedBeans, getEventListenersMethods inherited from interface org.eclipse.jetty.util.component.Destroyable
destroyMethods inherited from interface org.eclipse.jetty.util.component.Dumpable.DumpableContainer
isDumpableMethods inherited from interface org.eclipse.jetty.server.Handler.Container
getContainer, getDescendant, getDescendants, getDescendantsMethods inherited from interface org.eclipse.jetty.server.Handler.Singleton
getHandlers, getTail, insertHandler, setHandlerMethods 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
-
-
Method Details
-
put
Associates the given
Constraintto the given request path patten and HTTP method.- Parameters:
pathSpec- thePathSpecassociated to the given constraintmethod- the HTTP method associated to the given constraint, ornullor*to indicate all HTTP methodsconstraint- the constraint to associate- Returns:
- the previous constraint associated with the given path and HTTP method,
or
nullis there was no association
-
put
Associates the given
Constraintto the given request path pattern and HTTP method.- Parameters:
pathSpec- thePathSpecassociated to the given constraintmethod- the HTTP method associated to the given constraint, ornullor*to indicate all HTTP methodsconstraint- the constraint to associate- Returns:
- the previous constraint associated with the given path and HTTP method,
or
nullis there was no association
-
put
Associates the given
Constraintto the given request path pattern and HTTP methods.- Parameters:
pathSpec- thePathSpecassociated to the given constraintmethods- the list of HTTP methods associated to the given constraintconstraint- the constraint to associate
-
getConstraint
- Specified by:
getConstraintin classSecurityHandler
-
getKnownRoles
- Overrides:
getKnownRolesin classSecurityHandler
-