本文整理汇总了Java中javax.ws.rs.container.ContainerRequestContext.getCookies方法的典型用法代码示例。如果您正苦于以下问题:Java ContainerRequestContext.getCookies方法的具体用法?Java ContainerRequestContext.getCookies怎么用?Java ContainerRequestContext.getCookies使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.ws.rs.container.ContainerRequestContext
的用法示例。
在下文中一共展示了ContainerRequestContext.getCookies方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: apply
import javax.ws.rs.container.ContainerRequestContext; //导入方法依赖的package包/类
@Override
public Response apply(ContainerRequestContext arg0) {
SwaggerSpecFilter filter = FilterFactory.getFilter();
if (filter != null) {
Map<String, Cookie> cookiesvalue = arg0.getCookies();
Map<String, String> cookies = new HashMap<>();
if (cookiesvalue != null) {
for (String key : cookiesvalue.keySet()) {
cookies.put(key, cookiesvalue.get(key).getValue());
}
}
MultivaluedMap<String, String> headers = arg0.getHeaders();
return Response.ok().entity(new VendorSpecFilter().filter(getSwagger(), filter, null, cookies, headers)).build();
}
return Response.ok().entity(getSwagger()).build();
}
示例2: isAuthTokenValid
import javax.ws.rs.container.ContainerRequestContext; //导入方法依赖的package包/类
private boolean isAuthTokenValid(ContainerRequestContext containerRequestContext) {
Map<String, Cookie> cookies = containerRequestContext.getCookies();
if (cookies.get("jwt-authToken") != null) {
String authToken = cookies.get("jwt-authToken").getValue();
Logger.info(authToken);
Integer uid = JWTProvider.verifyToken(authToken).getClaim("uid").asInt();
Logger.info(uid);
return true;
}
return false;
}
示例3: filter
import javax.ws.rs.container.ContainerRequestContext; //导入方法依赖的package包/类
@Override
public void filter(ContainerRequestContext requestContext) throws IOException {
//Get request headers
final Map<String, Cookie> cookies = requestContext.getCookies();
//Fetch authorization header
final Cookie authorization = cookies.get(AUTHORIZATION_PROPERTY);
LOG.trace("URI : {}", requestContext.getUriInfo().getPath());
//If no authorization information present; block access
if( !(authorization == null) && ! requestContext.getUriInfo().getPath().equalsIgnoreCase(AuthenticateResource.PATH))
{
//Get encoded username and password
final String bearerCookie = authorization.getValue().replaceFirst(AUTHENTICATION_SCHEME + " ", "");
//Decode username and password
byte[] bearer = Base64.decode(bearerCookie.getBytes());
User user = UsersDao.getByBearer(bearer).orElseThrow(() -> new WebApplicationException(Response.Status.UNAUTHORIZED));
user.setRoles(RolesDao.getUserRoles(user));
LOG.trace("User accessing resource : {}", user);
requestContext.setSecurityContext(new ApiSecurityContext(user));
}
}