From ad95bf357b75ea2844a9f46477db9cd01fab5cef Mon Sep 17 00:00:00 2001 From: Peter Hormanns Date: Thu, 24 Oct 2019 19:21:07 +0200 Subject: [PATCH] small fixes, autoconfig option --- .../hsadmin/service/customer/CustomerVO.java | 3 +- .../main/resources/META-INF/persistence.xml | 4 +- .../de/hsadmin/service/ldap/LDAPRead.java | 80 +++++++++++++++++++ .../java/de/hsadmin/web/CustomerPanel.java | 1 - .../de/hsadmin/web/DomainOptionsEditor.java | 4 +- .../main/java/de/hsadmin/web/DomainPanel.java | 2 + .../main/java/de/hsadmin/web/GenericForm.java | 14 ++-- .../java/de/hsadmin/web/PackagePanel.java | 1 + .../resources/de/hsadmin/web/main.properties | 2 +- .../de/hsadmin/web/main_de.properties | 2 +- 10 files changed, 101 insertions(+), 12 deletions(-) create mode 100644 ldap-services/src/test/java/de/hsadmin/service/ldap/LDAPRead.java diff --git a/cust-services/src/main/java/de/hsadmin/service/customer/CustomerVO.java b/cust-services/src/main/java/de/hsadmin/service/customer/CustomerVO.java index e420312..85032aa 100644 --- a/cust-services/src/main/java/de/hsadmin/service/customer/CustomerVO.java +++ b/cust-services/src/main/java/de/hsadmin/service/customer/CustomerVO.java @@ -68,10 +68,11 @@ public class CustomerVO extends AbstractVO { @ElementsType(SEPADirectDebitVO.class) @ReadWrite(ReadWritePolicy.READ) - @Display(visible=DisplayPolicy.NEVER) + @Display(visible=DisplayPolicy.OPTIONAL) private List sepaDirectDebits; @ReadWrite(ReadWritePolicy.READWRITE) + @Display(visible=DisplayPolicy.NEVER) private final StringSet priceLists; public CustomerVO() throws TechnicalException { diff --git a/ldap-services/src/main/resources/META-INF/persistence.xml b/ldap-services/src/main/resources/META-INF/persistence.xml index a432242..f4765c8 100644 --- a/ldap-services/src/main/resources/META-INF/persistence.xml +++ b/ldap-services/src/main/resources/META-INF/persistence.xml @@ -5,6 +5,7 @@ xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"> HsarDataSource + diff --git a/ldap-services/src/test/java/de/hsadmin/service/ldap/LDAPRead.java b/ldap-services/src/test/java/de/hsadmin/service/ldap/LDAPRead.java new file mode 100644 index 0000000..2fcf9ee --- /dev/null +++ b/ldap-services/src/test/java/de/hsadmin/service/ldap/LDAPRead.java @@ -0,0 +1,80 @@ +package de.hsadmin.service.ldap; + +import java.io.IOException; +import java.security.KeyManagementException; +import java.security.NoSuchAlgorithmException; +import java.security.SecureRandom; +import java.security.cert.CertificateException; +import java.security.cert.X509Certificate; +import java.util.Properties; + +import javax.naming.AuthenticationException; +import javax.naming.Context; +import javax.naming.NamingException; +import javax.naming.directory.Attributes; +import javax.naming.ldap.InitialLdapContext; +import javax.naming.ldap.StartTlsRequest; +import javax.naming.ldap.StartTlsResponse; +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLSocketFactory; +import javax.net.ssl.TrustManager; +import javax.net.ssl.X509TrustManager; + +import de.hsadmin.common.config.Config; +import de.hsadmin.common.error.TechnicalException; + + + +public class LDAPRead { + + public static void main(String[] args) { + String ldapConnectString = ""; + String bind = ""; + String passwd = ""; + try { + Config conf = Config.getInstance(); + ldapConnectString = conf.getProperty("ldap.connect.url"); + bind = conf.getProperty("ldap.connect.bind"); + passwd = conf.getProperty("ldap.connect.password"); + } catch (TechnicalException e) { + System.out.println(e.getLocalizedMessage()); + return; + } + try { + try { + Thread.sleep(100L); + } catch (InterruptedException e1) { + } + + final Properties env = new Properties(); + env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); + env.put("com.sun.jndi.ldap.connect.pool", "true"); + env.put(Context.PROVIDER_URL, ldapConnectString); + final InitialLdapContext ctx = new InitialLdapContext(env, null); + final StartTlsResponse tls = (StartTlsResponse) ctx.extendedOperation(new StartTlsRequest()); + tls.negotiate(); + ctx.addToEnvironment(Context.SECURITY_AUTHENTICATION, "simple"); + String principal = bind; + ctx.addToEnvironment(Context.SECURITY_PRINCIPAL, principal); + ctx.addToEnvironment(Context.SECURITY_CREDENTIALS, passwd); + try { + ctx.reconnect(null); + String uid = "hsh-uwemueller"; + final Attributes attributes = ctx.getAttributes("uid=" + uid + ",ou=users,ou=" + uid.substring(0, 3) + ",ou=customers"); + System.out.println(attributes.get("nickName")); + } catch (AuthenticationException e) { + tls.close(); + ctx.close(); + System.out.println("Authentication failed " + e.getLocalizedMessage()); + return; + } + tls.close(); + ctx.close(); + System.out.println("Success"); + } catch (NamingException | IOException e) { + System.out.println("Authentication failed " + e.getLocalizedMessage()); + } + + } + +} diff --git a/web/src/main/java/de/hsadmin/web/CustomerPanel.java b/web/src/main/java/de/hsadmin/web/CustomerPanel.java index 0b3e906..d9a78a1 100644 --- a/web/src/main/java/de/hsadmin/web/CustomerPanel.java +++ b/web/src/main/java/de/hsadmin/web/CustomerPanel.java @@ -37,7 +37,6 @@ public class CustomerPanel extends CustomComponent implements IHSPanel, Selected final TabSheet tabsheet = new TabSheet(); tabsheet.setSizeFull(); tabsheet.addSelectedTabChangeListener(this); - tabsheet.addSelectedTabChangeListener(this); tabsheet.addTab(new GenericForm("customer", session, itemId, "name"), i18n.getText("customer")); final HSTab contactsTab = new HSTab("contact", session, "customer", itemId, "email"); diff --git a/web/src/main/java/de/hsadmin/web/DomainOptionsEditor.java b/web/src/main/java/de/hsadmin/web/DomainOptionsEditor.java index 4347949..8328a2b 100644 --- a/web/src/main/java/de/hsadmin/web/DomainOptionsEditor.java +++ b/web/src/main/java/de/hsadmin/web/DomainOptionsEditor.java @@ -26,8 +26,8 @@ public class DomainOptionsEditor extends CustomComponent implements IHSEditor { "htdocsfallback", "includes", "backupmxforexternalmx", - "letsencrypt"}; -// "phplatest"}; + "letsencrypt", + "autoconfig"}; private final PropertyInfo propertyInfo; private final VerticalLayout layout; diff --git a/web/src/main/java/de/hsadmin/web/DomainPanel.java b/web/src/main/java/de/hsadmin/web/DomainPanel.java index 607fecf..d0b0a11 100644 --- a/web/src/main/java/de/hsadmin/web/DomainPanel.java +++ b/web/src/main/java/de/hsadmin/web/DomainPanel.java @@ -31,6 +31,8 @@ public class DomainPanel extends CustomComponent implements IHSPanel, SelectedTa { final I18N i18n = session.getI18N(); final TabSheet tabsheet = new TabSheet(); + tabsheet.setSizeFull(); + tabsheet.addSelectedTabChangeListener(this); tabsheet.addTab(new GenericForm("domain", session, itemId, "name"), i18n.getText("domain")); HSTab emailTab = new HSTab("emailaddress", session, "domain", itemId, "id"); emailTab.fillTable(); diff --git a/web/src/main/java/de/hsadmin/web/GenericForm.java b/web/src/main/java/de/hsadmin/web/GenericForm.java index 544ef6c..29b595d 100644 --- a/web/src/main/java/de/hsadmin/web/GenericForm.java +++ b/web/src/main/java/de/hsadmin/web/GenericForm.java @@ -17,6 +17,7 @@ import de.hsadmin.model.TicketService; import de.hsadmin.rpc.HSAdminSession; import de.hsadmin.rpc.PropertyInfo; import de.hsadmin.rpc.RpcException; +import de.hsadmin.rpc.enums.DisplayPolicy; public class GenericForm extends CustomComponent { @@ -32,11 +33,14 @@ public class GenericForm extends CustomComponent { final Iterator iterator = session.getModulesManager().module(module).properties(); while (iterator.hasNext()) { final PropertyInfo propertyInfo = iterator.next(); - final String inputName = propertyInfo.getName(); - final IEditorFactory editorFactory = FactoryProducer.getEditorFactory(session.getI18N(), module); - final IHSEditor field = editorFactory.getEditor("view", propertyInfo); - inputFields.put(inputName, field); - formLayout.addComponent(field); + final DisplayPolicy displayVisible = propertyInfo.getDisplayVisible(); + if (DisplayPolicy.ALWAYS.equals(displayVisible)) { + final String inputName = propertyInfo.getName(); + final IEditorFactory editorFactory = FactoryProducer.getEditorFactory(session.getI18N(), module); + final IHSEditor field = editorFactory.getEditor("view", propertyInfo); + inputFields.put(inputName, field); + formLayout.addComponent(field); + } } setCompositionRoot(formLayout); diff --git a/web/src/main/java/de/hsadmin/web/PackagePanel.java b/web/src/main/java/de/hsadmin/web/PackagePanel.java index 7ac180e..01fa48b 100644 --- a/web/src/main/java/de/hsadmin/web/PackagePanel.java +++ b/web/src/main/java/de/hsadmin/web/PackagePanel.java @@ -30,6 +30,7 @@ public class PackagePanel extends CustomComponent implements IHSPanel, SelectedT public TabSheet createTabs(Object itemId) throws RpcException { final TabSheet tabsheet = new TabSheet(); + tabsheet.setSizeFull(); tabsheet.addSelectedTabChangeListener(this); tabsheet.addTab(new GenericForm("pac", session, itemId, "name"), session.getI18N().getText("pac")); final HSTab usersTab = new HSTab("user", session, "pac", itemId, "name"); diff --git a/web/src/main/resources/de/hsadmin/web/main.properties b/web/src/main/resources/de/hsadmin/web/main.properties index 3069810..ab06143 100644 --- a/web/src/main/resources/de/hsadmin/web/main.properties +++ b/web/src/main/resources/de/hsadmin/web/main.properties @@ -40,7 +40,7 @@ domainoption.htdocsfallback=htdocsfallback domainoption.includes=includes domainoption.backupmxforexternalmx=backupmxforexternalmx domainoption.letsencrypt=letsencrypt -# domainoption.phplatest=PHP 7.3 +domainoption.autoconfig=email autoconfig and autodiscover mysqluser.name=MySql username mysqluser.instance=MySql instance mysqluser.pac=MySql package diff --git a/web/src/main/resources/de/hsadmin/web/main_de.properties b/web/src/main/resources/de/hsadmin/web/main_de.properties index fabadca..bf5f3b1 100644 --- a/web/src/main/resources/de/hsadmin/web/main_de.properties +++ b/web/src/main/resources/de/hsadmin/web/main_de.properties @@ -40,7 +40,7 @@ domainoption.htdocsfallback=Fallback auf htdocs/htdocs-ssl domainoption.includes=Includes domainoption.backupmxforexternalmx=Backup-MX für externen Mailserver domainoption.letsencrypt=Let's Encrypt-Zertifikat -# domainoption.phplatest=PHP 7.3 +domainoption.autoconfig=E-Mail Auto-Konfiguration mysqluser.name=MySQL-Benutzer mysqluser.instance=Datenbanksystem mysqluser.pac=Web-Paket