當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。