コード例 #1
0
  @Test // @Ignore
  public void testChangePassword() throws Exception {
    SpmlConfiguration config = createConfiguration();
    SpmlConnector info = createConnector(config);
    try {
      Set<Attribute> attrs = fillInSampleUser(TEST_USER);

      // Delete the account if it already exists
      //
      deleteUser(TEST_USER, info);

      // Create the account
      //
      Uid newUid = info.create(ObjectClass.ACCOUNT, attrs, null);
      System.out.println(newUid.getValue() + " created");

      ConnectorObjectBuilder builder = new ConnectorObjectBuilder();
      builder.setUid(newUid);
      Attribute password =
          AttributeBuilder.build(
              OperationalAttributes.PASSWORD_NAME, new GuardedString("xyzzy123".toCharArray()));
      builder.addAttribute(password);
      builder.addAttribute(new Name(TEST_USER));
      ConnectorObject newUser = builder.build();
      info.update(newUser.getObjectClass(), newUser.getAttributes(), null);
    } finally {
      info.dispose();
    }
  }
コード例 #2
0
  private ConnectorObject getObjectToAuthenticate() {
    final String uidAttribute = freeIPAConfiguration.getUidAttribute();
    Map<String, ConnectorObject> entryDN2Object = new HashMap<String, ConnectorObject>();

    final Attribute attr = AttributeBuilder.build(uidAttribute, username);

    for (ConnectorObject object :
        LdapSearches.findObjects(
            freeIPAConnection,
            objectClass,
            LDAPConstants.USERS_DN_BASE_SUFFIX + "," + freeIPAConfiguration.getRootSuffix(),
            attr,
            "entryDN")) {
      String entryDN = object.getAttributeByName("entryDN").getValue().get(0).toString();
      entryDN2Object.put(entryDN, object);
    }

    // If we found more than one authentication candidates, no need to continue
    if (entryDN2Object.size() > 1) {
      throw new ConnectorSecurityException(
          freeIPAConnection.format("moreThanOneEntryMatched", null, username));
    }

    return !entryDN2Object.isEmpty() ? entryDN2Object.values().iterator().next() : null;
  }
コード例 #3
0
  @Test // @Ignore
  public void testModifyUser() throws Exception {
    SpmlConfiguration config = createConfiguration();
    SpmlConnector info = createConnector(config);

    try {
      // Delete the user
      //
      deleteUser(TEST_USER, info);

      Set<Attribute> attrs = fillInSampleUser(TEST_USER);
      info.create(ObjectClass.ACCOUNT, attrs, null);

      ConnectorObject user = getUser(TEST_USER);
      Set<Attribute> changed = new HashSet<Attribute>();
      changed.add(AttributeBuilder.build(ATTR_FIRSTNAME, "abel"));
      changed.add(user.getUid());
      info.update(ObjectClass.ACCOUNT, changed, null);

      ConnectorObject changedUser = getUser(TEST_USER);
      Attribute firstname = changedUser.getAttributeByName(ATTR_FIRSTNAME);
      displayUser(changedUser);
      Assert.assertNotNull(firstname);
      Assert.assertTrue(AttributeUtil.getStringValue(firstname).equalsIgnoreCase("abel"));
    } finally {
      info.dispose();
    }
  }
コード例 #4
0
 private Uid doAuthenticate() {
   final ConnectorObject authnObject = getObjectToAuthenticate();
   if (authnObject != null) {
     final String entryDN = authnObject.getName().getNameValue();
     try {
       freeIPAConnection.login(entryDN, password);
     } catch (final FreeIPAException e) {
       throw e;
     }
   }
   return authnObject.getUid();
 }
コード例 #5
0
  @Test // @Ignore
  public void testEnableDisable() throws Exception {
    SpmlConfiguration config = createConfiguration();
    SpmlConnector info = createConnector(config);
    try {
      Set<Attribute> attrs = fillInSampleUser(TEST_USER);

      // Delete the account if it already exists
      //
      deleteUser(TEST_USER, info);

      // Create the account
      //
      Uid newUid = info.create(ObjectClass.ACCOUNT, attrs, null);
      System.out.println(newUid.getValue() + " created");

      // Test disabling the user
      {
        ConnectorObjectBuilder builder = new ConnectorObjectBuilder();
        builder.setUid(newUid);
        Attribute password =
            AttributeBuilder.build(OperationalAttributes.ENABLE_NAME, Boolean.FALSE);
        builder.addAttribute(password);
        builder.addAttribute(new Name(TEST_USER));
        ConnectorObject newUser = builder.build();
        info.update(newUser.getObjectClass(), newUser.getAttributes(), null);

        Map map = new HashMap<String, Object>();
        map.put(
            OperationOptions.OP_ATTRIBUTES_TO_GET,
            new String[] {OperationalAttributes.ENABLE_NAME});
        OperationOptions options = new OperationOptions(map);

        ConnectorObject user = getUser(TEST_USER, options);
        Attribute enabled = user.getAttributeByName(OperationalAttributes.ENABLE_NAME);
        Assert.assertNotNull(enabled);
        Assert.assertFalse(AttributeUtil.getBooleanValue(enabled));
      }

      // Test enabling the user
      {
        ConnectorObjectBuilder builder = new ConnectorObjectBuilder();
        builder.setUid(newUid);
        Attribute password =
            AttributeBuilder.build(OperationalAttributes.ENABLE_NAME, Boolean.TRUE);
        builder.addAttribute(password);
        builder.addAttribute(new Name(TEST_USER));
        ConnectorObject newUser = builder.build();
        info.update(newUser.getObjectClass(), newUser.getAttributes(), null);

        Attribute enabled = newUser.getAttributeByName(OperationalAttributes.ENABLE_NAME);
        Assert.assertNotNull(enabled);
        Assert.assertTrue(AttributeUtil.getBooleanValue(enabled));
      }
    } finally {
      info.dispose();
    }
  }
コード例 #6
0
 /**
  * This will do a basic replace.
  *
  * @see UpdateOp#update(org.identityconnectors.framework.common.objects.ObjectClass,
  *     org.identityconnectors.framework.common.objects.Uid, java.util.Set,
  *     org.identityconnectors.framework.common.objects.OperationOptions)
  */
 public Uid update(
     ObjectClass objectClass, Uid uid, Set<Attribute> attrs, OperationOptions options) {
   String val = AttributeUtil.getAsStringValue(uid);
   int idx = Integer.valueOf(val).intValue();
   // get out the object..
   ConnectorObject base = objects.get(idx);
   ConnectorObjectBuilder bld = new ConnectorObjectBuilder();
   bld.add(base);
   bld.addAttributes(attrs);
   ConnectorObject obj = bld.build();
   objects.set(idx, obj);
   return obj.getUid();
 }
コード例 #7
0
 @Test // @Ignore
 public void testListAllUsers() throws Exception {
   SpmlConfiguration config = createConfiguration();
   SpmlConnector info = createConnector(config);
   try {
     TestHandler handler = new TestHandler();
     TestHelpers.search(info, ObjectClass.ACCOUNT, null, handler, null);
     for (ConnectorObject user : handler) {
       System.out.println("Read User:" + user.getUid().getValue());
     }
   } finally {
     info.dispose();
   }
 }
コード例 #8
0
 static {
   boolean enabled = true;
   for (int i = 0; i < 100; i++) {
     ConnectorObjectBuilder builder = new ConnectorObjectBuilder();
     builder.setUid(String.valueOf(i));
     builder.setName(String.format("user%03d", i));
     builder.addAttribute(AttributeBuilder.buildEnabled(enabled));
     Map<String, Object> mapAttribute = new HashMap<String, Object>();
     mapAttribute.put("email", "*****@*****.**");
     mapAttribute.put("primary", true);
     mapAttribute.put("usage", Arrays.asList("home", "work"));
     builder.addAttribute(AttributeBuilder.build("emails", mapAttribute));
     ConnectorObject co = builder.build();
     collection.put(co.getName().getNameValue(), co);
     enabled = !enabled;
   }
 }
コード例 #9
0
 private void displayUser(ConnectorObject user) {
   Set<Attribute> attributes = user.getAttributes();
   for (Attribute attribute : attributes) {
     System.out.println(attribute.getName());
     List<Object> values = attribute.getValue();
     for (Object value : values) {
       System.out.println("    " + value.getClass().getName() + ":" + value);
     }
   }
 }
コード例 #10
0
  @Test // @Ignore
  public void testGetSpecifiedUser() throws Exception {
    SpmlConfiguration config = createConfiguration();
    SpmlConnector info = createConnector(config);
    try {
      Set<Attribute> attrs = fillInSampleUser(TEST_USER);

      deleteUser(TEST_USER, info);

      info.create(ObjectClass.ACCOUNT, attrs, null);

      ConnectorObject user = getUser(TEST_USER);
      Assert.assertNotNull(user);

      TestHandler handler = new TestHandler();
      TestHelpers.search(
          info,
          ObjectClass.ACCOUNT,
          new EqualsFilter(AttributeBuilder.build(Uid.NAME, "asdhjfdaslfh alsk fhasldk ")),
          handler,
          null);
      Assert.assertFalse(handler.iterator().hasNext());

      handler = new TestHandler();
      String[] attributesToGet = {"firstname"};
      Map<String, Object> optionsMap = new HashMap<String, Object>();
      optionsMap.put(OperationOptions.OP_ATTRIBUTES_TO_GET, attributesToGet);
      OperationOptions options = new OperationOptions(optionsMap);
      TestHelpers.search(
          info,
          ObjectClass.ACCOUNT,
          new EqualsFilter(AttributeBuilder.build(Uid.NAME, TEST_USER)),
          handler,
          options);
      Assert.assertTrue(handler.iterator().hasNext());
      ConnectorObject object = handler.iterator().next();
      Assert.assertNotNull(object.getAttributeByName("firstname"));
      Assert.assertNull(object.getAttributeByName("lastname"));
    } finally {
      info.dispose();
    }
  }
コード例 #11
0
 private List<Object> getValuesSorted(final ConnectorObject resource, final String field) {
   final Attribute value = AttributeUtil.find(field, resource.getAttributes());
   if (value == null || value.getValue() == null || value.getValue().isEmpty()) {
     return Collections.emptyList();
   } else if (value.getValue().size() > 1) {
     List<Object> results = new ArrayList<Object>(value.getValue());
     Collections.sort(results, VALUE_COMPARATOR);
     return results;
   } else {
     return value.getValue();
   }
 }
コード例 #12
0
  @Test
  public void testAllBlocksReturnedFromSingleSyncCall() throws NamingException {
    LdapConfiguration config = newConfiguration();
    // Set a small block size so connector would have to do
    // a couple of searches to return all deltas.
    config.setChangeLogBlockSize(2);
    LdapConnection conn = newConnection(config);
    String baseContext = conn.getConfiguration().getBaseContexts()[0];

    int COUNT = 10;
    StringBuilder ldif = new StringBuilder();
    for (int i = 0; i < COUNT; i++) {
      String name = "user." + i;
      String entryDN = "uid=" + name + "," + baseContext;
      ldif.append(
          MessageFormat.format(
              "dn: {0}\n"
                  + "changetype: add\n"
                  + "objectClass: inetOrgPerson\n"
                  + "objectClass: organizationalPerson\n"
                  + "objectClass: person\n"
                  + "objectClass: top\n"
                  + "uid: {1}\n"
                  + "cn: {1}\n"
                  + "sn: {1}\n"
                  + "\n",
              entryDN, name));
    }

    List<SyncDelta> result = doTest(conn, ldif.toString(), COUNT);
    assertEquals(10, result.size());
    for (int i = 0; i < COUNT; i++) {
      String name = "user." + i;
      String entryDN = "uid=" + name + "," + baseContext;
      ConnectorObject object = result.get(i).getObject();
      assertEquals(new Uid(entryDN), object.getUid());
      assertEquals(new Name(entryDN), object.getName());
    }
  }
コード例 #13
0
  @Test // @Ignore
  public void testDelete() throws Exception {
    SpmlConfiguration config = createConfiguration();
    SpmlConnector info = createConnector(config);
    Set<Attribute> attrs = fillInSampleUser(TEST_USER);

    try {
      // Create the account if it doesn't already exist
      //
      ConnectorObject user = getUser(TEST_USER);
      Uid newUid = null;
      if (user == null) {
        try {
          newUid = info.create(ObjectClass.ACCOUNT, attrs, null);
          System.out.println(newUid.getValue() + " created");
        } catch (AlreadyExistsException rte) {
          // ignore
        }
      } else {
        newUid = user.getUid();
      }

      // Delete the account
      //
      info.delete(ObjectClass.ACCOUNT, newUid, null);
      System.out.println(newUid.getValue() + " deleted");

      try {
        info.delete(ObjectClass.ACCOUNT, newUid, null);
        Assert.fail("Should have seen exception");
      } catch (UnknownUidException uue) {
        // expected
      }
    } finally {
      info.dispose();
    }
  }
コード例 #14
0
  private Map<VirSchema, List<String>> getValues(final Any<?> any, final Set<VirSchema> schemas) {
    Collection<? extends ExternalResource> ownedResources =
        anyUtilsFactory.getInstance(any).getAllResources(any);

    Map<VirSchema, List<String>> result = new HashMap<>();

    Map<Provision, Set<VirSchema>> toRead = new HashMap<>();

    for (VirSchema schema : schemas) {
      if (ownedResources.contains(schema.getProvision().getResource())) {
        VirAttrCacheValue virAttrCacheValue =
            virAttrCache.get(any.getType().getKey(), any.getKey(), schema.getKey());

        if (virAttrCache.isValidEntry(virAttrCacheValue)) {
          LOG.debug("Values for {} found in cache: {}", schema, virAttrCacheValue);
          result.put(schema, virAttrCacheValue.getValues());
        } else {
          Set<VirSchema> schemasToRead = toRead.get(schema.getProvision());
          if (schemasToRead == null) {
            schemasToRead = new HashSet<>();
            toRead.put(schema.getProvision(), schemasToRead);
          }
          schemasToRead.add(schema);
        }
      } else {
        LOG.debug(
            "Not considering {} since {} is not assigned to {}",
            schema,
            any,
            schema.getProvision().getResource());
      }
    }

    for (Map.Entry<Provision, Set<VirSchema>> entry : toRead.entrySet()) {
      LOG.debug("About to read from {}: {}", entry.getKey(), entry.getValue());

      String connObjectKey =
          MappingUtils.getConnObjectKeyItem(entry.getKey()) == null
              ? null
              : mappingManager.getConnObjectKeyValue(any, entry.getKey());
      if (StringUtils.isBlank(connObjectKey)) {
        LOG.error("No ConnObjectKey found for {}, ignoring...", entry.getKey());
      } else {
        Set<MappingItem> linkingMappingItems = new HashSet<>();
        for (VirSchema schema : entry.getValue()) {
          linkingMappingItems.add(schema.asLinkingMappingItem());
        }

        Connector connector = connFactory.getConnector(entry.getKey().getResource());
        try {
          ConnectorObject connectorObject =
              connector.getObject(
                  entry.getKey().getObjectClass(),
                  new Uid(connObjectKey),
                  MappingUtils.buildOperationOptions(linkingMappingItems.iterator()));

          if (connectorObject == null) {
            LOG.debug("No read from {} about {}", entry.getKey(), connObjectKey);
          } else {
            for (VirSchema schema : entry.getValue()) {
              Attribute attr = connectorObject.getAttributeByName(schema.getExtAttrName());
              if (attr != null) {
                VirAttrCacheValue virAttrCacheValue = new VirAttrCacheValue();
                virAttrCacheValue.setValues(attr.getValue());
                virAttrCache.put(
                    any.getType().getKey(), any.getKey(), schema.getKey(), virAttrCacheValue);
                LOG.debug("Values for {} set in cache: {}", schema, virAttrCacheValue);

                result.put(schema, virAttrCacheValue.getValues());
              }
            }
          }
        } catch (Exception e) {
          LOG.error("Error reading from {}", entry.getKey(), e);
        }
      }
    }

    return result;
  }
コード例 #15
0
  @Test
  public void testSimple() throws Exception {
    LdapConnection conn = newConnection(newConfiguration());
    String baseContext = conn.getConfiguration().getBaseContexts()[0];

    String entryDN = "uid=foobar," + baseContext;
    List<SyncDelta> result =
        doTest(
            conn,
            "dn: "
                + entryDN
                + "\n"
                + "changetype: add\n"
                + "objectClass: inetOrgPerson\n"
                + "objectClass: organizationalPerson\n"
                + "objectClass: person\n"
                + "objectClass: top\n"
                + "uid: foobar\n"
                + "cn: Foo Bar\n"
                + "sn: Bar\n",
            1);

    assertEquals(1, result.size());
    SyncDelta delta = result.get(0);
    assertEquals(SyncDeltaType.CREATE_OR_UPDATE, delta.getDeltaType());
    ConnectorObject object = delta.getObject();
    assertEquals(new Uid(entryDN), object.getUid());
    assertEquals(new Name(entryDN), object.getName());
    assertEquals(AttributeBuilder.build("uid", "foobar"), object.getAttributeByName("uid"));
    assertEquals(AttributeBuilder.build("cn", "Foo Bar"), object.getAttributeByName("cn"));
    assertEquals(AttributeBuilder.build("sn", "Bar"), object.getAttributeByName("sn"));

    result =
        doTest(conn, "dn: " + entryDN + "\n" + "changeType: modrdn\n" + "newRdn: cn=Foo Bar", 1);
    entryDN = "cn=Foo Bar," + baseContext;

    assertEquals(1, result.size());
    delta = result.get(0);
    assertEquals(SyncDeltaType.CREATE_OR_UPDATE, delta.getDeltaType());
    object = delta.getObject();
    assertEquals(new Uid(entryDN), object.getUid());
    assertEquals(new Name(entryDN), object.getName());
    assertEquals(AttributeBuilder.build("uid", emptyList()), object.getAttributeByName("uid"));
    assertEquals(AttributeBuilder.build("cn", "Foo Bar"), object.getAttributeByName("cn"));
    assertEquals(AttributeBuilder.build("sn", "Bar"), object.getAttributeByName("sn"));

    result =
        doTest(
            conn,
            "dn: " + entryDN + "\n" + "changeType: modify\n" + "add: cn\n" + "cn: Dummy User",
            1);

    assertEquals(1, result.size());
    delta = result.get(0);
    assertEquals(SyncDeltaType.CREATE_OR_UPDATE, delta.getDeltaType());
    object = delta.getObject();
    assertEquals(
        AttributeBuilder.build("cn", "Foo Bar", "Dummy User"), object.getAttributeByName("cn"));

    result =
        doTest(
            conn,
            "dn: "
                + entryDN
                + "\n"
                + "changeType: modrdn\n"
                + "newRdn: cn=Dummy User\n"
                + "deleteOldRdn: FALSE",
            1);
    entryDN = "cn=Dummy User," + baseContext;

    assertEquals(1, result.size());
    delta = result.get(0);
    assertEquals(SyncDeltaType.CREATE_OR_UPDATE, delta.getDeltaType());
    object = delta.getObject();
    assertEquals(new Uid(entryDN), object.getUid());
    assertEquals(new Name(entryDN), object.getName());
    assertEquals(
        AttributeBuilder.build("cn", "Foo Bar", "Dummy User"), object.getAttributeByName("cn"));

    result =
        doTest(
            conn,
            "dn: " + entryDN + "\n" + "changeType: modify\n" + "delete: cn\n" + "cn: Foo Bar",
            1);

    assertEquals(1, result.size());
    delta = result.get(0);
    assertEquals(SyncDeltaType.CREATE_OR_UPDATE, delta.getDeltaType());
    object = delta.getObject();
    assertEquals(AttributeBuilder.build("cn", "Dummy User"), object.getAttributeByName("cn"));

    result = doTest(conn, "dn: " + entryDN + "\n" + "changeType: delete", 1);

    assertEquals(1, result.size());
    delta = result.get(0);
    assertEquals(SyncDeltaType.DELETE, delta.getDeltaType());
    assertEquals(new Uid(entryDN), delta.getUid());
  }
コード例 #16
0
  public void executeQuery(
      ObjectClass objectClass, Filter query, ResultsHandler handler, OperationOptions options) {

    SortKey[] sortKeys = options.getSortKeys();
    if (null == sortKeys) {
      sortKeys = new SortKey[] {new SortKey(Name.NAME, true)};
    }

    // Rebuild the full result set.
    TreeSet<ConnectorObject> resultSet =
        new TreeSet<ConnectorObject>(new ResourceComparator(sortKeys));

    if (null != query) {
      for (ConnectorObject co : collection.values()) {
        if (query.accept(co)) {
          resultSet.add(co);
        }
      }
    } else {
      resultSet.addAll(collection.values());
    }

    // Handle the results
    if (null != options.getPageSize()) {
      // Paged Search
      final String pagedResultsCookie = options.getPagedResultsCookie();
      String currentPagedResultsCookie = options.getPagedResultsCookie();
      final Integer pagedResultsOffset =
          null != options.getPagedResultsOffset()
              ? Math.max(0, options.getPagedResultsOffset())
              : 0;
      final Integer pageSize = options.getPageSize();

      int index = 0;
      int pageStartIndex = null == pagedResultsCookie ? 0 : -1;
      int handled = 0;

      for (ConnectorObject entry : resultSet) {
        if (pageStartIndex < 0 && pagedResultsCookie.equals(entry.getName().getNameValue())) {
          pageStartIndex = index + 1;
        }

        if (pageStartIndex < 0 || index < pageStartIndex) {
          index++;
          continue;
        }

        if (handled >= pageSize) {
          break;
        }

        if (index >= pagedResultsOffset + pageStartIndex) {
          if (handler.handle(entry)) {
            handled++;
            currentPagedResultsCookie = entry.getName().getNameValue();
          } else {
            break;
          }
        }
        index++;
      }

      if (index == resultSet.size()) {
        currentPagedResultsCookie = null;
      }

      if (handler instanceof SearchResultsHandler) {
        ((SearchResultsHandler) handler)
            .handleResult(new SearchResult(currentPagedResultsCookie, resultSet.size() - index));
      }
    } else {
      // Normal Search
      for (ConnectorObject entry : resultSet) {
        if (!handler.handle(entry)) {
          break;
        }
      }
      if (handler instanceof SearchResultsHandler) {
        ((SearchResultsHandler) handler).handleResult(new SearchResult());
      }
    }
  }
コード例 #17
0
  @Test // @Ignore
  public void testSearchSpecifiedUser() throws Exception {
    SpmlConfiguration config = createConfiguration();
    SpmlConnector info = createConnector(config);
    try {
      Set<Attribute> attrs = fillInSampleUser(TEST_USER);

      deleteUser(TEST_USER, info);
      Uid createdUserUid = info.create(ObjectClass.ACCOUNT, attrs, null);

      // Simple test of EqualsFilter
      //
      TestHandler handler = new TestHandler();
      TestHelpers.search(
          info,
          ObjectClass.ACCOUNT,
          new EqualsFilter(AttributeBuilder.build(ATTR_LASTNAME, "User")),
          handler,
          null);
      boolean found = false;
      int count = 0;
      for (ConnectorObject user : handler) {
        if (TEST_USER.equals(user.getName().getNameValue())) found = true;
        count++;
      }
      Assert.assertTrue(count == 1);
      Assert.assertTrue(found);

      // Simple test of StartsWithFilter
      //
      handler = new TestHandler();
      TestHelpers.search(
          info,
          ObjectClass.ACCOUNT,
          new StartsWithFilter(AttributeBuilder.build(ATTR_LASTNAME, "User")),
          handler,
          null);
      found = false;
      for (ConnectorObject user : handler) {
        if (TEST_USER.equals(user.getName().getNameValue())) found = true;
        Assert.assertTrue(
            AttributeUtil.getStringValue(user.getAttributeByName(ATTR_LASTNAME))
                .startsWith("User"));
      }
      Assert.assertTrue(found);

      // Simple test of EndsWithFilter
      //
      handler = new TestHandler();
      TestHelpers.search(
          info,
          ObjectClass.ACCOUNT,
          new EndsWithFilter(AttributeBuilder.build(ATTR_LASTNAME, "User")),
          handler,
          null);
      found = false;
      for (ConnectorObject user : handler) {
        if (TEST_USER.equals(user.getName().getNameValue())) found = true;
        Assert.assertTrue(
            AttributeUtil.getStringValue(user.getAttributeByName(ATTR_LASTNAME)).endsWith("User"));
      }
      Assert.assertTrue(found);

      // Simple test of ContainsFilter
      //
      handler = new TestHandler();
      TestHelpers.search(
          info,
          ObjectClass.ACCOUNT,
          new ContainsFilter(AttributeBuilder.build(ATTR_LASTNAME, "User")),
          handler,
          null);
      found = false;
      for (ConnectorObject user : handler) {
        if (TEST_USER.equals(user.getName().getNameValue())) found = true;
        Assert.assertTrue(
            AttributeUtil.getStringValue(user.getAttributeByName(ATTR_LASTNAME)).contains("User"));
      }
      Assert.assertTrue(found);

      // Simple test of EqualsFilter
      //
      {
        handler = new TestHandler();
        TestHelpers.search(
            info, ObjectClass.ACCOUNT, new EqualsFilter(createdUserUid), handler, null);
        found = false;
        count = 0;
        for (ConnectorObject user : handler) {
          if (TEST_USER.equals(user.getName().getNameValue())) found = true;
          count++;
        }
        Assert.assertTrue(count == 1);
        Assert.assertTrue(found);
      }

      // Test of And
      //
      handler = new TestHandler();
      Filter filter =
          new AndFilter(
              new EqualsFilter(AttributeBuilder.build(ATTR_LASTNAME, "User")),
              new EqualsFilter(AttributeBuilder.build(ATTR_FIRSTNAME, "SPML")));
      TestHelpers.search(info, ObjectClass.ACCOUNT, filter, handler, null);
      found = false;
      count = 0;
      for (ConnectorObject user : handler) {
        if (TEST_USER.equals(user.getName().getNameValue())) found = true;
        count++;
      }

      Assert.assertTrue(count == 1);
      Assert.assertTrue(found);

      // Change the first name
      //
      ConnectorObject updateUser = getUser(TEST_USER);
      Set<Attribute> changed = new HashSet<Attribute>();
      changed.add(AttributeBuilder.build(ATTR_FIRSTNAME, "abel"));
      changed.add(updateUser.getUid());
      info.update(ObjectClass.ACCOUNT, changed, null);

      // Test of And, which should fail, since firstname has changed
      //
      handler = new TestHandler();
      filter =
          new AndFilter(
              new EqualsFilter(AttributeBuilder.build(ATTR_LASTNAME, "User")),
              new EqualsFilter(AttributeBuilder.build(ATTR_FIRSTNAME, "SPML")));
      TestHelpers.search(info, ObjectClass.ACCOUNT, filter, handler, null);
      found = false;
      count = 0;
      for (ConnectorObject user : handler) {
        if (TEST_USER.equals(user.getName().getNameValue())) found = true;
        count++;
      }
      Assert.assertTrue(count == 0);
      Assert.assertTrue(!found);

      // Test of Or, which should succeed, since lastname has not changed
      //
      handler = new TestHandler();
      filter =
          new OrFilter(
              new EqualsFilter(AttributeBuilder.build(ATTR_LASTNAME, "User")),
              new EqualsFilter(AttributeBuilder.build(ATTR_FIRSTNAME, "SPML")));
      TestHelpers.search(info, ObjectClass.ACCOUNT, filter, handler, null);
      found = false;
      count = 0;
      for (ConnectorObject user : handler) {
        if (TEST_USER.equals(user.getName().getNameValue())) found = true;
        count++;
      }
      Assert.assertTrue(count > 0);
      Assert.assertTrue(found);

    } finally {
      info.dispose();
    }
  }