Loading projects/cadcAccessControl-Server/config/.dbrc_example +1 −1 Original line number Diff line number Diff line #server proxyuser proxyUserDN password driver serverURL <serverType in LdapConfig.properties: LDAP or DEVLDAP> <proxyUser in LdapConfig.properties> <proxyUserLdapDN> <password> N/A N/A <server hostname> <proxyUser in LdapConfig.properties> <proxyUserLdapDN> <password> N/A N/A projects/cadcAccessControl-Server/config/LdapConfig.properties +0 −1 Original line number Diff line number Diff line # This are the configuration fields required by the Ldap server = <name of server> port = <389 or 636> serverType = <DEVLDAP or LDAP or...> proxyUser = <name of proxy user> usersDn = <DN of users branch> groupsDn = <DN of groups branch> Loading projects/cadcAccessControl-Server/src/ca/nrc/cadc/ac/server/ldap/LdapConfig.java +7 −17 Original line number Diff line number Diff line Loading @@ -94,7 +94,6 @@ public class LdapConfig ".properties"; public static final String LDAP_SERVER = "server"; public static final String LDAP_PORT = "port"; public static final String LDAP_SERVER_TYPE = "serverType"; public static final String LDAP_SERVER_PROXY_USER = "proxyUser"; public static final String LDAP_USERS_DN = "usersDn"; public static final String LDAP_GROUPS_DN = "groupsDn"; Loading Loading @@ -122,7 +121,12 @@ public class LdapConfig public static LdapConfig getLdapConfig() { PropertiesReader pr = new PropertiesReader(CONFIG); return getLdapConfig(CONFIG); } public static LdapConfig getLdapConfig(final String ldapProperties) { PropertiesReader pr = new PropertiesReader(ldapProperties); MultiValuedProperties config = pr.getAllProperties(); Loading @@ -146,20 +150,6 @@ public class LdapConfig } int port = Integer.valueOf(prop.get(0)); prop = config.getProperty(LDAP_SERVER_TYPE); if ((prop == null) || (prop.size() != 1)) { throw new RuntimeException("failed to read property " + LDAP_SERVER_TYPE); } String serverType = prop.get(0); if (!"LDAP".equalsIgnoreCase(serverType) && !"DEVLDAP".equalsIgnoreCase(serverType)) { throw new RuntimeException("Unknow server type: " + serverType + " (valid: LDAP and DEVLDAP)"); } prop = config.getProperty(LDAP_SERVER_PROXY_USER); if ((prop == null) || (prop.size() != 1)) { Loading Loading @@ -205,7 +195,7 @@ public class LdapConfig { throw new RuntimeException("failed to read .dbrc file "); } ConnectionConfig cc = dbConfig.getConnectionConfig(serverType, ldapProxy); ConnectionConfig cc = dbConfig.getConnectionConfig(server, ldapProxy); if ( (cc == null) || (cc.getUsername() == null) || (cc.getPassword() == null)) { throw new RuntimeException("failed to find connection info in ~/.dbrc"); Loading projects/cadcAccessControl-Server/test/src/ca/nrc/cadc/ac/server/ldap/AbstractLdapDAOTest.java 0 → 100644 +82 −0 Original line number Diff line number Diff line /** ************************************************************************ ******************* CANADIAN ASTRONOMY DATA CENTRE ******************* ************** CENTRE CANADIEN DE DONNÉES ASTRONOMIQUES ************** * * (c) 2014. (c) 2014. * Government of Canada Gouvernement du Canada * National Research Council Conseil national de recherches * Ottawa, Canada, K1A 0R6 Ottawa, Canada, K1A 0R6 * All rights reserved Tous droits réservés * * NRC disclaims any warranties, Le CNRC dénie toute garantie * expressed, implied, or énoncée, implicite ou légale, * statutory, of any kind with de quelque nature que ce * respect to the software, soit, concernant le logiciel, * including without limitation y compris sans restriction * any warranty of merchantability toute garantie de valeur * or fitness for a particular marchande ou de pertinence * purpose. NRC shall not be pour un usage particulier. * liable in any event for any Le CNRC ne pourra en aucun cas * damages, whether direct or être tenu responsable de tout * indirect, special or general, dommage, direct ou indirect, * consequential or incidental, particulier ou général, * arising from the use of the accessoire ou fortuit, résultant * software. Neither the name de l'utilisation du logiciel. Ni * of the National Research le nom du Conseil National de * Council of Canada nor the Recherches du Canada ni les noms * names of its contributors may de ses participants ne peuvent * be used to endorse or promote être utilisés pour approuver ou * products derived from this promouvoir les produits dérivés * software without specific prior de ce logiciel sans autorisation * written permission. préalable et particulière * par écrit. * * This file is part of the Ce fichier fait partie du projet * OpenCADC project. OpenCADC. * * OpenCADC is free software: OpenCADC est un logiciel libre ; * you can redistribute it and/or vous pouvez le redistribuer ou le * modify it under the terms of modifier suivant les termes de * the GNU Affero General Public la “GNU Affero General Public * License as published by the License” telle que publiée * Free Software Foundation, par la Free Software Foundation * either version 3 of the : soit la version 3 de cette * License, or (at your option) licence, soit (à votre gré) * any later version. toute version ultérieure. * * OpenCADC is distributed in the OpenCADC est distribué * hope that it will be useful, dans l’espoir qu’il vous * but WITHOUT ANY WARRANTY; sera utile, mais SANS AUCUNE * without even the implied GARANTIE : sans même la garantie * warranty of MERCHANTABILITY implicite de COMMERCIALISABILITÉ * or FITNESS FOR A PARTICULAR ni d’ADÉQUATION À UN OBJECTIF * PURPOSE. See the GNU Affero PARTICULIER. Consultez la Licence * General Public License for Générale Publique GNU Affero * more details. pour plus de détails. * * You should have received Vous devriez avoir reçu une * a copy of the GNU Affero copie de la Licence Générale * General Public License along Publique GNU Affero avec * with OpenCADC. If not, see OpenCADC ; si ce n’est * <http://www.gnu.org/licenses/>. pas le cas, consultez : * <http://www.gnu.org/licenses/>. * ************************************************************************ */ package ca.nrc.cadc.ac.server.ldap; /** * Created by jburke on 2014-11-03. */ public class AbstractLdapDAOTest { static final String CONFIG = LdapConfig.class.getSimpleName() + ".test.properties"; static protected LdapConfig getLdapConfig() { return LdapConfig.getLdapConfig(CONFIG); } } projects/cadcAccessControl-Server/test/src/ca/nrc/cadc/ac/server/ldap/LdapDAOTest.java +3 −14 Original line number Diff line number Diff line Loading @@ -84,25 +84,15 @@ import org.junit.BeforeClass; import static org.junit.Assert.*; public class LdapDAOTest public class LdapDAOTest extends AbstractLdapDAOTest { static String usersDN = "ou=Users,ou=ds,dc=canfartest,dc=net"; static String groupsDN = "ou=Groups,ou=ds,dc=canfartest,dc=net"; static String adminGroupsDN = "ou=adminGroups,ou=ds,dc=canfartest,dc=net"; static LdapConfig config; @BeforeClass public static void setUpBeforeClass() throws Exception { // get the configuration of the development server from and config files... LdapConfig devServerConfig = LdapConfig.getLdapConfig(); // ... but use the test tree config = new LdapConfig(devServerConfig.getServer(), devServerConfig.getPort(), devServerConfig.getProxyUserDN(), devServerConfig.getProxyPasswd(), usersDN, groupsDN, adminGroupsDN); config = getLdapConfig(); } @Test public void testLdapBindConnection() throws Exception Loading Loading @@ -182,7 +172,6 @@ public class LdapDAOTest private void testConnection(final LDAPConnection ldapCon) { assertTrue("Not connected but should be.", ldapCon.isConnected()); assertTrue("Should be SSLSocketFactory.", (ldapCon.getSocketFactory() instanceof SSLSocketFactory)); } } Loading
projects/cadcAccessControl-Server/config/.dbrc_example +1 −1 Original line number Diff line number Diff line #server proxyuser proxyUserDN password driver serverURL <serverType in LdapConfig.properties: LDAP or DEVLDAP> <proxyUser in LdapConfig.properties> <proxyUserLdapDN> <password> N/A N/A <server hostname> <proxyUser in LdapConfig.properties> <proxyUserLdapDN> <password> N/A N/A
projects/cadcAccessControl-Server/config/LdapConfig.properties +0 −1 Original line number Diff line number Diff line # This are the configuration fields required by the Ldap server = <name of server> port = <389 or 636> serverType = <DEVLDAP or LDAP or...> proxyUser = <name of proxy user> usersDn = <DN of users branch> groupsDn = <DN of groups branch> Loading
projects/cadcAccessControl-Server/src/ca/nrc/cadc/ac/server/ldap/LdapConfig.java +7 −17 Original line number Diff line number Diff line Loading @@ -94,7 +94,6 @@ public class LdapConfig ".properties"; public static final String LDAP_SERVER = "server"; public static final String LDAP_PORT = "port"; public static final String LDAP_SERVER_TYPE = "serverType"; public static final String LDAP_SERVER_PROXY_USER = "proxyUser"; public static final String LDAP_USERS_DN = "usersDn"; public static final String LDAP_GROUPS_DN = "groupsDn"; Loading Loading @@ -122,7 +121,12 @@ public class LdapConfig public static LdapConfig getLdapConfig() { PropertiesReader pr = new PropertiesReader(CONFIG); return getLdapConfig(CONFIG); } public static LdapConfig getLdapConfig(final String ldapProperties) { PropertiesReader pr = new PropertiesReader(ldapProperties); MultiValuedProperties config = pr.getAllProperties(); Loading @@ -146,20 +150,6 @@ public class LdapConfig } int port = Integer.valueOf(prop.get(0)); prop = config.getProperty(LDAP_SERVER_TYPE); if ((prop == null) || (prop.size() != 1)) { throw new RuntimeException("failed to read property " + LDAP_SERVER_TYPE); } String serverType = prop.get(0); if (!"LDAP".equalsIgnoreCase(serverType) && !"DEVLDAP".equalsIgnoreCase(serverType)) { throw new RuntimeException("Unknow server type: " + serverType + " (valid: LDAP and DEVLDAP)"); } prop = config.getProperty(LDAP_SERVER_PROXY_USER); if ((prop == null) || (prop.size() != 1)) { Loading Loading @@ -205,7 +195,7 @@ public class LdapConfig { throw new RuntimeException("failed to read .dbrc file "); } ConnectionConfig cc = dbConfig.getConnectionConfig(serverType, ldapProxy); ConnectionConfig cc = dbConfig.getConnectionConfig(server, ldapProxy); if ( (cc == null) || (cc.getUsername() == null) || (cc.getPassword() == null)) { throw new RuntimeException("failed to find connection info in ~/.dbrc"); Loading
projects/cadcAccessControl-Server/test/src/ca/nrc/cadc/ac/server/ldap/AbstractLdapDAOTest.java 0 → 100644 +82 −0 Original line number Diff line number Diff line /** ************************************************************************ ******************* CANADIAN ASTRONOMY DATA CENTRE ******************* ************** CENTRE CANADIEN DE DONNÉES ASTRONOMIQUES ************** * * (c) 2014. (c) 2014. * Government of Canada Gouvernement du Canada * National Research Council Conseil national de recherches * Ottawa, Canada, K1A 0R6 Ottawa, Canada, K1A 0R6 * All rights reserved Tous droits réservés * * NRC disclaims any warranties, Le CNRC dénie toute garantie * expressed, implied, or énoncée, implicite ou légale, * statutory, of any kind with de quelque nature que ce * respect to the software, soit, concernant le logiciel, * including without limitation y compris sans restriction * any warranty of merchantability toute garantie de valeur * or fitness for a particular marchande ou de pertinence * purpose. NRC shall not be pour un usage particulier. * liable in any event for any Le CNRC ne pourra en aucun cas * damages, whether direct or être tenu responsable de tout * indirect, special or general, dommage, direct ou indirect, * consequential or incidental, particulier ou général, * arising from the use of the accessoire ou fortuit, résultant * software. Neither the name de l'utilisation du logiciel. Ni * of the National Research le nom du Conseil National de * Council of Canada nor the Recherches du Canada ni les noms * names of its contributors may de ses participants ne peuvent * be used to endorse or promote être utilisés pour approuver ou * products derived from this promouvoir les produits dérivés * software without specific prior de ce logiciel sans autorisation * written permission. préalable et particulière * par écrit. * * This file is part of the Ce fichier fait partie du projet * OpenCADC project. OpenCADC. * * OpenCADC is free software: OpenCADC est un logiciel libre ; * you can redistribute it and/or vous pouvez le redistribuer ou le * modify it under the terms of modifier suivant les termes de * the GNU Affero General Public la “GNU Affero General Public * License as published by the License” telle que publiée * Free Software Foundation, par la Free Software Foundation * either version 3 of the : soit la version 3 de cette * License, or (at your option) licence, soit (à votre gré) * any later version. toute version ultérieure. * * OpenCADC is distributed in the OpenCADC est distribué * hope that it will be useful, dans l’espoir qu’il vous * but WITHOUT ANY WARRANTY; sera utile, mais SANS AUCUNE * without even the implied GARANTIE : sans même la garantie * warranty of MERCHANTABILITY implicite de COMMERCIALISABILITÉ * or FITNESS FOR A PARTICULAR ni d’ADÉQUATION À UN OBJECTIF * PURPOSE. See the GNU Affero PARTICULIER. Consultez la Licence * General Public License for Générale Publique GNU Affero * more details. pour plus de détails. * * You should have received Vous devriez avoir reçu une * a copy of the GNU Affero copie de la Licence Générale * General Public License along Publique GNU Affero avec * with OpenCADC. If not, see OpenCADC ; si ce n’est * <http://www.gnu.org/licenses/>. pas le cas, consultez : * <http://www.gnu.org/licenses/>. * ************************************************************************ */ package ca.nrc.cadc.ac.server.ldap; /** * Created by jburke on 2014-11-03. */ public class AbstractLdapDAOTest { static final String CONFIG = LdapConfig.class.getSimpleName() + ".test.properties"; static protected LdapConfig getLdapConfig() { return LdapConfig.getLdapConfig(CONFIG); } }
projects/cadcAccessControl-Server/test/src/ca/nrc/cadc/ac/server/ldap/LdapDAOTest.java +3 −14 Original line number Diff line number Diff line Loading @@ -84,25 +84,15 @@ import org.junit.BeforeClass; import static org.junit.Assert.*; public class LdapDAOTest public class LdapDAOTest extends AbstractLdapDAOTest { static String usersDN = "ou=Users,ou=ds,dc=canfartest,dc=net"; static String groupsDN = "ou=Groups,ou=ds,dc=canfartest,dc=net"; static String adminGroupsDN = "ou=adminGroups,ou=ds,dc=canfartest,dc=net"; static LdapConfig config; @BeforeClass public static void setUpBeforeClass() throws Exception { // get the configuration of the development server from and config files... LdapConfig devServerConfig = LdapConfig.getLdapConfig(); // ... but use the test tree config = new LdapConfig(devServerConfig.getServer(), devServerConfig.getPort(), devServerConfig.getProxyUserDN(), devServerConfig.getProxyPasswd(), usersDN, groupsDN, adminGroupsDN); config = getLdapConfig(); } @Test public void testLdapBindConnection() throws Exception Loading Loading @@ -182,7 +172,6 @@ public class LdapDAOTest private void testConnection(final LDAPConnection ldapCon) { assertTrue("Not connected but should be.", ldapCon.isConnected()); assertTrue("Should be SSLSocketFactory.", (ldapCon.getSocketFactory() instanceof SSLSocketFactory)); } }