Skip to content

Commit

Permalink
Remove apache http client
Browse files Browse the repository at this point in the history
Signed-off-by: Aditya Sirish <[email protected]>
  • Loading branch information
adityasaky committed May 14, 2020
1 parent d00c3af commit bd49781
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 23 deletions.
5 changes: 0 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,6 @@
<artifactId>plain-credentials</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5</version>
</dependency>
</dependencies>
<build>
<plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import io.github.in_toto.models.Artifact.ArtifactHash;
import io.github.in_toto.keys.Signature;
import java.net.URI;
import org.apache.http.client.utils.URIBuilder;
import java.net.URISyntaxException;
import java.util.*;
import com.google.gson.Gson;
Expand All @@ -23,7 +22,7 @@

public class GrafeasTransport extends Transport {

URI uri;
GenericUrl uri;
GrafeasOccurrence occurrence;

public static class GrafeasInTotoMetadata {
Expand Down Expand Up @@ -136,19 +135,8 @@ private static Map<String, String> getParameterMap(String parameterString) {

public GrafeasTransport(URI uri) {
String scheme = uri.getScheme().split("\\+")[1];
String authority = uri.getAuthority();
String path = uri.getPath();
URIBuilder uriBuilder = new URIBuilder();

try {
this.uri = uriBuilder
.setScheme(scheme)
.setHost(authority)
.setPath(path)
.build();
} catch (URISyntaxException e) {
throw new RuntimeException("unable to build Grafeas URI: " + e.toString());
}
this.uri = new GenericUrl(uri);
this.uri.setScheme(scheme);

String parameterString = uri.getQuery();

Expand All @@ -168,13 +156,12 @@ public void submit(Link link) {

Gson gson = new Gson();
String jsonString = gson.toJson(this.occurrence);
GenericUrl url = new GenericUrl(this.uri);

// FIXME: Shamelessly copied from GenericCRUD.java
try {
HttpRequest request = new NetHttpTransport()
.createRequestFactory()
.buildPostRequest(url,
.buildPostRequest(this.uri,
ByteArrayContent.fromString("application/json",
jsonString));
HttpResponse response = request.execute();
Expand All @@ -183,7 +170,7 @@ public void submit(Link link) {
* but this gets the job done for a PoC
*/
} catch (IOException e) {
throw new RuntimeException("for URL " + url.toString() +
throw new RuntimeException("for URL " + this.uri.toString() +
" couldn't serialize to HTTP server: " + e.toString());
}
}
Expand Down

0 comments on commit bd49781

Please sign in to comment.