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


Java HttpServerExchange.setResponseCookie方法代码示例

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


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

示例1: signIn

import io.undertow.server.HttpServerExchange; //导入方法依赖的package包/类
public void signIn(HttpServerExchange exchange) {
    String id = exchange.getRelativePath().substring(1);
    boolean redirect = exchange.getQueryParameters().get("redirect") != null;

    AuthService service = services.get(id);
    if (service != null) {
        String state = service.generateState();
        if (redirect) {
            exchange.setResponseCookie(new CookieImpl("pxls-auth-redirect", "1").setPath("/"));
            redirect(exchange, service.getRedirectUrl(state+"|redirect"));
        } else {
            respond(exchange, StatusCodes.OK, new SignInResponse(service.getRedirectUrl(state+"|json")));
        }
    } else {
        respond(exchange, StatusCodes.BAD_REQUEST, new Error("bad_service", "No auth method named " + id));
    }
}
 
开发者ID:xSke,项目名称:Pxls,代码行数:18,代码来源:WebHandler.java

示例2: setSessionId

import io.undertow.server.HttpServerExchange; //导入方法依赖的package包/类
@Override
public void setSessionId(final HttpServerExchange exchange, final String sessionId) {
    Cookie cookie = new CookieImpl(cookieName, sessionId)
            .setPath(path)
            .setDomain(domain)
            .setDiscard(discard)
            .setSecure(secure)
            .setHttpOnly(httpOnly)
            .setComment(comment);
    if (maxAge > 0) {
        cookie.setMaxAge(maxAge);
    }
    exchange.setResponseCookie(cookie);
    exchange.getRequestCookies().put(cookieName, cookie);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:16,代码来源:SessionCookieConfig.java

示例3: clearSession

import io.undertow.server.HttpServerExchange; //导入方法依赖的package包/类
@Override
public void clearSession(final HttpServerExchange exchange, final String sessionId) {
    Cookie cookie = new CookieImpl(cookieName, sessionId)
            .setPath(path)
            .setDomain(domain)
            .setDiscard(discard)
            .setSecure(secure)
            .setHttpOnly(httpOnly)
            .setMaxAge(0);
    exchange.setResponseCookie(cookie);
    exchange.getRequestCookies().remove(cookieName);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:13,代码来源:SessionCookieConfig.java

示例4: setAuthCookie

import io.undertow.server.HttpServerExchange; //导入方法依赖的package包/类
private void setAuthCookie(HttpServerExchange exchange, String loginToken, int days) {
    Calendar cal2 = Calendar.getInstance();
    cal2.add(Calendar.DATE, -1);
    exchange.setResponseCookie(new CookieImpl("pxls-token", loginToken).setPath("/").setExpires(cal2.getTime()));
    Calendar cal = Calendar.getInstance();
    cal.add(Calendar.DATE, days);
    String hostname = App.getConfig().getString("host");
    exchange.setResponseCookie(new CookieImpl("pxls-token", loginToken).setHttpOnly(true).setPath("/").setDomain("." + hostname).setExpires(cal.getTime()));
    exchange.setResponseCookie(new CookieImpl("pxls-token", loginToken).setHttpOnly(true).setPath("/").setDomain(hostname).setExpires(cal.getTime()));
}
 
开发者ID:xSke,项目名称:Pxls,代码行数:11,代码来源:WebHandler.java

示例5: writeAttribute

import io.undertow.server.HttpServerExchange; //导入方法依赖的package包/类
@Override
public void writeAttribute(final HttpServerExchange exchange, final String newValue) throws ReadOnlyAttributeException {
    exchange.setResponseCookie(new CookieImpl(cookieName, newValue));
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:5,代码来源:CookieAttribute.java


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