本文整理匯總了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));
}
}