public class ConstraintSecurityHandler extends SecurityHandler implements ConstraintAware
Handler to enforce SecurityConstraints. This implementation is servlet spec 3.1 compliant and pre-computes the constraint combinations for runtime efficiency.
SecurityHandler.NotCheckedorg.eclipse.jetty.server.handler.AbstractHandler.ErrorDispatchHandlerorg.eclipse.jetty.util.component.AbstractLifeCycle.AbstractLifeCycleListener__NO_USER, __NOBODY| 构造器和说明 |
|---|
ConstraintSecurityHandler() |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
addConstraintMapping(ConstraintMapping mapping)
Add a Constraint Mapping.
|
void |
addRole(String role)
Add a Role definition.
|
boolean |
checkPathsWithUncoveredHttpMethods()
Servlet spec 3.1 pg. 147.
|
protected boolean |
checkUserDataPermissions(String pathInContext,
org.eclipse.jetty.server.Request request,
org.eclipse.jetty.server.Response response,
RoleInfo roleInfo) |
protected boolean |
checkWebResourcePermissions(String pathInContext,
org.eclipse.jetty.server.Request request,
org.eclipse.jetty.server.Response response,
Object constraintInfo,
org.eclipse.jetty.server.UserIdentity userIdentity) |
protected void |
configureRoleInfo(RoleInfo ri,
ConstraintMapping mapping)
Initialize or update the RoleInfo from the constraint
|
static org.eclipse.jetty.util.security.Constraint |
createConstraint() |
static org.eclipse.jetty.util.security.Constraint |
createConstraint(org.eclipse.jetty.util.security.Constraint constraint) |
static org.eclipse.jetty.util.security.Constraint |
createConstraint(String name,
boolean authenticate,
String[] roles,
int dataConstraint)
Create a security constraint
|
static org.eclipse.jetty.util.security.Constraint |
createConstraint(String name,
javax.servlet.HttpConstraintElement element)
Create a Constraint
|
static org.eclipse.jetty.util.security.Constraint |
createConstraint(String name,
String[] rolesAllowed,
javax.servlet.annotation.ServletSecurity.EmptyRoleSemantic permitOrDeny,
javax.servlet.annotation.ServletSecurity.TransportGuarantee transport)
Create Constraint
|
static List<ConstraintMapping> |
createConstraintsWithMappingsForPath(String name,
String pathSpec,
javax.servlet.ServletSecurityElement securityElement)
Generate Constraints and ContraintMappings for the given url pattern and ServletSecurityElement
|
protected void |
doStart() |
protected void |
doStop() |
void |
dump(Appendable out,
String indent) |
List<ConstraintMapping> |
getConstraintMappings() |
static List<ConstraintMapping> |
getConstraintMappingsForPath(String pathSpec,
List<ConstraintMapping> constraintMappings) |
protected Set<String> |
getOmittedMethods(String omission)
Given a string of the form
<method>. |
Set<String> |
getPathsWithUncoveredHttpMethods()
Servlet spec 3.1 pg. 147.
|
Set<String> |
getRoles() |
protected boolean |
isAuthMandatory(org.eclipse.jetty.server.Request baseRequest,
org.eclipse.jetty.server.Response base_response,
Object constraintInfo) |
boolean |
isDenyUncoveredHttpMethods() |
protected boolean |
omissionsExist(String path,
Map<String,RoleInfo> methodMappings)
Check if any http method omissions exist in the list of method
to auth info mappings.
|
protected RoleInfo |
prepareConstraintInfo(String pathInContext,
org.eclipse.jetty.server.Request request)
Find constraints that apply to the given path.
|
protected void |
processConstraintMapping(ConstraintMapping mapping)
Create and combine the constraint with the existing processed
constraints.
|
protected void |
processConstraintMappingWithMethodOmissions(ConstraintMapping mapping,
Map<String,RoleInfo> mappings)
Constraints that name method omissions are dealt with differently.
|
static List<ConstraintMapping> |
removeConstraintMappingsForPath(String pathSpec,
List<ConstraintMapping> constraintMappings)
Take out of the constraint mappings those that match the
given path.
|
void |
setConstraintMappings(ConstraintMapping[] constraintMappings)
Process the constraints following the combining rules in Servlet 3.0 EA
spec section 13.7.1 Note that much of the logic is in the RoleInfo class.
|
void |
setConstraintMappings(List<ConstraintMapping> constraintMappings)
Process the constraints following the combining rules in Servlet 3.0 EA
spec section 13.7.1 Note that much of the logic is in the RoleInfo class.
|
void |
setConstraintMappings(List<ConstraintMapping> constraintMappings,
Set<String> roles)
Process the constraints following the combining rules in Servlet 3.0 EA
spec section 13.7.1 Note that much of the logic is in the RoleInfo class.
|
void |
setDenyUncoveredHttpMethods(boolean deny)
See Servlet Spec 31, sec 13.8.4, pg 145
When true, requests with http methods not explicitly covered either by inclusion or omissions
in constraints, will have access denied.
|
void |
setRoles(Set<String> roles)
Set the known roles.
|
checkSecurity, findIdentityService, findLoginService, getAuthenticator, getAuthenticatorFactory, getAuthMethod, getCurrentSecurityHandler, getIdentityService, getInitParameter, getInitParameterNames, getLoginService, getRealmName, handle, isCheckWelcomeFiles, isSessionRenewedOnAuthentication, logout, setAuthenticator, setAuthenticatorFactory, setAuthMethod, setCheckWelcomeFiles, setIdentityService, setInitParameter, setLoginService, setRealmName, setSessionRenewedOnAuthenticationdestroy, expandChildren, getHandler, getHandlers, insertHandler, setHandlerexpandHandler, findContainerOf, getChildHandlerByClass, getChildHandlers, getChildHandlersByClass, setServeraddBean, addBean, addBean, addEventListener, addManaged, contains, dump, dump, dump, dump, dumpBeans, dumpObject, dumpStdErr, getBean, getBeans, getBeans, isManaged, manage, removeBean, removeBeans, removeEventListener, setBeans, setStopTimeout, start, stop, unmanage, updateBean, updateBean, updateBeansaddLifeCycleListener, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stoppublic static org.eclipse.jetty.util.security.Constraint createConstraint()
public static org.eclipse.jetty.util.security.Constraint createConstraint(org.eclipse.jetty.util.security.Constraint constraint)
public static org.eclipse.jetty.util.security.Constraint createConstraint(String name, boolean authenticate, String[] roles, int dataConstraint)
name - the name of the constraintauthenticate - true to authenticateroles - list of rolesdataConstraint - the data constraintpublic static org.eclipse.jetty.util.security.Constraint createConstraint(String name, javax.servlet.HttpConstraintElement element)
name - the nameelement - the http constraint elementpublic static org.eclipse.jetty.util.security.Constraint createConstraint(String name, String[] rolesAllowed, javax.servlet.annotation.ServletSecurity.EmptyRoleSemantic permitOrDeny, javax.servlet.annotation.ServletSecurity.TransportGuarantee transport)
name - the namerolesAllowed - the list of allowed rolespermitOrDeny - the permission semantictransport - the transport guaranteepublic static List<ConstraintMapping> getConstraintMappingsForPath(String pathSpec, List<ConstraintMapping> constraintMappings)
public static List<ConstraintMapping> removeConstraintMappingsForPath(String pathSpec, List<ConstraintMapping> constraintMappings)
pathSpec - the path specconstraintMappings - a new list minus the matching constraintspublic static List<ConstraintMapping> createConstraintsWithMappingsForPath(String name, String pathSpec, javax.servlet.ServletSecurityElement securityElement)
name - the namepathSpec - the path specsecurityElement - the servlet security elementpublic List<ConstraintMapping> getConstraintMappings()
getConstraintMappings 在接口中 ConstraintAwarepublic Set<String> getRoles()
getRoles 在接口中 ConstraintAwarepublic void setConstraintMappings(List<ConstraintMapping> constraintMappings)
constraintMappings - The constraintMappings to set, from which the set of known roles
is determined.public void setConstraintMappings(ConstraintMapping[] constraintMappings)
constraintMappings - The constraintMappings to set as array, from which the set of known roles
is determined. Needed to retain API compatibility for 7.xpublic void setConstraintMappings(List<ConstraintMapping> constraintMappings, Set<String> roles)
setConstraintMappings 在接口中 ConstraintAwareconstraintMappings - The constraintMappings to set.roles - The known roles (or null to determine them from the mappings)public void setRoles(Set<String> roles)
setConstraintMappings(ConstraintMapping[]) or
setConstraintMappings(List, Set).roles - The known roles (or null to determine them from the mappings)public void addConstraintMapping(ConstraintMapping mapping)
ConstraintAwareaddConstraintMapping 在接口中 ConstraintAwaremapping - the mappingConstraintAware.addConstraintMapping(ConstraintMapping)public void addRole(String role)
ConstraintAwareaddRole 在接口中 ConstraintAwarerole - the roleConstraintAware.addRole(String)protected void doStart()
throws Exception
doStart 在类中 SecurityHandlerExceptionSecurityHandler.doStart()protected void doStop()
throws Exception
doStop 在类中 SecurityHandlerExceptionprotected void processConstraintMapping(ConstraintMapping mapping)
mapping - the constraint mappingprotected void processConstraintMappingWithMethodOmissions(ConstraintMapping mapping, Map<String,RoleInfo> mappings)
mapping - the constraint mappingmappings - the mappings of rolesprotected void configureRoleInfo(RoleInfo ri, ConstraintMapping mapping)
ri - the role infomapping - the constraint mappingprotected RoleInfo prepareConstraintInfo(String pathInContext, org.eclipse.jetty.server.Request request)
protected boolean checkUserDataPermissions(String pathInContext, org.eclipse.jetty.server.Request request, org.eclipse.jetty.server.Response response, RoleInfo roleInfo) throws IOException
checkUserDataPermissions 在类中 SecurityHandlerIOExceptionprotected boolean isAuthMandatory(org.eclipse.jetty.server.Request baseRequest,
org.eclipse.jetty.server.Response base_response,
Object constraintInfo)
isAuthMandatory 在类中 SecurityHandlerprotected boolean checkWebResourcePermissions(String pathInContext, org.eclipse.jetty.server.Request request, org.eclipse.jetty.server.Response response, Object constraintInfo, org.eclipse.jetty.server.UserIdentity userIdentity) throws IOException
public void dump(Appendable out, String indent) throws IOException
dump 在接口中 org.eclipse.jetty.util.component.Dumpabledump 在类中 org.eclipse.jetty.util.component.ContainerLifeCycleIOExceptionpublic void setDenyUncoveredHttpMethods(boolean deny)
ConstraintAwaresetDenyUncoveredHttpMethods 在接口中 ConstraintAwaredeny - true for denied method accessConstraintAware.setDenyUncoveredHttpMethods(boolean)public boolean isDenyUncoveredHttpMethods()
isDenyUncoveredHttpMethods 在接口中 ConstraintAwarepublic boolean checkPathsWithUncoveredHttpMethods()
checkPathsWithUncoveredHttpMethods 在接口中 ConstraintAwarepublic Set<String> getPathsWithUncoveredHttpMethods()
protected boolean omissionsExist(String path, Map<String,RoleInfo> methodMappings)
path - the pathmethodMappings - the method mappingsCopyright © 2017. All rights reserved.