From d55b1d72599ed0f292cc33514e347ab0a9031cc8 Mon Sep 17 00:00:00 2001 From: Hynek Mlnarik Date: Sat, 19 May 2018 18:21:30 +0200 Subject: [PATCH] KEYCLOAK-7280 CXF JAX-WS example --- .../fuse/cxf-jaxws-fuse7-undertow/pom.xml | 95 +++++++++++++++ .../java/org/keycloak/example/ws/Product.java | 42 +++++++ .../org/keycloak/example/ws/ProductImpl.java | 44 +++++++ .../example/ws/UnknownProductFault.java | 52 +++++++++ .../keycloak/example/ws/types/GetProduct.java | 81 +++++++++++++ .../example/ws/types/GetProductResponse.java | 109 ++++++++++++++++++ .../example/ws/types/ObjectFactory.java | 73 ++++++++++++ .../example/ws/types/UnknownProductFault.java | 81 +++++++++++++ .../example/ws/types/package-info.java | 18 +++ .../OSGI-INF/blueprint/blueprint.xml | 47 ++++++++ .../src/main/resources/WEB-INF/keycloak.json | 7 ++ examples/fuse/pom.xml | 1 + 12 files changed, 650 insertions(+) create mode 100755 examples/fuse/cxf-jaxws-fuse7-undertow/pom.xml create mode 100644 examples/fuse/cxf-jaxws-fuse7-undertow/src/main/java/org/keycloak/example/ws/Product.java create mode 100644 examples/fuse/cxf-jaxws-fuse7-undertow/src/main/java/org/keycloak/example/ws/ProductImpl.java create mode 100644 examples/fuse/cxf-jaxws-fuse7-undertow/src/main/java/org/keycloak/example/ws/UnknownProductFault.java create mode 100644 examples/fuse/cxf-jaxws-fuse7-undertow/src/main/java/org/keycloak/example/ws/types/GetProduct.java create mode 100644 examples/fuse/cxf-jaxws-fuse7-undertow/src/main/java/org/keycloak/example/ws/types/GetProductResponse.java create mode 100644 examples/fuse/cxf-jaxws-fuse7-undertow/src/main/java/org/keycloak/example/ws/types/ObjectFactory.java create mode 100644 examples/fuse/cxf-jaxws-fuse7-undertow/src/main/java/org/keycloak/example/ws/types/UnknownProductFault.java create mode 100644 examples/fuse/cxf-jaxws-fuse7-undertow/src/main/java/org/keycloak/example/ws/types/package-info.java create mode 100644 examples/fuse/cxf-jaxws-fuse7-undertow/src/main/resources/OSGI-INF/blueprint/blueprint.xml create mode 100644 examples/fuse/cxf-jaxws-fuse7-undertow/src/main/resources/WEB-INF/keycloak.json diff --git a/examples/fuse/cxf-jaxws-fuse7-undertow/pom.xml b/examples/fuse/cxf-jaxws-fuse7-undertow/pom.xml new file mode 100755 index 0000000000..e761979e58 --- /dev/null +++ b/examples/fuse/cxf-jaxws-fuse7-undertow/pom.xml @@ -0,0 +1,95 @@ + + + + + + keycloak-examples-fuse-parent + org.keycloak + 4.0.0.Beta3-SNAPSHOT + + + 4.0.0 + org.keycloak.example.demo + cxf-jaxws-example-fuse7-undertow + bundle + CXF JAXWS Example - Secured in Karaf/Fuse 7.0 on Undertow + + + + + + + javax.jws;resolution:=optional, + javax.wsdl, + javax.xml.bind, + javax.xml.bind.annotation, + javax.xml.namespace, + javax.xml.ws, + META-INF.cxf;version="[2.7,3.3)", + META-INF.cxf.osgi;version="[2.7,3.3)";resolution:=optional, + org.apache.cxf.transport.http_undertow;version="[2.7,3.3)";resolution:=optional, + org.apache.cxf.transport.http_undertow.blueprint;version="[2.7,3.3)";resolution:=optional, + org.keycloak.*;version="${project.version}", + *;resolution:=optional + + + org.keycloak.example.ws.* + + + + + + org.apache.geronimo.specs + geronimo-ws-metadata_2.0_spec + 1.1.2 + + + org.apache.geronimo.specs + geronimo-jaxws_2.2_spec + 1.0 + + + javax.xml.bind + jaxb-api + 2.2 + + + + + install + + + + org.apache.felix + maven-bundle-plugin + true + + + ${project.name} + ${project.groupId}.${project.artifactId} + ${keycloak.osgi.import} + ${keycloak.osgi.private} + ${keycloak.osgi.export} + + + + + + + diff --git a/examples/fuse/cxf-jaxws-fuse7-undertow/src/main/java/org/keycloak/example/ws/Product.java b/examples/fuse/cxf-jaxws-fuse7-undertow/src/main/java/org/keycloak/example/ws/Product.java new file mode 100644 index 0000000000..90023bae34 --- /dev/null +++ b/examples/fuse/cxf-jaxws-fuse7-undertow/src/main/java/org/keycloak/example/ws/Product.java @@ -0,0 +1,42 @@ +/* + * Copyright 2016 Red Hat, Inc. and/or its affiliates + * and other contributors as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.keycloak.example.ws; + +import org.keycloak.example.ws.types.ObjectFactory; + +import javax.jws.WebMethod; +import javax.jws.WebParam; +import javax.jws.WebService; +import javax.xml.bind.annotation.XmlSeeAlso; +import javax.xml.ws.RequestWrapper; +import javax.xml.ws.ResponseWrapper; + +@WebService +@XmlSeeAlso({ObjectFactory.class}) +public interface Product { + + @RequestWrapper(localName = "GetProduct", className = "GetProduct") + @ResponseWrapper(localName = "GetProductResponse", className = "GetProductResponse") + @WebMethod(operationName = "GetProduct") + public void getProduct( + @WebParam(mode = WebParam.Mode.INOUT, name = "productId") + javax.xml.ws.Holder productId, + @WebParam(mode = WebParam.Mode.OUT, name = "name") + javax.xml.ws.Holder name + ) throws UnknownProductFault; +} diff --git a/examples/fuse/cxf-jaxws-fuse7-undertow/src/main/java/org/keycloak/example/ws/ProductImpl.java b/examples/fuse/cxf-jaxws-fuse7-undertow/src/main/java/org/keycloak/example/ws/ProductImpl.java new file mode 100644 index 0000000000..8041135478 --- /dev/null +++ b/examples/fuse/cxf-jaxws-fuse7-undertow/src/main/java/org/keycloak/example/ws/ProductImpl.java @@ -0,0 +1,44 @@ +/* + * Copyright 2016 Red Hat, Inc. and/or its affiliates + * and other contributors as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.keycloak.example.ws; + +import javax.jws.WebService; +import javax.xml.ws.Holder; + +@WebService(serviceName = "ProductService", endpointInterface = "org.keycloak.example.ws.Product") +public class ProductImpl implements Product { + + public void getProduct(Holder productId, Holder name) + throws UnknownProductFault + { + if (productId.value == null || productId.value.length() == 0) { + org.keycloak.example.ws.types.UnknownProductFault fault = new org.keycloak.example.ws.types.UnknownProductFault(); + fault.setProductId(productId.value); + throw new UnknownProductFault(null,fault); + } else if (productId.value.trim().equals("1")) { + name.value = "IPad"; + } else if (productId.value.trim().equals("2")) { + name.value = "IPhone"; + } else { + org.keycloak.example.ws.types.UnknownProductFault fault = new org.keycloak.example.ws.types.UnknownProductFault(); + fault.setProductId(productId.value); + throw new UnknownProductFault(null,fault); + } + } + +} diff --git a/examples/fuse/cxf-jaxws-fuse7-undertow/src/main/java/org/keycloak/example/ws/UnknownProductFault.java b/examples/fuse/cxf-jaxws-fuse7-undertow/src/main/java/org/keycloak/example/ws/UnknownProductFault.java new file mode 100644 index 0000000000..da7ceb1975 --- /dev/null +++ b/examples/fuse/cxf-jaxws-fuse7-undertow/src/main/java/org/keycloak/example/ws/UnknownProductFault.java @@ -0,0 +1,52 @@ +/* + * Copyright 2016 Red Hat, Inc. and/or its affiliates + * and other contributors as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.keycloak.example.ws; + +import javax.xml.ws.WebFault; + +@WebFault(name = "UnknownProductFault") +public class UnknownProductFault extends Exception { + + private org.keycloak.example.ws.types.UnknownProductFault unknownProductFault; + + public UnknownProductFault() { + super(); + } + + public UnknownProductFault(String message) { + super(message); + } + + public UnknownProductFault(String message, Throwable cause) { + super(message, cause); + } + + public UnknownProductFault(String message, org.keycloak.example.ws.types.UnknownProductFault unknownProductFault) { + super(message); + this.unknownProductFault = unknownProductFault; + } + + public UnknownProductFault(String message, org.keycloak.example.ws.types.UnknownProductFault unknownProductFault, Throwable cause) { + super(message, cause); + this.unknownProductFault = unknownProductFault; + } + + public org.keycloak.example.ws.types.UnknownProductFault getFaultInfo() { + return this.unknownProductFault; + } +} diff --git a/examples/fuse/cxf-jaxws-fuse7-undertow/src/main/java/org/keycloak/example/ws/types/GetProduct.java b/examples/fuse/cxf-jaxws-fuse7-undertow/src/main/java/org/keycloak/example/ws/types/GetProduct.java new file mode 100644 index 0000000000..6e4b1c8143 --- /dev/null +++ b/examples/fuse/cxf-jaxws-fuse7-undertow/src/main/java/org/keycloak/example/ws/types/GetProduct.java @@ -0,0 +1,81 @@ + +/* + * Copyright 2016 Red Hat, Inc. and/or its affiliates + * and other contributors as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.keycloak.example.ws.types; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="productId" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "productId" +}) +@XmlRootElement(name = "GetProduct") +public class GetProduct { + + @XmlElement(required = true) + protected String productId; + + /** + * Gets the value of the productId property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getProductId() { + return productId; + } + + /** + * Sets the value of the productId property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setProductId(String value) { + this.productId = value; + } + +} diff --git a/examples/fuse/cxf-jaxws-fuse7-undertow/src/main/java/org/keycloak/example/ws/types/GetProductResponse.java b/examples/fuse/cxf-jaxws-fuse7-undertow/src/main/java/org/keycloak/example/ws/types/GetProductResponse.java new file mode 100644 index 0000000000..a1220c3a69 --- /dev/null +++ b/examples/fuse/cxf-jaxws-fuse7-undertow/src/main/java/org/keycloak/example/ws/types/GetProductResponse.java @@ -0,0 +1,109 @@ + +/* + * Copyright 2016 Red Hat, Inc. and/or its affiliates + * and other contributors as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.keycloak.example.ws.types; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="productId" type="{http://www.w3.org/2001/XMLSchema}string"/>*
+ *         <element name="name" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "productId", + "name" +}) +@XmlRootElement(name = "GetProductResponse") +public class GetProductResponse { + + @XmlElement(required = true) + protected String productId; + @XmlElement(required = true) + protected String name; + + /** + * Gets the value of the productId property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getProductId() { + return productId; + } + + /** + * Sets the value of the productId property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setProductId(String value) { + this.productId = value; + } + + /** + * Gets the value of the name property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getName() { + return name; + } + + /** + * Sets the value of the name property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setName(String value) { + this.name = value; + } + +} diff --git a/examples/fuse/cxf-jaxws-fuse7-undertow/src/main/java/org/keycloak/example/ws/types/ObjectFactory.java b/examples/fuse/cxf-jaxws-fuse7-undertow/src/main/java/org/keycloak/example/ws/types/ObjectFactory.java new file mode 100644 index 0000000000..eef95634f6 --- /dev/null +++ b/examples/fuse/cxf-jaxws-fuse7-undertow/src/main/java/org/keycloak/example/ws/types/ObjectFactory.java @@ -0,0 +1,73 @@ + +/* + * Copyright 2016 Red Hat, Inc. and/or its affiliates + * and other contributors as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.keycloak.example.ws.types; + +import javax.xml.bind.annotation.XmlRegistry; + + +/** + * This object contains factory methods for each + * Java content interface and Java element interface + * generated in the org.apache.servicemix.samples.wsdl_first.types package. + *

An ObjectFactory allows you to programatically + * construct new instances of the Java representation + * for XML content. The Java representation of XML + * content can consist of schema derived interfaces + * and classes representing the binding of schema + * type definitions, element declarations and model + * groups. Factory methods for each of these are + * provided in this class. + * + */ +@XmlRegistry +public class ObjectFactory { + + + /** + * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: org.apache.servicemix.samples.wsdl_first.types + * + */ + public ObjectFactory() { + } + + /** + * Create an instance of {@link GetProductResponse } + * + */ + public GetProductResponse createGetProductResponse() { + return new GetProductResponse(); + } + + /** + * Create an instance of {@link GetProduct } + * + */ + public GetProduct createGetProduct() { + return new GetProduct(); + } + + /** + * Create an instance of {@link UnknownProductFault } + * + */ + public UnknownProductFault createUnknownProductFault() { + return new UnknownProductFault(); + } + +} diff --git a/examples/fuse/cxf-jaxws-fuse7-undertow/src/main/java/org/keycloak/example/ws/types/UnknownProductFault.java b/examples/fuse/cxf-jaxws-fuse7-undertow/src/main/java/org/keycloak/example/ws/types/UnknownProductFault.java new file mode 100644 index 0000000000..862239d4b0 --- /dev/null +++ b/examples/fuse/cxf-jaxws-fuse7-undertow/src/main/java/org/keycloak/example/ws/types/UnknownProductFault.java @@ -0,0 +1,81 @@ + +/* + * Copyright 2016 Red Hat, Inc. and/or its affiliates + * and other contributors as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.keycloak.example.ws.types; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="productId" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "productId" +}) +@XmlRootElement(name = "UnknownProductFault") +public class UnknownProductFault { + + @XmlElement(required = true) + protected String productId; + + /** + * Gets the value of the productId property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getProductId() { + return productId; + } + + /** + * Sets the value of the productId property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setProductId(String value) { + this.productId = value; + } + +} diff --git a/examples/fuse/cxf-jaxws-fuse7-undertow/src/main/java/org/keycloak/example/ws/types/package-info.java b/examples/fuse/cxf-jaxws-fuse7-undertow/src/main/java/org/keycloak/example/ws/types/package-info.java new file mode 100644 index 0000000000..4fd528b5de --- /dev/null +++ b/examples/fuse/cxf-jaxws-fuse7-undertow/src/main/java/org/keycloak/example/ws/types/package-info.java @@ -0,0 +1,18 @@ +/* + * Copyright 2016 Red Hat, Inc. and/or its affiliates + * and other contributors as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.keycloak.example.ws.types; diff --git a/examples/fuse/cxf-jaxws-fuse7-undertow/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/examples/fuse/cxf-jaxws-fuse7-undertow/src/main/resources/OSGI-INF/blueprint/blueprint.xml new file mode 100644 index 0000000000..8acae94de5 --- /dev/null +++ b/examples/fuse/cxf-jaxws-fuse7-undertow/src/main/resources/OSGI-INF/blueprint/blueprint.xml @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/fuse/cxf-jaxws-fuse7-undertow/src/main/resources/WEB-INF/keycloak.json b/examples/fuse/cxf-jaxws-fuse7-undertow/src/main/resources/WEB-INF/keycloak.json new file mode 100644 index 0000000000..e4caeb2c88 --- /dev/null +++ b/examples/fuse/cxf-jaxws-fuse7-undertow/src/main/resources/WEB-INF/keycloak.json @@ -0,0 +1,7 @@ +{ + "realm": "demo", + "resource": "custom-cxf-endpoint", + "bearer-only": "true", + "auth-server-url": "http://localhost:8080/auth", + "ssl-required" : "external" +} diff --git a/examples/fuse/pom.xml b/examples/fuse/pom.xml index d2131b4dd0..119cb245ce 100755 --- a/examples/fuse/pom.xml +++ b/examples/fuse/pom.xml @@ -39,6 +39,7 @@ cxf-jaxrs cxf-jaxrs-fuse7-undertow cxf-jaxws + cxf-jaxws-fuse7-undertow camel features external-config