From 6f14e048c59dee5fda8234f294dc0d906c79a49d Mon Sep 17 00:00:00 2001 From: Eduardo Pinto Date: Fri, 10 Jan 2025 12:48:53 +0000 Subject: [PATCH] docs: clarify asMap behaviour in JwtClaims (#129) --- akka-javasdk/src/main/java/akka/javasdk/JwtClaims.java | 7 ++++--- .../main/scala/akka/javasdk/impl/http/JwtClaimsImpl.scala | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/akka-javasdk/src/main/java/akka/javasdk/JwtClaims.java b/akka-javasdk/src/main/java/akka/javasdk/JwtClaims.java index 9ad3309c2..5483eb9fb 100644 --- a/akka-javasdk/src/main/java/akka/javasdk/JwtClaims.java +++ b/akka-javasdk/src/main/java/akka/javasdk/JwtClaims.java @@ -26,10 +26,11 @@ public interface JwtClaims { /** * Returns all the claims as a map of strings to strings. * - *

If the claim is a String claim, the value will be the raw String. For all other types, it - * will be the value of the claim encoded to JSON. + *

Note that all values will be encoded to JSON. This means that if the value is a string, it + * will include the quotes. E.g. "\"my-string-claim\"" for a string claim. * - * @return All the claims represented as a map of string claim names to string values. + * @return All the claims represented as a map of string claim names to string values containing a + * JSON representation of its value. */ Map asMap(); diff --git a/akka-javasdk/src/main/scala/akka/javasdk/impl/http/JwtClaimsImpl.scala b/akka-javasdk/src/main/scala/akka/javasdk/impl/http/JwtClaimsImpl.scala index f86b588c0..6982b7324 100644 --- a/akka-javasdk/src/main/scala/akka/javasdk/impl/http/JwtClaimsImpl.scala +++ b/akka-javasdk/src/main/scala/akka/javasdk/impl/http/JwtClaimsImpl.scala @@ -33,11 +33,12 @@ class JwtClaimsImpl(jwtClaims: RuntimeJwtClaims) extends JwtClaims { /** * Returns all the claims as a map of strings to strings. * - *

If the claim is a String claim, the value will be the raw String. For all other types, it will be the value of - * the claim encoded to JSON. + *

Note that all values will be encoded to JSON. This means that if the value is a string, it will include the + * quotes. E.g. "\"my-string-claim\"" for a string claim. * * @return - * All the claims represented as a map of string claim names to string values. + * All the claims represented as a map of string claim names to string values containing a JSON representation of + * its value. */ override def asMap(): util.Map[String, String] = jwtClaims.getAllClaimNames