mirror of https://github.com/jacekkow/keycloak-protocol-cas

Jacek Kowalski
2023-07-12 fdb9f6bf5fc43d54c9396dc4dd577b6c84ecdb9d
Update to Keycloak 22.0.0

Changes:
- replace javax.* packages with matching jakarta.*,
- use JDK 17, not JDK 11.
26 files modified
166 ■■■■ changed files
.github/workflows/release.yml 2 ●●● patch | view | raw | blame | history
.github/workflows/test.yml 2 ●●● patch | view | raw | blame | history
.github/workflows/update-deps.yml 2 ●●● patch | view | raw | blame | history
pom.xml 8 ●●●● patch | view | raw | blame | history
src/main/java/org/keycloak/protocol/cas/CASLoginProtocol.java 6 ●●●● patch | view | raw | blame | history
src/main/java/org/keycloak/protocol/cas/CASLoginProtocolService.java 8 ●●●●● patch | view | raw | blame | history
src/main/java/org/keycloak/protocol/cas/endpoints/AbstractValidateEndpoint.java 6 ●●●● patch | view | raw | blame | history
src/main/java/org/keycloak/protocol/cas/endpoints/AuthorizationEndpoint.java 7 ●●●●● patch | view | raw | blame | history
src/main/java/org/keycloak/protocol/cas/endpoints/LogoutEndpoint.java 14 ●●●●● patch | view | raw | blame | history
src/main/java/org/keycloak/protocol/cas/endpoints/SamlValidateEndpoint.java 15 ●●●●● patch | view | raw | blame | history
src/main/java/org/keycloak/protocol/cas/endpoints/ServiceValidateEndpoint.java 8 ●●●● patch | view | raw | blame | history
src/main/java/org/keycloak/protocol/cas/endpoints/ValidateEndpoint.java 9 ●●●●● patch | view | raw | blame | history
src/main/java/org/keycloak/protocol/cas/installation/KeycloakCASClientInstallation.java 6 ●●●● patch | view | raw | blame | history
src/main/java/org/keycloak/protocol/cas/representations/CASServiceResponse.java 2 ●●● patch | view | raw | blame | history
src/main/java/org/keycloak/protocol/cas/representations/CASServiceResponseAuthenticationFailure.java 8 ●●●● patch | view | raw | blame | history
src/main/java/org/keycloak/protocol/cas/representations/CASServiceResponseAuthenticationSuccess.java 7 ●●●● patch | view | raw | blame | history
src/main/java/org/keycloak/protocol/cas/representations/package-info.java 6 ●●●● patch | view | raw | blame | history
src/main/java/org/keycloak/protocol/cas/utils/AttributesMapAdapter.java 12 ●●●● patch | view | raw | blame | history
src/main/java/org/keycloak/protocol/cas/utils/CASValidationException.java 5 ●●●●● patch | view | raw | blame | history
src/main/java/org/keycloak/protocol/cas/utils/ContentTypeHelper.java 5 ●●●●● patch | view | raw | blame | history
src/main/java/org/keycloak/protocol/cas/utils/LogoutHelper.java 7 ●●●● patch | view | raw | blame | history
src/main/java/org/keycloak/protocol/cas/utils/ServiceResponseHelper.java 6 ●●●● patch | view | raw | blame | history
src/main/java/org/keycloak/protocol/cas/utils/ServiceResponseMarshaller.java 6 ●●●● patch | view | raw | blame | history
src/test/java/org/keycloak/protocol/cas/ContentTypeHelperTest.java 5 ●●●●● patch | view | raw | blame | history
src/test/java/org/keycloak/protocol/cas/SamlResponseTest.java 2 ●●● patch | view | raw | blame | history
src/test/java/org/keycloak/protocol/cas/XMLValidator.java 2 ●●● patch | view | raw | blame | history
.github/workflows/release.yml
@@ -21,7 +21,7 @@
        uses: actions/setup-java@v3
        with:
          distribution: zulu
          java-version: 11
          java-version: 17
      - id: vars
        name: Get project variables
.github/workflows/test.yml
@@ -19,7 +19,7 @@
        uses: actions/setup-java@v3
        with:
          distribution: zulu
          java-version: 11
          java-version: 17
      - id: vars
        name: Get project variables
.github/workflows/update-deps.yml
@@ -24,7 +24,7 @@
        uses: actions/setup-java@v3
        with:
          distribution: zulu
          java-version: 11
          java-version: 17
      - id: update_keycloak
        name: Update Keycloak
pom.xml
@@ -22,21 +22,21 @@
    <groupId>org.keycloak</groupId>
    <artifactId>keycloak-protocol-cas</artifactId>
    <version>21.1.2</version>
    <version>22.0.0</version>
    <name>Keycloak CAS Protocol</name>
    <description />
    <properties>
        <keycloak.version>${project.version}</keycloak.version>
        <apache.httpcomponents.version>4.5.13</apache.httpcomponents.version>
        <jboss.logging.version>3.4.1.Final</jboss.logging.version>
        <apache.httpcomponents.version>4.5.14</apache.httpcomponents.version>
        <jboss.logging.version>3.5.1.Final</jboss.logging.version>
        <jboss.logging.tools.version>2.2.1.Final</jboss.logging.tools.version>
        <junit.version>4.13.2</junit.version>
        <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>1687949811</project.build.outputTimestamp>
        <project.build.outputTimestamp>1689151642</project.build.outputTimestamp>
    </properties>
    <dependencies>
src/main/java/org/keycloak/protocol/cas/CASLoginProtocol.java
@@ -1,5 +1,8 @@
package org.keycloak.protocol.cas;
import jakarta.ws.rs.core.HttpHeaders;
import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.core.UriInfo;
import org.apache.http.HttpEntity;
import org.jboss.logging.Logger;
import org.keycloak.common.util.KeycloakUriBuilder;
@@ -17,9 +20,6 @@
import org.keycloak.services.managers.ResourceAdminManager;
import org.keycloak.sessions.AuthenticationSessionModel;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
import java.io.IOException;
import java.net.URI;
import java.util.UUID;
src/main/java/org/keycloak/protocol/cas/CASLoginProtocolService.java
@@ -1,5 +1,10 @@
package org.keycloak.protocol.cas;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.core.Context;
import jakarta.ws.rs.core.HttpHeaders;
import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.core.UriBuilder;
import org.jboss.resteasy.spi.HttpRequest;
import org.jboss.resteasy.spi.ResteasyProviderFactory;
import org.keycloak.events.EventBuilder;
@@ -7,9 +12,6 @@
import org.keycloak.models.RealmModel;
import org.keycloak.protocol.cas.endpoints.*;
import org.keycloak.services.resources.RealmsResource;
import javax.ws.rs.Path;
import javax.ws.rs.core.*;
public class CASLoginProtocolService {
    private KeycloakSession session;
src/main/java/org/keycloak/protocol/cas/endpoints/AbstractValidateEndpoint.java
@@ -1,5 +1,8 @@
package org.keycloak.protocol.cas.endpoints;
import jakarta.ws.rs.core.Context;
import jakarta.ws.rs.core.HttpHeaders;
import jakarta.ws.rs.core.Response;
import org.jboss.logging.Logger;
import org.jboss.resteasy.spi.HttpRequest;
import org.keycloak.common.ClientConnection;
@@ -17,9 +20,6 @@
import org.keycloak.services.managers.AuthenticationManager;
import org.keycloak.services.util.DefaultClientSessionContext;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.Response;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
src/main/java/org/keycloak/protocol/cas/endpoints/AuthorizationEndpoint.java
@@ -1,5 +1,8 @@
package org.keycloak.protocol.cas.endpoints;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.core.MultivaluedMap;
import jakarta.ws.rs.core.Response;
import org.jboss.logging.Logger;
import org.keycloak.events.Details;
import org.keycloak.events.Errors;
@@ -14,10 +17,6 @@
import org.keycloak.services.messages.Messages;
import org.keycloak.services.util.CacheControlUtil;
import org.keycloak.sessions.AuthenticationSessionModel;
import javax.ws.rs.GET;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
public class AuthorizationEndpoint extends AuthorizationEndpointBase {
    private static final Logger logger = Logger.getLogger(AuthorizationEndpoint.class);
src/main/java/org/keycloak/protocol/cas/endpoints/LogoutEndpoint.java
@@ -1,13 +1,14 @@
package org.keycloak.protocol.cas.endpoints;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.QueryParam;
import jakarta.ws.rs.core.Context;
import jakarta.ws.rs.core.HttpHeaders;
import jakarta.ws.rs.core.Response;
import org.jboss.logging.Logger;
import org.jboss.resteasy.annotations.cache.NoCache;
import org.jboss.resteasy.spi.HttpRequest;
import org.keycloak.common.ClientConnection;
import org.keycloak.events.Details;
import org.keycloak.events.Errors;
import org.keycloak.events.EventBuilder;
import org.keycloak.events.EventType;
import org.keycloak.models.ClientModel;
import org.keycloak.models.KeycloakSession;
import org.keycloak.models.RealmModel;
@@ -18,11 +19,6 @@
import org.keycloak.services.managers.AuthenticationManager;
import org.keycloak.services.messages.Messages;
import javax.ws.rs.GET;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.Response;
import java.net.URI;
public class LogoutEndpoint {
src/main/java/org/keycloak/protocol/cas/endpoints/SamlValidateEndpoint.java
@@ -1,5 +1,10 @@
package org.keycloak.protocol.cas.endpoints;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MultivaluedMap;
import jakarta.ws.rs.core.Response;
import org.keycloak.dom.saml.v1.protocol.SAML11ResponseType;
import org.keycloak.events.EventBuilder;
import org.keycloak.events.EventType;
@@ -12,18 +17,16 @@
import org.keycloak.services.Urls;
import org.xml.sax.InputSource;
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
import javax.xml.namespace.NamespaceContext;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathExpression;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;
import java.io.StringReader;
import java.util.*;
import java.util.Collections;
import java.util.Iterator;
import java.util.Map;
import java.util.Optional;
import static org.keycloak.protocol.cas.CASLoginProtocol.TARGET_PARAM;
src/main/java/org/keycloak/protocol/cas/endpoints/ServiceValidateEndpoint.java
@@ -1,13 +1,17 @@
package org.keycloak.protocol.cas.endpoints;
import jakarta.ws.rs.core.Context;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Request;
import jakarta.ws.rs.core.Response;
import org.keycloak.events.EventBuilder;
import org.keycloak.models.*;
import org.keycloak.models.RealmModel;
import org.keycloak.models.UserSessionModel;
import org.keycloak.protocol.cas.representations.CASServiceResponse;
import org.keycloak.protocol.cas.utils.CASValidationException;
import org.keycloak.protocol.cas.utils.ContentTypeHelper;
import org.keycloak.protocol.cas.utils.ServiceResponseHelper;
import javax.ws.rs.core.*;
import java.util.Map;
public class ServiceValidateEndpoint extends ValidateEndpoint {
src/main/java/org/keycloak/protocol/cas/endpoints/ValidateEndpoint.java
@@ -1,16 +1,15 @@
package org.keycloak.protocol.cas.endpoints;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.MultivaluedMap;
import jakarta.ws.rs.core.Response;
import org.jboss.resteasy.annotations.cache.NoCache;
import org.keycloak.events.EventBuilder;
import org.keycloak.events.EventType;
import org.keycloak.models.RealmModel;
import org.keycloak.protocol.cas.CASLoginProtocol;
import org.keycloak.protocol.cas.utils.CASValidationException;
import javax.ws.rs.GET;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
public class ValidateEndpoint extends AbstractValidateEndpoint {
src/main/java/org/keycloak/protocol/cas/installation/KeycloakCASClientInstallation.java
@@ -1,5 +1,8 @@
package org.keycloak.protocol.cas.installation;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.core.UriBuilder;
import org.keycloak.Config;
import org.keycloak.models.ClientModel;
import org.keycloak.models.KeycloakSession;
@@ -9,9 +12,6 @@
import org.keycloak.protocol.cas.CASLoginProtocol;
import org.keycloak.services.resources.RealmsResource;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriBuilder;
import java.net.URI;
public class KeycloakCASClientInstallation implements ClientInstallationProvider {
src/main/java/org/keycloak/protocol/cas/representations/CASServiceResponse.java
@@ -1,6 +1,6 @@
package org.keycloak.protocol.cas.representations;
import javax.xml.bind.annotation.XmlRootElement;
import jakarta.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name = "serviceResponse")
public class CASServiceResponse {
src/main/java/org/keycloak/protocol/cas/representations/CASServiceResponseAuthenticationFailure.java
@@ -1,9 +1,9 @@
package org.keycloak.protocol.cas.representations;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlValue;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlValue;
@XmlAccessorType(XmlAccessType.FIELD)
public class CASServiceResponseAuthenticationFailure {
src/main/java/org/keycloak/protocol/cas/representations/CASServiceResponseAuthenticationSuccess.java
@@ -1,9 +1,12 @@
package org.keycloak.protocol.cas.representations;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlElementWrapper;
import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import org.keycloak.protocol.cas.utils.AttributesMapAdapter;
import javax.xml.bind.annotation.*;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import java.util.List;
import java.util.Map;
src/main/java/org/keycloak/protocol/cas/representations/package-info.java
@@ -3,8 +3,8 @@
        xmlns = {
                @XmlNs(namespaceURI = "http://www.yale.edu/tp/cas", prefix = "cas")
        },
        elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
        elementFormDefault = jakarta.xml.bind.annotation.XmlNsForm.QUALIFIED)
package org.keycloak.protocol.cas.representations;
import javax.xml.bind.annotation.XmlNs;
import javax.xml.bind.annotation.XmlSchema;
import jakarta.xml.bind.annotation.XmlNs;
import jakarta.xml.bind.annotation.XmlSchema;
src/main/java/org/keycloak/protocol/cas/utils/AttributesMapAdapter.java
@@ -1,13 +1,13 @@
package org.keycloak.protocol.cas.utils;
import jakarta.xml.bind.JAXBElement;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlAnyElement;
import jakarta.xml.bind.annotation.XmlSchema;
import jakarta.xml.bind.annotation.adapters.XmlAdapter;
import org.keycloak.protocol.cas.representations.CASServiceResponse;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAnyElement;
import javax.xml.bind.annotation.XmlSchema;
import javax.xml.bind.annotation.adapters.XmlAdapter;
import javax.xml.namespace.QName;
import java.util.ArrayList;
import java.util.Collection;
src/main/java/org/keycloak/protocol/cas/utils/CASValidationException.java
@@ -1,9 +1,8 @@
package org.keycloak.protocol.cas.utils;
import jakarta.ws.rs.WebApplicationException;
import jakarta.ws.rs.core.Response;
import org.keycloak.protocol.cas.representations.CASErrorCode;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.Response;
public class CASValidationException extends WebApplicationException {
    private final CASErrorCode error;
src/main/java/org/keycloak/protocol/cas/utils/ContentTypeHelper.java
@@ -1,10 +1,9 @@
package org.keycloak.protocol.cas.utils;
import jakarta.ws.rs.BadRequestException;
import jakarta.ws.rs.core.*;
import org.jboss.resteasy.spi.HttpRequest;
import org.keycloak.protocol.cas.CASLoginProtocol;
import javax.ws.rs.BadRequestException;
import javax.ws.rs.core.*;
public class ContentTypeHelper {
    private final HttpRequest request;
src/main/java/org/keycloak/protocol/cas/utils/LogoutHelper.java
@@ -1,5 +1,6 @@
package org.keycloak.protocol.cas.utils;
import jakarta.ws.rs.core.HttpHeaders;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
@@ -7,20 +8,16 @@
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.keycloak.connections.httpclient.HttpClientProvider;
import org.keycloak.models.KeycloakSession;
import javax.ws.rs.core.HttpHeaders;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.UUID;
import java.util.LinkedList;
import java.util.List;
import java.util.UUID;
public class LogoutHelper {
    //although it looks alike, the CAS SLO protocol has nothing to do with SAML; so we build the format
src/main/java/org/keycloak/protocol/cas/utils/ServiceResponseHelper.java
@@ -1,13 +1,13 @@
package org.keycloak.protocol.cas.utils;
import jakarta.ws.rs.core.HttpHeaders;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
import org.keycloak.protocol.cas.representations.CASErrorCode;
import org.keycloak.protocol.cas.representations.CASServiceResponse;
import org.keycloak.protocol.cas.representations.CASServiceResponseAuthenticationFailure;
import org.keycloak.protocol.cas.representations.CASServiceResponseAuthenticationSuccess;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.util.List;
import java.util.Map;
src/main/java/org/keycloak/protocol/cas/utils/ServiceResponseMarshaller.java
@@ -5,11 +5,11 @@
import com.fasterxml.jackson.core.util.DefaultIndenter;
import com.fasterxml.jackson.core.util.DefaultPrettyPrinter;
import com.fasterxml.jackson.databind.ObjectMapper;
import jakarta.xml.bind.JAXBContext;
import jakarta.xml.bind.JAXBException;
import jakarta.xml.bind.Marshaller;
import org.keycloak.protocol.cas.representations.CASServiceResponse;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import java.io.StringWriter;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
src/test/java/org/keycloak/protocol/cas/ContentTypeHelperTest.java
@@ -1,13 +1,12 @@
package org.keycloak.protocol.cas;
import jakarta.ws.rs.core.HttpHeaders;
import jakarta.ws.rs.core.MediaType;
import org.jboss.resteasy.mock.MockHttpRequest;
import org.jboss.resteasy.mock.MockHttpResponse;
import org.jboss.resteasy.specimpl.RequestImpl;
import org.junit.Test;
import org.keycloak.protocol.cas.utils.ContentTypeHelper;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MediaType;
import static org.junit.Assert.assertEquals;
src/test/java/org/keycloak/protocol/cas/SamlResponseTest.java
@@ -1,5 +1,6 @@
package org.keycloak.protocol.cas;
import jakarta.ws.rs.core.Response;
import org.junit.Test;
import org.keycloak.dom.saml.v1.protocol.SAML11ResponseType;
import org.keycloak.protocol.cas.representations.CASErrorCode;
@@ -7,7 +8,6 @@
import org.keycloak.protocol.cas.utils.CASValidationException;
import org.w3c.dom.Document;
import javax.ws.rs.core.Response;
import java.util.Collections;
import static org.junit.Assert.assertNotNull;
src/test/java/org/keycloak/protocol/cas/XMLValidator.java
@@ -1,6 +1,6 @@
package org.keycloak.protocol.cas;
import com.sun.xml.bind.v2.util.FatalAdapter;
import org.glassfish.jaxb.runtime.v2.util.FatalAdapter;
import org.w3c.dom.Document;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;