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


Java WebContext.setResponseHeader方法代码示例

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


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

示例1: isAuthorized

import org.pac4j.core.context.WebContext; //导入方法依赖的package包/类
@Override
public Boolean isAuthorized(WebContext context, List<CommonProfile> profiles) throws HttpAction {
    final String url = context.getFullRequestURL().toLowerCase();
    if (!url.endsWith(".css")
            && !url.endsWith(".js")
            && !url.endsWith(".png")
            && !url.endsWith(".jpg")
            && !url.endsWith(".ico")
            && !url.endsWith(".jpeg")
            && !url.endsWith(".bmp")
            && !url.endsWith(".gif")) {
        context.setResponseHeader("Cache-Control", "no-cache, no-store, max-age=0, must-revalidate");
        context.setResponseHeader("Pragma", "no-cache");
        context.setResponseHeader("Expires", "0");
    }
    return true;
}
 
开发者ID:millross,项目名称:pac4j-async,代码行数:18,代码来源:CacheControlHeader.java

示例2: isAuthorized

import org.pac4j.core.context.WebContext; //导入方法依赖的package包/类
@Override
public boolean isAuthorized(final WebContext context, final List<CommonProfile> profiles) throws HttpAction {
    final String url = context.getFullRequestURL().toLowerCase();
    if (!url.endsWith(".css")
            && !url.endsWith(".js")
            && !url.endsWith(".png")
            && !url.endsWith(".jpg")
            && !url.endsWith(".ico")
            && !url.endsWith(".jpeg")
            && !url.endsWith(".bmp")
            && !url.endsWith(".gif")) {
        context.setResponseHeader("Cache-Control", "no-cache, no-store, max-age=0, must-revalidate");
        context.setResponseHeader("Pragma", "no-cache");
        context.setResponseHeader("Expires", "0");
    }
    return true;
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:18,代码来源:CacheControlHeader.java

示例3: isAuthorized

import org.pac4j.core.context.WebContext; //导入方法依赖的package包/类
@Override
public Boolean isAuthorized(final WebContext context, final List<CommonProfile> profiles) throws HttpAction {
    if (ContextHelper.isHttpsOrSecure(context)) {
        context.setResponseHeader("Strict-Transport-Security", "max-age=" + maxAge + " ; includeSubDomains");
    }
    return true;
}
 
开发者ID:millross,项目名称:pac4j-async,代码行数:8,代码来源:StrictTransportSecurityHeader.java

示例4: isAuthorized

import org.pac4j.core.context.WebContext; //导入方法依赖的package包/类
@Override
public Boolean isAuthorized(WebContext context, List<CommonProfile> profiles) throws HttpAction {

    CommonHelper.assertNotBlank("allowOrigin", allowOrigin);

    context.setResponseHeader(HttpConstants.ACCESS_CONTROL_ALLOW_ORIGIN_HEADER, allowOrigin);

    if (CommonHelper.isNotBlank(exposeHeaders)) {
        context.setResponseHeader(HttpConstants.ACCESS_CONTROL_EXPOSE_HEADERS_HEADER, exposeHeaders);
    }

    if (maxAge != -1) {
        context.setResponseHeader(HttpConstants.ACCESS_CONTROL_MAX_AGE_HEADER, "" + maxAge);
    }

    if (allowCredentials != null) {
        context.setResponseHeader(HttpConstants.ACCESS_CONTROL_ALLOW_CREDENTIALS_HEADER, allowCredentials.toString());
    }

    if (allowMethods != null) {
        final String methods = allowMethods.stream().map(m -> m.toString()).collect(Collectors.joining(", "));
        context.setResponseHeader(HttpConstants.ACCESS_CONTROL_ALLOW_METHODS_HEADER, methods);
    }

    if (CommonHelper.isNotBlank(allowHeaders)) {
        context.setResponseHeader(HttpConstants.ACCESS_CONTROL_ALLOW_HEADERS_HEADER, allowHeaders);
    }

    return true;
}
 
开发者ID:millross,项目名称:pac4j-async,代码行数:31,代码来源:CorsAuthorizer.java

示例5: isAuthorized

import org.pac4j.core.context.WebContext; //导入方法依赖的package包/类
@Override
public boolean isAuthorized(final WebContext context, final List<CommonProfile> profiles) throws HttpAction {
    if (ContextHelper.isHttpsOrSecure(context)) {
        context.setResponseHeader("Strict-Transport-Security", "max-age=" + maxAge + " ; includeSubDomains");
    }
    return true;
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:8,代码来源:StrictTransportSecurityHeader.java

示例6: isAuthorized

import org.pac4j.core.context.WebContext; //导入方法依赖的package包/类
@Override
public boolean isAuthorized(WebContext context, List<CommonProfile> profiles) throws HttpAction {
    CommonHelper.assertNotBlank("allowOrigin", allowOrigin);

    context.setResponseHeader(HttpConstants.ACCESS_CONTROL_ALLOW_ORIGIN_HEADER, allowOrigin);

    if (CommonHelper.isNotBlank(exposeHeaders)) {
        context.setResponseHeader(HttpConstants.ACCESS_CONTROL_EXPOSE_HEADERS_HEADER, exposeHeaders);
    }

    if (maxAge != -1) {
        context.setResponseHeader(HttpConstants.ACCESS_CONTROL_MAX_AGE_HEADER, "" + maxAge);
    }

    if (allowCredentials != null) {
        context.setResponseHeader(HttpConstants.ACCESS_CONTROL_ALLOW_CREDENTIALS_HEADER, allowCredentials.toString());
    }

    if (allowMethods != null) {
        final String methods = allowMethods.stream().map(m -> m.toString()).collect(Collectors.joining(", "));
        context.setResponseHeader(HttpConstants.ACCESS_CONTROL_ALLOW_METHODS_HEADER, methods);
    }

    if (CommonHelper.isNotBlank(allowHeaders)) {
        context.setResponseHeader(HttpConstants.ACCESS_CONTROL_ALLOW_HEADERS_HEADER, allowHeaders);
    }

    return true;
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:30,代码来源:CorsAuthorizer.java

示例7: isAuthorized

import org.pac4j.core.context.WebContext; //导入方法依赖的package包/类
@Override
public Boolean isAuthorized(WebContext context, List<CommonProfile> profiles) throws HttpAction {
    context.setResponseHeader("X-Frame-Options", "DENY");
    return true;
}
 
开发者ID:millross,项目名称:pac4j-async,代码行数:6,代码来源:XFrameOptionsHeader.java

示例8: isAuthorized

import org.pac4j.core.context.WebContext; //导入方法依赖的package包/类
@Override
public Boolean isAuthorized(WebContext context, List<CommonProfile> profiles) throws HttpAction {
    context.setResponseHeader("X-Content-Type-Options", "nosniff");
    return true;
}
 
开发者ID:millross,项目名称:pac4j-async,代码行数:6,代码来源:XContentTypeOptionsHeader.java

示例9: isAuthorized

import org.pac4j.core.context.WebContext; //导入方法依赖的package包/类
@Override
public Boolean isAuthorized(WebContext context, List<CommonProfile> profiles) throws HttpAction {
    context.setResponseHeader("X-XSS-Protection", "1; mode=block");
    return true;

}
 
开发者ID:millross,项目名称:pac4j-async,代码行数:7,代码来源:XSSProtectionHeader.java

示例10: isAuthorized

import org.pac4j.core.context.WebContext; //导入方法依赖的package包/类
@Override
public boolean isAuthorized(final WebContext context, final List<CommonProfile> profiles) throws HttpAction {
    context.setResponseHeader("X-Frame-Options", "DENY");
    return true;
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:6,代码来源:XFrameOptionsHeader.java

示例11: isAuthorized

import org.pac4j.core.context.WebContext; //导入方法依赖的package包/类
@Override
public boolean isAuthorized(final WebContext context, final List<CommonProfile> profiles) throws HttpAction {
    context.setResponseHeader("X-Content-Type-Options", "nosniff");
    return true;
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:6,代码来源:XContentTypeOptionsHeader.java

示例12: isAuthorized

import org.pac4j.core.context.WebContext; //导入方法依赖的package包/类
@Override
public boolean isAuthorized(final WebContext context, final List<CommonProfile> profiles) throws HttpAction {
    context.setResponseHeader("X-XSS-Protection", "1; mode=block");
    return true;
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:6,代码来源:XSSProtectionHeader.java

示例13: unauthorized

import org.pac4j.core.context.WebContext; //导入方法依赖的package包/类
/**
 * Build a basic auth popup credentials.
 *
 * @param message message
 * @param context context
 * @param realmName realm name
 * @return a basic auth popup credentials
 */
public static HttpAction unauthorized(final String message, final WebContext<?> context, final String realmName) {
    if (CommonHelper.isNotBlank(realmName)) {
        context.setResponseHeader(HttpConstants.AUTHENTICATE_HEADER, "Basic realm=\"" + realmName + "\"");
    }
    context.setResponseStatus(HttpConstants.UNAUTHORIZED);
    return new HttpAction(message, HttpConstants.UNAUTHORIZED);
}
 
开发者ID:millross,项目名称:pac4j-async,代码行数:16,代码来源:HttpAction.java

示例14: unauthorizedDigest

import org.pac4j.core.context.WebContext; //导入方法依赖的package包/类
/**
 * Build a digest auth popup credentials.
 *
 * @param message message
 * @param context context
 * @param realmName realm name
 * @param qop qop
 * @param nonce nonce
 * @return a digest auth popup credentials
 */
public static HttpAction unauthorizedDigest(final String message, final WebContext<?> context, final String realmName, final String qop, final String nonce) {
    if (CommonHelper.isNotBlank(realmName)) {
        context.setResponseHeader(HttpConstants.AUTHENTICATE_HEADER, "Digest realm=\"" + realmName + "\", qop=\"" + qop + "\", nonce=\"" + nonce + "\"");
    }
    context.setResponseStatus(HttpConstants.UNAUTHORIZED);
    return new HttpAction(message, HttpConstants.UNAUTHORIZED);
}
 
开发者ID:millross,项目名称:pac4j-async,代码行数:18,代码来源:HttpAction.java

示例15: unauthorized

import org.pac4j.core.context.WebContext; //导入方法依赖的package包/类
/**
 * Build a basic auth popup credentials.
 * 
 * @param message message
 * @param context context
 * @param realmName realm name
 * @return a basic auth popup credentials
 */
public static HttpAction unauthorized(final String message, final WebContext context, final String realmName) {
    if (CommonHelper.isNotBlank(realmName)) {
        context.setResponseHeader(HttpConstants.AUTHENTICATE_HEADER, "Basic realm=\"" + realmName + "\"");
    }
    context.setResponseStatus(HttpConstants.UNAUTHORIZED);
    return new HttpAction(message, HttpConstants.UNAUTHORIZED);
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:16,代码来源:HttpAction.java


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