You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by co...@apache.org on 2018/04/04 15:44:19 UTC

[cxf] branch master updated: Separated Kerberos + LDAP system tests + added a test for JAX-RS Search using the LdapQueryVisitor

This is an automated email from the ASF dual-hosted git repository.

coheigea pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cxf.git


The following commit(s) were added to refs/heads/master by this push:
     new 8a15cad  Separated Kerberos + LDAP system tests + added a test for JAX-RS Search using the LdapQueryVisitor
8a15cad is described below

commit 8a15cad27deaea3510d49968791fbae13b6a409a
Author: Colm O hEigeartaigh <co...@apache.org>
AuthorDate: Wed Apr 4 16:43:50 2018 +0100

    Separated Kerberos + LDAP system tests + added a test for JAX-RS Search using the LdapQueryVisitor
---
 systests/kerberos/pom.xml                          |  48 --------
 .../cxf/systest/kerberos/jaxrs/kerberos/Book.java  |  60 ----------
 .../systest/kerberos/jaxrs/kerberos/Chapter.java   | 106 -----------------
 .../jaxrs/kerberos/JAXRSKerberosBookTest.java      |   6 +-
 .../kerberos/wssec/kerberos/KerberosTokenTest.java |   8 +-
 .../kerberos/wssec/spnego/SpnegoTokenTest.java     |   8 +-
 systests/{kerberos => ldap}/pom.xml                |  38 +-----
 .../cxf/systest/ldap/jaxrs/JAXRSLDAPUserTest.java  | 127 ++++++++++++++++++++
 .../org/apache/cxf/systest/ldap/jaxrs/User.java}   |  38 ++++--
 .../cxf/systest/ldap/jaxrs/UserLDAPServer.java     |  56 +++++++++
 .../cxf/systest/ldap/jaxrs/UserNotFoundFault.java} |  13 ++-
 .../cxf/systest/ldap/jaxrs/UserService.java}       |  34 +++---
 .../cxf/systest/ldap/jaxrs/UserServiceImpl.java    | 129 +++++++++++++++++++++
 .../cxf/systest/ldap/sts}/LDAPClaimsTest.java      |   5 +-
 systests/ldap/src/test/resources/ldap-jaxrs.xml    |  31 +++++
 .../src/test/resources/ldap.ldif                   |   0
 .../src/test/resources/ldap.properties             |   0
 .../{kerberos => ldap}/src/test/resources/ldap.xml |   0
 .../ldap/src/test/resources/logging.properties     |  74 ++++++++++++
 systests/pom.xml                                   |   1 +
 20 files changed, 488 insertions(+), 294 deletions(-)

diff --git a/systests/kerberos/pom.xml b/systests/kerberos/pom.xml
index ae672e1..41bda7a 100644
--- a/systests/kerberos/pom.xml
+++ b/systests/kerberos/pom.xml
@@ -205,59 +205,11 @@
             <scope>test</scope>
         </dependency>
         <dependency>
-            <groupId>org.apache.directory.server</groupId>
-            <artifactId>apacheds-core-annotations</artifactId>
-            <version>${cxf.apacheds.version}</version>
-            <scope>test</scope>
-            <exclusions>
-                <exclusion>
-                    <groupId>bouncycastle</groupId>
-                    <artifactId>bcprov-jdk15</artifactId>
-                </exclusion>
-            </exclusions>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.directory.server</groupId>
-            <artifactId>apacheds-core-integ</artifactId>
-            <version>${cxf.apacheds.version}</version>
-            <scope>test</scope>
-            <exclusions>
-                <exclusion>
-                    <groupId>bouncycastle</groupId>
-                    <artifactId>bcprov-jdk15</artifactId>
-                </exclusion>
-            </exclusions>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.directory.server</groupId>
-            <artifactId>apacheds-protocol-shared</artifactId>
-            <version>${cxf.apacheds.version}</version>
-            <scope>test</scope>
-            <exclusions>
-                <exclusion>
-                    <groupId>bouncycastle</groupId>
-                    <artifactId>bcprov-jdk15</artifactId>
-                </exclusion>
-            </exclusions>
-        </dependency>
-        <dependency>
             <groupId>org.apache.kerby</groupId>
             <artifactId>kerb-simplekdc</artifactId>
             <version>${cxf.kerby.version}</version>
             <scope>test</scope>
         </dependency>
-        <dependency>
-            <groupId>org.springframework.ldap</groupId>
-            <artifactId>spring-ldap-core</artifactId>
-            <version>${cxf.spring.ldap.version}</version>
-            <scope>test</scope>
-            <exclusions>
-                <exclusion>
-                    <groupId>commons-logging</groupId>
-                    <artifactId>commons-logging</artifactId>
-                </exclusion>
-            </exclusions>
-        </dependency>
 
     </dependencies>
     <profiles>
diff --git a/systests/kerberos/src/test/java/org/apache/cxf/systest/kerberos/jaxrs/kerberos/Book.java b/systests/kerberos/src/test/java/org/apache/cxf/systest/kerberos/jaxrs/kerberos/Book.java
index 784f9e8..d3ccc5b 100644
--- a/systests/kerberos/src/test/java/org/apache/cxf/systest/kerberos/jaxrs/kerberos/Book.java
+++ b/systests/kerberos/src/test/java/org/apache/cxf/systest/kerberos/jaxrs/kerberos/Book.java
@@ -19,16 +19,8 @@
 
 package org.apache.cxf.systest.kerberos.jaxrs.kerberos;
 
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.ws.rs.GET;
 import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
 import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlSeeAlso;
 
 import com.fasterxml.jackson.annotation.JsonTypeInfo;
 import com.fasterxml.jackson.annotation.JsonTypeInfo.As;
@@ -36,15 +28,11 @@ import com.fasterxml.jackson.annotation.JsonTypeInfo.Id;
 
 @JsonTypeInfo(use = Id.CLASS, include = As.PROPERTY, property = "class")
 @XmlRootElement(name = "Book")
-@XmlSeeAlso(SuperBook.class)
 public class Book {
     private String name;
     private long id;
-    private Map<Long, Chapter> chapters = new HashMap<>();
 
     public Book() {
-        init();
-        //System.out.println("----chapters: " + chapters.size());
     }
 
     public Book(String name, long id) {
@@ -73,52 +61,4 @@ public class Book {
         name = book.getName();
     }
 
-    @GET
-    public Book retrieveState() {
-        return this;
-    }
-
-    @GET
-    @Path("chapters/{chapterid}/")
-    @Produces("application/xml;charset=ISO-8859-1")
-    public Chapter getChapter(@PathParam("chapterid")int chapterid) {
-        return chapters.get(new Long(chapterid));
-    }
-
-    @GET
-    @Path("chapters/acceptencoding/{chapterid}/")
-    @Produces("application/xml")
-    public Chapter getChapterAcceptEncoding(@PathParam("chapterid")int chapterid) {
-        return chapters.get(new Long(chapterid));
-    }
-
-    @GET
-    @Path("chapters/badencoding/{chapterid}/")
-    @Produces("application/xml;charset=UTF-48")
-    public Chapter getChapterBadEncoding(@PathParam("chapterid")int chapterid) {
-        return chapters.get(new Long(chapterid));
-    }
-
-    @Path("chapters/sub/{chapterid}/")
-    public Chapter getSubChapter(@PathParam("chapterid")int chapterid) {
-        return chapters.get(new Long(chapterid));
-    }
-
-    @Path("chaptersobject/sub/{chapterid}/")
-    public Object getSubChapterObject(@PathParam("chapterid")int chapterid) {
-        return getSubChapter(chapterid);
-    }
-
-
-    final void init() {
-        Chapter c1 = new Chapter();
-        c1.setId(1);
-        c1.setTitle("chapter 1");
-        chapters.put(c1.getId(), c1);
-        Chapter c2 = new Chapter();
-        c2.setId(2);
-        c2.setTitle("chapter 2");
-        chapters.put(c2.getId(), c2);
-    }
-
 }
diff --git a/systests/kerberos/src/test/java/org/apache/cxf/systest/kerberos/jaxrs/kerberos/Chapter.java b/systests/kerberos/src/test/java/org/apache/cxf/systest/kerberos/jaxrs/kerberos/Chapter.java
deleted file mode 100644
index d76f2a4..0000000
--- a/systests/kerberos/src/test/java/org/apache/cxf/systest/kerberos/jaxrs/kerberos/Chapter.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.apache.cxf.systest.kerberos.jaxrs.kerberos;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.UriInfo;
-import javax.xml.bind.annotation.XmlRootElement;
-
-
-@XmlRootElement(name = "Chapter")
-public class Chapter {
-    private String title;
-    private long id;
-
-    public Chapter() {
-    }
-
-    public void setTitle(String n) {
-        title = n;
-    }
-
-    public String getTitle() {
-        return title;
-    }
-
-    public void setId(long i) {
-        id = i;
-    }
-    public long getId() {
-        return id;
-    }
-
-    @GET
-    @Path("/recurse")
-    @Produces("application/xml")
-    public Chapter getItself() {
-        return this;
-    }
-
-    @Path("/recurse2")
-    public Chapter getItself2() {
-        return this;
-    }
-
-    @GET
-    @Produces("application/xml;charset=ISO-8859-1")
-    public Chapter get() {
-        return this;
-    }
-
-    @GET
-    @Path("/ids")
-    @Produces("application/xml;charset=ISO-8859-1")
-    public Chapter getWithBookId(@PathParam("bookId") int bookId,
-                                 @PathParam("chapterid") int chapterId) {
-        if (bookId != 123 || chapterId != 1) {
-            throw new RuntimeException();
-        }
-        return this;
-    }
-
-
-    @GET
-    @Path("/matched-resources")
-    @Produces("text/plain")
-    public String getMatchedResources(@Context UriInfo ui) {
-        List<String> list = new ArrayList<>();
-        for (Object obj : ui.getMatchedResources()) {
-            list.add(obj.toString());
-        }
-        return list.toString();
-    }
-
-    @GET
-    @Path("/matched%21uris")
-    @Produces("text/plain")
-    public String getMatchedUris(@Context UriInfo ui,
-                                 @QueryParam("decode") String decode) {
-        return ui.getMatchedURIs(Boolean.parseBoolean(decode)).toString();
-    }
-}
diff --git a/systests/kerberos/src/test/java/org/apache/cxf/systest/kerberos/jaxrs/kerberos/JAXRSKerberosBookTest.java b/systests/kerberos/src/test/java/org/apache/cxf/systest/kerberos/jaxrs/kerberos/JAXRSKerberosBookTest.java
index 4c7bca5..3ac446c 100644
--- a/systests/kerberos/src/test/java/org/apache/cxf/systest/kerberos/jaxrs/kerberos/JAXRSKerberosBookTest.java
+++ b/systests/kerberos/src/test/java/org/apache/cxf/systest/kerberos/jaxrs/kerberos/JAXRSKerberosBookTest.java
@@ -27,10 +27,10 @@ import org.apache.cxf.jaxrs.client.JAXRSClientFactory;
 import org.apache.cxf.jaxrs.client.WebClient;
 import org.apache.cxf.jaxrs.security.KerberosAuthOutInterceptor;
 import org.apache.cxf.systest.kerberos.common.SecurityTestUtil;
+import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
 import org.apache.cxf.testutil.common.AbstractClientServerTestBase;
 import org.apache.cxf.transport.http.auth.HttpAuthHeader;
 import org.apache.cxf.transport.http.auth.SpnegoAuthSupplier;
-import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
 import org.apache.kerby.kerberos.kerb.server.SimpleKdcServer;
 import org.ietf.jgss.GSSName;
 
@@ -41,7 +41,7 @@ import org.junit.Test;
 /**
  * A set of tests for Kerberos Tokens that use an Apache Kerby instance as the KDC.
  */
-public class JAXRSKerberosBookTest extends AbstractLdapTestUnit {
+public class JAXRSKerberosBookTest extends AbstractBusClientServerTestBase {
     public static final String PORT = BookKerberosServer.PORT;
 
     private static final String KERBEROS_CONFIG_FILE =
@@ -60,7 +60,7 @@ public class JAXRSKerberosBookTest extends AbstractLdapTestUnit {
         if (!"IBM Corporation".equals(System.getProperty("java.vendor"))) {
             runTests = true;
         }
-        
+
         String basedir = System.getProperty("basedir");
         if (basedir == null) {
             basedir = new File(".").getCanonicalPath();
diff --git a/systests/kerberos/src/test/java/org/apache/cxf/systest/kerberos/wssec/kerberos/KerberosTokenTest.java b/systests/kerberos/src/test/java/org/apache/cxf/systest/kerberos/wssec/kerberos/KerberosTokenTest.java
index f17430f..1cf1e62 100644
--- a/systests/kerberos/src/test/java/org/apache/cxf/systest/kerberos/wssec/kerberos/KerberosTokenTest.java
+++ b/systests/kerberos/src/test/java/org/apache/cxf/systest/kerberos/wssec/kerberos/KerberosTokenTest.java
@@ -32,9 +32,9 @@ import org.apache.cxf.bus.spring.SpringBusFactory;
 import org.apache.cxf.systest.kerberos.common.SecurityTestUtil;
 import org.apache.cxf.systest.kerberos.wssec.sts.STSServer;
 import org.apache.cxf.systest.kerberos.wssec.sts.StaxSTSServer;
+import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
 import org.apache.cxf.testutil.common.AbstractClientServerTestBase;
 import org.apache.cxf.testutil.common.TestUtil;
-import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
 import org.apache.kerby.kerberos.kerb.server.SimpleKdcServer;
 import org.apache.wss4j.dom.engine.WSSConfig;
 import org.example.contract.doubleit.DoubleItPortType;
@@ -45,7 +45,7 @@ import org.junit.BeforeClass;
 /**
  * A set of tests for Kerberos Tokens that use an Apache Kerby instance as the KDC.
  */
-public class KerberosTokenTest extends AbstractLdapTestUnit {
+public class KerberosTokenTest extends AbstractBusClientServerTestBase {
     static final String PORT = TestUtil.getPortNumber(Server.class);
     static final String STAX_PORT = TestUtil.getPortNumber(StaxServer.class);
     static final String PORT2 = TestUtil.getPortNumber(Server.class, 2);
@@ -62,7 +62,7 @@ public class KerberosTokenTest extends AbstractLdapTestUnit {
         SecurityTestUtil.checkUnrestrictedPoliciesInstalled();
 
     private static boolean runTests;
-    
+
     private static SimpleKdcServer kerbyServer;
 
     @BeforeClass
@@ -76,7 +76,7 @@ public class KerberosTokenTest extends AbstractLdapTestUnit {
         if (!"IBM Corporation".equals(System.getProperty("java.vendor"))) {
             runTests = true;
         }
-        
+
         String basedir = System.getProperty("basedir");
         if (basedir == null) {
             basedir = new File(".").getCanonicalPath();
diff --git a/systests/kerberos/src/test/java/org/apache/cxf/systest/kerberos/wssec/spnego/SpnegoTokenTest.java b/systests/kerberos/src/test/java/org/apache/cxf/systest/kerberos/wssec/spnego/SpnegoTokenTest.java
index ec55f58..bde426c 100644
--- a/systests/kerberos/src/test/java/org/apache/cxf/systest/kerberos/wssec/spnego/SpnegoTokenTest.java
+++ b/systests/kerberos/src/test/java/org/apache/cxf/systest/kerberos/wssec/spnego/SpnegoTokenTest.java
@@ -29,9 +29,9 @@ import org.apache.cxf.Bus;
 import org.apache.cxf.BusFactory;
 import org.apache.cxf.bus.spring.SpringBusFactory;
 import org.apache.cxf.systest.kerberos.common.SecurityTestUtil;
+import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
 import org.apache.cxf.testutil.common.AbstractClientServerTestBase;
 import org.apache.cxf.testutil.common.TestUtil;
-import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
 import org.apache.kerby.kerberos.kerb.server.SimpleKdcServer;
 import org.apache.wss4j.dom.engine.WSSConfig;
 import org.example.contract.doubleit.DoubleItPortType;
@@ -42,7 +42,7 @@ import org.junit.BeforeClass;
 /**
  * A set of tests for Spnego Tokens that use an Apache Kerby instance as the KDC.
  */
-public class SpnegoTokenTest extends AbstractLdapTestUnit {
+public class SpnegoTokenTest extends AbstractBusClientServerTestBase {
     static final String PORT = TestUtil.getPortNumber(Server.class);
     static final String STAX_PORT = TestUtil.getPortNumber(StaxServer.class);
     static final String PORT2 = TestUtil.getPortNumber(Server.class, 2);
@@ -55,7 +55,7 @@ public class SpnegoTokenTest extends AbstractLdapTestUnit {
             SecurityTestUtil.checkUnrestrictedPoliciesInstalled();
 
     private static boolean runTests;
-    
+
     private static SimpleKdcServer kerbyServer;
 
     @BeforeClass
@@ -68,7 +68,7 @@ public class SpnegoTokenTest extends AbstractLdapTestUnit {
         if (!"IBM Corporation".equals(System.getProperty("java.vendor"))) {
             runTests = true;
         }
-        
+
         String basedir = System.getProperty("basedir");
         if (basedir == null) {
             basedir = new File(".").getCanonicalPath();
diff --git a/systests/kerberos/pom.xml b/systests/ldap/pom.xml
similarity index 84%
copy from systests/kerberos/pom.xml
copy to systests/ldap/pom.xml
index ae672e1..c81076b 100644
--- a/systests/kerberos/pom.xml
+++ b/systests/ldap/pom.xml
@@ -26,9 +26,9 @@
     </parent>
     <modelVersion>4.0.0</modelVersion>
     <groupId>org.apache.cxf.systests</groupId>
-    <artifactId>cxf-systests-kerberos</artifactId>
-    <name>Apache CXF Kerberos Integration System Tests</name>
-    <description>Apache CXF Kerberos Integration System Tests</description>
+    <artifactId>cxf-systests-ldap</artifactId>
+    <name>Apache CXF LDAP Integration System Tests</name>
+    <description>Apache CXF LDAP Integration System Tests</description>
     <url>http://cxf.apache.org</url>
     <build>
         <testSourceDirectory>${basedir}/src/test/java</testSourceDirectory>
@@ -48,32 +48,6 @@
         </testResources>
         <plugins>
             <plugin>
-                <groupId>org.apache.cxf</groupId>
-                <artifactId>cxf-codegen-plugin</artifactId>
-                <version>${project.version}</version>
-                <executions>
-                    <execution>
-                        <phase>generate-sources</phase>
-                        <configuration>
-                            <fork>${cxf.codegenplugin.forkmode}</fork>
-                            <sourceRoot>${basedir}/target/generated-sources</sourceRoot>
-                            <defaultOptions>
-                                <markGenerated>true</markGenerated>
-                                <faultSerialVersionUID>1</faultSerialVersionUID>
-                            </defaultOptions>
-                            <wsdlOptions>
-                                <wsdlOption>
-                                    <wsdl>${basedir}/src/test/resources/DoubleItLogical.wsdl</wsdl>
-                                </wsdlOption>
-                            </wsdlOptions>
-                        </configuration>
-                        <goals>
-                            <goal>wsdl2java</goal>
-                        </goals>
-                    </execution>
-                </executions>
-            </plugin>
-            <plugin>
                 <artifactId>maven-jar-plugin</artifactId>
                 <executions>
                     <execution>
@@ -241,12 +215,6 @@
             </exclusions>
         </dependency>
         <dependency>
-            <groupId>org.apache.kerby</groupId>
-            <artifactId>kerb-simplekdc</artifactId>
-            <version>${cxf.kerby.version}</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
             <groupId>org.springframework.ldap</groupId>
             <artifactId>spring-ldap-core</artifactId>
             <version>${cxf.spring.ldap.version}</version>
diff --git a/systests/ldap/src/test/java/org/apache/cxf/systest/ldap/jaxrs/JAXRSLDAPUserTest.java b/systests/ldap/src/test/java/org/apache/cxf/systest/ldap/jaxrs/JAXRSLDAPUserTest.java
new file mode 100644
index 0000000..a31ce73
--- /dev/null
+++ b/systests/ldap/src/test/java/org/apache/cxf/systest/ldap/jaxrs/JAXRSLDAPUserTest.java
@@ -0,0 +1,127 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.cxf.systest.ldap.jaxrs;
+
+import java.io.File;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+
+import org.apache.cxf.jaxrs.client.WebClient;
+import org.apache.cxf.testutil.common.AbstractClientServerTestBase;
+import org.apache.directory.server.annotations.CreateLdapServer;
+import org.apache.directory.server.annotations.CreateTransport;
+import org.apache.directory.server.core.annotations.ApplyLdifFiles;
+import org.apache.directory.server.core.annotations.CreateDS;
+import org.apache.directory.server.core.annotations.CreateIndex;
+import org.apache.directory.server.core.annotations.CreatePartition;
+import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
+import org.apache.directory.server.core.integ.FrameworkRunner;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(FrameworkRunner.class)
+
+//Define the DirectoryService
+@CreateDS(name = "JAXRSLDAPUserTest-class",
+        enableAccessControl = false,
+        allowAnonAccess = false,
+        enableChangeLog = true,
+        partitions = {
+      @CreatePartition(
+          name = "example",
+          suffix = "dc=example,dc=com",
+          indexes = {
+              @CreateIndex(attribute = "objectClass"),
+              @CreateIndex(attribute = "dc"),
+              @CreateIndex(attribute = "ou")
+          }
+      ) }
+  )
+
+@CreateLdapServer(
+  transports = {
+      @CreateTransport(protocol = "LDAP", address = "localhost")
+      }
+  )
+
+//Inject an file containing entries
+@ApplyLdifFiles("ldap.ldif")
+
+/**
+ * Add a test for JAX-RS search using the LdapQueryVisitor.
+ */
+public class JAXRSLDAPUserTest extends AbstractLdapTestUnit {
+    public static final String PORT = UserLDAPServer.PORT;
+    private static boolean portUpdated;
+
+    @BeforeClass
+    public static void startServers() throws Exception {
+
+        // Launch servers
+        org.junit.Assert.assertTrue(
+            "Server failed to launch",
+            // run the server in the same process
+            // set this to false to fork
+            AbstractClientServerTestBase.launchServer(UserLDAPServer.class, true)
+        );
+    }
+
+    @Before
+    public void updatePort() throws Exception {
+        if (!portUpdated) {
+            String basedir = System.getProperty("basedir");
+            if (basedir == null) {
+                basedir = new File(".").getCanonicalPath();
+            }
+
+            // Read in ldap.xml and substitute in the correct port
+            Path path = FileSystems.getDefault().getPath(basedir, "/src/test/resources/ldap-jaxrs.xml");
+            String content = new String(Files.readAllBytes(path), StandardCharsets.UTF_8);
+            content = content.replaceAll("portno", "" + super.getLdapServer().getPort());
+
+            Path path2 = FileSystems.getDefault().getPath(basedir, "/target/test-classes/ldap-jaxrsport.xml");
+            Files.write(path2, content.getBytes());
+
+            portUpdated = true;
+        }
+
+    }
+
+    @org.junit.AfterClass
+    public static void cleanup() throws Exception {
+        AbstractClientServerTestBase.stopAllServers();
+    }
+
+    @Test
+    public void testSearchUser() throws Exception {
+        WebClient wc = WebClient.create("http://localhost:" + PORT);
+
+        User user = wc.path("users/search/name==alice").get(User.class);
+        Assert.assertEquals("alice", user.getName());
+        Assert.assertEquals("smith", user.getSurname());
+    }
+
+}
diff --git a/systests/kerberos/src/test/java/org/apache/cxf/systest/kerberos/jaxrs/kerberos/SuperBook.java b/systests/ldap/src/test/java/org/apache/cxf/systest/ldap/jaxrs/User.java
similarity index 54%
copy from systests/kerberos/src/test/java/org/apache/cxf/systest/kerberos/jaxrs/kerberos/SuperBook.java
copy to systests/ldap/src/test/java/org/apache/cxf/systest/ldap/jaxrs/User.java
index 2523800..9de6452 100644
--- a/systests/kerberos/src/test/java/org/apache/cxf/systest/kerberos/jaxrs/kerberos/SuperBook.java
+++ b/systests/ldap/src/test/java/org/apache/cxf/systest/ldap/jaxrs/User.java
@@ -17,29 +17,43 @@
  * under the License.
  */
 
-package org.apache.cxf.systest.kerberos.jaxrs.kerberos;
+package org.apache.cxf.systest.ldap.jaxrs;
 
 import javax.xml.bind.annotation.XmlRootElement;
 
+import com.fasterxml.jackson.annotation.JsonTypeInfo;
+import com.fasterxml.jackson.annotation.JsonTypeInfo.As;
+import com.fasterxml.jackson.annotation.JsonTypeInfo.Id;
 
-@XmlRootElement(name = "SuperBook")
-public class SuperBook extends Book implements SuperBookInterface {
-    private boolean superBook;
+@JsonTypeInfo(use = Id.CLASS, include = As.PROPERTY, property = "class")
+@XmlRootElement(name = "User")
+public class User {
+    private String name;
+    private String surname;
 
-    public SuperBook() {
+    public User() {
 
     }
 
-    public SuperBook(String name, long id, boolean superStatus) {
-        super(name, id);
-        this.superBook = superStatus;
+    public User(String name, String surname) {
+        this.name = name;
+        this.surname = surname;
     }
 
-    public boolean isSuperBook() {
-        return superBook;
+    public void setName(String n) {
+        name = n;
     }
 
-    public void setSuperBook(boolean superBook) {
-        this.superBook = superBook;
+    public String getName() {
+        return name;
     }
+
+    public void setSurname(String n) {
+        this.surname = n;
+    }
+
+    public String getSurname() {
+        return surname;
+    }
+
 }
diff --git a/systests/ldap/src/test/java/org/apache/cxf/systest/ldap/jaxrs/UserLDAPServer.java b/systests/ldap/src/test/java/org/apache/cxf/systest/ldap/jaxrs/UserLDAPServer.java
new file mode 100644
index 0000000..d8e3d8a
--- /dev/null
+++ b/systests/ldap/src/test/java/org/apache/cxf/systest/ldap/jaxrs/UserLDAPServer.java
@@ -0,0 +1,56 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.cxf.systest.ldap.jaxrs;
+
+import java.util.Collections;
+
+import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
+import org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider;
+import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
+import org.apache.cxf.testutil.common.TestUtil;
+
+public class UserLDAPServer extends AbstractBusTestServerBase {
+    public static final String PORT = TestUtil.getPortNumber("jaxrs-ldap");
+
+    protected void run() {
+
+        JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
+        sf.setResourceClasses(UserService.class);
+        sf.setResourceProvider(UserService.class,
+                               new SingletonResourceProvider(new UserServiceImpl()));
+        sf.setProviders(Collections.singletonList(new org.apache.cxf.jaxrs.ext.search.SearchContextProvider()));
+        sf.setAddress("http://localhost:" + PORT + "/");
+
+        sf.create();
+    }
+
+    public static void main(String[] args) {
+        try {
+            UserLDAPServer s = new UserLDAPServer();
+            s.start();
+        } catch (Exception ex) {
+            ex.printStackTrace();
+            System.exit(-1);
+        } finally {
+            System.out.println("done!");
+        }
+    }
+
+}
diff --git a/systests/kerberos/src/test/java/org/apache/cxf/systest/kerberos/jaxrs/kerberos/SuperBookInterface.java b/systests/ldap/src/test/java/org/apache/cxf/systest/ldap/jaxrs/UserNotFoundFault.java
similarity index 73%
rename from systests/kerberos/src/test/java/org/apache/cxf/systest/kerberos/jaxrs/kerberos/SuperBookInterface.java
rename to systests/ldap/src/test/java/org/apache/cxf/systest/ldap/jaxrs/UserNotFoundFault.java
index 4b04413..df34c99 100644
--- a/systests/kerberos/src/test/java/org/apache/cxf/systest/kerberos/jaxrs/kerberos/SuperBookInterface.java
+++ b/systests/ldap/src/test/java/org/apache/cxf/systest/ldap/jaxrs/UserNotFoundFault.java
@@ -16,8 +16,17 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.cxf.systest.kerberos.jaxrs.kerberos;
 
-public interface SuperBookInterface {
+package org.apache.cxf.systest.ldap.jaxrs;
+
+import javax.xml.ws.WebFault;
+
+@WebFault
+public class UserNotFoundFault extends Exception {
+    private static final long serialVersionUID = 4833573020359208072L;
+
+    public UserNotFoundFault(String errorMessage) {
+        super(errorMessage);
+    }
 
 }
diff --git a/systests/kerberos/src/test/java/org/apache/cxf/systest/kerberos/jaxrs/kerberos/SuperBook.java b/systests/ldap/src/test/java/org/apache/cxf/systest/ldap/jaxrs/UserService.java
similarity index 58%
rename from systests/kerberos/src/test/java/org/apache/cxf/systest/kerberos/jaxrs/kerberos/SuperBook.java
rename to systests/ldap/src/test/java/org/apache/cxf/systest/ldap/jaxrs/UserService.java
index 2523800..6c40bdc 100644
--- a/systests/kerberos/src/test/java/org/apache/cxf/systest/kerberos/jaxrs/kerberos/SuperBook.java
+++ b/systests/ldap/src/test/java/org/apache/cxf/systest/ldap/jaxrs/UserService.java
@@ -17,29 +17,25 @@
  * under the License.
  */
 
-package org.apache.cxf.systest.kerberos.jaxrs.kerberos;
+package org.apache.cxf.systest.ldap.jaxrs;
 
-import javax.xml.bind.annotation.XmlRootElement;
 
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Context;
 
-@XmlRootElement(name = "SuperBook")
-public class SuperBook extends Book implements SuperBookInterface {
-    private boolean superBook;
+import org.apache.cxf.jaxrs.ext.search.SearchContext;
 
-    public SuperBook() {
+@Path("/users")
+public interface UserService {
 
-    }
-
-    public SuperBook(String name, long id, boolean superStatus) {
-        super(name, id);
-        this.superBook = superStatus;
-    }
+    @GET
+    @Path("/search/{query}")
+    @Produces("application/xml")
+    User searchUser(@PathParam("query") String query,
+                    @Context SearchContext searchContext) throws UserNotFoundFault;
+}
 
-    public boolean isSuperBook() {
-        return superBook;
-    }
 
-    public void setSuperBook(boolean superBook) {
-        this.superBook = superBook;
-    }
-}
diff --git a/systests/ldap/src/test/java/org/apache/cxf/systest/ldap/jaxrs/UserServiceImpl.java b/systests/ldap/src/test/java/org/apache/cxf/systest/ldap/jaxrs/UserServiceImpl.java
new file mode 100644
index 0000000..9720eb4
--- /dev/null
+++ b/systests/ldap/src/test/java/org/apache/cxf/systest/ldap/jaxrs/UserServiceImpl.java
@@ -0,0 +1,129 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.cxf.systest.ldap.jaxrs;
+
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.SearchControls;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.core.Context;
+
+import org.apache.cxf.helpers.CastUtils;
+import org.apache.cxf.jaxrs.ext.search.SearchCondition;
+import org.apache.cxf.jaxrs.ext.search.SearchContext;
+import org.apache.cxf.jaxrs.ext.search.ldap.LdapQueryVisitor;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+import org.springframework.ldap.core.AttributesMapper;
+import org.springframework.ldap.core.LdapTemplate;
+import org.springframework.ldap.filter.AndFilter;
+import org.springframework.ldap.filter.EqualsFilter;
+import org.springframework.ldap.filter.HardcodedFilter;
+
+/**
+ * Search for a user's attributes in an LDAP backend. Note this is a test implementation only - care needs to be
+ * taken to avoid LDAP injection attacks in real-world scenarios!
+ */
+public class UserServiceImpl implements UserService {
+
+    @Override
+    public User searchUser(@PathParam("query") String query, @Context SearchContext searchContext)
+        throws UserNotFoundFault {
+
+        SearchCondition<User> sc = searchContext.getCondition(query, User.class);
+        if (sc == null) {
+            throw new UserNotFoundFault("Search exception");
+        }
+
+        LdapQueryVisitor<User> visitor =
+            new LdapQueryVisitor<User>(Collections.singletonMap("name", "cn"));
+        sc.accept(visitor.visitor());
+        String parsedQuery = visitor.getQuery();
+
+        ClassPathXmlApplicationContext appContext = new ClassPathXmlApplicationContext("ldap-jaxrsport.xml");
+        LdapTemplate template = (LdapTemplate)appContext.getBean("ldapTemplate");
+
+        String userBaseDn = "OU=users,DC=example,DC=com";
+        String[] attributes = new String[] {"sn", "cn"};
+        Map<String, Attribute> attrs =
+            getAttributesOfEntry(template, userBaseDn, "person", parsedQuery, attributes);
+
+        appContext.close();
+
+        if (attrs == null || attrs.isEmpty()) {
+            throw new UserNotFoundFault("Search exception");
+        }
+        User user = new User();
+        try {
+            for (Entry<String, Attribute> result : attrs.entrySet()) {
+                if ("sn".equals(result.getKey())) {
+                    user.setSurname((String)result.getValue().get());
+                } else if ("cn".equals(result.getKey())) {
+                    user.setName((String)result.getValue().get());
+                }
+            }
+        } catch (NamingException e) {
+            throw new UserNotFoundFault("Search exception");
+        }
+
+        return user;
+    }
+
+    private static Map<String, Attribute> getAttributesOfEntry(LdapTemplate ldapTemplate, String baseDN,
+                                                               String objectClass, String searchFilter,
+                                                               String[] searchAttributes) {
+
+        Map<String, Attribute> ldapAttributes = null;
+
+        AttributesMapper<Map<String, Attribute>> mapper =
+            new AttributesMapper<Map<String, Attribute>>() {
+            public Map<String, Attribute> mapFromAttributes(Attributes attrs) throws NamingException {
+                Map<String, Attribute> map = new HashMap<>();
+                NamingEnumeration<? extends Attribute> attrEnum = attrs.getAll();
+                while (attrEnum.hasMore()) {
+                    Attribute att = attrEnum.next();
+                    map.put(att.getID(), att);
+                }
+                return map;
+            }
+        };
+
+        AndFilter filter = new AndFilter();
+        filter.and(new EqualsFilter("objectclass", objectClass)).and(new HardcodedFilter(searchFilter));
+
+        List<?> result = ldapTemplate.search((baseDN == null) ? "" : baseDN, filter.toString(),
+            SearchControls.SUBTREE_SCOPE, searchAttributes, mapper);
+        if (result != null && !result.isEmpty()) {
+            ldapAttributes = CastUtils.cast((Map<?, ?>)result.get(0));
+        }
+
+        return ldapAttributes;
+    }
+}
+
+
diff --git a/systests/kerberos/src/test/java/org/apache/cxf/systest/kerberos/ldap/LDAPClaimsTest.java b/systests/ldap/src/test/java/org/apache/cxf/systest/ldap/sts/LDAPClaimsTest.java
similarity index 99%
rename from systests/kerberos/src/test/java/org/apache/cxf/systest/kerberos/ldap/LDAPClaimsTest.java
rename to systests/ldap/src/test/java/org/apache/cxf/systest/ldap/sts/LDAPClaimsTest.java
index dd18c25f..3bcc690 100644
--- a/systests/kerberos/src/test/java/org/apache/cxf/systest/kerberos/ldap/LDAPClaimsTest.java
+++ b/systests/ldap/src/test/java/org/apache/cxf/systest/ldap/sts/LDAPClaimsTest.java
@@ -17,7 +17,7 @@
  * under the License.
  */
 
-package org.apache.cxf.systest.kerberos.ldap;
+package org.apache.cxf.systest.ldap.sts;
 
 import java.io.ByteArrayInputStream;
 import java.io.File;
@@ -90,6 +90,9 @@ import org.junit.runner.RunWith;
 //Inject an file containing entries
 @ApplyLdifFiles("ldap.ldif")
 
+/**
+ * Test the LdapClaimsHandler that ships with the STS
+ */
 public class LDAPClaimsTest extends AbstractLdapTestUnit {
 
     private static Properties props;
diff --git a/systests/ldap/src/test/resources/ldap-jaxrs.xml b/systests/ldap/src/test/resources/ldap-jaxrs.xml
new file mode 100644
index 0000000..0c4c294
--- /dev/null
+++ b/systests/ldap/src/test/resources/ldap-jaxrs.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0"?>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements. See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership. The ASF licenses this file
+    to you 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.
+
+-->
+<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util" xsi:schemaLocation="         http://www.springframework.org/schema/util         http://www.springframework.org/schema/util/spring-util-4.2.xsd          http://www.springframework.org/schema/beans         http://www.springframework.org/schema/beans/spring-beans-4.2.xsd">
+    <bean id="contextSource" class="org.springframework.ldap.core.support.LdapContextSource">
+        <property name="url" value="ldap://localhost:portno"/>
+        <property name="userDn" value="UID=admin,DC=example,DC=com"/>
+        <property name="password" value="ldap_su"/>
+    </bean>
+    <bean id="ldapTemplate" class="org.springframework.ldap.core.LdapTemplate">
+        <constructor-arg ref="contextSource"/>
+    </bean>
+</beans>
diff --git a/systests/kerberos/src/test/resources/ldap.ldif b/systests/ldap/src/test/resources/ldap.ldif
similarity index 100%
rename from systests/kerberos/src/test/resources/ldap.ldif
rename to systests/ldap/src/test/resources/ldap.ldif
diff --git a/systests/kerberos/src/test/resources/ldap.properties b/systests/ldap/src/test/resources/ldap.properties
similarity index 100%
rename from systests/kerberos/src/test/resources/ldap.properties
rename to systests/ldap/src/test/resources/ldap.properties
diff --git a/systests/kerberos/src/test/resources/ldap.xml b/systests/ldap/src/test/resources/ldap.xml
similarity index 100%
rename from systests/kerberos/src/test/resources/ldap.xml
rename to systests/ldap/src/test/resources/ldap.xml
diff --git a/systests/ldap/src/test/resources/logging.properties b/systests/ldap/src/test/resources/logging.properties
new file mode 100644
index 0000000..b2e5a79
--- /dev/null
+++ b/systests/ldap/src/test/resources/logging.properties
@@ -0,0 +1,74 @@
+#
+#
+#    Licensed to the Apache Software Foundation (ASF) under one
+#    or more contributor license agreements. See the NOTICE file
+#    distributed with this work for additional information
+#    regarding copyright ownership. The ASF licenses this file
+#    to you 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.
+#
+#
+############################################################
+#  	Default Logging Configuration File
+#
+# You can use a different file by specifying a filename
+# with the java.util.logging.config.file system property.  
+# For example java -Djava.util.logging.config.file=myfile
+############################################################
+
+############################################################
+#  	Global properties
+############################################################
+
+# "handlers" specifies a comma separated list of log Handler 
+# classes.  These handlers will be installed during VM startup.
+# Note that these classes must be on the system classpath.
+# By default we only configure a ConsoleHandler, which will only
+# show messages at the INFO and above levels.
+#handlers= java.util.logging.ConsoleHandler
+
+# To also add the FileHandler, use the following line instead.
+#handlers= java.util.logging.FileHandler, java.util.logging.ConsoleHandler
+
+# Default global logging level.
+# This specifies which kinds of events are logged across
+# all loggers.  For any given facility this global level
+# can be overriden by a facility specific level
+# Note that the ConsoleHandler also has a separate level
+# setting to limit messages printed to the console.
+.level= INFO
+
+############################################################
+# Handler specific properties.
+# Describes specific configuration info for Handlers.
+############################################################
+
+# default file output is in user's home directory.
+java.util.logging.FileHandler.pattern = %h/java%u.log
+java.util.logging.FileHandler.limit = 50000
+java.util.logging.FileHandler.count = 1
+java.util.logging.FileHandler.formatter = java.util.logging.XMLFormatter
+
+# Limit the message that are printed on the console to INFO and above.
+java.util.logging.ConsoleHandler.level = INFO
+java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
+
+
+############################################################
+# Facility specific properties.
+# Provides extra control for each logger.
+############################################################
+
+# For example, set the com.xyz.foo logger to only log SEVERE
+# messages:
+#com.xyz.foo.level = SEVERE
diff --git a/systests/pom.xml b/systests/pom.xml
index e1f2ab5..f8f643c 100644
--- a/systests/pom.xml
+++ b/systests/pom.xml
@@ -45,6 +45,7 @@
         <module>ws-security</module>
         <module>ws-security-examples</module>
         <module>kerberos</module>
+        <module>ldap</module>
         <module>rs-security</module>
         <module>wsdl_maven</module>
         <module>cdi</module>

-- 
To stop receiving notification emails like this one, please contact
coheigea@apache.org.