Package org.nasutekds.guitools.controlpanel.datamodel

Examples of org.nasutekds.guitools.controlpanel.datamodel.ControlPanelInfo


      {
        Boolean isServerRunning = Boolean.TRUE;
        ctx = null;
        try
        {
          ControlPanelInfo info = ControlPanelInfo.getInstance();
          info.setTrustManager(getTrustManager());
          info.setConnectTimeout(timeout);
          info.regenerateDescriptor();
          ConfigFromFile conf = new ConfigFromFile();
          conf.readConfiguration();
          String dn = ADSContext.getAdministratorDN(tfUid.getText());
          String pwd = tfPwd.getText();
          info.setConnectionPolicy(ConnectionProtocolPolicy.USE_ADMIN);
          usedUrl = info.getAdminConnectorURL();
          if (usedUrl == null)
          {
            throw new ApplicationException(ReturnCode.APPLICATION_ERROR,
                ERR_COULD_NOT_FIND_VALID_LDAPURL.get(), null);
          }
View Full Code Here


    if (v != DsFrameworkCliReturnCode.SUCCESSFUL_NOP.getReturnCode()) {
      println(Message.raw(argParser.getUsage()));
      return v;
    } else {
      ControlPanelInfo controlInfo = ControlPanelInfo.getInstance();
      controlInfo.setTrustManager(getTrustManager());
      controlInfo.setConnectTimeout(argParser.getConnectTimeout());
      controlInfo.regenerateDescriptor();
      boolean authProvided = false;
      if (controlInfo.getServerDescriptor().getStatus() ==
        ServerDescriptor.ServerStatus.STARTED) {
        String bindDn;
        String bindPwd;
        if (argParser.isInteractive()) {
          ManagementContext ctx = null;

          // This is done because we do not need to ask the user about these
          // parameters.  If we force their presence the class
          // LDAPConnectionConsoleInteraction will not prompt the user for
          // them.
          SecureConnectionCliArgs secureArgsList =
            argParser.getSecureArgsList();

          int port =
            AdministrationConnector.DEFAULT_ADMINISTRATION_CONNECTOR_PORT;
          controlInfo.setConnectionPolicy(
            ConnectionProtocolPolicy.USE_ADMIN);
          String ldapUrl = controlInfo.getURLToConnect();
          try {
            URI uri = new URI(ldapUrl);
            port = uri.getPort();
          } catch (Throwable t) {
            LOG.log(Level.SEVERE, "Error parsing url: " + ldapUrl);
          }
          secureArgsList.hostNameArg.setPresent(true);
          secureArgsList.portArg.setPresent(true);
          secureArgsList.hostNameArg.addValue(
            secureArgsList.hostNameArg.getDefaultValue());
          secureArgsList.portArg.addValue(Integer.toString(port));
          // We already know if SSL or StartTLS can be used.  If we cannot
          // use them we will not propose them in the connection parameters
          // and if none of them can be used we will just not ask for the
          // protocol to be used.
          LDAPConnectionConsoleInteraction ci =
            new LDAPConnectionConsoleInteraction(
            this, argParser.getSecureArgsList());
          try {
            ci.run(true, false);
            bindDn = ci.getBindDN();
            bindPwd = ci.getBindPassword();

            LDAPManagementContextFactory factory =
              new LDAPManagementContextFactory(alwaysSSL);
            ctx = factory.getManagementContext(this, ci);
            interactiveTrustManager = ci.getTrustManager();
            controlInfo.setTrustManager(interactiveTrustManager);
            useInteractiveTrustManager = true;
          } catch (ArgumentException e) {
            println(e.getMessageObject());
            return ErrorReturnCode.USER_CANCELLED_OR_DATA_ERROR.getReturnCode();
          } catch (ClientException e) {
            println(e.getMessageObject());
            writeStatus(controlInfo);
            return ErrorReturnCode.USER_CANCELLED_OR_DATA_ERROR.getReturnCode();
          } finally {
            if (ctx != null) {
              try {
                ctx.close();
              } catch (Throwable t) {
              }
            }
          }
        } else {
          bindDn = argParser.getBindDN();
          bindPwd = argParser.getBindPassword();
        }

        authProvided = bindPwd != null;

        if (bindDn == null) {
          bindDn = "";
        }
        if (bindPwd == null) {
          bindPwd = "";
        }

        if (authProvided) {
          InitialLdapContext ctx = null;
          try {
            ctx = Utilities.getAdminDirContext(controlInfo, bindDn, bindPwd);
            controlInfo.setDirContext(ctx);
            controlInfo.regenerateDescriptor();
            writeStatus(controlInfo);

            if (!controlInfo.getServerDescriptor().getExceptions().isEmpty()) {
              return ErrorReturnCode.ERROR_READING_CONFIGURATION_WITH_LDAP.
                getReturnCode();
            }
          } catch (NamingException ne) {
            // This should not happen but this is useful information to
View Full Code Here

TOP

Related Classes of org.nasutekds.guitools.controlpanel.datamodel.ControlPanelInfo

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.