本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}