/** {@inheritDoc} */ @Override public int hashCode() { return SystemUtils.hashCode(getName(), getValue(), getVersion(), getPath(), getDomain()); }
@Override public Cookie createEntry(String name, String value) { return new Cookie(name, value); }
/** {@inheritDoc} */ @Override public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof CookieSetting)) { return false; } CookieSetting that = (CookieSetting) obj; return super.equals(obj) && this.maxAge == that.maxAge && this.secure == that.secure && Objects.equals(this.comment, that.comment); }
/** {@inheritDoc} */ @Override public int hashCode() { return Engine.hashCode(super.hashCode(), getVersion(), getPath(), getDomain()); }
log.debug(ssoCookie.toString()); ssoCookie.getName()) && StringUtil.hasText(ssoCookie.getValue())) { SSOCookieManager ssoCookieManager = new SSOCookieManager(); try { DelegationToken cookieToken = ssoCookieManager.parse( ssoCookie.getValue()); cookieCredentialList = ssoCookieManager.getSSOCookieCredentials(ssoCookie.getValue(), NetUtil.getDomainName(getRequest().getResourceRef().toUrl())); } catch (InvalidDelegationTokenException | IOException e) {
/** * Restores credentials from the cookie named {@link #getCookieName()} if available. The usual * processing is the followed. */ @Override protected boolean authenticate(final Request request, final Response response) { // Restore credentials from the cookie final Cookie credentialsCookie = request.getCookies().getFirst(this.getCookieName()); if(credentialsCookie != null) { ChallengeResponse credentials = this.parseCredentials(credentialsCookie.getValue()); if(credentials == null) { response.getCookieSettings().removeAll(this.getCookieName()); } else { request.setChallengeResponse(credentials); } } this.log.debug("Calling super.authenticate"); return super.authenticate(request, response); }
/** * Gets the cookies whose name is a key in the given map. If a matching * cookie is found, its value is put in the map. * * @param source * The source list of cookies. * @param destination * The cookies map controlling the reading. */ public static void getCookies(List<Cookie> source, Map<String, Cookie> destination) { Cookie cookie; for (final Iterator<Cookie> iter = source.iterator(); iter.hasNext();) { cookie = iter.next(); if (destination.containsKey(cookie.getName())) { destination.put(cookie.getName(), cookie); } } }
result = new Cookie(this.globalVersion, pair.getName(), pair.getValue()); pair = readPair(true); && (pair.getName().isEmpty() || pair.getName().charAt(0) == '$')) { if (pair.getName().equalsIgnoreCase(NAME_PATH)) { result.setPath(pair.getValue()); } else if (pair.getName().equalsIgnoreCase(NAME_DOMAIN)) { result.setDomain(pair.getValue()); } else {
/** * Appends a list of cookies as an HTTP header. * * @param cookies * The list of cookies to format. * @return This writer. */ public CookieWriter append(List<Cookie> cookies) { if ((cookies != null) && !cookies.isEmpty()) { Cookie cookie; for (int i = 0; i < cookies.size(); i++) { cookie = cookies.get(i); if (i == 0) { if (cookie.getVersion() > 0) { append("$Version=\"").append(cookie.getVersion()) .append("\"; "); } } else { append("; "); } append(cookie); } } return this; }
/** {@inheritDoc} */ @Override public int hashCode() { return SystemUtils.hashCode(super.hashCode(), getComment(), getMaxAge(), isSecure()); }
@Override protected int beforeHandle(Request request, Response response) { Cookie cookie = request.getCookies().getFirst("Credentials"); if (cookie != null) { // Extract the challenge response from the cookie String[] credentials = cookie.getValue().split("="); if (credentials.length == 2) { String identifier = credentials[0]; String secret = credentials[1]; request.setChallengeResponse(new ChallengeResponse( ChallengeScheme.HTTP_COOKIE, identifier, secret)); } } else if (Method.POST.equals(request.getMethod()) && request.getResourceRef().getQueryAsForm().getFirst("login") != null) { // Intercepting a login form Form credentials = new Form(request.getEntity()); String identifier = credentials.getFirstValue("identifier"); String secret = credentials.getFirstValue("secret"); request.setChallengeResponse(new ChallengeResponse( ChallengeScheme.HTTP_COOKIE, identifier, secret)); // Continue call processing to return the target representation if // authentication is successful or a new login page request.setMethod(Method.GET); } return super.beforeHandle(request, response); }
@Override public Cookie getCookie(String name) { if (getTarget().getCookies().size() > 0) { for (org.restlet.data.Cookie cookie : getTarget().getCookies()) { if (cookie.getName().equals(name)) { return new CookieAdapter(cookie); } } } return null; }
/** {@inheritDoc} */ @Override public int hashCode() { return Engine.hashCode(super.hashCode(), getComment(), getMaxAge(), isSecure()); }
public CookieAdapter(org.restlet.data.Cookie target) { this.target = new CookieSetting( target.getVersion(), target.getName(), target.getValue(), target.getPath(), target.getDomain() ); }
@Override protected int beforeHandle(Request request, Response response) { Cookie cookie = request.getCookies().getFirst("Credentials"); if (cookie != null) { // Extract the challenge response from the cookie String[] credentials = cookie.getValue().split("="); if (credentials.length == 2) { String identifier = credentials[0]; String secret = credentials[1]; request.setChallengeResponse(new ChallengeResponse( ChallengeScheme.HTTP_COOKIE, identifier, secret)); } } else if (Method.POST.equals(request.getMethod()) && request.getResourceRef().getQueryAsForm().getFirst("login") != null) { // Intercepting a login form Form credentials = new Form(request.getEntity()); String identifier = credentials.getFirstValue("identifier"); String secret = credentials.getFirstValue("secret"); request.setChallengeResponse(new ChallengeResponse( ChallengeScheme.HTTP_COOKIE, identifier, secret)); // Continue call processing to return the target representation if // authentication is successful or a new login page request.setMethod(Method.GET); } return super.beforeHandle(request, response); }
private void addCookieParam(Request request, String representationAsText, Annotation annotation) { Series<Cookie> cookies = request.getCookies(); if (cookies == null) { cookies = new Series<Cookie>(Cookie.class); } cookies.add(new Cookie(((CookieParam) annotation).value(), representationAsText)); request.setCookies(cookies); }
if (!rc.getName().equals(cookieName)) { continue;
/** {@inheritDoc} */ @Override public int hashCode() { return SystemUtils.hashCode(super.hashCode(), getComment(), getMaxAge(), isSecure()); }
/** {@inheritDoc} */ @Override public boolean equals(Object obj) { boolean result = (obj == this); // if obj == this no need to go further if (!result) { // test for equality at Cookie level i.e. name and value. if (super.equals(obj)) { // if obj isn't a cookie setting or is null don't evaluate // further if (obj instanceof CookieSetting) { final CookieSetting that = (CookieSetting) obj; result = (this.maxAge == that.maxAge) && (this.secure == that.secure); if (result) // if "maxAge" and "secure" properties are equal // test comments { if (!(this.comment == null)) // compare comments // taking care of nulls { result = (this.comment.equals(that.comment)); } else { result = (that.comment == null); } } } } } return result; }
/** {@inheritDoc} */ @Override public int hashCode() { return SystemUtils.hashCode(getName(), getValue(), getVersion(), getPath(), getDomain()); }