[KEYCLOAK-11185] Fixed build with JDK 11

This commit is contained in:
Douglas Palmer 2019-09-23 16:48:19 -07:00 committed by Bruno Oliveira da Silva
parent e3d755fe9d
commit a32c8c5190
14 changed files with 103 additions and 32 deletions

View file

@ -32,7 +32,6 @@
<modules>
<module>adapter-core</module>
<module>as7-eap6</module>
<module>installed</module>
<module>fuse7</module>
<module>kcinit</module>
@ -51,4 +50,16 @@
<module>wildfly</module>
<module>wildfly-elytron</module>
</modules>
<profiles>
<profile>
<id>AS7</id>
<activation>
<jdk>[,9)</jdk>
</activation>
<modules>
<module>as7-eap6</module>
</modules>
</profile>
</profiles>
</project>

View file

@ -128,17 +128,4 @@
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
</project>

View file

@ -8,9 +8,11 @@ package org.keycloak.adapters.cloned;
import java.io.InputStream;
import java.security.cert.X509Certificate;
import java.util.List;
import javax.xml.crypto.XMLStructure;
import javax.xml.crypto.dsig.keyinfo.KeyInfo;
import javax.xml.crypto.dsig.keyinfo.KeyName;
import javax.xml.crypto.dsig.keyinfo.X509Data;
import org.hamcrest.Matcher;
import static org.hamcrest.CoreMatchers.*;
import org.junit.Test;
import static org.junit.Assert.*;
@ -25,7 +27,7 @@ import org.keycloak.saml.common.exceptions.ParsingException;
*/
public class HttpAdapterUtilsTest {
private <T> T getContent(List<Object> objects, Class<T> clazz) {
private <T> T getContent(List<?> objects, Class<T> clazz) {
for (Object o : objects) {
if (clazz.isInstance(o)) {
return (T) o;
@ -49,10 +51,14 @@ public class HttpAdapterUtilsTest {
X509Data x509data;
X509Certificate x509certificate;
Matcher<Iterable<? super XMLStructure>> x509DataMatcher = hasItem(instanceOf(X509Data.class));
Matcher<Iterable<? super XMLStructure>> keyNameMatcher = hasItem(instanceOf(KeyName.class));
ki = res.get(KeycloakSamlAdapterV1QNames.ATTR_SIGNING.getQName().getLocalPart()).get(0);
assertThat(ki.getContent().size(), equalTo(2));
assertThat((List<Object>) ki.getContent(), hasItem(instanceOf(X509Data.class)));
assertThat((List<Object>) ki.getContent(), hasItem(instanceOf(KeyName.class)));
assertThat((Iterable<? super XMLStructure>) ki.getContent(), x509DataMatcher);
assertThat((Iterable<? super XMLStructure>) ki.getContent(), keyNameMatcher);
keyName = getContent(ki.getContent(), KeyName.class);
assertThat(keyName.getName(), equalTo("rJkJlvowmv1Id74GznieaAC5jU5QQp_ILzuG-GsweTI"));
@ -65,8 +71,8 @@ public class HttpAdapterUtilsTest {
ki = res.get(KeycloakSamlAdapterV1QNames.ATTR_SIGNING.getQName().getLocalPart()).get(1);
assertThat(ki.getContent().size(), equalTo(2));
assertThat((List<Object>) ki.getContent(), hasItem(instanceOf(X509Data.class)));
assertThat((List<Object>) ki.getContent(), hasItem(instanceOf(KeyName.class)));
assertThat((Iterable<? super XMLStructure>) ki.getContent(), x509DataMatcher);
assertThat((Iterable<? super XMLStructure>) ki.getContent(), keyNameMatcher);
keyName = getContent(ki.getContent(), KeyName.class);
assertThat(keyName.getName(), equalTo("BzYc4GwL8HVrAhNyNdp-lTah2DvU9jU03kby9Ynohr4"));

View file

@ -36,7 +36,6 @@
<module>undertow</module>
<module>tomcat</module>
<module>wildfly</module>
<module>as7-eap6</module>
<module>servlet-filter</module>
<module>wildfly-elytron</module>
</modules>
@ -53,5 +52,15 @@
<module>jetty</module>
</modules>
</profile>
<profile>
<id>AS7</id>
<activation>
<jdk>[,9)</jdk>
</activation>
<modules>
<module>as7-eap6</module>
</modules>
</profile>
</profiles>
</project>

View file

@ -68,6 +68,10 @@
<artifactId>hamcrest-all</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.sun.activation</groupId>
<artifactId>javax.activation</artifactId>
</dependency>
</dependencies>
<build>
<resources>

View file

@ -31,7 +31,6 @@
<packaging>pom</packaging>
<modules>
<module>as7-eap6-adapter</module>
<module>fuse-adapter-zip</module>
<module>js-adapter-zip</module>
<module>osgi</module>
@ -55,5 +54,14 @@
<module>js-adapter-npm-zip</module>
</modules>
</profile>
<profile>
<id>AS7</id>
<activation>
<jdk>(,9]</jdk>
</activation>
<modules>
<module>as7-eap6-adapter</module>
</modules>
</profile>
</profiles>
</project>

View file

@ -32,7 +32,6 @@
<modules>
<module>wildfly-adapter</module>
<module>as7-eap6-adapter</module>
</modules>
<profiles>
@ -51,6 +50,15 @@
<module>tomcat7-adapter-zip</module>
</modules>
</profile>
<profile>
<id>AS7</id>
<activation>
<jdk>(,9]</jdk>
</activation>
<modules>
<module>as7-eap6-adapter</module>
</modules>
</profile>
</profiles>
</project>

24
pom.xml
View file

@ -85,6 +85,7 @@
<slf4j.version>1.7.22</slf4j.version>
<sun.istack.version>3.0.7</sun.istack.version>
<sun.jaxb.version>2.3.1</sun.jaxb.version>
<sun.activation.version>1.2.0</sun.activation.version>
<org.glassfish.jaxb.xsom.version>2.3.1</org.glassfish.jaxb.xsom.version>
<undertow.version>2.0.26.Final</undertow.version>
<elytron.version>1.10.3.Final</elytron.version>
@ -144,7 +145,7 @@
<jmeter.analysis.plugin.version>1.0.4</jmeter.analysis.plugin.version>
<minify.plugin.version>1.7.6</minify.plugin.version>
<osgi.bundle.plugin.version>2.3.7</osgi.bundle.plugin.version>
<wildfly.plugin.version>1.1.0.Final</wildfly.plugin.version>
<wildfly.plugin.version>1.2.1.Final</wildfly.plugin.version>
<nexus.staging.plugin.version>1.6.5</nexus.staging.plugin.version>
<frontend.plugin.version>1.5</frontend.plugin.version>
<docker.maven.plugin.version>0.28.0</docker.maven.plugin.version>
@ -259,11 +260,32 @@
<artifactId>istack-commons-tools</artifactId>
<version>${sun.istack.version}</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>${sun.jaxb.version}</version>
</dependency>
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>rt</artifactId>
<version>${sun.jaxb.version}</version>
<exclusions>
<exclusion>
<groupId>com.fasterxml.woodstox</groupId>
<artifactId>woodstox-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.sun.xml.bind.external</groupId>
<artifactId>rngom</artifactId>
<version>${sun.jaxb.version}</version>
</dependency>
<dependency>
<groupId>com.sun.activation</groupId>
<artifactId>javax.activation</artifactId>
<version>${sun.activation.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>xsom</artifactId>

View file

@ -52,6 +52,14 @@
<groupId>org.apache.santuario</groupId>
<artifactId>xmlsec</artifactId>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
</dependency>
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>rt</artifactId>
</dependency>
</dependencies>
<build>
<resources>

View file

@ -73,6 +73,14 @@
<version>2.6</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
</dependency>
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>rt</artifactId>
</dependency>
</dependencies>
<build>
<resources>

View file

@ -34,7 +34,7 @@ public class KeyInfoTools {
* @param clazz
* @return The object or {@code null} if not found.
*/
public static <T> T getContent(Iterable<Object> objects, Class<T> clazz) {
public static <T> T getContent(Iterable<?> objects, Class<T> clazz) {
if (objects == null) {
return null;
}

View file

@ -41,6 +41,7 @@ import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
import javax.xml.bind.JAXBException;
import javax.xml.crypto.XMLStructure;
import javax.xml.crypto.MarshalException;
import javax.xml.crypto.dsig.CanonicalizationMethod;
import javax.xml.crypto.dsig.DigestMethod;
@ -740,7 +741,7 @@ public class XMLSignatureUtil {
private static KeyInfo createKeyInfo(String keyName, PublicKey publicKey, X509Certificate x509Certificate) throws KeyException {
KeyInfoFactory keyInfoFactory = fac.getKeyInfoFactory();
List<Object> items = new LinkedList<>();
List<XMLStructure> items = new LinkedList<>();
if (keyName != null) {
items.add(keyInfoFactory.newKeyName(keyName));

View file

@ -78,8 +78,7 @@
</configuration>
</execution>
</executions>
<version>2.5.5</version>
</plugin>
</plugins>
</build>
</project>
</project>

View file

@ -1724,8 +1724,8 @@ public class SAMLServletAdapterTest extends AbstractSAMLServletAdapterTest {
//printDocument(authnRequestMessage.getSOAPPart().getContent(), System.out);
Iterator<SOAPHeaderElement> it = authnRequestMessage.getSOAPHeader().<SOAPHeaderElement>getChildElements(new QName("urn:oasis:names:tc:SAML:2.0:profiles:SSO:ecp", "Request"));
SOAPHeaderElement ecpRequestHeader = it.next();
Iterator<javax.xml.soap.Node> it = authnRequestMessage.getSOAPHeader().<SOAPHeaderElement>getChildElements(new QName("urn:oasis:names:tc:SAML:2.0:profiles:SSO:ecp", "Request"));
SOAPHeaderElement ecpRequestHeader = (SOAPHeaderElement)it.next();
NodeList idpList = ecpRequestHeader.getElementsByTagNameNS("urn:oasis:names:tc:SAML:2.0:protocol", "IDPList");
Assert.assertThat("No IDPList returned from Service Provider", idpList.getLength(), is(1));
@ -1811,13 +1811,13 @@ public class SAMLServletAdapterTest extends AbstractSAMLServletAdapterTest {
.get();
SOAPMessage authnRequestMessage = MessageFactory.newInstance().createMessage(null, new ByteArrayInputStream(authnRequestResponse.readEntity(byte[].class)));
Iterator<SOAPHeaderElement> it = authnRequestMessage.getSOAPHeader().<SOAPHeaderElement>getChildElements(new QName("urn:liberty:paos:2003-08", "Request"));
Iterator<javax.xml.soap.Node> it = authnRequestMessage.getSOAPHeader().<SOAPHeaderElement>getChildElements(new QName("urn:liberty:paos:2003-08", "Request"));
it.next();
it = authnRequestMessage.getSOAPHeader().<SOAPHeaderElement>getChildElements(new QName("urn:oasis:names:tc:SAML:2.0:profiles:SSO:ecp", "Request"));
SOAPHeaderElement ecpRequestHeader = it.next();
NodeList idpList = ecpRequestHeader.getElementsByTagNameNS("urn:oasis:names:tc:SAML:2.0:protocol", "IDPList");
javax.xml.soap.Node ecpRequestHeader = it.next();
NodeList idpList = ((SOAPHeaderElement)ecpRequestHeader).getElementsByTagNameNS("urn:oasis:names:tc:SAML:2.0:protocol", "IDPList");
Assert.assertThat("No IDPList returned from Service Provider", idpList.getLength(), is(1));