本文整理汇总了Java中org.pac4j.core.context.WebContext.getRequestHeader方法的典型用法代码示例。如果您正苦于以下问题:Java WebContext.getRequestHeader方法的具体用法?Java WebContext.getRequestHeader怎么用?Java WebContext.getRequestHeader使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.pac4j.core.context.WebContext
的用法示例。
在下文中一共展示了WebContext.getRequestHeader方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: matches
import org.pac4j.core.context.WebContext; //导入方法依赖的package包/类
@Override
public boolean matches(final WebContext context) throws HttpAction {
CommonHelper.assertNotBlank("headerName", headerName);
final String headerValue = context.getRequestHeader(this.headerName);
final boolean headerNull = expectedValue == null && headerValue == null;
final boolean headerMatches = headerValue != null && pattern != null && pattern.matcher(headerValue).matches();
return headerNull || headerMatches;
}
示例2: isAuthorized
import org.pac4j.core.context.WebContext; //导入方法依赖的package包/类
@Override
public boolean isAuthorized(final WebContext context, final List<CommonProfile> profiles) throws HttpAction {
final boolean checkRequest = !onlyCheckPostRequest || ContextHelper.isPost(context);
if (checkRequest) {
final String parameterToken = context.getRequestParameter(parameterName);
final String headerToken = context.getRequestHeader(headerName);
final String sessionToken = (String) context.getSessionAttribute(Pac4jConstants.CSRF_TOKEN);
return sessionToken != null && (sessionToken.equals(parameterToken) || sessionToken.equals(headerToken));
} else {
return true;
}
}
示例3: extract
import org.pac4j.core.context.WebContext; //导入方法依赖的package包/类
@Override
public TokenCredentials extract(WebContext context) throws HttpAction {
final String header = context.getRequestHeader(this.headerName);
if (header == null) {
return null;
}
if (!header.startsWith(this.prefixHeader)) {
throw new CredentialsException("Wrong prefix for header: " + this.headerName);
}
final String headerWithoutPrefix = header.substring(this.prefixHeader.length());
return new TokenCredentials(headerWithoutPrefix, clientName);
}
示例4: extract
import org.pac4j.core.context.WebContext; //导入方法依赖的package包/类
public TokenCredentials extract(WebContext context) throws HttpAction {
final String ip;
if (alternateIpHeader == null) {
ip = context.getRemoteAddr();
} else {
ip = context.getRequestHeader(alternateIpHeader);
}
if (ip == null) {
return null;
}
return new TokenCredentials(ip, clientName);
}
示例5: isMultipartRequest
import org.pac4j.core.context.WebContext; //导入方法依赖的package包/类
private boolean isMultipartRequest(final WebContext context) {
final String contentType = context.getRequestHeader(HttpConstants.CONTENT_TYPE_HEADER);
return contentType != null && contentType.toLowerCase().startsWith("multipart");
}