public boolean existsUser(String userId) { if (userId == null) { throw new IllegalArgumentException("UserId cannot be null"); } return checkExistence(this.config.getProperty(PRINCIPAL_QUERY), userId); }
public DBUserGroupCallbackImpl(boolean activate) { String propertiesLocation = System.getProperty("jbpm.usergroup.callback.properties"); config = readProperties(propertiesLocation, DEFAULT_PROPERTIES_NAME); init(); }
@Test(expected = IllegalArgumentException.class) public void testInvalidArgument() { DBUserGroupCallbackImpl callback = new DBUserGroupCallbackImpl(props); callback.getGroupsForUser(null); fail("Should fail as it does not have valid configuration"); } }
@Test public void testGroupNotExists() { DBUserGroupCallbackImpl callback = new DBUserGroupCallbackImpl(props); boolean exists = callback.existsGroup("HR"); assertFalse(exists); }
@Test public void testUserExists() { DBUserGroupCallbackImpl callback = new DBUserGroupCallbackImpl(props); boolean exists = callback.existsUser("john"); assertTrue(exists); }
public static UserGroupCallback getUserGroupCallback() { UserGroupCallback callback = new MvelUserGroupCallbackImpl(true); if ("ldap".equalsIgnoreCase(USER_CALLBACK_IMPL)) { callback = new LDAPUserGroupCallbackImpl(true); } else if ("db".equalsIgnoreCase(USER_CALLBACK_IMPL)) { callback = new DBUserGroupCallbackImpl(true); } else if ("mvel".equalsIgnoreCase(USER_CALLBACK_IMPL)) { callback = new MvelUserGroupCallbackImpl(true); } else if ("props".equalsIgnoreCase(USER_CALLBACK_IMPL)) { callback = new JBossUserGroupCallbackImpl(true); } else if ("jaas".equalsIgnoreCase(USER_CALLBACK_IMPL)) { callback = new JAASUserGroupCallbackImpl(true); } else if ("custom".equalsIgnoreCase(USER_CALLBACK_IMPL)) { try { callback = (UserGroupCallback) Class.forName(CUSTOM_USER_CALLBACK_IMPL).newInstance(); } catch (Exception e) { throw new RuntimeException("Unable to create instance of custom user group callback impl", e); } } return callback; }
public DBUserGroupCallbackImpl(Properties config) { this.config = config; init(); }
@Test(expected = IllegalArgumentException.class) public void testInvalidConfiguration() { Properties invalidProps = new Properties(); DBUserGroupCallbackImpl callback = new DBUserGroupCallbackImpl(invalidProps); callback.getGroupsForUser("mike"); fail("Should fail as it does not have valid configuration"); }
@Test public void testGroupExists() { DBUserGroupCallbackImpl callback = new DBUserGroupCallbackImpl(props); boolean exists = callback.existsGroup("PM"); assertTrue(exists); }
@Test public void testUserNotExists() { DBUserGroupCallbackImpl callback = new DBUserGroupCallbackImpl(props); boolean exists = callback.existsUser("mike"); assertFalse(exists); }
public static UserGroupCallback getUserGroupCallback() { UserGroupCallback callback = new MvelUserGroupCallbackImpl(true); if ("ldap".equalsIgnoreCase(USER_CALLBACK_IMPL)) { callback = new LDAPUserGroupCallbackImpl(true); } else if ("db".equalsIgnoreCase(USER_CALLBACK_IMPL)) { callback = new DBUserGroupCallbackImpl(true); } else if ("mvel".equalsIgnoreCase(USER_CALLBACK_IMPL)) { callback = new MvelUserGroupCallbackImpl(true); } else if ("props".equalsIgnoreCase(USER_CALLBACK_IMPL)) { callback = new JBossUserGroupCallbackImpl(true); } else if ("jaas".equalsIgnoreCase(USER_CALLBACK_IMPL)) { callback = new JAASUserGroupCallbackImpl(true); } else if ("custom".equalsIgnoreCase(USER_CALLBACK_IMPL)) { try { callback = (UserGroupCallback) Class.forName(CUSTOM_USER_CALLBACK_IMPL).newInstance(); } catch (Exception e) { throw new RuntimeException("Unable to create instance of custom user group callback impl", e); } } return callback; }
@Test public void testNoUserGroups() { DBUserGroupCallbackImpl callback = new DBUserGroupCallbackImpl(props); List<String> groups = callback.getGroupsForUser("mike"); assertNotNull(groups); assertEquals(0, groups.size()); }
public boolean existsGroup(String groupId) { if (groupId == null) { throw new IllegalArgumentException("GroupId cannot be null"); } return checkExistence(this.config.getProperty(ROLES_QUERY), groupId); }
@Test public void testUserGroups() { DBUserGroupCallbackImpl callback = new DBUserGroupCallbackImpl(props); List<String> groups = callback.getGroupsForUser("john"); assertNotNull(groups); assertEquals(1, groups.size()); assertEquals("PM", groups.get(0)); }