Package org.nasutekds.server.api

Examples of org.nasutekds.server.api.IdentityMapper


      if (mapperConfiguration.isEnabled())
      {
        String className = mapperConfiguration.getJavaClass();
        try
        {
          IdentityMapper mapper = loadMapper(className, mapperConfiguration,
                                             true);
          identityMappers.put(mapperConfiguration.dn(), mapper);
          DirectoryServer.registerIdentityMapper(mapperConfiguration.dn(),
                                                 mapper);
        }
View Full Code Here


    if (! configuration.isEnabled())
    {
      return new ConfigChangeResult(resultCode, adminActionRequired, messages);
    }

    IdentityMapper identityMapper = null;

    // Get the name of the class and make sure we can instantiate it as an
    // identity mapper.
    String className = configuration.getJavaClass();
    try
View Full Code Here

    boolean           adminActionRequired = false;
    ArrayList<Message> messages            = new ArrayList<Message>();

    DirectoryServer.deregisterIdentityMapper(configuration.dn());

    IdentityMapper identityMapper = identityMappers.remove(configuration.dn());
    if (identityMapper != null)
    {
      identityMapper.finalizeIdentityMapper();
    }

    return new ConfigChangeResult(resultCode, adminActionRequired, messages);
  }
View Full Code Here

    boolean           adminActionRequired = false;
    ArrayList<Message> messages            = new ArrayList<Message>();


    // Get the existing mapper if it's already enabled.
    IdentityMapper existingMapper = identityMappers.get(configuration.dn());


    // If the new configuration has the mapper disabled, then disable it if it
    // is enabled, or do nothing if it's already disabled.
    if (! configuration.isEnabled())
    {
      if (existingMapper != null)
      {
        DirectoryServer.deregisterIdentityMapper(configuration.dn());

        IdentityMapper identityMapper =
             identityMappers.remove(configuration.dn());
        if (identityMapper != null)
        {
          identityMapper.finalizeIdentityMapper();
        }
      }

      return new ConfigChangeResult(resultCode, adminActionRequired, messages);
    }


    // Get the class for the identity mapper.  If the mapper is already enabled,
    // then we shouldn't do anything with it although if the class has changed
    // then we'll at least need to indicate that administrative action is
    // required.  If the mapper is disabled, then instantiate the class and
    // initialize and register it as an identity mapper.
    String className = configuration.getJavaClass();
    if (existingMapper != null)
    {
      if (! className.equals(existingMapper.getClass().getName()))
      {
        adminActionRequired = true;
      }

      return new ConfigChangeResult(resultCode, adminActionRequired, messages);
    }

    IdentityMapper identityMapper = null;
    try
    {
      identityMapper = loadMapper(className, configuration, true);
    }
    catch (InitializationException ie)
View Full Code Here

           IdentityMapperCfgDefn.getInstance();
      ClassPropertyDefinition propertyDefinition =
           definition.getJavaClassPropertyDefinition();
      Class<? extends IdentityMapper> mapperClass =
           propertyDefinition.loadClass(className, IdentityMapper.class);
      IdentityMapper mapper = mapperClass.newInstance();

      if (initialize)
      {
        Method method = mapper.getClass().getMethod("initializeIdentityMapper",
            configuration.configurationClass());
        method.invoke(mapper, configuration);
      }
      else
      {
        Method method = mapper.getClass().getMethod("isConfigurationAcceptable",
                                                    IdentityMapperCfg.class,
                                                    List.class);

        List<Message> unacceptableReasons = new ArrayList<Message>();
        Boolean acceptable = (Boolean) method.invoke(mapper, configuration,
View Full Code Here

  @Test()
  public void testMapperEnabled()
         throws Exception
  {
    DN mapperDN = DN.decode("cn=Exact Match,cn=Identity Mappers,cn=config");
    IdentityMapper mapper = DirectoryServer.getIdentityMapper(mapperDN);
    assertNotNull(mapper);
    assertTrue(mapper instanceof ExactMatchIdentityMapper);
  }
View Full Code Here

  public void testChangingMapAttribute()
         throws Exception
  {
    String mapperDNString = "cn=Exact Match,cn=Identity Mappers,cn=config";
    DN mapperDN = DN.decode(mapperDNString);
    IdentityMapper mapper = DirectoryServer.getIdentityMapper(mapperDN);
    assertNotNull(mapper);
    assertTrue(mapper instanceof ExactMatchIdentityMapper);


    // Create a user entry and add it to the directory.
    TestCaseUtils.initializeTestBackend(true);
    Entry userEntry = TestCaseUtils.makeEntry(
         "dn: uid=test,o=test",
         "objectClass: top",
         "objectClass: person",
         "objectClass: organizationalPerson",
         "objectClass: inetOrgPerson",
         "uid: test",
         "givenName: Test",
         "sn: User",
         "cn: Test User",
         "userPassword: password");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(userEntry.getDN(), userEntry.getObjectClasses(),
                         userEntry.getUserAttributes(),
                         userEntry.getOperationalAttributes());
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);


    // Verify that "test" works for the initial configuration but "test user"
    // does not.
    Entry mappedEntry = mapper.getEntryForID("test");
    assertNotNull(mappedEntry);
    assertEquals(mappedEntry.getDN(), DN.decode("uid=test,o=test"));

    mappedEntry = mapper.getEntryForID("test user");
    assertNull(mappedEntry);


    // Create a modification to change the map attribute from uid to cn.
    ArrayList<ByteString> values = new ArrayList<ByteString>();
    values.add(ByteString.valueOf("cn"));

    ArrayList<RawModification> mods = new ArrayList<RawModification>();
    mods.add(new LDAPModification(ModificationType.REPLACE,
                                  new LDAPAttribute("ds-cfg-match-attribute",
                                                    values)));
    ModifyOperation modifyOperation =
         conn.processModify(ByteString.valueOf(mapperDNString), mods);
    assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS);


    // Verify that "test" no longer works but "test user" does.
    mappedEntry = mapper.getEntryForID("test");
    assertNull(mappedEntry);

    mappedEntry = mapper.getEntryForID("test user");
    assertNotNull(mappedEntry);
    assertEquals(mappedEntry.getDN(), DN.decode("uid=test,o=test"));


    // Change the configuration back to the way it was.
    values.set(0, ByteString.valueOf("uid"));
    modifyOperation =
         conn.processModify(ByteString.valueOf(mapperDNString), mods);
    assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS);


    // Verify that the original matching pattern is back.
    mappedEntry = mapper.getEntryForID("test");
    assertNotNull(mappedEntry);
    assertEquals(mappedEntry.getDN(), DN.decode("uid=test,o=test"));

    mappedEntry = mapper.getEntryForID("test user");
    assertNull(mappedEntry);
  }
View Full Code Here

  public void testChangingMapBaseDN()
         throws Exception
  {
    String mapperDNString = "cn=Exact Match,cn=Identity Mappers,cn=config";
    DN mapperDN = DN.decode(mapperDNString);
    IdentityMapper mapper = DirectoryServer.getIdentityMapper(mapperDN);
    assertNotNull(mapper);
    assertTrue(mapper instanceof ExactMatchIdentityMapper);


    // Create a user entry and add it to the directory.
    TestCaseUtils.initializeTestBackend(true);
    Entry userEntry = TestCaseUtils.makeEntry(
         "dn: uid=test,o=test",
         "objectClass: top",
         "objectClass: person",
         "objectClass: organizationalPerson",
         "objectClass: inetOrgPerson",
         "uid: test",
         "givenName: Test",
         "sn: User",
         "cn: Test User",
         "userPassword: password");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(userEntry.getDN(), userEntry.getObjectClasses(),
                         userEntry.getUserAttributes(),
                         userEntry.getOperationalAttributes());
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);


    // Verify that we can retrieve the user.
    Entry mappedEntry = mapper.getEntryForID("test");
    assertNotNull(mappedEntry);
    assertEquals(mappedEntry.getDN(), DN.decode("uid=test,o=test"));


    // Create a modification to set the map base DN to "dc=example,dc=com".
    ArrayList<ByteString> values = new ArrayList<ByteString>();
    values.add(ByteString.valueOf("dc=example,dc=com"));

    ArrayList<RawModification> mods = new ArrayList<RawModification>();
    mods.add(new LDAPModification(ModificationType.REPLACE,
                                  new LDAPAttribute("ds-cfg-match-base-dn",
                                                    values)));
    ModifyOperation modifyOperation =
         conn.processModify(ByteString.valueOf(mapperDNString), mods);
    assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS);


    // Verify that we can't find the user anymore.
    mappedEntry = mapper.getEntryForID("test");
    assertNull(mappedEntry);


    // Change the base DN to "o=test".
    values.set(0, ByteString.valueOf("o=test"));
    modifyOperation =
         conn.processModify(ByteString.valueOf(mapperDNString), mods);
    assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS);


    // Verify that we can retrieve the user again.
    mappedEntry = mapper.getEntryForID("test");
    assertNotNull(mappedEntry);
    assertEquals(mappedEntry.getDN(), DN.decode("uid=test,o=test"));


    // Change the configuration back to its original setting.
    values.clear();
    modifyOperation =
         conn.processModify(ByteString.valueOf(mapperDNString), mods);
    assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS);


    // Verify that we can still retrieve the user.
    mappedEntry = mapper.getEntryForID("test");
    assertNotNull(mappedEntry);
    assertEquals(mappedEntry.getDN(), DN.decode("uid=test,o=test"));
  }
View Full Code Here

  public void testMapperEnabled()
         throws Exception
  {
    DN mapperDN =
         DN.decode("cn=Regular Expression,cn=Identity Mappers,cn=config");
    IdentityMapper mapper = DirectoryServer.getIdentityMapper(mapperDN);
    assertNotNull(mapper);
    assertTrue(mapper instanceof RegularExpressionIdentityMapper);
  }
View Full Code Here

TOP

Related Classes of org.nasutekds.server.api.IdentityMapper

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.