/** {@inheritDoc} */ @Override public boolean equals(final Object obj) { if (obj == this) { return true; } if (!(obj instanceof ChallengeRequest)) { return false; } final ChallengeRequest that = (ChallengeRequest) obj; return getParameters().equals(that.getParameters()) && Objects.equals(getRealm(), that.getRealm()) && Objects.equals(getScheme(), that.getScheme()); }
/** {@inheritDoc} */ @Override public int hashCode() { return Engine.hashCode(getScheme(), getRealm(), getParameters()); }
/** {@inheritDoc} */ @Override public final boolean equals(final Object obj) { boolean result = (obj == this); // if obj == this no need to go further if (!result) { // if obj isn't a challenge request or is null don't evaluate // further if (obj instanceof ChallengeRequest) { final ChallengeRequest that = (ChallengeRequest) obj; result = (getParameters().equals(that.getParameters())); if (result) { if (getRealm() != null) { result = getRealm().equals(that.getRealm()); } else { result = (that.getRealm() == null); } if (result) { if (getScheme() != null) { result = getScheme().equals(that.getScheme()); } else { result = (that.getScheme() == null); } } } } } return result; }
challenge.setRealm(param.getValue()); } else { challenge.getParameters().add(param);
@Override public void formatRequest(ChallengeWriter cw, ChallengeRequest challenge, Response response, Series<Header> httpHeaders) throws IOException { // Format the parameters WWW-Authenticate: OAuth realm='Example // Service', error='expired-token' cw.append("realm='"); cw.append(challenge.getRealm()); cw.append("'"); for (Parameter p : challenge.getParameters()) { cw.append(", "); cw.append(p.getName()); cw.append("='"); cw.append(p.getValue()); cw.append("'"); } }