From 4d94388e69f5c4720669bd3551d8a5785af27d71 Mon Sep 17 00:00:00 2001
From: Rodolphe Prin <rodolphe.prin@univ-lr.fr>
Date: Tue, 10 Nov 2026 13:45:03 +0000
Subject: [PATCH] Fix compilation against Keycloak 26.8.2 (OAuth2Code userId)
---
src/main/java/org/keycloak/protocol/cas/endpoints/AbstractValidateEndpoint.java | 11 ++++++++---
1 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/src/main/java/org/keycloak/protocol/cas/endpoints/AbstractValidateEndpoint.java b/src/main/java/org/keycloak/protocol/cas/endpoints/AbstractValidateEndpoint.java
index 6a93fac..73d0aae 100644
--- a/src/main/java/org/keycloak/protocol/cas/endpoints/AbstractValidateEndpoint.java
+++ b/src/main/java/org/keycloak/protocol/cas/endpoints/AbstractValidateEndpoint.java
@@ -320,7 +320,7 @@
{
String key = UUID.randomUUID().toString();
UserSessionModel userSession = clientSession.getUserSession();
- OAuth2Code codeData = new OAuth2Code(key, clientSession.getClient().getId(), Time.currentTime() + userSession.getRealm().getAccessCodeLifespan(), null, null, null, redirectUriParam, null, null, null, userSession.getId());
+ OAuth2Code codeData = new OAuth2Code(key, clientSession.getClient().getId(), Time.currentTime() + userSession.getRealm().getAccessCodeLifespan(), null, null, null, redirectUriParam, null, null, null, userSession.getId(), userSession.getUser().getId());
session.singleUseObjects().put(prefix + key, clientSession.getUserSession().getRealm().getAccessCodeLifespan(), codeData.serializeCode());
return prefix + key + "--" + hexEncode(clientSession.getUserSession().getId()) + "--" + clientSession.getClient().getId();
}
@@ -330,7 +330,12 @@
}
private String hexDecode(String hex) {
- byte[] bytes = HexFormat.of().parseHex(hex);
- return new String(bytes, StandardCharsets.US_ASCII);
+ try {
+ byte[] bytes = HexFormat.of().parseHex(hex);
+ return new String(bytes, StandardCharsets.US_ASCII);
+ } catch (IllegalArgumentException e) {
+ event.error(Errors.INVALID_CODE);
+ throw new CASValidationException(CASErrorCode.INVALID_TICKET_SPEC, "Invalid format of the code", Response.Status.BAD_REQUEST);
+ }
}
}
--
Gitblit v1.10.0