From d602a9c8533a325b9cf748ff42b76bff1c4b7781 Mon Sep 17 00:00:00 2001 From: Aaron Coburn Date: Fri, 7 Apr 2023 13:38:13 -0400 Subject: [PATCH] JCL-328: Deprecate UmaSession --- .../java/com/inrupt/client/auth/package-info.java | 6 +++--- .../java/com/inrupt/client/core/package-info.java | 2 +- .../com/inrupt/client/core/DefaultClientTest.java | 15 +++++++-------- .../java/com/inrupt/client/uma/UmaSession.java | 3 +++ .../java/com/inrupt/client/uma/package-info.java | 15 +-------------- 5 files changed, 15 insertions(+), 26 deletions(-) diff --git a/api/src/main/java/com/inrupt/client/auth/package-info.java b/api/src/main/java/com/inrupt/client/auth/package-info.java index a87639a7e28..902642b3657 100644 --- a/api/src/main/java/com/inrupt/client/auth/package-info.java +++ b/api/src/main/java/com/inrupt/client/auth/package-info.java @@ -36,9 +36,9 @@ * for each implementation. Some examples: * *
{@code
-    Session session = OpenIdSession.ofIdToken(token);
-    Session sessionWithConfig = OpenIdSession.ofIdToken(token, config);
-    Session umaSession = UmaSession.of(session);
+    Session openidSession = OpenIdSession.ofIdToken(token);
+    Session openidSessionWithConfig = OpenIdSession.ofIdToken(token, config);
+    Session accessGrantSession = AccessGrantSession.ofAccessGrant(openidSession, accessGrant);
  * }
* *

HTTP challenges

diff --git a/core/src/main/java/com/inrupt/client/core/package-info.java b/core/src/main/java/com/inrupt/client/core/package-info.java index 2923766d67c..4e8168b0314 100644 --- a/core/src/main/java/com/inrupt/client/core/package-info.java +++ b/core/src/main/java/com/inrupt/client/core/package-info.java @@ -44,7 +44,7 @@ .POST(Request.BodyPublishers.ofString("Test String 1")) .build(); - Response response = client.session(UmaSession.of(s)) + Response response = client .send(request, Response.BodyHandlers.discarding()) .toCompletableFuture().join(); * } diff --git a/core/src/test/java/com/inrupt/client/core/DefaultClientTest.java b/core/src/test/java/com/inrupt/client/core/DefaultClientTest.java index 89d6a4035af..1fcc0a5520a 100644 --- a/core/src/test/java/com/inrupt/client/core/DefaultClientTest.java +++ b/core/src/test/java/com/inrupt/client/core/DefaultClientTest.java @@ -36,7 +36,6 @@ import com.inrupt.client.jena.JenaBodyPublishers; import com.inrupt.client.openid.OpenIdConfig; import com.inrupt.client.openid.OpenIdSession; -import com.inrupt.client.uma.UmaSession; import java.io.IOException; import java.io.InputStream; @@ -206,10 +205,10 @@ void testOfModelPublisherBearer() throws IOException, InterruptedException { claims.put("azp", AZP); claims.put("cnf", Collections.singletonMap("jkt", ecJwk.calculateBase64urlEncodedThumbprint(SHA_256))); final String token = generateIdToken(claims); - final Session session = UmaSession.of(OpenIdSession.ofIdToken(token, config)); + final Session session = OpenIdSession.ofIdToken(token, config); assertEquals(Optional.of(URI.create(WEBID)), session.getPrincipal()); - final Session session2 = UmaSession.of(); + final Session session2 = Session.anonymous(); assertFalse(session2.getPrincipal().isPresent()); assertNotEquals(session2.getId(), session.getId()); assertFalse(session2.generateProof(null, null).isPresent()); @@ -327,7 +326,7 @@ void testPutRDF() throws Exception { } @Test - void testOfStringPublisherUmaSession() throws IOException, InterruptedException { + void testOfStringPublisherOpenidSession() throws IOException, InterruptedException { final Map claims = new HashMap<>(); claims.put("webid", WEBID); claims.put("sub", SUB); @@ -346,7 +345,7 @@ void testOfStringPublisherUmaSession() throws IOException, InterruptedException config.setProofKeyPairs(Collections.singletonMap("RS256", new KeyPair(jwk.getPublicKey(), jwk.getPrivateKey()))); - final Response response = client.session(UmaSession.of(OpenIdSession.ofIdToken(token, config))) + final Response response = client.session(OpenIdSession.ofIdToken(token, config)) .send(request, Response.BodyHandlers.discarding()) .toCompletableFuture().join(); @@ -361,7 +360,7 @@ void testOfStringPublisherUmaAnonSession() throws IOException, InterruptedExcept .POST(Request.BodyPublishers.ofString("Test String 1")) .build(); - final Response response = client.session(UmaSession.of()) + final Response response = client.session(Session.anonymous()) .send(request, Response.BodyHandlers.discarding()) .toCompletableFuture().join(); @@ -375,7 +374,7 @@ void testNullSession() { } @Test - void testUmaSessionExpiredIdToken() throws Exception { + void testSessionExpiredIdToken() throws Exception { final Map claims = new HashMap<>(); claims.put("webid", WEBID); claims.put("sub", SUB); @@ -398,7 +397,7 @@ void testUmaSessionExpiredIdToken() throws Exception { .POST(Request.BodyPublishers.ofString("Test String 1")) .build(); - final Response response = client.session(UmaSession.of(s)) + final Response response = client.session(s) .send(request, Response.BodyHandlers.discarding()) .toCompletableFuture().join(); diff --git a/uma/src/main/java/com/inrupt/client/uma/UmaSession.java b/uma/src/main/java/com/inrupt/client/uma/UmaSession.java index 0e26ad6e5da..89c73b0f1ac 100644 --- a/uma/src/main/java/com/inrupt/client/uma/UmaSession.java +++ b/uma/src/main/java/com/inrupt/client/uma/UmaSession.java @@ -38,7 +38,10 @@ /** * A session implementation for use with UMA Authorization Servers. + * + * @deprecated As of Beta3, this class is deprecated */ +@Deprecated public final class UmaSession implements Session { private final String id; diff --git a/uma/src/main/java/com/inrupt/client/uma/package-info.java b/uma/src/main/java/com/inrupt/client/uma/package-info.java index a220b2e9504..247d75237f5 100644 --- a/uma/src/main/java/com/inrupt/client/uma/package-info.java +++ b/uma/src/main/java/com/inrupt/client/uma/package-info.java @@ -23,23 +23,10 @@ * *

UMA builds on the OAuth 2.0 authorization framework, defining a mechanism by which * a client can iteratively negotiate for an access token. - * + * *

{@code UmaClient} helps in the interaction with different endpoints, to construct helper * requests for authentication and to negotiate for a token. - * - *

Using a UMA session

- * - *

This module has a session implementation, {@code UmaSession}, for use with UMA Authorization Servers. * - *

This session implementation can be used to wrap other session objects, such as - * ones that use OpenID Connect tokens. - * - *

{@code
- *   Client client = ClientProvider.getClient();
- *   Session session = client.session(UmaSession.ofSession(OpenIdSession.ofIdToken(jwt)));
- *   Response res = session.send(req, bodyHandler);
- * }
- * *

Discovering the UMA configuration

* *
{@code