Examples of ADSContext


Examples of org.nasutekds.admin.ads.ADSContext

   */
  public DsFrameworkCliReturnCode performSubCommand(SubCommand subCmd,
      OutputStream outStream, OutputStream errStream)
      throws ADSContextException, ArgumentException
  {
    ADSContext adsCtx = null ;
    InitialLdapContext ctx = null ;

    DsFrameworkCliReturnCode returnCode = ERROR_UNEXPECTED;

    try
    {
      //
      // create-ads subcommand
      if (subCmd.getName().equals(createAdsSubCmd.getName()))
      {
        String backendName = null;
        if (createAdsBackendNameArg.isPresent())
        {
          backendName = createAdsBackendNameArg.getValue();
        }
        ctx = argParser.getContext(outStream, errStream);
        if (ctx == null)
        {
          return CANNOT_CONNECT_TO_ADS;
        }
        adsCtx = new ADSContext(ctx);
        adsCtx.createAdminData(backendName);
        returnCode = SUCCESSFUL;
      }
      else if (subCmd.getName().equals(deleteAdsSubCmd.getName()))
      {
        String backendName = deleteAdsBackendNameArg.getValue();
        ADSContextHelper helper = new ADSContextHelper();
        ctx = argParser.getContext(outStream, errStream);
        if (ctx == null)
        {
          return CANNOT_CONNECT_TO_ADS;
        }
        adsCtx = new ADSContext(ctx);
        helper
            .removeAdministrationSuffix(adsCtx.getDirContext(), backendName);
        returnCode =  SUCCESSFUL;
      }
      else
      {
        // Should never occurs: If we are here, it means that the code to
View Full Code Here

Examples of org.nasutekds.admin.ads.ADSContext

  public DsFrameworkCliReturnCode performSubCommand(SubCommand subCmd,
      OutputStream outStream, OutputStream errStream)
      throws ADSContextException, ArgumentException
  {

    ADSContext adsCtx = null;
    InitialLdapContext ctx = null;
    DsFrameworkCliReturnCode returnCode = ERROR_UNEXPECTED;

    try
    {
      // -----------------------
      // register-server subcommand
      // -----------------------
      if (subCmd.getName().equals(registerServerSubCmd.getName()))
      {
        String serverId ;
        Map<ServerProperty, Object> map =
          mapSetOptionsToMap(registerServerSetArg);
        if (registerServerServerIdArg.isPresent())
        {
          serverId = registerServerServerIdArg.getValue();
        }
        else
        {
          serverId = ADSContext.getServerIdFromServerProperties(map);
        }
        map.put(ServerProperty.ID, serverId);

        ctx = argParser.getContext(outStream, errStream);
        if (ctx == null)
        {
          return CANNOT_CONNECT_TO_ADS;
        }
        adsCtx = new ADSContext(ctx);
        adsCtx.registerServer(map);

        returnCode = SUCCESSFUL;
      }
      else
      // -----------------------
      // unregister-server subcommand
      // -----------------------
      if (subCmd.getName().equals(unregisterServerSubCmd.getName()))
      {
        returnCode = SUCCESSFUL;

        Map<ServerProperty, Object> map = new HashMap<ServerProperty, Object>();
        String serverId = null;
        if (unregisterServerServerIDArg.isPresent())
        {
          serverId = unregisterServerServerIDArg.getValue();
        }
        else
        {
          serverId = ADSContext.getServerIdFromServerProperties(map);
        }
        map.put(ServerProperty.ID,serverId);

        ctx = argParser.getContext(outStream, errStream);
        if (ctx == null)
        {
          return CANNOT_CONNECT_TO_ADS;
        }
        adsCtx = new ADSContext(ctx);

        // update groups in which server was registered
        Set<Map<ServerProperty, Object>> serverList =
          adsCtx.readServerRegistry();
        boolean found = false;
        for (Map<ServerProperty,Object> elm : serverList)
        {
          if (serverId.equals(elm.get(ServerProperty.ID)))
          {
            found = true ;
            break ;
          }
        }
        if ( ! found )
        {
          throw new ADSContextException (ErrorType.NOT_YET_REGISTERED) ;
        }

        // unregister the server
        adsCtx.unregisterServer(map);
      }
      else
      // -----------------------
      // list-servers subcommand
      // -----------------------
      if (subCmd.getName().equals(listServersSubCmd.getName()))
      {
        ctx = argParser.getContext(outStream, errStream);
        if (ctx == null)
        {
          return CANNOT_CONNECT_TO_ADS;
        }
        adsCtx = new ADSContext(ctx);
        Set<Map<ServerProperty, Object>> serverList = adsCtx
            .readServerRegistry();

        PrintStream out = new PrintStream(outStream);
        for (Map<ServerProperty, Object> server : serverList)
        {
          // print out server ID
          out.println(ServerProperty.ID.getAttributeName() + ": "
              + server.get(ServerProperty.ID));
        }
        returnCode = SUCCESSFUL;
      }
      else
      // -----------------------
      // get-server-properties subcommand
      // -----------------------
      if (subCmd.getName().equals(getServerPropertiesSubCmd.getName()))
      {
        ctx = argParser.getContext(outStream, errStream);
        if (ctx == null)
        {
          return CANNOT_CONNECT_TO_ADS;
        }
        adsCtx = new ADSContext(ctx);
        Set<Map<ServerProperty, Object>> adsServerList = adsCtx
            .readServerRegistry();

        LinkedList<String> userServerList = getServerPropertiesServerIdArg
            .getValues();
        PrintStream out = new PrintStream(outStream);
        for (Map<ServerProperty, Object> server : adsServerList)
        {
          String serverID = (String) server.get(ServerProperty.ID);
          if (!userServerList.contains(serverID))
          {
            continue;
          }
          // print out server ID
          out.println(ServerProperty.ID.getAttributeName() + ": "
              + server.get(ServerProperty.ID));
          for (ServerProperty sp : server.keySet())
          {
            if (sp.equals(ServerProperty.ID))
            {
              continue;
            }
            out.println(sp.getAttributeName() + ": " + server.get(sp));
          }
          out.println();
        }
        returnCode = SUCCESSFUL;
      }
      else
      // -----------------------
      // set-server-properties subcommand
      // -----------------------
      if (subCmd.getName().equals(setServerPropertiesSubCmd.getName()))
      {
        Map<ServerProperty, Object> map =
          mapSetOptionsToMap(setServerPropertiesSetArg);

        // if the ID is specify in the --set list, it may mean that
        // the user wants to rename the serverID
        String newServerId = (String) map.get(ServerProperty.ID) ;

        // replace the serverID in the map
        map.put(ServerProperty.ID, setServerPropertiesServerIdArg.getValue());

        ctx = argParser.getContext(outStream, errStream);
        if (ctx == null)
        {
          return CANNOT_CONNECT_TO_ADS;
        }
        adsCtx = new ADSContext(ctx);
        adsCtx.updateServer(map, newServerId);
        returnCode = SUCCESSFUL;
      }
      else
      // -----------------------
      // list-server-properties subcommand
View Full Code Here

Examples of org.nasutekds.admin.ads.ADSContext

   */
  public DsFrameworkCliReturnCode performSubCommand(SubCommand subCmd,
      OutputStream outStream, OutputStream errStream)
      throws ADSContextException, ArgumentException
  {
    ADSContext adsCtx = null ;
    InitialLdapContext ctx = null ;

    DsFrameworkCliReturnCode returnCode = ERROR_UNEXPECTED;
    try
    {
      // -----------------------
      // create-group subcommand
      // -----------------------
      if (subCmd.getName().equals(createGroupSubCmd.getName()))
      {
        String groupId = createGroupGroupNameArg.getValue();
        HashMap<ServerGroupProperty, Object> serverGroupProperties =
          new HashMap<ServerGroupProperty, Object>();

        // get the GROUP_NAME
        serverGroupProperties.put(ServerGroupProperty.UID, groupId);

        // get the Description
        if (createGroupDescriptionArg.isPresent())
        {
          serverGroupProperties.put(ServerGroupProperty.DESCRIPTION,
              createGroupDescriptionArg.getValue());
        }

        // Create the group
        ctx = argParser.getContext(outStream, errStream);
        if (ctx == null)
        {
          return CANNOT_CONNECT_TO_ADS;
        }
        adsCtx = new ADSContext(ctx) ;
        adsCtx.createServerGroup(serverGroupProperties);
        returnCode = SUCCESSFUL;
      }
      // -----------------------
      // delete-group subcommand
      // -----------------------
      else if (subCmd.getName().equals(deleteGroupSubCmd.getName()))
      {
        returnCode = SUCCESSFUL;
        String groupId = deleteGroupGroupNameArg.getValue();
        if (groupId.equals(ADSContext.ALL_SERVERGROUP_NAME))
        {
          return ACCESS_PERMISSION ;
        }
        HashMap<ServerGroupProperty, Object> serverGroupProperties =
          new HashMap<ServerGroupProperty, Object>();

        // Get ADS context
        ctx = argParser.getContext(outStream, errStream);
        if (ctx == null)
        {
          return CANNOT_CONNECT_TO_ADS;
        }
        adsCtx = new ADSContext(ctx) ;

        // update server Property "GROUPS"
        Set<String> serverList = adsCtx.getServerGroupMemberList(groupId);
        for (String serverId : serverList)
        {
          // serverId contains "cn=" string, just remove it.
          removeServerFromGroup(adsCtx, groupId,serverId.substring(3));
        }

        // Delete the group
        serverGroupProperties.put(ServerGroupProperty.UID, groupId);
        adsCtx.deleteServerGroup(serverGroupProperties);
      }
      // -----------------------
      // list-groups subcommand
      // -----------------------
      else if (subCmd.getName().equals(listGroupSubCmd.getName()))
      {
        ctx = argParser.getContext(outStream, errStream);
        if (ctx == null)
        {
          return CANNOT_CONNECT_TO_ADS;
        }
        adsCtx = new ADSContext(ctx) ;

        Set<Map<ServerGroupProperty, Object>> result = adsCtx
            .readServerGroupRegistry();
        StringBuilder buffer = new StringBuilder();

        // if not verbose mode, print group name (1 per line)
        if (! verboseArg.isPresent())
        {
          for (Map<ServerGroupProperty, Object> groupProps : result)
          {
            // Get the group name
            buffer.append(groupProps.get(ServerGroupProperty.UID));
            buffer.append(EOL);
          }
        }
        else
        {
          // Look for the max group identifier length
          int uidLength = 0 ;
          for (ServerGroupProperty sgp : ServerGroupProperty.values())
          {
            int cur = attributeDisplayName.get(sgp).toString().length();
            if (cur > uidLength)
            {
              uidLength = cur;
            }
          }
          uidLength++;

          for (Map<ServerGroupProperty, Object> groupProps : result)
          {
            // Get the group name
            buffer.append(attributeDisplayName.get(ServerGroupProperty.UID));
            // add space
            int curLen = attributeDisplayName.get(ServerGroupProperty.UID)
                .length();
            for (int i = curLen; i < uidLength; i++)
            {
              buffer.append(" ");
            }
            buffer.append(": ");
            buffer.append(groupProps.get(ServerGroupProperty.UID));
            buffer.append(EOL);

            // Write other props
            for (ServerGroupProperty propName : ServerGroupProperty.values())
            {
              if (propName.compareTo(ServerGroupProperty.UID) == 0)
              {
                // We have already displayed the group Id
                continue;
              }
              buffer.append(attributeDisplayName.get(propName));
              // add space
              curLen = attributeDisplayName.get(propName).length();
              for (int i = curLen; i < uidLength; i++)
              {
                buffer.append(" ");
              }
              buffer.append(": ");

              if (propName.compareTo(ServerGroupProperty.MEMBERS) == 0)
              {
                Set atts = (Set) groupProps.get(propName);
                if (atts != null)
                {
                  boolean indent = false;
                  for (Object att : atts)
                  {
                    if (indent)
                    {
                      buffer.append(EOL);
                      for (int i = 0; i < uidLength + 2; i++)
                      {
                        buffer.append(" ");
                      }
                    }
                    else
                    {
                      indent = true;
                    }
                    buffer.append(att.toString().substring(3));
                  }
                }
              }
              else
              {
                if (groupProps.get(propName) != null)
                {
                  buffer.append(groupProps.get(propName));
                }
              }
              buffer.append(EOL);
            }
            buffer.append(EOL);
          }
        }
        try
        {
          outStream.write(buffer.toString().getBytes());
        }
        catch (IOException e)
        {
        }
        returnCode = SUCCESSFUL;
      }
      // -----------------------
      // modify-group subcommand
      // -----------------------
      else if (subCmd.getName().equals(modifyGroupSubCmd.getName()))
      {
        String groupId = modifyGroupGroupNameArg.getValue();
        HashMap<ServerGroupProperty, Object> serverGroupProperties =
          new HashMap<ServerGroupProperty, Object>();
        HashSet<ServerGroupProperty> serverGroupPropertiesToRemove =
          new HashSet<ServerGroupProperty>();

        Boolean updateRequired = false;
        Boolean removeRequired = false;
        // get the GROUP_ID
        if (modifyGroupGroupIdArg.isPresent())
        {
          // rename the entry !
          serverGroupProperties.put(ServerGroupProperty.UID,
              modifyGroupGroupIdArg.getValue());
          updateRequired = true;
        }
        else
        {
          serverGroupProperties.put(ServerGroupProperty.UID, groupId) ;
        }


        // get the Description
        if (modifyGroupDescriptionArg.isPresent())
        {
          String newDesc = modifyGroupDescriptionArg.getValue();
          if (newDesc.length() == 0)
          {
            serverGroupPropertiesToRemove.add(ServerGroupProperty.DESCRIPTION);
            removeRequired = true;
          }
          else
          {
            serverGroupProperties.put(ServerGroupProperty.DESCRIPTION,
                modifyGroupDescriptionArg.getValue());
            updateRequired = true;
          }
        }


        // Update the server group
        if ( ! (updateRequired || removeRequired ) )
        {
          returnCode = SUCCESSFUL_NOP;
        }

        // We need to perform an update
        ctx = argParser.getContext(outStream, errStream);
        if (ctx == null)
        {
          return CANNOT_CONNECT_TO_ADS;
        }
        adsCtx = new ADSContext(ctx) ;

        if (updateRequired)
        {
          adsCtx.updateServerGroup(groupId, serverGroupProperties);
        }
        if (removeRequired)
        {
          adsCtx.removeServerGroupProp(groupId,
              serverGroupPropertiesToRemove);
        }

        returnCode = SUCCESSFUL;
      }
      // -----------------------
      // add-to-group subcommand
      // -----------------------
      else if (subCmd.getName().equals(addToGroupSubCmd.getName()))
      {
        String groupId = addToGroupGroupNameArg.getValue();

        ctx = argParser.getContext(outStream, errStream);
        if (ctx == null)
        {
          return CANNOT_CONNECT_TO_ADS;
        }
        adsCtx = new ADSContext(ctx) ;

        // Check if the server is registered inside to ADS
        Set<Map<ServerProperty, Object>> serverList = adsCtx
            .readServerRegistry();
        boolean found = false ;
        Map<ServerProperty, Object> foundServerProperties = null ;
        for (Map<ServerProperty, Object> serverProperties : serverList)
        {
          String serverId = ADSContext
              .getServerIdFromServerProperties(serverProperties);
          if (addToGoupMemberNameArg.getValue().equals(serverId))
          {
            found = true;
            foundServerProperties = serverProperties ;
            break;
          }
        }
        if ( !found )
        {
          throw new ADSContextException (ErrorType.NOT_YET_REGISTERED) ;
        }

        // Add the server inside the group
        returnCode = addServerTogroup(adsCtx, groupId, foundServerProperties);
      }
      // -----------------------
      // remove-from-group subcommand
      // -----------------------
      else if (subCmd.getName().equals(removeFromGroupSubCmd.getName()))
      {
        ctx = argParser.getContext(outStream, errStream);
        if (ctx == null)
        {
          return CANNOT_CONNECT_TO_ADS;
        }
        adsCtx = new ADSContext(ctx) ;

        returnCode = removeServerFromGroup(adsCtx,
            removeFromGroupGroupNameArg.getValue(),
            removeFromGoupMemberNameArg.getValue());
      }
      // -----------------------
      // list-members subcommand
      // -----------------------
      else if (subCmd.getName().equals(listMembersSubCmd.getName()))
      {
        String groupId = listMembersGroupNameArg.getValue();

        ctx = argParser.getContext(outStream, errStream);
        if (ctx == null)
        {
          return CANNOT_CONNECT_TO_ADS;
        }
        adsCtx = new ADSContext(ctx) ;

        // get the current member list
        Set<String> memberList = adsCtx.getServerGroupMemberList(groupId);
        if (memberList == null)
        {
          returnCode = SUCCESSFUL;
        }
        StringBuilder buffer = new StringBuilder();
        for (String member : memberList)
        {
          // We shouldn't print out the "cn="
          buffer.append(member.substring(3));
          buffer.append(EOL);
        }
        try
        {
          outStream.write(buffer.toString().getBytes());
        }
        catch (IOException e)
        {
        }

        returnCode = SUCCESSFUL;
      }
      // -----------------------
      // list-membership subcommand
      // -----------------------
      else if (subCmd.getName().equals(listMembershipSubCmd.getName()))
      {

        ctx = argParser.getContext(outStream, errStream);
        if (ctx == null)
        {
          return CANNOT_CONNECT_TO_ADS;
        }
        adsCtx = new ADSContext(ctx) ;

        Set<Map<ServerGroupProperty, Object>> result = adsCtx
            .readServerGroupRegistry();
        String MemberId = listMembershipMemberNameArg.getValue();

        StringBuilder buffer = new StringBuilder();
        for (Map<ServerGroupProperty, Object> groupProps : result)
View Full Code Here

Examples of org.nasutekds.admin.ads.ADSContext

      }
      ctx = createAdministrativeContext(host, port, useSSL, useStartTLS, dn,
          pwd, getConnectTimeout(),
          userData.getTrustManager());

      ADSContext adsContext = new ADSContext(ctx);
      if (interactive && (userData.getTrustManager() == null))
      {
        // This is required when the user did  connect to the server using SSL
        // or Start TLS in interactive mode.  In this case
        // LDAPConnectionInteraction.run does not initialize the keystore and
View Full Code Here

Examples of org.nasutekds.admin.ads.ADSContext

      BackgroundTask<TopologyCache> worker = new BackgroundTask<TopologyCache>()
      {
        public TopologyCache processBackgroundTask() throws Throwable
        {
          LOG.log(Level.INFO, "Loading Topology Cache in askForAuthentication");
          ADSContext adsContext = new ADSContext(ctx);
          TopologyCache cache = new TopologyCache(adsContext,
              getTrustManager(), getConnectTimeout());
          cache.getFilter().setSearchMonitoringInformation(false);
          cache.reloadTopology();
          return cache;
View Full Code Here

Examples of org.nasutekds.admin.ads.ADSContext

              serverDisplay, t.toString());
      throw new ApplicationException(
          ReturnCode.CONFIGURATION_ERROR, errorMessage,
          t);
    }
    ADSContext adsContext = new ADSContext(ctx);

    try
    {
      if (adsContext.hasAdminData() && (serverADSProperties != null))
      {
        LOG.log(Level.INFO, "Unregistering server on ADS of server "+
            ConnectionUtils.getHostPort(ctx)+".  Properties: "+
            serverADSProperties);
        adsContext.unregisterServer(serverADSProperties);
      }
    }
    catch (ADSContextException ace)
    {
      if (ace.getError() !=
View Full Code Here

Examples of org.nasutekds.admin.ads.ADSContext

  public DsFrameworkCliReturnCode performSubCommand(SubCommand subCmd,
      OutputStream outStream, OutputStream errStream)
      throws ADSContextException, ArgumentException
  {

    ADSContext adsCtx = null;
    InitialLdapContext ctx = null;
    DsFrameworkCliReturnCode returnCode = ERROR_UNEXPECTED;

    try
    {
      // -----------------------
      // create-admin-user subcommand.
      // -----------------------
      if (subCmd.getName().equals(createAdminUserSubCmd.getName()))
      {
        String userId  = createAdminUserUserIdArg.getValue();
        Map<AdministratorProperty, Object> map =
          mapSetOptionsToMap(createAdminUserSetArg,true);
        map.put(AdministratorProperty.UID, userId);

        ctx = argParser.getContext(outStream, errStream);
        if (ctx == null)
        {
          return CANNOT_CONNECT_TO_ADS;
        }
        adsCtx = new ADSContext(ctx);
        adsCtx.createAdministrator(map);

        returnCode = SUCCESSFUL;
      }
      else
      // -----------------------
      // delete-admin-user subcommand.
      // -----------------------
      if (subCmd.getName().equals(deleteAdminUserSubCmd.getName()))
      {
        String userId  = deleteAdminUserUserIdArg.getValue();
        Map<AdministratorProperty, Object> map =
          new HashMap<AdministratorProperty, Object>();
        map.put(AdministratorProperty.UID, userId);

        ctx = argParser.getContext(outStream, errStream);
        if (ctx == null)
        {
          return CANNOT_CONNECT_TO_ADS;
        }
        adsCtx = new ADSContext(ctx);
        adsCtx.deleteAdministrator(map);

        returnCode = SUCCESSFUL;
      }
      else
      // -----------------------
      // list-admin-user subcommand.
      // -----------------------
      if (subCmd.getName().equals(listAdminUserSubCmd.getName()))
      {
        ctx = argParser.getContext(outStream, errStream);
        if (ctx == null)
        {
          return CANNOT_CONNECT_TO_ADS;
        }
        adsCtx = new ADSContext(ctx);
        Set<Map<AdministratorProperty, Object>> adminUserList = adsCtx
            .readAdministratorRegistry();

        PrintStream out = new PrintStream(outStream);
        for (Map<AdministratorProperty, Object> user : adminUserList)
        {
          // print out server ID
          out.println(AdministratorProperty.UID.getAttributeName() + ": "
              + user.get(AdministratorProperty.UID));
        }
        returnCode = SUCCESSFUL;
      }
      else
      // -----------------------
      // get-admin-user-properties subcommand.
      // -----------------------
      if (subCmd.getName().equals(getAdminUserPropertiesSubCmd.getName()))
      {
        ctx = argParser.getContext(outStream, errStream);
        if (ctx == null)
        {
          return CANNOT_CONNECT_TO_ADS;
        }
        adsCtx = new ADSContext(ctx);
        Set<Map<AdministratorProperty, Object>> adsAdminUserList = adsCtx
            .readAdministratorRegistry();

        LinkedList<String> userAdminUserList = getAdminUserPropertiesUserIdArg
            .getValues();
        PrintStream out = new PrintStream(outStream);
        for (Map<AdministratorProperty, Object> adminUser : adsAdminUserList)
        {
          String adminUserID = (String) adminUser
              .get(AdministratorProperty.UID);
          if (!userAdminUserList.contains(adminUserID))
          {
            continue;
          }
          // print out the Admin User ID
          out.println(AdministratorProperty.UID.getAttributeName() + ": "
              + adminUser.get(AdministratorProperty.UID));
          for (AdministratorProperty ap : adminUser.keySet())
          {
            if (ap.equals(AdministratorProperty.UID))
            {
              continue;
            }
            out.println(ap.getAttributeName() + ": " + adminUser.get(ap));
          }
          out.println();
        }
        returnCode = SUCCESSFUL;
      }
      else
      // -----------------------
      // set-admin-user-properties subcommand.
      // -----------------------
      if (subCmd.getName().equals(setAdminUserPropertiesSubCmd.getName()))
      {
        Map<AdministratorProperty, Object> map =
          mapSetOptionsToMap(setAdminUserPropertiesSetArg,false);

        // if the ID is specify in the --set list, it may mean that
        // the user wants to rename the serverID
        String newServerId = (String) map.get(AdministratorProperty.UID) ;

        // replace the serverID in the map
        map.put(AdministratorProperty.UID, setAdminUserPropertiesUserIdArg
            .getValue());

        ctx = argParser.getContext(outStream, errStream);
        if (ctx == null)
        {
          return CANNOT_CONNECT_TO_ADS;
        }
        adsCtx = new ADSContext(ctx);
        adsCtx.updateAdministrator(map, newServerId);
        returnCode = SUCCESSFUL;
      }
      else
      // -----------------------
      // list-admin-user-properties subcommand.
View Full Code Here

Examples of org.nasutekds.admin.ads.ADSContext

      // initialize the keystore and the trust manager is null.
      forceTrustManagerInitialization();
    }
    try
    {
      ADSContext adsContext = new ADSContext(ctx[0]);
      if (adsContext.hasAdminData())
      {
        boolean reloadTopology = true;
        LinkedList<Message> exceptionMsgs = new LinkedList<Message>();
        while (reloadTopology && !cancelled)
        {
          // We must recreate the cache because the trust manager in the
          // LDAPConnectionConsoleInteraction object might have changed.

          TopologyCache cache = new TopologyCache(adsContext,
              getTrustManager(), getConnectTimeout());
          cache.getFilter().setSearchMonitoringInformation(false);
          cache.getFilter().setSearchBaseDNInformation(false);
          cache.setPreferredConnections(
              PreferredConnection.getPreferredConnections(ctx[0]));
          cache.reloadTopology();

          reloadTopology = false;
          exceptionMsgs.clear();

          /* Analyze if we had any exception while loading servers.  For the
           * moment only throw the exception found if the user did not provide
           * the Administrator DN and this caused a problem authenticating in
           * one server or if there is a certificate problem.
           */
          Set<TopologyCacheException> exceptions =
            new HashSet<TopologyCacheException>();
          Set<ServerDescriptor> servers = cache.getServers();
          for (ServerDescriptor server : servers)
          {
            TopologyCacheException e = server.getLastException();
            if (e != null)
            {
              exceptions.add(e);
            }
          }
          /* Check the exceptions and see if we throw them or not. */
          boolean notGlobalAdministratorError = false;
          for (TopologyCacheException e : exceptions)
          {
            if (notGlobalAdministratorError)
            {
              break;
            }
            switch (e.getType())
            {
              case NOT_GLOBAL_ADMINISTRATOR:
                notGlobalAdministratorError = true;
                boolean connected = false;

                String adminUid = uData.getAdminUid();
                String adminPwd = uData.getAdminPwd();

                boolean errorDisplayed = false;
                while (!connected)
                {
                  if ((!triedWithUserProvidedAdmin) && (adminPwd == null))
                  {
                    adminUid = getValue(argParser.getAdministratorUID(),
                        argParser.getDefaultAdministratorUID());
                    adminPwd = argParser.getBindPasswordAdmin();
                    triedWithUserProvidedAdmin = true;
                  }
                  if (adminPwd == null)
                  {
                    if (!errorDisplayed)
                    {
                      println();
                      println(
                          INFO_NOT_GLOBAL_ADMINISTRATOR_PROVIDED.get());
                      errorDisplayed = true;
                    }
                    adminUid = askForAdministratorUID(
                        argParser.getDefaultAdministratorUID(), LOG);
                    println();
                    adminPwd = askForAdministratorPwd(LOG);
                    println();
                  }
                  try
                  {
                    ctx[0].close();
                  }
                  catch (Throwable t)
                  {
                  }
                  try
                  {
                    ctx[0] = createAdministrativeContext(host, port, isSSL,
                        isStartTLS, ADSContext.getAdministratorDN(adminUid),
                        adminPwd, getConnectTimeout(), getTrustManager());
                    adsContext = new ADSContext(ctx[0]);
                    cache = new TopologyCache(adsContext, getTrustManager(),
                        getConnectTimeout());
                    cache.getFilter().setSearchMonitoringInformation(false);
                    cache.getFilter().setSearchBaseDNInformation(false);
                    cache.setPreferredConnections(
View Full Code Here

Examples of org.nasutekds.admin.ads.ADSContext

  private boolean hasAdministrator(InitialLdapContext ctx)
  {
    boolean isAdminDefined = false;
    try
    {
      ADSContext adsContext = new ADSContext(ctx);
      if (adsContext.hasAdminData())
      {
        Set<?> administrators = adsContext.readAdministratorRegistry();
        isAdminDefined = administrators.size() > 0;
      }
    }
    catch (Throwable t)
    {
View Full Code Here

Examples of org.nasutekds.admin.ads.ADSContext

  {
    boolean isAdminDefined = false;
    String adminUid = uData.getAdminUid();
    try
    {
      ADSContext adsContext = new ADSContext(ctx);
      Set<Map<AdministratorProperty, Object>> administrators =
        adsContext.readAdministratorRegistry();
      for (Map<AdministratorProperty, Object> admin : administrators)
      {
        String uid = (String)admin.get(AdministratorProperty.UID);
        if (uid != null)
        {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.