Skip to content

Commit

Permalink
Add embedded LDAP container interface
Browse files Browse the repository at this point in the history
Issue gh-10138
  • Loading branch information
eleftherias committed Jan 18, 2022
1 parent dfcd898 commit 2894ed3
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -77,7 +77,8 @@
* supported with no GA version to replace it.
*/
@Deprecated
public class ApacheDSContainer implements InitializingBean, DisposableBean, Lifecycle, ApplicationContextAware {
public class ApacheDSContainer
implements EmbeddedLdapServerContainer, InitializingBean, DisposableBean, Lifecycle, ApplicationContextAware {

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

Expand Down Expand Up @@ -177,10 +178,12 @@ public void setWorkingDirectory(File workingDir) {
this.service.setWorkingDirectory(workingDir);
}

@Override
public void setPort(int port) {
this.port = port;
}

@Override
public int getPort() {
return this.port;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright 2002-2022 the original author or authors.
*
* 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
*
* https://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.springframework.security.ldap.server;

/**
* Provides lifecycle services for an embedded LDAP server.
*
* @author Eleftheria Stein
* @since 5.7
*/
public interface EmbeddedLdapServerContainer {

/**
* Returns the embedded LDAP server port.
* @return the embedded LDAP server port
*/
int getPort();

/**
* The embedded LDAP server port to connect to. Supplying 0 as the port indicates that
* a random available port should be selected.
* @param port the port to connect to
*/
void setPort(int port);

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -38,7 +38,8 @@
/**
* @author Eddú Meléndez
*/
public class UnboundIdContainer implements InitializingBean, DisposableBean, Lifecycle, ApplicationContextAware {
public class UnboundIdContainer
implements EmbeddedLdapServerContainer, InitializingBean, DisposableBean, Lifecycle, ApplicationContextAware {

private InMemoryDirectoryServer directoryServer;

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

@Override
public int getPort() {
return this.port;
}

@Override
public void setPort(int port) {
this.port = port;
}
Expand Down

0 comments on commit 2894ed3

Please sign in to comment.