Select and apply an Authenticator to a request.
The Authenticator may either be directly set on the handler
or it will be created during start() with a call to
either the default or set AuthenticatorFactory.
SecurityHandler has a set of parameters that are used by the Authentication.Configuration. At startup, any context init parameters that start with "org.eclipse.jetty.security." that do not have values in the SecurityHandler init parameters, are copied.
| Modifier and Type | Class and Description |
|---|---|
| public class | |
| public static class | SecurityHandler.
A concrete implementation of |
| Modifier and Type | Field and Description |
|---|---|
| private static final List | |
| private String | |
| private Authenticator | |
| private Authenticator. | |
| private AuthenticationState. | |
| private IdentityService | |
| private LoginService | |
| private final Map | |
| private String | |
| private boolean | |
| private int | |
| private static final Logger | |
| public static String |
| Access | Constructor and Description |
|---|---|
| protected | |
| protected |
| Modifier and Type | Method and Description |
|---|---|
| protected void | doStart()
Overrides org. Starts the managed lifecycle beans in the order they were added. |
| protected void | doStop()
Overrides org. Stops the managed lifecycle beans in the reverse order they were added. |
| protected IdentityService | |
| protected LoginService | Returns: An appropriateLoginService or nullFind an appropriate |
| public String | getAuthenticationType()
Implements org. Returns: the name of the Authenticator |
| public Authenticator | |
| public Authenticator. | |
| protected abstract Constraint | |
| public static SecurityHandler | |
| public IdentityService | Returns: the identityServiceImplements org. Get the identityService. |
| public List | |
| protected Set | |
| public LoginService | Returns: the loginServiceImplements org. Get the loginService. |
| public String | getParameter(String
parameter name key)Implements org. Get a SecurityHandler init parameter |
| public Set | getParameterNames()
Implements org. Get a SecurityHandler init parameter names |
| public String | getRealmName()
Implements org. Returns: the realmName |
| public int | getSessionMaxInactiveIntervalOnAuthentication()
Implements org. Get the interval in seconds, which if non-zero, will be set
with |
| public boolean | handle(Request
the HTTP request to handle request, Response the HTTP response to handle response, Callback the callback to complete when the handling is complete callback)Overrides org. Implements org. Invoked to handle the passed HTTP request and response. |
| protected boolean | |
| public boolean | isSessionRenewedOnAuthentication()
Implements org. Should session ID be renewed on authentication. |
| protected void | |
| public void | |
| public void | |
| public void | |
| public void | setIdentityService(IdentityService
the identityService to set identityService)Set the identityService. |
| public void | |
| public String | Returns: previous valuethe key key, String the init value value)Set an authentication parameter for retrieval via |
| public void | |
| public void | setSessionMaxInactiveIntervalOnAuthentication(int
An interval in seconds; or 0 to not set the interval
on authentication; or a negative number to make the
session never timeout after authentication. seconds)Set the interval in seconds, which if non-zero, will be set with
|
| public void | setSessionRenewedOnAuthentication(boolean
true to renew the authentication on session renew)Set renew the session on Authentication. |
| __knownAuthenticatorFactories | back to summary |
|---|---|
| private static final List<Authenticator. | |
| _authenticationType | back to summary |
|---|---|
| private String _authenticationType | |
| _authenticator | back to summary |
|---|---|
| private Authenticator _authenticator | |
| _authenticatorFactory | back to summary |
|---|---|
| private Authenticator. | |
| _deferred | back to summary |
|---|---|
| private AuthenticationState. | |
| _identityService | back to summary |
|---|---|
| private IdentityService _identityService | |
| _loginService | back to summary |
|---|---|
| private LoginService _loginService | |
| _parameters | back to summary |
|---|---|
| private final Map<String, String> _parameters | |
| _realmName | back to summary |
|---|---|
| private String _realmName | |
| _renewSessionOnAuthentication | back to summary |
|---|---|
| private boolean _renewSessionOnAuthentication | |
| _sessionMaxInactiveIntervalOnAuthentication | back to summary |
|---|---|
| private int _sessionMaxInactiveIntervalOnAuthentication | |
| LOG | back to summary |
|---|---|
| private static final Logger LOG | |
| SESSION_AUTHENTICATED_ATTRIBUTE | back to summary |
|---|---|
| public static String SESSION_AUTHENTICATED_ATTRIBUTE | |
| SecurityHandler | back to summary |
|---|---|
| protected SecurityHandler() | |
| SecurityHandler | back to summary |
|---|---|
| protected SecurityHandler(Handler handler) | |
| doStart | back to summary |
|---|---|
| protected void doStart() throws Exception Overrides org. Doc from org. Starts the managed lifecycle beans in the order they were added.
| |
| doStop | back to summary |
|---|---|
| protected void doStop() throws Exception Overrides org. Doc from org. Stops the managed lifecycle beans in the reverse order they were added.
| |
| findIdentityService | back to summary |
|---|---|
| protected IdentityService findIdentityService() | |
| findLoginService | back to summary |
|---|---|
| protected LoginService findLoginService() Find an appropriate
| |
| getAuthenticationType | back to summary |
|---|---|
| public String getAuthenticationType() Implements org. | |
| getAuthenticator | back to summary |
|---|---|
| public Authenticator getAuthenticator() | |
| getAuthenticatorFactory | back to summary |
|---|---|
public Authenticator.
| |
| getConstraint | back to summary |
|---|---|
| protected abstract Constraint getConstraint(String pathInContext, Request request) | |
| getCurrentSecurityHandler | back to summary |
|---|---|
| public static SecurityHandler getCurrentSecurityHandler() | |
| getIdentityService | back to summary |
|---|---|
| public IdentityService getIdentityService() Implements org. Get the identityService.
| |
| getKnownAuthenticatorFactories | back to summary |
|---|---|
public List
| |
| getKnownRoles | back to summary |
|---|---|
| protected Set | |
| getLoginService | back to summary |
|---|---|
| public LoginService getLoginService() Implements org. Get the loginService.
| |
| getParameter | back to summary |
|---|---|
| public String getParameter(String key) Implements org. Doc from org. Get a SecurityHandler init parameter | |
| getParameterNames | back to summary |
|---|---|
| public Set Implements org. Doc from org. Get a SecurityHandler init parameter names | |
| getRealmName | back to summary |
|---|---|
| public String getRealmName() Implements org. | |
| getSessionMaxInactiveIntervalOnAuthentication | back to summary |
|---|---|
| public int getSessionMaxInactiveIntervalOnAuthentication() Implements org. Doc from org. Get the interval in seconds, which if non-zero, will be set
with
| |
| handle | back to summary |
|---|---|
| public boolean handle(Request request, Response response, Callback callback) throws Exception Overrides org. Implements org. Doc from org. Invoked to handle the passed HTTP request and response. The request is accepted by returning true, then handling must be concluded by completing the passed callback. The handling may be asynchronous, i.e. this method may return true and complete the given callback later, possibly from a different thread. If this method returns false, then the callback must not be invoked and any mutation on the response reversed. Exceptions thrown by this method may be subsequently handled by an error The simplest implementation is:
public boolean handle(Request request, Response response, Callback callback)
{
callback.succeeded();
return true;
}
A HelloWorld implementation is:
public boolean handle(Request request, Response response, Callback callback)
{
response.write(true, ByteBuffer.wrap("Hello World\n".getBytes(StandardCharsets.UTF_8)), callback);
return true;
}
| |
| isAuthorized | back to summary |
|---|---|
| protected boolean isAuthorized(Constraint constraint, AuthenticationState authenticationState) | |
| isSessionRenewedOnAuthentication | back to summary |
|---|---|
| public boolean isSessionRenewedOnAuthentication() Implements org. Doc from org. Should session ID be renewed on authentication.
| |
| redirectToSecure | back to summary |
|---|---|
| protected void redirectToSecure(Request request, Response response, Callback callback) | |
| setAuthenticationType | back to summary |
|---|---|
public void setAuthenticationType(String authenticationType)
| |
| setAuthenticator | back to summary |
|---|---|
| public void setAuthenticator(Authenticator authenticator) Set the authenticator.
| |
| setAuthenticatorFactory | back to summary |
|---|---|
public void setAuthenticatorFactory(Authenticator.
| |
| setIdentityService | back to summary |
|---|---|
| public void setIdentityService(IdentityService identityService) Set the identityService.
| |
| setLoginService | back to summary |
|---|---|
| public void setLoginService(LoginService loginService) Set the loginService.
If a
| |
| setParameter | back to summary |
|---|---|
| public String setParameter(String key, String value) Set an authentication parameter for retrieval via
| |
| setRealmName | back to summary |
|---|---|
public void setRealmName(String realmName)
| |
| setSessionMaxInactiveIntervalOnAuthentication | back to summary |
|---|---|
| public void setSessionMaxInactiveIntervalOnAuthentication(int seconds) Set the interval in seconds, which if non-zero, will be set with
| |
| setSessionRenewedOnAuthentication | back to summary |
|---|---|
| public void setSessionRenewedOnAuthentication(boolean renew) Set renew the session on Authentication. If set to true, then on authentication, the session associated with a request is invalidated and replaced with a new session.
| |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public String | |
| public SecurityHandler | |
| public String | toString()
Overrides java. Implements java. Returns a string representation of this |
| NotChecked | back to summary |
|---|---|
| public NotChecked() | |
| getName | back to summary |
|---|---|
| public String getName() Implements java. Doc from java. Returns the name of this | |
| getSecurityHandler | back to summary |
|---|---|
| public SecurityHandler getSecurityHandler() | |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Implements java. Doc from java. Returns a string representation of this | |
A concrete implementation of SecurityHandler that uses a PathMappings to
match request to a list of Constraints, which are applied in the order of
least significant to most significant.
An example of using this class is:
SecurityHandler.PathMapped handler = new SecurityHandler.PathMapped();
handler.put("/*", Constraint.combine(Constraint.FORBIDDEN, Constraint.SECURE_TRANSPORT);
handler.put("", Constraint.ALLOWED);
handler.put("/login", Constraint.ALLOWED);
handler.put("*.png", Constraint.ANY_TRANSPORT);
handler.put("/admin/*", Constraint.from("admin", "operator"));
handler.put("/admin/super/*", Constraint.from("operator"));
handler.put("/user/*", Constraint.ANY_USER);
handler.put("*.xml", Constraint.FORBIDDEN);
When getConstraint(String, Request) is called, any matching
constraints are sorted into least to most significant with
compare(PathSpec, PathSpec), resulting in the order in which
Constraint#combine(Constraint, Constraint) will be applied.
For example:
"/admin/index.html" matches "/*" and "/admin/*", resulting in a
constraint of Authorization#SPECIFIC_ROLE and Transport#SECURE."/admin/logo.png" matches "/*", "/admin/*" and "*.png", resulting in a
constraint of Authorization#SPECIFIC_ROLE and Transport#ANY."/admin/config.xml" matches "/*", "/admin/*" and "*.xml", resulting in a
constraint of Authorization#FORBIDDEN and Transport#SECURE."/admin/super/index.html" matches "/*", "/admin/*" and "/admin/super/*", resulting in a
constraint of Authorization#SPECIFIC_ROLE and Transport#SECURE.| Modifier and Type | Field and Description |
|---|---|
| private final Set | |
| private final PathMappings |
| Access | Constructor and Description |
|---|---|
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| public int | Returns: -1, 0 or 1the first ps1, PathSpec PathSpec to be compared.the second ps2)PathSpec to be compared.Implements java.
|
| pack-priv int | compare(MappedResource<Constraint>
the first object to be compared. c1, MappedResource<Constraint> the second object to be compared. c2)Implements java. Compares its two arguments for order. |
| public Constraint | |
| protected Constraint | getConstraint(String pathInContext, Request request)
Implements abstract org.
|
| protected Set | |
| protected int | Returns: An integer representing relative precedence betweenPathSpecGroups.The group to rank. group)Get the relative precedence of a |
| public Constraint | |
| public Constraint | |
| public Constraint |
| _knownRoles | back to summary |
|---|---|
| private final Set<String> _knownRoles | |
| _mappings | back to summary |
|---|---|
| private final PathMappings<Constraint> _mappings | |
| PathMapped | back to summary |
|---|---|
| public PathMapped() | |
| PathMapped | back to summary |
|---|---|
| public PathMapped(Handler handler) | |
| compare | back to summary |
|---|---|
| public int compare(PathSpec ps1, PathSpec ps2) Implements java.
| |
| compare | back to summary |
|---|---|
| pack-priv int compare(MappedResource<Constraint> c1, MappedResource<Constraint> c2) Implements java. Doc from java. Compares its two arguments for order. Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.
The implementor must ensure that
The implementor must also ensure that the relation is transitive:
Finally, the implementor must ensure that
| |
| get | back to summary |
|---|---|
| public Constraint get(PathSpec pathSpec) | |
| getConstraint | back to summary |
|---|---|
| protected Constraint getConstraint(String pathInContext, Request request) Implements abstract org.
| |
| getKnownRoles | back to summary |
|---|---|
| protected Set Overrides org.
| |
| pathSpecGroupPrecedence | back to summary |
|---|---|
| protected int pathSpecGroupPrecedence(PathSpecGroup group) Get the relative precedence of a
| |
| put | back to summary |
|---|---|
| public Constraint put(String pathSpec, Constraint constraint) | |
| put | back to summary |
|---|---|
| public Constraint put(PathSpec pathSpec, Constraint constraint) | |
| remove | back to summary |
|---|---|
| public Constraint remove(PathSpec pathSpec) | |