Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
<!-- please maintain alphabetical order here -->
<cxf.activemq.artemis.version>2.26.0</cxf.activemq.artemis.version>
<cxf.ahc.version>2.12.3</cxf.ahc.version>
<cxf.apacheds.version>2.0.0.AM26</cxf.apacheds.version>
<cxf.arquillian.version>1.7.0.Alpha13</cxf.arquillian.version>
<cxf.arquillian.weld.container.version>3.0.0.Final</cxf.arquillian.weld.container.version>
<cxf.aspectj.version>1.9.1</cxf.aspectj.version>
Expand Down Expand Up @@ -147,6 +146,7 @@
<cxf.junit.version>4.13.2</cxf.junit.version>
<cxf.junit5.version>5.9.1</cxf.junit5.version>
<cxf.kerby.version>2.0.2</cxf.kerby.version>
<cxf.ldapsdk.version>6.0.7</cxf.ldapsdk.version>
<cxf.littleproxy.version>1.1.2</cxf.littleproxy.version>
<cxf.logback.classic.version>1.4.5</cxf.logback.classic.version>
<cxf.lucene.version>9.4.2</cxf.lucene.version>
Expand Down Expand Up @@ -2171,7 +2171,7 @@
<properties>
<!-- EasyMock stills uses JDK Internal APIs: see please https://bugs.openjdk.java.net/browse/JDK-8255363 -->
<!-- JAXB: see please https://github.com/javaee/jaxb-v2/issues/1184 -->
<cxf.surefire.fork.vmargs>-ea --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/sun.security.x509=ALL-UNNAMED --add-opens java.base/sun.security.util=ALL-UNNAMED --add-opens java.xml/com.sun.org.apache.xerces.internal.dom=ALL-UNNAMED --add-opens java.base/java.net=ALL-UNNAMED --add-opens java.base/sun.net.www.protocol.https=ALL-UNNAMED</cxf.surefire.fork.vmargs>
<cxf.surefire.fork.vmargs>-ea --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.xml/com.sun.org.apache.xerces.internal.dom=ALL-UNNAMED --add-opens java.base/java.net=ALL-UNNAMED --add-opens java.base/sun.net.www.protocol.https=ALL-UNNAMED</cxf.surefire.fork.vmargs>
</properties>
</profile>
</profiles>
Expand Down
36 changes: 6 additions & 30 deletions systests/ldap/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -197,40 +197,16 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.directory.server</groupId>
<artifactId>apacheds-core-annotations</artifactId>
<version>${cxf.apacheds.version}</version>
<groupId>com.unboundid</groupId>
<artifactId>unboundid-ldapsdk</artifactId>
<version>${cxf.ldapsdk.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>
<groupId>org.zapodot</groupId>
<artifactId>embedded-ldap-junit</artifactId>
<version>0.9.0</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.springframework.ldap</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,56 +28,33 @@
import jakarta.ws.rs.InternalServerErrorException;
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.zapodot.junit.ldap.EmbeddedLdapRule;
import org.zapodot.junit.ldap.EmbeddedLdapRuleBuilder;

import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.ClassRule;
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 class JAXRSLDAPUserTest {
public static final String PORT = UserLDAPServer.PORT;
public static final String PORT2 = UserLDAPServer.PORT2;

@ClassRule
public static EmbeddedLdapRule embeddedLdapRule = EmbeddedLdapRuleBuilder
.newInstance()
.bindingToAddress("localhost")
.usingBindCredentials("ldap_su")
.usingBindDSN("UID=admin,DC=example,DC=com")
.usingDomainDsn("dc=example,dc=com")
.importingLdifs("ldap.ldif")
.build();

private static boolean portUpdated;

@BeforeClass
Expand All @@ -103,7 +80,7 @@ public void updatePort() throws Exception {
// 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", Integer.toString(super.getLdapServer().getPort()));
content = content.replaceAll("portno", Integer.toString(embeddedLdapRule.embeddedServerPort()));

Path path2 = FileSystems.getDefault().getPath(basedir, "/target/test-classes/ldap-jaxrsport.xml");
Files.write(path2, content.getBytes());
Expand All @@ -113,7 +90,7 @@ public void updatePort() throws Exception {

}

@org.junit.AfterClass
@AfterClass
public static void cleanup() throws Exception {
AbstractClientServerTestBase.stopAllServers();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,55 +45,29 @@
import org.apache.cxf.sts.claims.ProcessedClaim;
import org.apache.cxf.sts.claims.ProcessedClaimCollection;
import org.apache.cxf.ws.security.sts.provider.STSException;
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.apache.wss4j.common.principal.CustomTokenPrincipal;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.zapodot.junit.ldap.EmbeddedLdapRule;
import org.zapodot.junit.ldap.EmbeddedLdapRuleBuilder;

import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;

@RunWith(FrameworkRunner.class)

//Define the DirectoryService
@CreateDS(name = "LDAPClaimsTest-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")
import org.junit.ClassRule;

/**
* Test the LdapClaimsHandler that ships with the STS
*/
public class LDAPClaimsTest extends AbstractLdapTestUnit {
public class LDAPClaimsTest {
@ClassRule
public static EmbeddedLdapRule embeddedLdapRule = EmbeddedLdapRuleBuilder
.newInstance()
.bindingToAddress("localhost")
.usingBindCredentials("ldap_su")
.usingBindDSN("UID=admin,DC=example,DC=com")
.usingDomainDsn("dc=example,dc=com")
.importingLdifs("ldap.ldif")
.build();

private static Properties props;
private static boolean portUpdated;
Expand Down Expand Up @@ -122,7 +96,7 @@ public void updatePort() throws Exception {
// Read in ldap.xml and substitute in the correct port
Path path = FileSystems.getDefault().getPath(basedir, "/src/test/resources/ldap.xml");
String content = new String(Files.readAllBytes(path), StandardCharsets.UTF_8);
content = content.replaceAll("portno", Integer.toString(super.getLdapServer().getPort()));
content = content.replaceAll("portno", Integer.toString(embeddedLdapRule.embeddedServerPort()));

Path path2 = FileSystems.getDefault().getPath(basedir, "/target/test-classes/ldapport.xml");
Files.write(path2, content.getBytes());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,54 +34,29 @@
import org.apache.cxf.xkms.x509.repo.ldap.LdapCertificateRepo;
import org.apache.cxf.xkms.x509.repo.ldap.LdapSchemaConfig;
import org.apache.cxf.xkms.x509.repo.ldap.LdapSearch;
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.zapodot.junit.ldap.EmbeddedLdapRule;
import org.zapodot.junit.ldap.EmbeddedLdapRuleBuilder;

import org.junit.ClassRule;
import org.junit.Test;
import org.junit.runner.RunWith;

import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;

@RunWith(FrameworkRunner.class)

//Define the DirectoryService
@CreateDS(name = "LDAPCertificateRepoTest-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 the XKMS LDAP CertificateRepo
*/
public class LDAPCertificateRepoTest extends AbstractLdapTestUnit {
public class LDAPCertificateRepoTest {
@ClassRule
public static EmbeddedLdapRule embeddedLdapRule = EmbeddedLdapRuleBuilder
.newInstance()
.bindingToAddress("localhost")
.usingBindCredentials("ldap_su")
.usingBindDSN("UID=admin,DC=example,DC=com")
.usingDomainDsn("dc=example,dc=com")
.importingLdifs("ldap.ldif")
.build();

private static final String EXPECTED_SUBJECT_DN = "cn=dave,ou=users";
private static final String ROOT_DN = "dc=example,dc=com";
private static final String EXPECTED_SUBJECT_DN2 = "cn=newuser,ou=users";
Expand Down Expand Up @@ -160,7 +135,7 @@ public void testSaveServiceCert() throws Exception {
}

private CertificateRepo createLdapCertificateRepo() throws CertificateException {
LdapSearch ldapSearch = new LdapSearch("ldap://localhost:" + super.getLdapServer().getPort(),
LdapSearch ldapSearch = new LdapSearch("ldap://localhost:" + embeddedLdapRule.embeddedServerPort(),
"UID=admin,DC=example,DC=com", "ldap_su", 2);

LdapSchemaConfig ldapSchemaConfig = new LdapSchemaConfig();
Expand Down
2 changes: 1 addition & 1 deletion systests/ldap/src/test/resources/ldap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<entry key="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname" value="sn"/>
<entry key="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress" value="mail"/>
<entry key="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/country" value="c"/>
<entry key="http://custom/x509" value="usercertificate"/>
<entry key="http://custom/x509" value="userCertificate"/>
</util:map>
<bean id="testClaimsHandler" class="org.apache.cxf.sts.claims.LdapClaimsHandler">
<property name="ldapTemplate" ref="ldapTemplate" />
Expand Down