當前位置: 首頁>>代碼示例>>Java>>正文


Java DispatcherType.REQUEST屬性代碼示例

本文整理匯總了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);
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:16,代碼來源:ServletSecurityRoleHandler.java

示例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);
    }
}
 
開發者ID:yangfuhai,項目名稱:jboot,代碼行數:37,代碼來源:JbootResourceServlet.java

示例3: getDispatcherType

@Override
public DispatcherType getDispatcherType() {
    if (internalDispatcherType == null) {
        return DispatcherType.REQUEST;
    }

    return this.internalDispatcherType;
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:8,代碼來源:Request.java

示例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);
    }
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:34,代碼來源:DefaultServlet.java

示例5: getDispatcherType

@Override
public DispatcherType getDispatcherType() {
	if (internalDispatcherType == null) {
		return DispatcherType.REQUEST;
	}

	return this.internalDispatcherType;
}
 
開發者ID:how2j,項目名稱:lazycat,代碼行數:8,代碼來源:Request.java

示例6: get

@Override
public Object get(Request request, String name) {
    return (request.internalDispatcherType == null) ? DispatcherType.REQUEST
            : request.internalDispatcherType;
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:5,代碼來源:Request.java

示例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);
    }
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:9,代碼來源:ServletInitialHandler.java

示例8: get

@Override
public Object get(Request request, String name) {
	return (request.internalDispatcherType == null) ? DispatcherType.REQUEST
			: request.internalDispatcherType;
}
 
開發者ID:how2j,項目名稱:lazycat,代碼行數:5,代碼來源:Request.java


注:本文中的javax.servlet.DispatcherType.REQUEST屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。