本文整理匯總了Java中javax.servlet.DispatcherType.REQUEST屬性的典型用法代碼示例。如果您正苦於以下問題:Java DispatcherType.REQUEST屬性的具體用法?Java DispatcherType.REQUEST怎麽用?Java DispatcherType.REQUEST使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類javax.servlet.DispatcherType
的用法示例。
在下文中一共展示了DispatcherType.REQUEST屬性的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: handleRequest
@Override
public void handleRequest(final HttpServerExchange exchange) throws Exception {
final ServletRequestContext servletRequestContext = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY);
ServletRequest request = servletRequestContext.getServletRequest();
if (request.getDispatcherType() == DispatcherType.REQUEST) {
List<SingleConstraintMatch> constraints = servletRequestContext.getRequiredConstrains();
SecurityContext sc = exchange.getSecurityContext();
if (!authorizationManager.canAccessResource(constraints, sc.getAuthenticatedAccount(), servletRequestContext.getCurrentServlet().getManagedServlet().getServletInfo(), servletRequestContext.getOriginalRequest(), servletRequestContext.getDeployment())) {
HttpServletResponse response = (HttpServletResponse) servletRequestContext.getServletResponse();
response.sendError(StatusCodes.FORBIDDEN);
return;
}
}
next.handleRequest(exchange);
}
示例2: isAllowed
private boolean isAllowed(String path, DispatcherType dispatcherType) {
if (!path.isEmpty()) {
if (dispatcherType == DispatcherType.REQUEST) {
//WFLY-3543 allow the dispatcher to access stuff in web-inf and meta inf
if (path.startsWith("/META-INF") ||
path.startsWith("META-INF") ||
path.startsWith("/WEB-INF") ||
path.startsWith("WEB-INF")) {
return false;
}
}
}
if (defaultAllowed && disallowed.isEmpty()) {
return true;
}
int pos = path.lastIndexOf('/');
final String lastSegment;
if (pos == -1) {
lastSegment = path;
} else {
lastSegment = path.substring(pos + 1);
}
if (lastSegment.isEmpty()) {
return true;
}
int ext = lastSegment.lastIndexOf('.');
if (ext == -1) {
//no extension
return true;
}
final String extension = lastSegment.substring(ext + 1, lastSegment.length()).toLowerCase();
if (defaultAllowed) {
return !disallowed.contains(extension);
} else {
return allowed.contains(extension);
}
}
示例3: getDispatcherType
@Override
public DispatcherType getDispatcherType() {
if (internalDispatcherType == null) {
return DispatcherType.REQUEST;
}
return this.internalDispatcherType;
}
示例4: isAllowed
private boolean isAllowed(String path, DispatcherType dispatcherType) {
if (!path.isEmpty()) {
if(dispatcherType == DispatcherType.REQUEST) {
//WFLY-3543 allow the dispatcher to access stuff in web-inf and meta inf
if (path.startsWith("/META-INF") ||
path.startsWith("META-INF") ||
path.startsWith("/WEB-INF") ||
path.startsWith("WEB-INF")) {
return false;
}
}
}
int pos = path.lastIndexOf('/');
final String lastSegment;
if (pos == -1) {
lastSegment = path;
} else {
lastSegment = path.substring(pos + 1);
}
if (lastSegment.isEmpty()) {
return true;
}
int ext = lastSegment.lastIndexOf('.');
if (ext == -1) {
//no extension
return true;
}
final String extension = lastSegment.substring(ext + 1, lastSegment.length());
if (defaultAllowed) {
return !disallowed.contains(extension);
} else {
return allowed.contains(extension);
}
}
示例5: getDispatcherType
@Override
public DispatcherType getDispatcherType() {
if (internalDispatcherType == null) {
return DispatcherType.REQUEST;
}
return this.internalDispatcherType;
}
示例6: get
@Override
public Object get(Request request, String name) {
return (request.internalDispatcherType == null) ? DispatcherType.REQUEST
: request.internalDispatcherType;
}
示例7: dispatchRequest
private void dispatchRequest(final HttpServerExchange exchange, final ServletRequestContext servletRequestContext, final ServletChain servletChain, final DispatcherType dispatcherType) throws Exception {
servletRequestContext.setDispatcherType(dispatcherType);
servletRequestContext.setCurrentServlet(servletChain);
if (dispatcherType == DispatcherType.REQUEST || dispatcherType == DispatcherType.ASYNC) {
handleFirstRequest(exchange, servletChain, servletRequestContext, servletRequestContext.getServletRequest(), servletRequestContext.getServletResponse());
} else {
next.handleRequest(exchange);
}
}
示例8: get
@Override
public Object get(Request request, String name) {
return (request.internalDispatcherType == null) ? DispatcherType.REQUEST
: request.internalDispatcherType;
}