@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null || (getClass() != obj.getClass())) { return false; } Credentials that = (Credentials) obj; return version.equals(that.version) && apiKey.equals(that.apiKey) && signature.equals(that.signature) && path.equals(that.path) && timestamp.equals(that.timestamp) && method.equals(that.method) && Arrays.equals(content, that.content); }
@Override public int hashCode() { int result = version != null ? version.hashCode() : 0; result = 31 * result + (apiKey != null ? apiKey.hashCode() : 0); result = 31 * result + (signature != null ? signature.hashCode() : 0); result = 31 * result + (path != null ? path.hashCode() : 0); result = 31 * result + (timestamp != null ? timestamp.hashCode() : 0); result = 31 * result + (method != null ? method.hashCode() : 0); result = 31 * result + Arrays.hashCode(content); return result; }
public static Version fromValue(String value) { checkNotNull(value); for (Version version : Version.values()) { if (value.equalsIgnoreCase(version.value)) { return version; } } throw new IllegalArgumentException(value + " does not have a valid mapping in Version"); }
private void addVersion(ClientRequest request, Version version) { request.getHeaders().putSingle(this.requestConfiguration.getVersionHttpHeader(), version.toString()); }
public P provide() { final ContainerRequest request = getRequestProvider().get(); final UriInfo uriInfo = request.getUriInfo(); final URI requestUri = uriInfo.getRequestUri(); final MultivaluedMap<? super String, ? extends String> queryParameters = uriInfo .getQueryParameters(); final List<? extends String> apiKeys = queryParameters.get("apiKey"); if (apiKeys == null || apiKeys.isEmpty()) { throw new BadRequestException("apiKey is required"); } final CredentialsBuilder builder = builder(); builder.withApiKey(!apiKeys.isEmpty() ? apiKeys.get(0) : null); builder.withSignature(request.getHeaderString("X-Auth-Signature")); builder.withTimestamp(request.getHeaderString("X-Auth-Timestamp")); builder.withVersion( Version.fromValue(request.getHeaderString("X-Auth-Version"))); builder.withMethod(request.getMethod()); builder.withPath(requestUri.getPath() + "?" + requestUri.getQuery()); final P retval = getAuthenticator().authenticate(builder.build()); if (retval == null) { throw new NotAuthorizedException(status(UNAUTHORIZED).build()); } return retval; }
private void addVersion(ClientRequest request, Version version) { request.getHeaders().putSingle(this.requestConfiguration.getVersionHttpHeader(), version.toString()); }
builder.withTimestamp(request.getHeaderString(DEFAULT_TIMESTAMP_HTTP_HEADER)); builder.withVersion( Version.fromValue(request.getHeaderString(DEFAULT_VERSION_HTTP_HEADER))); builder.withMethod(request.getMethod()); builder.withPath(requestUri.getPath() + "?" + requestUri.getQuery());
private void addVersion(ClientRequest request, Version version) { request.getHeaders().putSingle(this.requestConfiguration.getVersionHttpHeader(), version.toString()); }
builder.withTimestamp(request.getHeaderString(DEFAULT_TIMESTAMP_HTTP_HEADER)); builder.withVersion( Version.fromValue(request.getHeaderString(DEFAULT_VERSION_HTTP_HEADER))); builder.withMethod(request.getMethod()); builder.withPath(requestUri.getPath() + "?" + requestUri.getQuery());
@Override public int hashCode() { int result = version != null ? version.hashCode() : 0; result = 31 * result + (apiKey != null ? apiKey.hashCode() : 0); result = 31 * result + (signature != null ? signature.hashCode() : 0); result = 31 * result + (path != null ? path.hashCode() : 0); result = 31 * result + (timestamp != null ? timestamp.hashCode() : 0); result = 31 * result + (method != null ? method.hashCode() : 0); result = 31 * result + Arrays.hashCode(content); return result; }
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null || (getClass() != obj.getClass())) { return false; } Credentials that = (Credentials) obj; return version.equals(that.version) && apiKey.equals(that.apiKey) && signature.equals(that.signature) && path.equals(that.path) && timestamp.equals(that.timestamp) && method.equals(that.method) && Arrays.equals(content, that.content); }
public static Version fromValue(String value) { checkNotNull(value); for (Version version : Version.values()) { if (value.equalsIgnoreCase(version.value)) { return version; } } throw new IllegalArgumentException(value + " does not have a valid mapping in Version"); }