Skip to content

Commit 3855ac8

Browse files
committed
Add embedded LDAP container interface
Issue gh-10138
1 parent ba8844a commit 3855ac8

File tree

3 files changed

+50
-4
lines changed

3 files changed

+50
-4
lines changed

ldap/src/main/java/org/springframework/security/ldap/server/ApacheDSContainer.java

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -77,7 +77,8 @@
7777
* supported with no GA version to replace it.
7878
*/
7979
@Deprecated
80-
public class ApacheDSContainer implements InitializingBean, DisposableBean, Lifecycle, ApplicationContextAware {
80+
public class ApacheDSContainer
81+
implements EmbeddedLdapServerContainer, InitializingBean, DisposableBean, Lifecycle, ApplicationContextAware {
8182

8283
private final Log logger = LogFactory.getLog(getClass());
8384

@@ -177,10 +178,12 @@ public void setWorkingDirectory(File workingDir) {
177178
this.service.setWorkingDirectory(workingDir);
178179
}
179180

181+
@Override
180182
public void setPort(int port) {
181183
this.port = port;
182184
}
183185

186+
@Override
184187
public int getPort() {
185188
return this.port;
186189
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright 2002-2021 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.security.ldap.server;
18+
19+
/**
20+
* Provides lifecycle services for an embedded LDAP server.
21+
*
22+
* @author Eleftheria Stein
23+
* @since 5.6
24+
*/
25+
public interface EmbeddedLdapServerContainer {
26+
27+
/**
28+
* Returns the embedded LDAP server port.
29+
* @return the embedded LDAP server port
30+
*/
31+
int getPort();
32+
33+
/**
34+
* The embedded LDAP server port to connect to. Supplying 0 as the port indicates that
35+
* a random available port should be selected.
36+
* @param port the port to connect to
37+
*/
38+
void setPort(int port);
39+
40+
}

ldap/src/main/java/org/springframework/security/ldap/server/UnboundIdContainer.java

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -38,7 +38,8 @@
3838
/**
3939
* @author Eddú Meléndez
4040
*/
41-
public class UnboundIdContainer implements InitializingBean, DisposableBean, Lifecycle, ApplicationContextAware {
41+
public class UnboundIdContainer
42+
implements EmbeddedLdapServerContainer, InitializingBean, DisposableBean, Lifecycle, ApplicationContextAware {
4243

4344
private InMemoryDirectoryServer directoryServer;
4445

@@ -57,10 +58,12 @@ public UnboundIdContainer(String defaultPartitionSuffix, String ldif) {
5758
this.ldif = ldif;
5859
}
5960

61+
@Override
6062
public int getPort() {
6163
return this.port;
6264
}
6365

66+
@Override
6467
public void setPort(int port) {
6568
this.port = port;
6669
}

0 commit comments

Comments
 (0)