Package com.inrupt.client.core


package com.inrupt.client.core

Core classes and utilities for the Inrupt Java Client Libraries.

This module provides default implementation for some of the APIs of the library.

A default HTTP client

The DefaultClient builds on top of the HTTP client loaded on the classpath. It adds the reactive authorization functionality as a default on HTTP requests. To make use of it check out the following code.


    //Creates an unauthenticated default client if there is no other on the classpath
    Client client = ClientProvider.getClient();

    //Creates an authenticated client
    Session session = OpenIdSession.ofIdToken(token, config);
    Client client = ClientProvider.getClient().session(session);

    //Send POST UMA authenticated request
    Request request = Request.newBuilder()
        .uri("https://storage.example/container/"))
        .header("Content-Type", "text/plain")
        .POST(Request.BodyPublishers.ofString("Test String 1"))
        .build();

    Response<Void> response = client
        .send(request, Response.BodyHandlers.discarding())
        .toCompletableFuture().join();
 

If we have multiple HTTP clients on the classpath we can also still access the DefaultClient through the DefaultClientProviderResolver.

A service to work with DPoP

DefaultDpopService provides, as the name implies, an already implemented DPoP service for you to make use of. The DPoP service creates a DPoP Manager which keeps track of the keypairs involved in the authentication. By default, the manager creates a keypair based on the ES256 algorithm for which it generates a SHA-256 public JWK. One can change the defaults and make use of the out of the box service to generate proofs.

Next we exemplify how to generate a ES256 proof for the GET method.


    DPoP dpop = DPoP.of();
    String method = "GET";
    URI uri = URI.create("https://storage.example/resource");
    String proof = dpop.generateProof("ES256", uri, method);
 

Header parsing default

The DefaultHeaderParser parses among the WWW-Authenticate header also some Solid useful headers like WAC-Allow and Link headers.