From ea95558acf6c66acdfca2a3d25032e7e2ec45f50 Mon Sep 17 00:00:00 2001 From: Mateusz Małek <ieg3lwut8aippmr7tzhqyznn@noreply.damisa.net> Date: Tue, 08 Nov 2022 09:10:50 +0000 Subject: [PATCH] Update to Keycloak 20.0.0 --- src/main/java/org/keycloak/protocol/cas/mappers/GroupMembershipMapper.java | 3 ++- pom.xml | 4 ++-- src/main/java/org/keycloak/protocol/cas/endpoints/LogoutEndpoint.java | 2 +- src/main/java/org/keycloak/protocol/cas/endpoints/AuthorizationEndpoint.java | 2 +- src/main/java/org/keycloak/protocol/cas/endpoints/AbstractValidateEndpoint.java | 5 +++-- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/pom.xml b/pom.xml index 3f7e091..1d7c9a5 100644 --- a/pom.xml +++ b/pom.xml @@ -22,7 +22,7 @@ <groupId>org.keycloak</groupId> <artifactId>keycloak-protocol-cas</artifactId> - <version>19.0.3</version> + <version>20.0.0</version> <name>Keycloak CAS Protocol</name> <description /> @@ -36,7 +36,7 @@ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <maven.compiler.target>1.8</maven.compiler.target> <maven.compiler.source>1.8</maven.compiler.source> - <project.build.outputTimestamp>1665133202</project.build.outputTimestamp> + <project.build.outputTimestamp>1667379314</project.build.outputTimestamp> </properties> <dependencies> 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 b480679..d3af96c 100644 --- a/src/main/java/org/keycloak/protocol/cas/endpoints/AbstractValidateEndpoint.java +++ b/src/main/java/org/keycloak/protocol/cas/endpoints/AbstractValidateEndpoint.java @@ -22,6 +22,7 @@ import java.util.HashMap; import java.util.Map; import java.util.Set; +import java.util.stream.Collectors; public abstract class AbstractValidateEndpoint { protected final Logger logger = Logger.getLogger(getClass()); @@ -61,7 +62,7 @@ throw new CASValidationException(CASErrorCode.INVALID_REQUEST, "Missing parameter: " + CASLoginProtocol.SERVICE_PARAM, Response.Status.BAD_REQUEST); } - client = realm.getClients().stream() + client = realm.getClientsStream() .filter(c -> CASLoginProtocol.LOGIN_PROTOCOL.equals(c.getProtocol())) .filter(c -> RedirectUtils.verifyRedirectUri(session, service, c) != null) .findFirst().orElse(null); @@ -155,7 +156,7 @@ // CAS protocol does not support scopes, so pass null scopeParam ClientSessionContext clientSessionCtx = DefaultClientSessionContext.fromClientSessionAndScopeParameter(clientSession, null, session); - Set<ProtocolMapperModel> mappings = clientSessionCtx.getProtocolMappers(); + Set<ProtocolMapperModel> mappings = clientSessionCtx.getProtocolMappersStream().collect(Collectors.toSet()); KeycloakSessionFactory sessionFactory = session.getKeycloakSessionFactory(); Map<String, Object> attributes = new HashMap<>(); for (ProtocolMapperModel mapping : mappings) { diff --git a/src/main/java/org/keycloak/protocol/cas/endpoints/AuthorizationEndpoint.java b/src/main/java/org/keycloak/protocol/cas/endpoints/AuthorizationEndpoint.java index d046247..f3cd9fd 100644 --- a/src/main/java/org/keycloak/protocol/cas/endpoints/AuthorizationEndpoint.java +++ b/src/main/java/org/keycloak/protocol/cas/endpoints/AuthorizationEndpoint.java @@ -76,7 +76,7 @@ throw new ErrorPageException(session, Response.Status.BAD_REQUEST, Messages.MISSING_PARAMETER, CASLoginProtocol.SERVICE_PARAM); } - client = realm.getClients().stream() + client = realm.getClientsStream() .filter(c -> CASLoginProtocol.LOGIN_PROTOCOL.equals(c.getProtocol())) .filter(c -> RedirectUtils.verifyRedirectUri(session, service, c) != null) .findFirst().orElse(null); diff --git a/src/main/java/org/keycloak/protocol/cas/endpoints/LogoutEndpoint.java b/src/main/java/org/keycloak/protocol/cas/endpoints/LogoutEndpoint.java index 7bafe92..aaaa45d 100644 --- a/src/main/java/org/keycloak/protocol/cas/endpoints/LogoutEndpoint.java +++ b/src/main/java/org/keycloak/protocol/cas/endpoints/LogoutEndpoint.java @@ -70,7 +70,7 @@ return; } - client = realm.getClients().stream() + client = realm.getClientsStream() .filter(c -> CASLoginProtocol.LOGIN_PROTOCOL.equals(c.getProtocol())) .filter(c -> RedirectUtils.verifyRedirectUri(session, service, c) != null) .findFirst().orElse(null); diff --git a/src/main/java/org/keycloak/protocol/cas/mappers/GroupMembershipMapper.java b/src/main/java/org/keycloak/protocol/cas/mappers/GroupMembershipMapper.java index e5a9a89..80870f0 100644 --- a/src/main/java/org/keycloak/protocol/cas/mappers/GroupMembershipMapper.java +++ b/src/main/java/org/keycloak/protocol/cas/mappers/GroupMembershipMapper.java @@ -9,6 +9,7 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; public class GroupMembershipMapper extends AbstractCASProtocolMapper { private static final List<ProviderConfigProperty> configProperties = new ArrayList<ProviderConfigProperty>(); @@ -54,7 +55,7 @@ KeycloakSession session, ClientSessionContext clientSessionCt) { List<String> membership = new LinkedList<>(); boolean fullPath = useFullPath(mappingModel); - for (GroupModel group : userSession.getUser().getGroups()) { + for (GroupModel group : userSession.getUser().getGroupsStream().collect(Collectors.toSet())) { if (fullPath) { membership.add(ModelToRepresentation.buildGroupPath(group)); } else { -- Gitblit v1.9.1