From fca7b4d14404bed7d277c1083f17e9ff7bf1b826 Mon Sep 17 00:00:00 2001
From: Updater Bot <updater@travis-ci.org>
Date: Wed, 06 May 2020 01:08:11 +0000
Subject: [PATCH] Update to Keycloak 9.0.2

---
 src/main/java/org/keycloak/protocol/cas/utils/ContentTypeHelper.java |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/main/java/org/keycloak/protocol/cas/utils/ContentTypeHelper.java b/src/main/java/org/keycloak/protocol/cas/utils/ContentTypeHelper.java
index 0e13ca6..b5ad8a5 100644
--- a/src/main/java/org/keycloak/protocol/cas/utils/ContentTypeHelper.java
+++ b/src/main/java/org/keycloak/protocol/cas/utils/ContentTypeHelper.java
@@ -3,6 +3,7 @@
 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 {
@@ -22,7 +23,12 @@
             //if parameter is set, it overrides all header values (see spec section 2.5.1)
             request.getMutableHeaders().putSingle(HttpHeaders.ACCEPT, "application/" + format.toLowerCase());
         }
-        Variant variant = restRequest.selectVariant(Variant.mediaTypes(MediaType.APPLICATION_XML_TYPE, MediaType.APPLICATION_JSON_TYPE).build());
-        return variant == null ? MediaType.APPLICATION_XML_TYPE : variant.getMediaType();
+        try {
+            Variant variant = restRequest.selectVariant(Variant.mediaTypes(MediaType.APPLICATION_XML_TYPE, MediaType.APPLICATION_JSON_TYPE).build());
+            return variant == null ? MediaType.APPLICATION_XML_TYPE : variant.getMediaType();
+        } catch (BadRequestException e) {
+            //the default Accept header set by java.net.HttpURLConnection is invalid (cf. RESTEASY-960)
+            return MediaType.APPLICATION_XML_TYPE;
+        }
     }
 }

--
Gitblit v1.9.1