@@ -194,6 +194,28 @@ private void validateJwt(DecodedJWT decodedJWT) throws GuacamoleException {
194
194
}
195
195
}
196
196
197
+ /**
198
+ * Decodes a JSON Web Token (JWT) using the public key configured in the service.
199
+ *
200
+ * <p>This method decodes a JWT by verifying it with an elliptic curve public key
201
+ * fetched from the configuration service. The public key is decoded from Base64
202
+ * and used to create a verifier instance which then verifies and decodes the JWT.
203
+ *
204
+ * @param token
205
+ * The JWT token to decode.
206
+ *
207
+ * @return
208
+ * The decoded JWT.
209
+ *
210
+ * @throws GuacamoleException
211
+ * If there is an error in the configuration service.
212
+ *
213
+ * @throws NoSuchAlgorithmException
214
+ * If the algorithm for the key factory is not available.
215
+ *
216
+ * @throws InvalidKeySpecException
217
+ * If the provided key specification is invalid.
218
+ */
197
219
private DecodedJWT getDecodedJWT (String token ) throws GuacamoleException , NoSuchAlgorithmException ,
198
220
InvalidKeySpecException {
199
221
@@ -269,6 +291,21 @@ private boolean isUserAllowed(String uid) throws GuacamoleException {
269
291
return confService .getAllowedUser ().contains (uid );
270
292
}
271
293
294
+ /**
295
+ * Decodes a Base64 encoded JSON payload and extracts the uid
296
+ *
297
+ * <p>This method takes a Base64 encoded string as input, decodes it to a JSON string,
298
+ * parses the JSON to extract the user ID from the "userdata" object.
299
+ *
300
+ * @param payload
301
+ * The Base64 encoded JSON string containing user data.
302
+ *
303
+ * @return
304
+ * The user ID extracted from the decoded JSON payload.
305
+ *
306
+ * @throws JsonProcessingException
307
+ * If there is an error processing the JSON payload.
308
+ */
272
309
private String getUserId (String payload ) throws JsonProcessingException {
273
310
byte [] decodedBytes = Base64 .getDecoder ().decode (payload );
274
311
String decodedPayload = new String (decodedBytes , StandardCharsets .UTF_8 );
0 commit comments