diff --git a/src/main/java/de/jalin/ldapadmin/ldap/LDAPConfig.java b/src/main/java/de/jalin/ldapadmin/ldap/LDAPConfig.java index 93215d1..c221ee0 100644 --- a/src/main/java/de/jalin/ldapadmin/ldap/LDAPConfig.java +++ b/src/main/java/de/jalin/ldapadmin/ldap/LDAPConfig.java @@ -1,6 +1,5 @@ package de.jalin.ldapadmin.ldap; -import de.jalin.ldapadmin.server.LDAPUriParser; import java.io.IOException; import java.io.InputStream; import java.util.Properties; @@ -14,11 +13,6 @@ public class LDAPConfig { private String ldapProviderUrl; private String ldapSecurityPrincipal; private String ldapSecurityPassword; - private String ldapDistinguishedName; - private String ldapHost; - private String ldapPort; - private String ldapDataDir; - private boolean ldapUseTLS; private String smtpFromAddress; private String smtpHost; private String smtpPort; @@ -29,13 +23,8 @@ public class LDAPConfig { private LDAPConfig() { ldapProviderUrl = "ldap://localhost:10389/dc=domain,dc=example,dc=com"; - ldapDistinguishedName = "dc=domain,dc=example,dc=com"; - ldapHost = "localhost"; - ldapPort = "10389"; - ldapUseTLS = false; ldapSecurityPrincipal = "uid=admin,ou=system"; ldapSecurityPassword = "secret"; - ldapDataDir = "ldapdata"; smtpHost = "localhost"; smtpPort = "25"; smtpFromAddress = "nobody@example.com"; @@ -46,7 +35,6 @@ public class LDAPConfig { ldapProviderUrl = props.getProperty("provider.url", ldapProviderUrl); ldapSecurityPrincipal = props.getProperty("security.principal", ldapSecurityPrincipal); ldapSecurityPassword = props.getProperty("security.password", ldapSecurityPassword); - ldapDataDir = props.getProperty("data.path", ldapDataDir); smtpHost = props.getProperty("smtp.host", smtpHost); smtpPort = props.getProperty("smtp.port", smtpPort); smtpFromAddress = props.getProperty("smtp.from", smtpFromAddress); @@ -54,11 +42,6 @@ public class LDAPConfig { pacAdmin = props.getProperty("pac.user", "xyz00"); pacPassword = props.getProperty("pac.password", "secret"); tempDir = props.getProperty("temp.dir", tempDir); - final LDAPUriParser uriParser = new LDAPUriParser(ldapProviderUrl); - ldapDistinguishedName = uriParser.getDn(); - ldapHost = uriParser.getHost(); - ldapPort = uriParser.getPort(); - ldapUseTLS = uriParser.isUseTLS(); } catch (IOException ex) { Logger.getLogger(LDAPConfig.class.getName()).log(Level.SEVERE, null, ex); } @@ -83,26 +66,6 @@ public class LDAPConfig { return ldapSecurityPassword; } - public String getLdapDistinguishedName() { - return ldapDistinguishedName; - } - - public String getLdapHost() { - return ldapHost; - } - - public String getLdapPort() { - return ldapPort; - } - - public String getLdapDataDir() { - return ldapDataDir; - } - - public boolean isLdapUseTLS() { - return ldapUseTLS; - } - public String getSmtpHost() { return smtpHost; } diff --git a/src/main/java/de/jalin/ldapadmin/server/LDAPUriParser.java b/src/main/java/de/jalin/ldapadmin/server/LDAPUriParser.java deleted file mode 100644 index 361462f..0000000 --- a/src/main/java/de/jalin/ldapadmin/server/LDAPUriParser.java +++ /dev/null @@ -1,37 +0,0 @@ -package de.jalin.ldapadmin.server; - -public class LDAPUriParser { - - private final boolean useTLS; - private final String dn; - private final String port; - private final String host; - - public LDAPUriParser (final String uri) { - final String[] uriParts = uri.split("\\/"); - final String protocol = uriParts[0]; - final String hostAndPort = uriParts[2]; - final String[] hostAndPortParts = hostAndPort.split(":"); - host = hostAndPortParts[0]; - port = hostAndPortParts[1]; - dn = uriParts[3]; - useTLS = protocol.toLowerCase().startsWith("ldaps"); - } - - public String getDn() { - return dn; - } - - public String getHost() { - return host; - } - - public String getPort() { - return port; - } - - public boolean isUseTLS() { - return useTLS; - } - -} diff --git a/src/main/java/de/jalin/ldapadmin/server/WebappDirectoryServer.java b/src/main/java/de/jalin/ldapadmin/server/WebappDirectoryServer.java deleted file mode 100644 index 359f045..0000000 --- a/src/main/java/de/jalin/ldapadmin/server/WebappDirectoryServer.java +++ /dev/null @@ -1,35 +0,0 @@ -package de.jalin.ldapadmin.server; - -import de.jalin.ldapadmin.ldap.DirectoryServiceRunner; -import de.jalin.ldapadmin.ldap.LDAPConfig; -import java.util.logging.Level; -import java.util.logging.Logger; -import javax.servlet.ServletContextEvent; -import javax.servlet.ServletContextListener; -import javax.servlet.annotation.WebListener; - -@WebListener -public class WebappDirectoryServer implements ServletContextListener { - - private DirectoryServiceRunner directoryServer; - - @Override - public void contextInitialized(final ServletContextEvent evt) { - try { - final LDAPConfig cfg = LDAPConfig.getConfig(); - directoryServer = new DirectoryServiceRunner("main", cfg.getLdapDistinguishedName(), cfg.getLdapHost(), cfg.getLdapPort(), cfg.isLdapUseTLS(), cfg.getLdapDataDir()); - } catch (Exception ex) { - Logger.getLogger(WebappDirectoryServer.class.getName()).log(Level.SEVERE, null, ex); - } - } - - @Override - public void contextDestroyed(final ServletContextEvent evt) { - try { - directoryServer.shutdown(); - } catch (Exception ex) { - Logger.getLogger(WebappDirectoryServer.class.getName()).log(Level.SEVERE, null, ex); - } - } - -} diff --git a/src/test/java/de/jalin/ldapadmin/server/TestLDAPUriParser.java b/src/test/java/de/jalin/ldapadmin/server/TestLDAPUriParser.java deleted file mode 100644 index 54717b6..0000000 --- a/src/test/java/de/jalin/ldapadmin/server/TestLDAPUriParser.java +++ /dev/null @@ -1,17 +0,0 @@ -package de.jalin.ldapadmin.server; - -import static org.junit.Assert.assertEquals; -import org.junit.Test; - -public class TestLDAPUriParser { - - @Test - public void testLDAPUriParser() { - final LDAPUriParser ldapUriParser = new LDAPUriParser("ldap://localhost:10389/dc=example,dc=com"); - assertEquals("localhost", ldapUriParser.getHost()); - assertEquals("10389", ldapUriParser.getPort()); - assertEquals("dc=example,dc=com", ldapUriParser.getDn()); - assertEquals(false, ldapUriParser.isUseTLS()); - } - -}