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


Java ContainerRequestContext.getCookies方法代码示例

本文整理汇总了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();
}
 
开发者ID:groovylabs,项目名称:lyre,代码行数:19,代码来源:SwaggerInflector.java

示例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;
}
 
开发者ID:xujiajun,项目名称:tastjava,代码行数:13,代码来源:ResourceAuthFilter.java

示例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));
    }


}
 
开发者ID:javathought,项目名称:devoxx-2017,代码行数:33,代码来源:SecurityFilter.java


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