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


Java Cookie.getValue方法代码示例

本文整理汇总了Java中javax.ws.rs.core.Cookie.getValue方法的典型用法代码示例。如果您正苦于以下问题:Java Cookie.getValue方法的具体用法?Java Cookie.getValue怎么用?Java Cookie.getValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.ws.rs.core.Cookie的用法示例。


在下文中一共展示了Cookie.getValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: provideValue

import javax.ws.rs.core.Cookie; //导入方法依赖的package包/类
@Override
public Object provideValue(Parameter parameter, ContainerRequestContext requestContext, ObjectMapper objectMapper) {
	Object returnValue;
	String cookieName = parameter.getAnnotation(CookieParam.class).value();
	Cookie cookie = requestContext.getCookies().get(cookieName);
	if (cookie == null) {
		return null;
	} else {
		if (Cookie.class.isAssignableFrom(parameter.getType())) {
			returnValue = cookie;
		} else if (String.class.isAssignableFrom(parameter.getType())) {
			returnValue = cookie.getValue();
		} else {
			try {
				returnValue = objectMapper.readValue(cookie.getValue(), parameter.getType());
			} catch (IOException e) {
				throw new IllegalStateException(e);
			}
		}
	}

	return returnValue;
}
 
开发者ID:crnk-project,项目名称:crnk-framework,代码行数:24,代码来源:CookieParamProvider.java

示例2: provideValue

import javax.ws.rs.core.Cookie; //导入方法依赖的package包/类
@Override
public Object provideValue(Parameter parameter, ContainerRequestContext requestContext, ObjectMapper objectMapper) {
    Object returnValue;
    String cookieName = parameter.getAnnotation(CookieParam.class).value();
    Cookie cookie = requestContext.getCookies().get(cookieName);
    if (cookie == null) {
        return null;
    } else {
        if (Cookie.class.isAssignableFrom(parameter.getType())) {
            returnValue = cookie;
        } else if (String.class.isAssignableFrom(parameter.getType())) {
            returnValue = cookie.getValue();
        } else {
            try {
                returnValue = objectMapper.readValue(cookie.getValue(), parameter.getType());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
    }

    return returnValue;
}
 
开发者ID:katharsis-project,项目名称:katharsis-framework,代码行数:24,代码来源:CookieParamProvider.java

示例3: logout

import javax.ws.rs.core.Cookie; //导入方法依赖的package包/类
/**
 * Perform logout for the given token.
 *
 * @param token - authentication token
 * @param tokenAccessCookie - old session-based cookie with token.
 */
public Response logout(String token, Cookie tokenAccessCookie, UriInfo uriInfo) {
  Response.ResponseBuilder response;
  String accessToken = token;
  if (accessToken == null && tokenAccessCookie != null) {
    accessToken = tokenAccessCookie.getValue();
  }

  boolean secure = uriInfo.getRequestUri().getScheme().equals("https");
  if (accessToken != null) {
    response = Response.ok();
    AccessTicket accessTicket = ticketManager.removeTicket(accessToken);
    if (accessTicket != null) {
      LOG.info("EVENT#user-sso-logged-out# USER#{}#", accessTicket.getUserId());
    } else {
      LOG.warn("AccessTicket not found. Nothing to do.");
    }
  } else {
    response = Response.status(Response.Status.BAD_REQUEST);
    LOG.warn("Token not found in request.");
  }
  if (cookieBuilder != null) {
    cookieBuilder.clearCookies(response, accessToken, secure);
  }
  return response.build();
}
 
开发者ID:codenvy,项目名称:codenvy,代码行数:32,代码来源:AuthenticationDaoImpl.java

示例4: startServices

import javax.ws.rs.core.Cookie; //导入方法依赖的package包/类
public static void startServices() throws Exception {
	//System.setProperty("bdb.log.level", "trace");
       startAdminServer();
	ctx = startCacheServer("0");
	
   	//URI baseURI = new URI("https://localhost:3443");
   	URI baseURI = new URI("http://localhost:3030");
   	ClientConfig clientConfig = new ClientConfig();
   	Client client = ClientBuilder.newClient(clientConfig);
   	target = client.target(baseURI);

   	LoginParams params = new LoginParams("default", "guest", "password");
       Response response = target.path("access/login").request()
       		.header("Content-Type", "application/json")
       		.post(Entity.json(params), Response.class);
       assertEquals(Status.OK.getStatusCode(), response.getStatus());

       Cookie cc = response.getCookies().get(bg_cookie);
       assertNotNull(cc);
       assertEquals(bg_cookie, cc.getName());
       cuid = cc.getValue();
}
 
开发者ID:dsukhoroslov,项目名称:bagri,代码行数:23,代码来源:RestServiceTest.java

示例5: getValue

import javax.ws.rs.core.Cookie; //导入方法依赖的package包/类
@Override
public T getValue(HttpContext httpContext) {
    final Cookie cookie = httpContext.getRequest().getCookies().get(this.cookie);

    if (cookie != null) {
        final String value = cookie.getValue();
        try {
            final Optional<T> result = authenticator.authenticate(value);
            if (result.isPresent()) {
                return result.get();
            }
        } catch (AuthenticationException e) {
            e.printStackTrace();
        }
    }

    if (required) {
        throw new WebApplicationException(
                Response.status(Response.Status.UNAUTHORIZED)
                        .entity("Credentials are required to access this resource")
                        .type(MediaType.TEXT_PLAIN_TYPE)
                        .build());
    }

    return null;
}
 
开发者ID:plant42,项目名称:dropwizard-cookie-authprovider,代码行数:27,代码来源:CookieAuthProvider.java

示例6: getRememberedSerializedIdentity

import javax.ws.rs.core.Cookie; //导入方法依赖的package包/类
@Override
protected byte[] getRememberedSerializedIdentity(SubjectContext subjectContext) {
    if (isIdentityRemoved()) {
        return null;
    }

    Cookie cookie = Requests.getCookies().get(getCookie().getName());
    //no cookie set - new site visitor?
    if (cookie == null) return null;
    String base64 = cookie.getValue();
    if (Cookies.DELETED_COOKIE_VALUE.equals(base64)) return null;

    if (base64 != null) {
        base64 = ensurePadding(base64);
        logger.trace("Acquired Base64 encoded identity [" + base64 + "]");
        byte[] decoded = Base64.decode(base64);
        logger.trace("Base64 decoded byte array length: " + (decoded != null ? decoded.length : 0) + " bytes.");
        return decoded;
    } else {
        //no cookie set - new site visitor?
        return null;
    }
}
 
开发者ID:icode,项目名称:ameba-shiro,代码行数:24,代码来源:CookieRememberMeManager.java

示例7: extractCookie

import javax.ws.rs.core.Cookie; //导入方法依赖的package包/类
public static Function<ContainerRequestContext,String> extractCookie(final String cookieName) {
    return new Function<ContainerRequestContext, String>() {
        @Nullable
        @Override
        public String apply(@Nullable ContainerRequestContext request) {
            if (request == null) {
                return null;
            } else {
                Cookie cookie = request.getCookies().get(cookieName);
                if (cookie == null) {
                    return null;
                } else {
                    return cookie.getValue();
                }
            }
        }
    };
}
 
开发者ID:Multifarious,项目名称:skid-road,代码行数:19,代码来源:RecorderFilterFactory.java

示例8: restoreWithTimestamp

import javax.ws.rs.core.Cookie; //导入方法依赖的package包/类
<T> TimestampedState<T> restoreWithTimestamp(final Cookie cookie, final Class<T> type) {
    final String value = cookie.getValue();

    final String[] parts = value.split("\\|", 5);

    final byte[] atime = DECODER.decode(parts[1]);

    final long atimeLong = atime(atime);

    if (atimeLong + timeout < timeSource.getAsLong()) {
        throw new IllegalArgumentException("Given value has timed out at: " + Instant.ofEpochSecond(atimeLong));
    }

    final byte[] tid = DECODER.decode(parts[2]);
    if (!MessageDigest.isEqual(tid, edition.tid)) {
        throw new IllegalArgumentException(String.format("Given TID `%s`, mismatches current TID `%s`",
            new BigInteger(tid).toString(16), new BigInteger(edition.tid).toString(16)));
    }

    final KeySource keySource = edition.keySource();
    final int lastSeparatorIdx = value.lastIndexOf('|');
    final byte[] mac = DECODER.decode(parts[4]);
    final byte[] calculated = mac(edition.authenticationAlgorithm, value.substring(0, lastSeparatorIdx),
        keySource.authenticationKey());
    if (!MessageDigest.isEqual(mac, calculated)) {
        throw new IllegalArgumentException("Cookie value fails authenticity check");
    }

    final byte[] iv = DECODER.decode(parts[3]);
    final byte[] encrypted = DECODER.decode(parts[0]);
    final byte[] clear = decrypt(edition.encryptionAlgorithm, iv, encrypted, keySource.encryptionKey());

    @SuppressWarnings("unchecked")
    final T ret = (T) deserialization.apply(type, clear);

    return new TimestampedState<>(ret, atimeLong);
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:38,代码来源:ClientSideState.java

示例9: toString

import javax.ws.rs.core.Cookie; //导入方法依赖的package包/类
@Override
public String toString(final Cookie cookie) {
    final HttpCookie httpCookie = new HttpCookie(cookie.getName(), cookie.getValue());
    httpCookie.setDomain(cookie.getDomain());
    httpCookie.setPath(cookie.getPath());
    return httpCookie.toString();
}
 
开发者ID:minijax,项目名称:minijax,代码行数:8,代码来源:MinijaxCookieDelegate.java

示例10: get

import javax.ws.rs.core.Cookie; //导入方法依赖的package包/类
@Override
public T get() {
    final MinijaxRequestContext context = MinijaxRequestContext.getThreadLocal();
    final Cookie cookie = context.getCookies().get(key.getName());
    final String cookieValue = cookie == null ? null : cookie.getValue();
    return context.getApplication().convertParamToType(cookieValue, key.getType(), key.getAnnotations());
}
 
开发者ID:minijax,项目名称:minijax,代码行数:8,代码来源:CookieParamProvider.java

示例11: filter

import javax.ws.rs.core.Cookie; //导入方法依赖的package包/类
@Override
public void filter(ClientRequestContext clientRequestContext) throws IOException {
    String query = clientRequestContext.getUri().getQuery();
    Cookie cookie = clientRequestContext.getCookies().get("cookie");
    String cookieValue = cookie==null?"null":cookie.getValue();
    String header = clientRequestContext.getHeaderString("MyHeader");
    clientRequestContext.abortWith(Response.ok(query + " " + cookieValue + " " + header).build());
}
 
开发者ID:eclipse,项目名称:microprofile-rest-client,代码行数:9,代码来源:BeanParamFilter.java

示例12: filter

import javax.ws.rs.core.Cookie; //导入方法依赖的package包/类
@Override
public void filter(ContainerRequestContext requestContext) throws IOException {
	boolean useAuthentication = AccessServices.useAuthentication();
	if(useAuthentication) {
		Cookie sessionCookie = requestContext.getCookies().get("sessionid");
		if(sessionCookie!=null) {
			String token = sessionCookie.getValue();
			try {
				Session session = validateToken(token);
				requestContext.setProperty("session", session);
				
				Secured annotation = extendendUriInfo.getMatchedResourceMethod().getInvocable().getHandlingMethod().getAnnotation(Secured.class);
				String right = annotation.right();
				if(right.length()>0) {
					Profile profile = session.getProfile();
					
					boolean hasRight = profile.getRights().contains(right);
					
					if(!hasRight) {
						requestContext.abortWith(Response.status(Response.Status.UNAUTHORIZED).build());
					}
				}
			} catch (Exception e) {
				requestContext.abortWith(Response.status(Response.Status.UNAUTHORIZED).build());
			}
		} else {
			requestContext.abortWith(Response.status(Response.Status.UNAUTHORIZED).build());
		}
	} else {
		requestContext.setProperty("session", AccessServices.ANONYMOUS_SESSION);
	}
}
 
开发者ID:denkbar,项目名称:step,代码行数:33,代码来源:AuthenticationFilter.java

示例13: authenticate

import javax.ws.rs.core.Cookie; //导入方法依赖的package包/类
@Override
public Optional<User> authenticate(final Cookie cookie) throws AuthenticationException {
    final String token = cookie.getValue();
    final Optional<Map<String, Object>> maybeClaims = getClaims(token);

    try {
        return maybeClaims.transform(jwtTokenManager::fromJWTClaim);
    } catch (final IllegalArgumentException e) {
        LOGGER.warn("Unable to read User from JWT claim", e);
        return Optional.absent();
    }
}
 
开发者ID:lewisd32,项目名称:authrite,代码行数:13,代码来源:JWTAuthenticator.java

示例14: getLoginCookie

import javax.ws.rs.core.Cookie; //导入方法依赖的package包/类
/**
 * Get the LoginCookie for a specific client
 *
 * @param client to find the login cookie for
 * @return the login cookie
 */
public static LoginCookie getLoginCookie(
        final EntityManager em,
        final ContainerRequestContext req,
        final Client client
) {
    final Cookie cookie = getCookie(req, client);
    if (cookie == null) {
        return null;
    }
    // the cookie value is the login cookie secret
    final String secret = cookie.getValue();
    return getLoginCookie(em, secret, client);
}
 
开发者ID:moodysalem,项目名称:oauth-service,代码行数:20,代码来源:CookieUtil.java

示例15: getUserToken

import javax.ws.rs.core.Cookie; //导入方法依赖的package包/类
public String getUserToken(String reefssid) throws Exception {
    WebTarget target = client.target(IElementsUserApi.CLOUD_URL);

    // create a new client proxy for the BooksResource
    IElementsUserApi elementsCloud = WebResourceFactory.newResource(IElementsUserApi.class, target);

    Response response = elementsCloud.connect("gigaset", reefssid);
    Cookie usercookie = response.getCookies().get("usertoken");
    return usercookie.getValue();
}
 
开发者ID:hkuhn42,项目名称:openhab2.elements,代码行数:11,代码来源:ElementsClient.java


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