Loading cadcAccessControl-Server/src/ca/nrc/cadc/ac/server/ldap/LdapConfig.java +45 −2 Original line number Diff line number Diff line Loading @@ -115,8 +115,15 @@ public class LdapConfig public enum PoolPolicy { roundRobin, fewestConnections; }; fewestConnections } public enum SystemState { ONLINE, READONLY, OFFLINE } public class LdapPool { Loading Loading @@ -210,6 +217,7 @@ public class LdapConfig private String proxyUserDN; private String proxyPasswd; private String dbrcHost; private SystemState systemState; public String getProxyUserDN() { Loading Loading @@ -251,6 +259,8 @@ public class LdapConfig ldapConfig.groupsDN = getProperty(pr, LDAP_GROUPS_DN); ldapConfig.adminGroupsDN = getProperty(pr, LDAP_ADMIN_GROUPS_DN); ldapConfig.systemState = getSystemState(ldapConfig); try { DBConfig dbConfig = new DBConfig(); Loading Loading @@ -304,6 +314,27 @@ public class LdapConfig return Arrays.asList(props); } private static SystemState getSystemState(LdapConfig ldapConfig) { if (ldapConfig.getReadOnlyPool().getMaxSize() == 0) { return SystemState.OFFLINE; } if (ldapConfig.getUnboundReadOnlyPool().getMaxSize() == 0) { return SystemState.OFFLINE; } if (ldapConfig.getReadWritePool().getMaxSize() == 0) { return SystemState.READONLY; } return SystemState.ONLINE; } @Override public boolean equals(Object other) { Loading Loading @@ -409,6 +440,17 @@ public class LdapConfig return this.proxyPasswd; } /** * Check if in read-only or offline mode. * * A read max connection size of zero implies offline mode. * A read-wrtie max connection size of zero implies read-only mode. */ public SystemState getSystemState() { return systemState; } public String toString() { StringBuilder sb = new StringBuilder(); Loading @@ -421,4 +463,5 @@ public class LdapConfig return sb.toString(); } } cadcAccessControl-Server/src/ca/nrc/cadc/ac/server/ldap/LdapConnectionPool.java +4 −41 Original line number Diff line number Diff line Loading @@ -69,13 +69,11 @@ package ca.nrc.cadc.ac.server.ldap; import org.apache.log4j.Logger; import ca.nrc.cadc.ac.server.ldap.LdapConfig.LdapPool; import ca.nrc.cadc.ac.server.ldap.LdapConfig.PoolPolicy; import ca.nrc.cadc.ac.server.ldap.LdapConfig.SystemState; import ca.nrc.cadc.net.TransientException; import ca.nrc.cadc.profiler.Profiler; import com.unboundid.ldap.sdk.FewestConnectionsServerSet; import com.unboundid.ldap.sdk.Filter; import com.unboundid.ldap.sdk.LDAPConnection; Loading @@ -87,6 +85,7 @@ import com.unboundid.ldap.sdk.SearchRequest; import com.unboundid.ldap.sdk.SearchScope; import com.unboundid.ldap.sdk.ServerSet; import com.unboundid.ldap.sdk.SimpleBindRequest; import org.apache.log4j.Logger; /** * This object is designed to be shared between the DAO classes Loading @@ -100,13 +99,6 @@ public class LdapConnectionPool { private static final Logger logger = Logger.getLogger(LdapConnectionPool.class); private enum SystemState { ONLINE, READONLY, OFFLINE }; Profiler profiler = new Profiler(LdapConnectionPool.class); protected LdapConfig currentConfig; Loading @@ -115,7 +107,7 @@ public class LdapConnectionPool private Object poolMonitor = new Object(); private LDAPConnectionOptions connectionOptions; private boolean readOnly; SystemState systemState = SystemState.ONLINE; private SystemState systemState; public LdapConnectionPool(LdapConfig config, LdapPool poolConfig, String poolName, boolean boundPool, boolean readOnly) { Loading @@ -133,7 +125,7 @@ public class LdapConnectionPool this.poolName = poolName; this.readOnly = readOnly; systemState = getSystemState(config); systemState = config.getSystemState(); logger.debug("Construct pool: " + poolName + ". system state: " + systemState); if (SystemState.ONLINE.equals(systemState) || (SystemState.READONLY.equals(systemState) && readOnly)) { Loading Loading @@ -288,33 +280,4 @@ public class LdapConnectionPool } } /** * Check if in read-only or offline mode. * * A read max connection size of zero implies offline mode. * A read-wrtie max connection size of zero implies read-only mode. */ private SystemState getSystemState(LdapConfig config) { if (config.getReadOnlyPool().getMaxSize() == 0) { return SystemState.OFFLINE; } if (config.getUnboundReadOnlyPool().getMaxSize() == 0) { return SystemState.OFFLINE; } if (config.getReadWritePool().getMaxSize() == 0) { return SystemState.READONLY; } return SystemState.ONLINE; } } cadcAccessControl-Server/src/ca/nrc/cadc/ac/server/ldap/LdapUserDAO.java +1 −8 Original line number Diff line number Diff line Loading @@ -209,7 +209,7 @@ public class LdapUserDAO<T extends Principal> extends LdapDAO * @param password password to verify. * @return Boolean * @throws TransientException * @throws UserNotFoundExceptionjoellama * @throws UserNotFoundException */ public Boolean doLogin(final String username, final String password) throws TransientException, UserNotFoundException Loading Loading @@ -479,13 +479,6 @@ public class LdapUserDAO<T extends Principal> extends LdapDAO SearchRequest searchRequest = new SearchRequest(usersDN, SearchScope.ONE, filter, userAttribs); //if (proxy) //{ // String proxyDN = "dn:" + getSubjectDN().toNormalizedString(); // logger.debug("Proxying auth as: " + proxyDN); // searchRequest.addControl(new ProxiedAuthorizationV2RequestControl(proxyDN)); //} searchResult = getReadOnlyConnection().searchForEntry(searchRequest); } catch (LDAPException e) Loading cadcAccessControl-Server/test/config/testConfig.offline.properties 0 → 100644 +39 −0 Original line number Diff line number Diff line ############################################################### # # Test ldap config #1 # # ############################################################### # Read-only connection pool readOnly.servers = server1 server2 server3 readOnly.poolInitSize = 3 readOnly.poolMaxSize = 0 readOnly.poolPolicy = roundRobin readOnly.maxWait = 30000 readOnly.createIfNeeded = false # Read-write connection pool readWrite.servers = server4 server5 readWrite.poolInitSize = 4 readWrite.poolMaxSize = 9 readWrite.poolPolicy = fewestConnections readWrite.maxWait = 30000 readWrite.createIfNeeded = false # Unbound-Read-only connection pool unboundReadOnly.servers = server1 server2 server3 unboundReadOnly.poolInitSize = 3 unboundReadOnly.poolMaxSize = 8 unboundReadOnly.poolPolicy = roundRobin unboundReadOnly.maxWait = 30000 unboundReadOnly.createIfNeeded = false # server configuration -- applies to all servers dbrcHost = devLdap port = 389 proxyUser = uid=testproxy,ou=SpecialUsers,dc=testcanfar usersDN = usersDN userRequestsDN = userRequestsDN groupsDN = groupsDN adminGroupsDN = adminGroupsDN No newline at end of file cadcAccessControl-Server/test/config/testConfig.read-only.properties 0 → 100644 +39 −0 Original line number Diff line number Diff line ############################################################### # # Test ldap config #1 # # ############################################################### # Read-only connection pool readOnly.servers = server1 server2 server3 readOnly.poolInitSize = 3 readOnly.poolMaxSize = 8 readOnly.poolPolicy = roundRobin readOnly.maxWait = 30000 readOnly.createIfNeeded = false # Read-write connection pool readWrite.servers = server4 server5 readWrite.poolInitSize = 4 readWrite.poolMaxSize = 0 readWrite.poolPolicy = fewestConnections readWrite.maxWait = 30000 readWrite.createIfNeeded = false # Unbound-Read-only connection pool unboundReadOnly.servers = server1 server2 server3 unboundReadOnly.poolInitSize = 3 unboundReadOnly.poolMaxSize = 8 unboundReadOnly.poolPolicy = roundRobin unboundReadOnly.maxWait = 30000 unboundReadOnly.createIfNeeded = false # server configuration -- applies to all servers dbrcHost = devLdap port = 389 proxyUser = uid=testproxy,ou=SpecialUsers,dc=testcanfar usersDN = usersDN userRequestsDN = userRequestsDN groupsDN = groupsDN adminGroupsDN = adminGroupsDN No newline at end of file Loading
cadcAccessControl-Server/src/ca/nrc/cadc/ac/server/ldap/LdapConfig.java +45 −2 Original line number Diff line number Diff line Loading @@ -115,8 +115,15 @@ public class LdapConfig public enum PoolPolicy { roundRobin, fewestConnections; }; fewestConnections } public enum SystemState { ONLINE, READONLY, OFFLINE } public class LdapPool { Loading Loading @@ -210,6 +217,7 @@ public class LdapConfig private String proxyUserDN; private String proxyPasswd; private String dbrcHost; private SystemState systemState; public String getProxyUserDN() { Loading Loading @@ -251,6 +259,8 @@ public class LdapConfig ldapConfig.groupsDN = getProperty(pr, LDAP_GROUPS_DN); ldapConfig.adminGroupsDN = getProperty(pr, LDAP_ADMIN_GROUPS_DN); ldapConfig.systemState = getSystemState(ldapConfig); try { DBConfig dbConfig = new DBConfig(); Loading Loading @@ -304,6 +314,27 @@ public class LdapConfig return Arrays.asList(props); } private static SystemState getSystemState(LdapConfig ldapConfig) { if (ldapConfig.getReadOnlyPool().getMaxSize() == 0) { return SystemState.OFFLINE; } if (ldapConfig.getUnboundReadOnlyPool().getMaxSize() == 0) { return SystemState.OFFLINE; } if (ldapConfig.getReadWritePool().getMaxSize() == 0) { return SystemState.READONLY; } return SystemState.ONLINE; } @Override public boolean equals(Object other) { Loading Loading @@ -409,6 +440,17 @@ public class LdapConfig return this.proxyPasswd; } /** * Check if in read-only or offline mode. * * A read max connection size of zero implies offline mode. * A read-wrtie max connection size of zero implies read-only mode. */ public SystemState getSystemState() { return systemState; } public String toString() { StringBuilder sb = new StringBuilder(); Loading @@ -421,4 +463,5 @@ public class LdapConfig return sb.toString(); } }
cadcAccessControl-Server/src/ca/nrc/cadc/ac/server/ldap/LdapConnectionPool.java +4 −41 Original line number Diff line number Diff line Loading @@ -69,13 +69,11 @@ package ca.nrc.cadc.ac.server.ldap; import org.apache.log4j.Logger; import ca.nrc.cadc.ac.server.ldap.LdapConfig.LdapPool; import ca.nrc.cadc.ac.server.ldap.LdapConfig.PoolPolicy; import ca.nrc.cadc.ac.server.ldap.LdapConfig.SystemState; import ca.nrc.cadc.net.TransientException; import ca.nrc.cadc.profiler.Profiler; import com.unboundid.ldap.sdk.FewestConnectionsServerSet; import com.unboundid.ldap.sdk.Filter; import com.unboundid.ldap.sdk.LDAPConnection; Loading @@ -87,6 +85,7 @@ import com.unboundid.ldap.sdk.SearchRequest; import com.unboundid.ldap.sdk.SearchScope; import com.unboundid.ldap.sdk.ServerSet; import com.unboundid.ldap.sdk.SimpleBindRequest; import org.apache.log4j.Logger; /** * This object is designed to be shared between the DAO classes Loading @@ -100,13 +99,6 @@ public class LdapConnectionPool { private static final Logger logger = Logger.getLogger(LdapConnectionPool.class); private enum SystemState { ONLINE, READONLY, OFFLINE }; Profiler profiler = new Profiler(LdapConnectionPool.class); protected LdapConfig currentConfig; Loading @@ -115,7 +107,7 @@ public class LdapConnectionPool private Object poolMonitor = new Object(); private LDAPConnectionOptions connectionOptions; private boolean readOnly; SystemState systemState = SystemState.ONLINE; private SystemState systemState; public LdapConnectionPool(LdapConfig config, LdapPool poolConfig, String poolName, boolean boundPool, boolean readOnly) { Loading @@ -133,7 +125,7 @@ public class LdapConnectionPool this.poolName = poolName; this.readOnly = readOnly; systemState = getSystemState(config); systemState = config.getSystemState(); logger.debug("Construct pool: " + poolName + ". system state: " + systemState); if (SystemState.ONLINE.equals(systemState) || (SystemState.READONLY.equals(systemState) && readOnly)) { Loading Loading @@ -288,33 +280,4 @@ public class LdapConnectionPool } } /** * Check if in read-only or offline mode. * * A read max connection size of zero implies offline mode. * A read-wrtie max connection size of zero implies read-only mode. */ private SystemState getSystemState(LdapConfig config) { if (config.getReadOnlyPool().getMaxSize() == 0) { return SystemState.OFFLINE; } if (config.getUnboundReadOnlyPool().getMaxSize() == 0) { return SystemState.OFFLINE; } if (config.getReadWritePool().getMaxSize() == 0) { return SystemState.READONLY; } return SystemState.ONLINE; } }
cadcAccessControl-Server/src/ca/nrc/cadc/ac/server/ldap/LdapUserDAO.java +1 −8 Original line number Diff line number Diff line Loading @@ -209,7 +209,7 @@ public class LdapUserDAO<T extends Principal> extends LdapDAO * @param password password to verify. * @return Boolean * @throws TransientException * @throws UserNotFoundExceptionjoellama * @throws UserNotFoundException */ public Boolean doLogin(final String username, final String password) throws TransientException, UserNotFoundException Loading Loading @@ -479,13 +479,6 @@ public class LdapUserDAO<T extends Principal> extends LdapDAO SearchRequest searchRequest = new SearchRequest(usersDN, SearchScope.ONE, filter, userAttribs); //if (proxy) //{ // String proxyDN = "dn:" + getSubjectDN().toNormalizedString(); // logger.debug("Proxying auth as: " + proxyDN); // searchRequest.addControl(new ProxiedAuthorizationV2RequestControl(proxyDN)); //} searchResult = getReadOnlyConnection().searchForEntry(searchRequest); } catch (LDAPException e) Loading
cadcAccessControl-Server/test/config/testConfig.offline.properties 0 → 100644 +39 −0 Original line number Diff line number Diff line ############################################################### # # Test ldap config #1 # # ############################################################### # Read-only connection pool readOnly.servers = server1 server2 server3 readOnly.poolInitSize = 3 readOnly.poolMaxSize = 0 readOnly.poolPolicy = roundRobin readOnly.maxWait = 30000 readOnly.createIfNeeded = false # Read-write connection pool readWrite.servers = server4 server5 readWrite.poolInitSize = 4 readWrite.poolMaxSize = 9 readWrite.poolPolicy = fewestConnections readWrite.maxWait = 30000 readWrite.createIfNeeded = false # Unbound-Read-only connection pool unboundReadOnly.servers = server1 server2 server3 unboundReadOnly.poolInitSize = 3 unboundReadOnly.poolMaxSize = 8 unboundReadOnly.poolPolicy = roundRobin unboundReadOnly.maxWait = 30000 unboundReadOnly.createIfNeeded = false # server configuration -- applies to all servers dbrcHost = devLdap port = 389 proxyUser = uid=testproxy,ou=SpecialUsers,dc=testcanfar usersDN = usersDN userRequestsDN = userRequestsDN groupsDN = groupsDN adminGroupsDN = adminGroupsDN No newline at end of file
cadcAccessControl-Server/test/config/testConfig.read-only.properties 0 → 100644 +39 −0 Original line number Diff line number Diff line ############################################################### # # Test ldap config #1 # # ############################################################### # Read-only connection pool readOnly.servers = server1 server2 server3 readOnly.poolInitSize = 3 readOnly.poolMaxSize = 8 readOnly.poolPolicy = roundRobin readOnly.maxWait = 30000 readOnly.createIfNeeded = false # Read-write connection pool readWrite.servers = server4 server5 readWrite.poolInitSize = 4 readWrite.poolMaxSize = 0 readWrite.poolPolicy = fewestConnections readWrite.maxWait = 30000 readWrite.createIfNeeded = false # Unbound-Read-only connection pool unboundReadOnly.servers = server1 server2 server3 unboundReadOnly.poolInitSize = 3 unboundReadOnly.poolMaxSize = 8 unboundReadOnly.poolPolicy = roundRobin unboundReadOnly.maxWait = 30000 unboundReadOnly.createIfNeeded = false # server configuration -- applies to all servers dbrcHost = devLdap port = 389 proxyUser = uid=testproxy,ou=SpecialUsers,dc=testcanfar usersDN = usersDN userRequestsDN = userRequestsDN groupsDN = groupsDN adminGroupsDN = adminGroupsDN No newline at end of file