Remove try / catch / throw anti-pattern
| | |
| | | * Actually performs the install in this thread. The thread is blocked. |
| | | * |
| | | */ |
| | | @Override |
| | | public void run() |
| | | { |
| | | runError = null; |
| | |
| | | { |
| | | new ServerController(this).startServer(!isStartVerbose()); |
| | | } |
| | | catch (ApplicationException ae) |
| | | { |
| | | throw ae; |
| | | } |
| | | finally |
| | | { |
| | | if (!isStartVerbose()) |
| | |
| | | { |
| | | new ServerController(this).startServer(!isStartVerbose()); |
| | | } |
| | | catch (ApplicationException ae) |
| | | { |
| | | throw ae; |
| | | } |
| | | finally |
| | | { |
| | | if (!isVerbose()) |
| | |
| | | * |
| | | * @return The hash code for this stack frame. |
| | | */ |
| | | @Override |
| | | public int hashCode() |
| | | { |
| | | return (className.hashCode() + methodName.hashCode()); |
| | |
| | | * @return <CODE>true</CODE> if the provided object may be considered equal |
| | | * to this stack frame, or <CODE>false</CODE> if not. |
| | | */ |
| | | @Override |
| | | public boolean equals(Object o) |
| | | { |
| | | if (o == null) |
| | |
| | | * @throws ClassCastException If the provided object is not a profile stack |
| | | * frame. |
| | | */ |
| | | @Override |
| | | public int compareTo(Object o) |
| | | throws ClassCastException |
| | | { |
| | | ProfileStackFrame f; |
| | | try |
| | | { |
| | | f = (ProfileStackFrame) o; |
| | | } |
| | | catch (ClassCastException cce) |
| | | { |
| | | throw cce; |
| | | } |
| | | ProfileStackFrame f = (ProfileStackFrame) o; |
| | | |
| | | long thisCount = getTotalCount(); |
| | | long thatCount = f.getTotalCount(); |
| | |
| | | * |
| | | * @return A string representation of this stack frame. |
| | | */ |
| | | @Override |
| | | public String toString() |
| | | { |
| | | StringBuilder buffer = new StringBuilder(); |
| | |
| | | * they are built by buildAciValue, so that we are less likely to screw up |
| | | * the syntax. |
| | | */ |
| | | @SuppressWarnings("javadoc") |
| | | @Test(sequential=true, groups="slow") |
| | | public class AciTests extends AciTestCase { |
| | | // TODO: test modify use cases |
| | |
| | | SingleSearchParams.nonProxiedSearch(ADMIN_DN, ADMIN_PW, LEVEL_3_USER_DN, |
| | | OBJECTCLASS_STAR, SCOPE_BASE, |
| | | null, null, null); |
| | | try { |
| | | { |
| | | addEntries(BASIC_LDIF__GROUP_SEARCH_TESTS, DIR_MGR_DN, DIR_MGR_PW); |
| | | modEntries(COMPARE_ACI, DIR_MGR_DN, DIR_MGR_PW); |
| | | String userResults = |
| | | ldapCompare(adminParam.getLdapCompareArgs("cn:level3 user")); |
| | | Assert.assertFalse(userResults.equals("")); |
| | | } catch(Throwable e) { |
| | | throw e; |
| | | } |
| | | } |
| | | |
| | |
| | | "pa$$word",PROXY_USER_DN, SALES_USER_NEW_1, |
| | | OBJECTCLASS_STAR, SCOPE_BASE, |
| | | null, null, null); |
| | | try { |
| | | { |
| | | addEntries(BASIC_LDIF__GROUP_SEARCH_TESTS, DIR_MGR_DN, DIR_MGR_PW); |
| | | modEntries(ACI_PROXY_IMPORT_MGR, DIR_MGR_DN, DIR_MGR_PW); |
| | | modEntries(ACI_PROXY_CONTROL_LEVEL_1, DIR_MGR_DN, DIR_MGR_PW); |
| | |
| | | modEntries(modrdnLdif1, LEVEL_1_USER_DN, "pa$$word", PROXY_USER_DN); |
| | | String userOrigResults = ldapSearch(userParamOrig.getLdapSearchArgs()); |
| | | Assert.assertFalse(userOrigResults.equals("")); |
| | | } catch (Throwable e) { |
| | | throw e; |
| | | } |
| | | } |
| | | |
| | |
| | | null, null, null); |
| | | |
| | | |
| | | try { |
| | | { |
| | | addEntries(BASIC_LDIF__GROUP_SEARCH_TESTS, DIR_MGR_DN, DIR_MGR_PW); |
| | | modEntries(ACI_IMPORT_MGR, DIR_MGR_DN, DIR_MGR_PW); |
| | | modEntries(ACI_IMPORT_MGR_NEW, DIR_MGR_DN, DIR_MGR_PW); |
| | |
| | | modEntries(modrdnLdif1, LEVEL_1_USER_DN, "pa$$word"); |
| | | String userOrigResults = ldapSearch(userParamOrig.getLdapSearchArgs()); |
| | | Assert.assertFalse(userOrigResults.equals("")); |
| | | } catch (Throwable e) { |
| | | throw e; |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | @Test() |
| | | public void testNonSelfWrite() throws Throwable { |
| | | try { |
| | | addEntries(BASIC_LDIF__GROUP_SEARCH_TESTS, DIR_MGR_DN, DIR_MGR_PW); |
| | | modEntries(SELFWRITE_ACI, DIR_MGR_DN, DIR_MGR_PW); |
| | | deleteAttrFromEntry(OU_GROUP_1_DN, "member",LEVEL_1_USER_DN, |
| | | LEVEL_3_USER_DN, "pa$$word", false); |
| | | } catch(Throwable e) { |
| | | throw e; |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Test() |
| | | public void testSelfWrite() throws Throwable { |
| | | try { |
| | | addEntries(BASIC_LDIF__GROUP_SEARCH_TESTS, DIR_MGR_DN, DIR_MGR_PW); |
| | | modEntries(SELFWRITE_ACI, DIR_MGR_DN, DIR_MGR_PW); |
| | | deleteAttrFromEntry(OU_GROUP_1_DN, "member",LEVEL_1_USER_DN, |
| | | LEVEL_1_USER_DN, "pa$$word", true); |
| | | } catch(Throwable e) { |
| | | throw e; |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | "pa$$word", LEVEL_3_USER_DN, |
| | | OBJECTCLASS_STAR, SCOPE_BASE, |
| | | null, null, null); |
| | | try { |
| | | { |
| | | addEntries(BASIC_LDIF__GROUP_SEARCH_TESTS, DIR_MGR_DN, DIR_MGR_PW); |
| | | modEntries(DNS_ALL_ACI, DIR_MGR_DN, DIR_MGR_PW); |
| | | String userResults = ldapSearch(userParam.getLdapSearchArgs()); |
| | | Assert.assertFalse(userResults.equals("")); |
| | | } catch(Throwable e) { |
| | | throw e; |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Test group bind rule ACI keywords. |
| | | * |
| | | * @throws Throwable |
| | | */ |
| | | @Test() |
| | | public void testGroupAcis() throws Throwable { |
| | |
| | | "pa$$word", LEVEL_3_USER_DN, |
| | | OBJECTCLASS_STAR, SCOPE_BASE, |
| | | null, null, null); |
| | | try { |
| | | { |
| | | addEntries(BASIC_LDIF__GROUP_SEARCH_TESTS, DIR_MGR_DN, DIR_MGR_PW); |
| | | modEntries(GROUP1_GROUPDN_MODS, DIR_MGR_DN, DIR_MGR_PW); |
| | | String userResults = ldapSearch(userParam.getLdapSearchArgs()); |
| | | Assert.assertFalse(userResults.equals("")); |
| | | String adminResults = ldapSearch(adminParam.getLdapSearchArgs()); |
| | | Assert.assertTrue(adminResults.equals("")); |
| | | } catch(Throwable e) { |
| | | throw e; |
| | | } |
| | | } |
| | | |
| | |
| | | "pa$$word", OU_BASE_DN, |
| | | OBJECTCLASS_STAR, SCOPE_BASE, |
| | | null, null, null); |
| | | try { |
| | | |
| | | addEntries(BASIC_LDIF__SEARCH_TESTS, DIR_MGR_DN, DIR_MGR_PW); |
| | | modEntries(GLOBAL_MODS, DIR_MGR_DN, DIR_MGR_PW); |
| | | String monitorResults = ldapSearch(monitorParam.getLdapSearchArgs()); |
| | |
| | | Assert.assertTrue(monitorResults.equals("")); |
| | | baseResults = ldapSearch(baseParam.getLdapSearchArgs()); |
| | | Assert.assertTrue(baseResults.equals("")); |
| | | } catch (Throwable e) { |
| | | throw e; |
| | | } |
| | | } |
| | | |
| | | @Test(dataProvider = "searchTestParams") |
| | |
| | | "pa$$word", OU_BASE_DN, |
| | | OBJECTCLASS_STAR, SCOPE_BASE, |
| | | null, null, null); |
| | | try { |
| | | |
| | | String monitorResults = ldapSearch(monitorParam.getLdapSearchArgs()); |
| | | Assert.assertFalse(monitorResults.equals("")); |
| | | String baseResults = ldapSearch(baseParam.getLdapSearchArgs()); |
| | |
| | | Assert.assertTrue(monitorResults.equals("")); |
| | | baseResults = ldapSearch(baseParam.getLdapSearchArgs()); |
| | | Assert.assertTrue(baseResults.equals("")); |
| | | } catch (Throwable e) { |
| | | throw e; |
| | | } |
| | | |
| | | // Test selfwrite right. Attempt to bind as level3 user and remove |
| | | // level1 user from a group, should fail. |
| | | try { |
| | | deleteAttrFromEntry(OU_GROUP_1_DN, "member", LEVEL_1_USER_DN, |
| | | LEVEL_3_USER_DN, "pa$$word", false); |
| | | } catch (Throwable e) { |
| | | throw e; |
| | | } |
| | | |
| | | // Test selfwrite right. Attempt to bind as level1 user and remove |
| | | // itself from a group, should succeed. |
| | | try { |
| | | deleteAttrFromEntry(OU_GROUP_1_DN, "member", LEVEL_1_USER_DN, |
| | | LEVEL_1_USER_DN, "pa$$word", true); |
| | | } catch (Throwable e) { |
| | | throw e; |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | /** |
| | | * BackendImpl Tester. |
| | | */ |
| | | @SuppressWarnings("javadoc") |
| | | public class TestBackendImpl extends JebTestCase { |
| | | private String homeDirName; |
| | | |
| | |
| | | ResultCode success = ResultCode.SUCCESS; |
| | | ResultCode noSuchObject = ResultCode.NO_SUCH_OBJECT; |
| | | |
| | | DN testComDN = null; |
| | | DN peopleTestComDN = null; |
| | | DN dummyTestComDN = null; |
| | | DN dummyPeopleTestComDN = null; |
| | | |
| | | try |
| | | { |
| | | testComDN = DN.decode( "dc=test,dc=com"); |
| | | dummyTestComDN = DN.decode( "cn=dummy,dc=test,dc=com"); |
| | | peopleTestComDN = DN.decode( "ou=people,dc=test,dc=com"); |
| | | dummyPeopleTestComDN = DN.decode("cn=dummy,ou=people,dc=test,dc=com"); |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | | throw de; |
| | | } |
| | | DN testComDN = DN.decode( "dc=test,dc=com"); |
| | | DN peopleTestComDN = DN.decode( "cn=dummy,dc=test,dc=com"); |
| | | DN dummyTestComDN = DN.decode( "ou=people,dc=test,dc=com"); |
| | | DN dummyPeopleTestComDN = DN.decode("cn=dummy,ou=people,dc=test,dc=com"); |
| | | |
| | | // Sets of DNs |
| | | Object[][] myData = |
| | |
| | | public Object[][] initDNSet_1() |
| | | throws Exception |
| | | { |
| | | DN dnNull = null; |
| | | DN baseDN1 = null; |
| | | DN subordinateDN1 = null; |
| | | DN unrelatedDN = null; |
| | | |
| | | try |
| | | { |
| | | dnNull = DN.decode (""); |
| | | baseDN1 = DN.decode ("o=test"); |
| | | subordinateDN1 = DN.decode ("ou=subtest,o=test"); |
| | | unrelatedDN = DN.decode ("o=dummy"); |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | | throw de; |
| | | } |
| | | DN dnNull = DN.decode (""); |
| | | DN baseDN1 = DN.decode ("o=test"); |
| | | DN subordinateDN1 = DN.decode ("ou=subtest,o=test"); |
| | | DN unrelatedDN = DN.decode ("o=dummy"); |
| | | |
| | | // Sets of DNs |
| | | Object[][] myData = |
| | |
| | | // | | |
| | | // | | |
| | | // ou=subordinate3 |
| | | try |
| | | { |
| | | String suffix = "ou=test1"; |
| | | String baseDN1 = suffix; |
| | |
| | | unrelatedDN = DN.decode ("o=dummy"); |
| | | rootDSE = DN.decode (""); |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | | throw de; |
| | | } |
| | | |
| | | // Sets of DNs |
| | | Object[][] myData = |
| | |
| | | // | | |
| | | // | | |
| | | // ou=subordinate2 ou=subordinate3 |
| | | try |
| | | { |
| | | String suffix = "dc=example,dc=com"; |
| | | String baseDN1 = suffix; |
| | |
| | | unrelatedDN = DN.decode ("o=dummy"); |
| | | rootDSE = DN.decode (""); |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | | throw de; |
| | | } |
| | | |
| | | // Sets of DNs |
| | | Object[][] myData = |
| | |
| | | package org.opends.server.core.networkgroups; |
| | | |
| | | |
| | | import static org.testng.Assert.assertEquals; |
| | | import static org.testng.Assert.assertNotNull; |
| | | import static org.testng.Assert.assertNull; |
| | | import static org.opends.server.config.ConfigConstants.DN_BACKEND_BASE; |
| | | import static org.opends.messages.CoreMessages.*; |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | | |
| | | import static org.opends.messages.CoreMessages.*; |
| | | |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.DirectoryServerTestCase; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.admin.std.meta.NetworkGroupCfgDefn.AllowedAuthMethod; |
| | | import org.opends.server.api.ClientConnection; |
| | | import org.opends.server.core.*; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.ldap.LDAPFilter; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.Attributes; |
| | | import org.opends.server.types.AuthenticationInfo; |
| | | import org.opends.server.types.ByteString; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.Modification; |
| | | import org.opends.server.types.ModificationType; |
| | | import org.opends.server.types.ResultCode; |
| | | import org.opends.server.types.SearchScope; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.workflowelement.WorkflowElement; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | |
| | | String networkGroupID2 = "networkGroup2"; |
| | | |
| | | // Workflow base DNs |
| | | DN dn1 = null; |
| | | DN dn2 = null; |
| | | try |
| | | { |
| | | dn1 = DN.decode("o=test1"); |
| | | dn2 = DN.decode("o=test2"); |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | | throw de; |
| | | } |
| | | DN dn1 = DN.decode("o=test1"); |
| | | DN dn2 = DN.decode("o=test2"); |
| | | |
| | | // Network group info |
| | | Object[][] myData = |
| | |
| | | public Object[][] initDNSet_1() |
| | | throws Exception |
| | | { |
| | | DN dnRootDSE = null; |
| | | DN dnConfig = null; |
| | | DN dnMonitor = null; |
| | | DN dnSchema = null; |
| | | DN dnTasks = null; |
| | | DN dnBackups = null; |
| | | DN dnDummy = null; |
| | | DN dnRootDSE = DN.decode(""); |
| | | DN dnConfig = DN.decode("cn=config"); |
| | | DN dnMonitor = DN.decode("cn=monitor"); |
| | | DN dnSchema = DN.decode("cn=schema"); |
| | | DN dnTasks = DN.decode("cn=tasks"); |
| | | DN dnBackups = DN.decode("cn=backups"); |
| | | DN dnDummy = DN.decode("o=dummy_suffix"); |
| | | |
| | | DN dnSubordinateConfig = null; |
| | | DN dnSubordinateMonitor = null; |
| | | DN dnSubordinateTasks = null; |
| | | |
| | | try |
| | | { |
| | | dnRootDSE = DN.decode(""); |
| | | dnConfig = DN.decode("cn=config"); |
| | | dnMonitor = DN.decode("cn=monitor"); |
| | | dnSchema = DN.decode("cn=schema"); |
| | | dnTasks = DN.decode("cn=tasks"); |
| | | dnBackups = DN.decode("cn=backups"); |
| | | dnDummy = DN.decode("o=dummy_suffix"); |
| | | |
| | | dnSubordinateConfig = DN.decode("cn=Work Queue,cn=config"); |
| | | dnSubordinateMonitor = DN.decode("cn=schema Backend,cn=monitor"); |
| | | dnSubordinateTasks = DN.decode("cn=Scheduled Tasks,cn=tasks"); |
| | | |
| | | DN dnSubordinateConfig = DN.decode("cn=Work Queue,cn=config"); |
| | | DN dnSubordinateMonitor = DN.decode("cn=schema Backend,cn=monitor"); |
| | | DN dnSubordinateTasks = DN.decode("cn=Scheduled Tasks,cn=tasks"); |
| | | // No DN subordinate for schema because the schema backend is |
| | | // currently empty. |
| | | // No DN subordinate for cn=backups because by default there is no |
| | | // child entry under cn=backups. |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | | throw de; |
| | | } |
| | | |
| | | // Sets of DNs |
| | | Object[][] myData = |
| | |
| | | throws Exception |
| | | { |
| | | // Network group definition |
| | | DN dn1 = null; |
| | | DN dn2 = null; |
| | | DN dn3 = null; |
| | | DN subordinate1 = null; |
| | | DN subordinate2 = null; |
| | | DN subordinate3 = null; |
| | | DN unrelatedDN = null; |
| | | try |
| | | { |
| | | dn1 = DN.decode("o=test1"); |
| | | dn2 = DN.decode("o=test2"); |
| | | dn3 = DN.decode("o=test3"); |
| | | subordinate1 = DN.decode("ou=subtest1,o=test1"); |
| | | subordinate2 = DN.decode("ou=subtest2,o=test2"); |
| | | subordinate3 = DN.decode("ou=subtest3,o=test3"); |
| | | unrelatedDN = DN.decode("o=dummy"); |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | | throw de; |
| | | } |
| | | DN dn1 = DN.decode("o=test1"); |
| | | DN dn2 = DN.decode("o=test2"); |
| | | DN dn3 = DN.decode("o=test3"); |
| | | DN subordinate1 = DN.decode("ou=subtest1,o=test1"); |
| | | DN subordinate2 = DN.decode("ou=subtest2,o=test2"); |
| | | DN subordinate3 = DN.decode("ou=subtest3,o=test3"); |
| | | DN unrelatedDN = DN.decode("o=dummy"); |
| | | |
| | | // Network group info |
| | | Object[][] myData = |
| | |
| | | { |
| | | // Network group definition |
| | | String networkGroupID = "networkGroup1"; |
| | | DN dn = null; |
| | | DN dn = DN.decode("o=test1"); |
| | | int prio = 1; |
| | | |
| | | // Resource limits |
| | |
| | | int searchSizeLimit = 50; |
| | | int minSubstringLength = 4; |
| | | |
| | | try |
| | | { |
| | | dn = DN.decode("o=test1"); |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | | throw de; |
| | | } |
| | | |
| | | // Network group info |
| | | Object[][] myData = |
| | | { |
| | |
| | | { |
| | | String networkGroupID1 = "group1"; |
| | | String networkGroupID2 = "group2"; |
| | | DN dn1 = null; |
| | | DN dn2 = null; |
| | | DN dn1 = DN.decode("o=test1"); |
| | | DN dn2 = DN.decode("o=test2"); |
| | | |
| | | try { |
| | | dn1 = DN.decode("o=test1"); |
| | | dn2 = DN.decode("o=test2"); |
| | | } catch (DirectoryException de) { |
| | | throw de; |
| | | } |
| | | Object[][] myData = { |
| | | { |
| | | networkGroupID1, |
| | |
| | | networkGroup.register(); |
| | | networkGroup.setConnectionCriteria(secCriteria); |
| | | |
| | | NetworkGroup defaultNg = NetworkGroup.getDefaultNetworkGroup(); |
| | | |
| | | // Create a new client connection, with anonymous authentication |
| | | // It should match the secured group as internal connections |
| | | // are secured |