Package com.google.dataconnector.util

Examples of com.google.dataconnector.util.ConnectionException


      frameSender.start();

      LOG.info("Attemping login");

      if (!authorize()) {
        throw new ConnectionException("Authorization failed");
      }
      LOG.info("Successful login");

      // send registration info to the SDC server
      registration.sendRegistrationInfo(frameSender);

      // setup to start receiving and processing registration response
      frameReceiver.registerDispatcher(FrameInfo.Type.REGISTRATION, registration);

      // Setup Healthcheck
      if (localConf.getRunHeartBeatThread()) {
        LOG.info("Starting hearbeat/ health check thread.");
        healthCheckHandler.setFrameSender(frameSender);
        healthCheckHandler.setFailCallback(this);
        frameReceiver.registerDispatcher(FrameInfo.Type.HEALTH_CHECK, healthCheckHandler);
        healthCheckHandler.start();
      }

      // Setup Socket Data.
      socksDataHandler.setFrameSender(frameSender);
      frameReceiver.registerDispatcher(FrameInfo.Type.SOCKET_DATA, socksDataHandler);

      // Setup AgentRequest handler
      agentRequestHandler.setFrameSender(frameSender);
      frameReceiver.registerDispatcher(FrameInfo.Type.FETCH_REQUEST, agentRequestHandler);

      // Setup SocketSessionRequestHandler
      socketSessionRequestHandler.setFrameSender(frameSender);
      frameReceiver.registerDispatcher(FrameInfo.Type.SOCKET_SESSION, socketSessionRequestHandler);

      // a thread to watch for changes in the resources.xml file
      // make this thread a daemon - so it can't hold up the process from exiting
      LOG.info("starting a thread to watch resources file");
      resourcesFileWatcher.setFrameSender(frameSender);
      resourcesFileWatcher.start();

      // Add to shutdown manager so it gets gracefully shutdown.
      shutdownManager.addStoppable(this);
      frameReceiver.startDispatching();
    } catch (IOException e) {
      throw new ConnectionException(e);
    } catch (FramingException e) {
      throw new ConnectionException(e);
    }
  }
View Full Code Here


    // Get Principal from session.
    final X509Certificate cert;
    try {
      cert = session.getPeerCertificateChain()[0];
    } catch (SSLPeerUnverifiedException e) {
      throw new ConnectionException(e);
    }
    Principal principal = cert.getSubjectDN();

    // Compare CNs between actual host and the one we thought we connected to.
    final Rdn expectedCn;
    try {
      expectedCn = new Rdn("CN", localConf.getSdcServerHost());

      // Get actual CN
      final LdapName ldapName = new LdapName(principal.getName());
      Rdn actualCn = null;
      for (final Rdn rdn : ldapName.getRdns()) {
        if (rdn.getType().equals("CN")) {
          actualCn = rdn;
          break;
        }
      }
      // Reported CN must match expected.
      if (expectedCn.equals(actualCn)) {
        return;
      }

      // No match, FAIL.
      final String errorMessage = "Wrong server X.500 name. Expected: <" +
        localConf.getSdcServerHost() + ">. Actual: <" +
        (actualCn == null ? "null" : actualCn.getValue()) + ">.";
      LOG.error(errorMessage);
      throw new ConnectionException(errorMessage);

    } catch (InvalidNameException e) {
      throw new ConnectionException(e);
    }
  }
View Full Code Here

TOP

Related Classes of com.google.dataconnector.util.ConnectionException

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.