/** {@inheritDoc} */ @Override public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof Cookie)) { // if obj isn't a cookie or is null don't evaluate further return false; } Cookie that = (Cookie) obj; return Objects.equals(getName(), that.getName()) && Objects.equals(getValue(), that.getValue()) && (this.version == that.version) && Objects.equals(getDomain(), that.getDomain()) && Objects.equals(getPath(), that.getPath()); }
/** {@inheritDoc} */ @Override public int hashCode() { return SystemUtils.hashCode(getName(), getValue(), getVersion(), getPath(), getDomain()); }
/** {@inheritDoc} */ @Override public int hashCode() { return SystemUtils.hashCode(getName(), getValue(), getVersion(), getPath(), getDomain()); }
public CookieAdapter(org.restlet.data.Cookie target) { this.target = new CookieSetting( target.getVersion(), target.getName(), target.getValue(), target.getPath(), target.getDomain() ); }
/** * Converts a Restlet Cookie to a JAX-RS Cookie * * @param restletCookie * the Restlet Cookie * @return the JAX-RS Cookie */ public static Cookie toJaxRsCookie(org.restlet.data.Cookie restletCookie) { if (restletCookie == null) { return null; } return new Cookie(restletCookie.getName(), restletCookie.getValue(), restletCookie.getPath(), restletCookie.getDomain(), restletCookie.getVersion()); }
@Override public CookieWriter append(Cookie cookie) throws IllegalArgumentException { String name = cookie.getName(); String value = cookie.getValue(); int version = cookie.getVersion(); if ((name == null) || (name.length() == 0)) { throw new IllegalArgumentException( "Can't write cookie. Invalid name detected"); } appendValue(name, 0).append('='); // Append the value if ((value != null) && (value.length() > 0)) { appendValue(value, version); } if (version > 0) { // Append the path String path = cookie.getPath(); if ((path != null) && (path.length() > 0)) { append("; $Path="); appendQuotedString(path); } // Append the domain String domain = cookie.getDomain(); if ((domain != null) && (domain.length() > 0)) { append("; $Domain="); appendQuotedString(domain); } } return this; }
&& 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); }
@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 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); }