当前位置: 首页>>代码示例>>Java>>正文


Java HttpServerExchange.endExchange方法代码示例

本文整理汇总了Java中io.undertow.server.HttpServerExchange.endExchange方法的典型用法代码示例。如果您正苦于以下问题:Java HttpServerExchange.endExchange方法的具体用法?Java HttpServerExchange.endExchange怎么用?Java HttpServerExchange.endExchange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.undertow.server.HttpServerExchange的用法示例。


在下文中一共展示了HttpServerExchange.endExchange方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handleRequest

import io.undertow.server.HttpServerExchange; //导入方法依赖的package包/类
/**
 * Only allow the request through if successfully authenticated or if authentication is not required.
 *
 * @see io.undertow.server.HttpHandler#handleRequest(io.undertow.server.HttpServerExchange)
 */
@Override
public void handleRequest(final HttpServerExchange exchange) throws Exception {
    if(exchange.isInIoThread()) {
        exchange.dispatch(this);
        return;
    }
    SecurityContext context = exchange.getSecurityContext();
    if (context.authenticate()) {
        if(!exchange.isComplete()) {
           next.handleRequest(exchange);
        }
    } else {
        if(exchange.getResponseCode() >= StatusCodes.BAD_REQUEST && !exchange.isComplete()) {
            ServletRequestContext src = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY);
            src.getOriginalResponse().sendError(exchange.getResponseCode());
        } else {
            exchange.endExchange();
        }
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:26,代码来源:ServletAuthenticationCallHandler.java

示例2: cancel

import io.undertow.server.HttpServerExchange; //导入方法依赖的package包/类
void cancel(final HttpServerExchange exchange) {
    final ProxyConnection connectionAttachment = exchange.getAttachment(CONNECTION);
    if (connectionAttachment != null) {
        ClientConnection clientConnection = connectionAttachment.getConnection();
        UndertowLogger.REQUEST_LOGGER.timingOutRequest(clientConnection.getPeerAddress() + "" + exchange.getRequestURI());
        IoUtils.safeClose(clientConnection);
    } else {
        UndertowLogger.REQUEST_LOGGER.timingOutRequest(exchange.getRequestURI());
    }
    if (exchange.isResponseStarted()) {
        IoUtils.safeClose(exchange.getConnection());
    } else {
        exchange.setResponseCode(StatusCodes.SERVICE_UNAVAILABLE);
        exchange.endExchange();
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:ProxyHandler.java

示例3: handleRequest

import io.undertow.server.HttpServerExchange; //导入方法依赖的package包/类
/**
 * Only allow the request through if successfully authenticated or if authentication is not required.
 *
 * @see io.undertow.server.HttpHandler#handleRequest(io.undertow.server.HttpServerExchange)
 */
@Override
public void handleRequest(final HttpServerExchange exchange) throws Exception {
    if(exchange.isInIoThread()) {
        exchange.dispatch(this);
        return;
    }
    SecurityContext context = exchange.getSecurityContext();
    if (context.authenticate()) {
        if(!exchange.isComplete()) {
           next.handleRequest(exchange);
        }
    } else {
        exchange.endExchange();
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:AuthenticationCallHandler.java

示例4: handleRequest

import io.undertow.server.HttpServerExchange; //导入方法依赖的package包/类
@Override
public void handleRequest(HttpServerExchange exchange) throws Exception {
    Map<String, Object> examples = new HashMap<>();
    if(examples.size() > 0) {
        exchange.getResponseHeaders().add(new HttpString("Content-Type"), "application/json");
        exchange.getResponseSender().send((String)examples.get("application/json"));
    } else {
        exchange.endExchange();
    }
}
 
开发者ID:tnscorcoran,项目名称:light-4-j-plugin-wrapper,代码行数:11,代码来源:ServerInfoGetHandler.java

示例5: handleRequest

import io.undertow.server.HttpServerExchange; //导入方法依赖的package包/类
@Override
public void handleRequest(final HttpServerExchange exchange) throws Exception {

	PluginWrapperClient.doAuthorize(exchange);
	if(exchange.getResponseCode()==403){
		exchange.endExchange();
	}
	else{
		next.handleRequest(exchange);
	}    	
}
 
开发者ID:tnscorcoran,项目名称:light-4-j-plugin-wrapper,代码行数:12,代码来源:CInterceptor.java

示例6: deleteUser

import io.undertow.server.HttpServerExchange; //导入方法依赖的package包/类
public static void deleteUser(HttpServerExchange exchange) {
    String email = userRequests.email(exchange);

    // If you care about it you can handle it.
    if (false == userDao.delete(email)) {
        ApiHandlers.notFound(exchange, String.format("User {} not found.", email));
        return;
    }
    exchange.setStatusCode(StatusCodes.NO_CONTENT);
    exchange.endExchange();
}
 
开发者ID:StubbornJava,项目名称:StubbornJava,代码行数:12,代码来源:UserRoutes.java

示例7: couldNotResolveBackend

import io.undertow.server.HttpServerExchange; //导入方法依赖的package包/类
@Override
public void couldNotResolveBackend(HttpServerExchange exchange) {
    if (exchange.isResponseStarted()) {
        IoUtils.safeClose(exchange.getConnection());
    } else {
        exchange.setResponseCode(StatusCodes.SERVICE_UNAVAILABLE);
        exchange.endExchange();
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:ProxyHandler.java

示例8: runFormAuth

import io.undertow.server.HttpServerExchange; //导入方法依赖的package包/类
public AuthenticationMechanismOutcome runFormAuth(final HttpServerExchange exchange, final SecurityContext securityContext) {
    final FormDataParser parser = formParserFactory.createParser(exchange);
    if (parser == null) {
        UndertowLogger.REQUEST_LOGGER.debug("Could not authenticate as no form parser is present");
        // TODO - May need a better error signaling mechanism here to prevent repeated attempts.
        return AuthenticationMechanismOutcome.NOT_AUTHENTICATED;
    }

    try {
        final FormData data = parser.parseBlocking();
        final FormData.FormValue jUsername = data.getFirst("j_username");
        final FormData.FormValue jPassword = data.getFirst("j_password");
        if (jUsername == null || jPassword == null) {
            UndertowLogger.REQUEST_LOGGER.debug("Could not authenticate as username or password was not present in the posted result");
            return AuthenticationMechanismOutcome.NOT_AUTHENTICATED;
        }
        final String userName = jUsername.getValue();
        final String password = jPassword.getValue();
        AuthenticationMechanismOutcome outcome = null;
        PasswordCredential credential = new PasswordCredential(password.toCharArray());
        try {
            IdentityManager identityManager = securityContext.getIdentityManager();
            Account account = identityManager.verify(userName, credential);
            if (account != null) {
                securityContext.authenticationComplete(account, name, true);
                outcome = AuthenticationMechanismOutcome.AUTHENTICATED;
            } else {
                securityContext.authenticationFailed(MESSAGES.authenticationFailed(userName), name);
            }
        } finally {
            if (outcome == AuthenticationMechanismOutcome.AUTHENTICATED) {
                handleRedirectBack(exchange);
                exchange.endExchange();
            }
            return outcome != null ? outcome : AuthenticationMechanismOutcome.NOT_AUTHENTICATED;
        }
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:41,代码来源:FormAuthenticationMechanism.java

示例9: handleRequest

import io.undertow.server.HttpServerExchange; //导入方法依赖的package包/类
@Override
public void handleRequest(final HttpServerExchange exchange) throws Exception {
    InetSocketAddress peer = exchange.getSourceAddress();
    if (isAllowed(peer.getAddress())) {
        next.handleRequest(exchange);
    } else {
        exchange.setResponseCode(denyResponseCode);
        exchange.endExchange();
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:11,代码来源:IPAddressAccessControlHandler.java

示例10: handleRequest

import io.undertow.server.HttpServerExchange; //导入方法依赖的package包/类
@Override
public void handleRequest(final HttpServerExchange exchange) throws Exception {
    if (disallowedMethods.contains(exchange.getRequestMethod())) {
        exchange.setResponseCode(StatusCodes.METHOD_NOT_ALLOWED);
        exchange.endExchange();
    } else {
        next.handleRequest(exchange);
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:DisallowedMethodsHandler.java

示例11: report

import io.undertow.server.HttpServerExchange; //导入方法依赖的package包/类
public void report(HttpServerExchange exchange) {
    User user = exchange.getAttachment(AuthReader.USER);

    if (user == null) {
        exchange.setStatusCode(StatusCodes.BAD_REQUEST);
        exchange.endExchange();
        return;
    }

    FormData data = exchange.getAttachment(FormDataParser.FORM_DATA);

    FormData.FormValue xq = data.getFirst("x");
    FormData.FormValue yq = data.getFirst("y");
    FormData.FormValue idq = data.getFirst("id");
    FormData.FormValue msgq = data.getFirst("message");

    if (xq == null || yq == null || idq == null || msgq == null) {
        exchange.setStatusCode(StatusCodes.BAD_REQUEST);
        exchange.endExchange();
        return;
    }
    int x = Integer.parseInt(xq.getValue());
    int y = Integer.parseInt(yq.getValue());
    int id = Integer.parseInt(idq.getValue());
    if (x < 0 || x >= App.getWidth() || y < 0 || y >= App.getHeight()) {
        exchange.setStatusCode(StatusCodes.BAD_REQUEST);
        exchange.endExchange();
        return;
    }
    DBPixelPlacement pxl = App.getDatabase().getPixelByID(id);
    if (pxl.x != x || pxl.y != y) {
        exchange.setStatusCode(StatusCodes.BAD_REQUEST);
        exchange.endExchange();
        return;
    }
    App.getDatabase().addReport(user.getId(), id, x, y, msgq.getValue());
    exchange.setStatusCode(200);
}
 
开发者ID:xSke,项目名称:Pxls,代码行数:39,代码来源:WebHandler.java

示例12: temporary

import io.undertow.server.HttpServerExchange; //导入方法依赖的package包/类
default void temporary(HttpServerExchange exchange, String location) {
    exchange.setStatusCode(StatusCodes.FOUND);
    exchange.getResponseHeaders().put(Headers.LOCATION, location);
    exchange.endExchange();
}
 
开发者ID:StubbornJava,项目名称:StubbornJava,代码行数:6,代码来源:RedirectSenders.java

示例13: respond

import io.undertow.server.HttpServerExchange; //导入方法依赖的package包/类
private void respond(HttpServerExchange exchange, int code, Object obj) {
    exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, "application/json");
    exchange.setStatusCode(code);
    exchange.getResponseSender().send(App.getGson().toJson(obj));
    exchange.endExchange();
}
 
开发者ID:xSke,项目名称:Pxls,代码行数:7,代码来源:WebHandler.java

示例14: onException

import io.undertow.server.HttpServerExchange; //导入方法依赖的package包/类
@Override
public void onException(final HttpServerExchange exchange, final Sender sender, final IOException exception) {
    UndertowLogger.REQUEST_IO_LOGGER.ioException(exception);
    cache.dereference();
    exchange.endExchange();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:7,代码来源:ResponseCache.java

示例15: referer

import io.undertow.server.HttpServerExchange; //导入方法依赖的package包/类
default void referer(HttpServerExchange exchange) {
    exchange.setStatusCode(StatusCodes.FOUND);
    exchange.getResponseHeaders().put(Headers.LOCATION, exchange.getRequestHeaders().get(Headers.REFERER, 0));
    exchange.endExchange();
}
 
开发者ID:StubbornJava,项目名称:StubbornJava,代码行数:6,代码来源:RedirectSenders.java


注:本文中的io.undertow.server.HttpServerExchange.endExchange方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。