Java 类org.apache.hadoop.security.ssl.SslSocketConnectorSecure 实例源码

项目:hadoop    文件:TestJettyHelper.java   
private Server createJettyServer() {
  try {
    InetAddress localhost = InetAddress.getByName("localhost");
    String host = "localhost";
    ServerSocket ss = new ServerSocket(0, 50, localhost);
    int port = ss.getLocalPort();
    ss.close();
    Server server = new Server(0);
    if (!ssl) {
      server.getConnectors()[0].setHost(host);
      server.getConnectors()[0].setPort(port);
    } else {
      SslSocketConnector c = new SslSocketConnectorSecure();
      c.setHost(host);
      c.setPort(port);
      c.setNeedClientAuth(false);
      c.setKeystore(keyStore);
      c.setKeystoreType(keyStoreType);
      c.setKeyPassword(keyStorePassword);
      server.setConnectors(new Connector[] {c});
    }
    return server;
  } catch (Exception ex) {
    throw new RuntimeException("Could not stop embedded servlet container, " + ex.getMessage(), ex);
  }
}
项目:aliyun-oss-hadoop-fs    文件:TestJettyHelper.java   
private Server createJettyServer() {
  try {
    InetAddress localhost = InetAddress.getByName("localhost");
    String host = "localhost";
    ServerSocket ss = new ServerSocket(0, 50, localhost);
    int port = ss.getLocalPort();
    ss.close();
    Server server = new Server(0);
    if (!ssl) {
      server.getConnectors()[0].setHost(host);
      server.getConnectors()[0].setPort(port);
    } else {
      SslSocketConnector c = new SslSocketConnectorSecure();
      c.setHost(host);
      c.setPort(port);
      c.setNeedClientAuth(false);
      c.setKeystore(keyStore);
      c.setKeystoreType(keyStoreType);
      c.setKeyPassword(keyStorePassword);
      server.setConnectors(new Connector[] {c});
    }
    return server;
  } catch (Exception ex) {
    throw new RuntimeException("Could not start embedded servlet container, " + ex.getMessage(), ex);
  }
}
项目:aliyun-oss-hadoop-fs    文件:MiniKMS.java   
private static Server createJettyServer(String keyStore, String password, int inPort) {
  try {
    boolean ssl = keyStore != null;
    String host = "localhost";
    Server server = new Server(inPort);
    if (!ssl) {
      server.getConnectors()[0].setHost(host);
    } else {
      SslSocketConnector c = new SslSocketConnectorSecure();
      c.setHost(host);
      c.setNeedClientAuth(false);
      c.setKeystore(keyStore);
      c.setKeystoreType("jks");
      c.setKeyPassword(password);
      server.setConnectors(new Connector[]{c});
    }
    return server;
  } catch (Exception ex) {
    throw new RuntimeException("Could not start embedded servlet container, "
        + ex.getMessage(), ex);
  }
}
项目:big-c    文件:TestJettyHelper.java   
private Server createJettyServer() {
  try {
    InetAddress localhost = InetAddress.getByName("localhost");
    String host = "localhost";
    ServerSocket ss = new ServerSocket(0, 50, localhost);
    int port = ss.getLocalPort();
    ss.close();
    Server server = new Server(0);
    if (!ssl) {
      server.getConnectors()[0].setHost(host);
      server.getConnectors()[0].setPort(port);
    } else {
      SslSocketConnector c = new SslSocketConnectorSecure();
      c.setHost(host);
      c.setPort(port);
      c.setNeedClientAuth(false);
      c.setKeystore(keyStore);
      c.setKeystoreType(keyStoreType);
      c.setKeyPassword(keyStorePassword);
      server.setConnectors(new Connector[] {c});
    }
    return server;
  } catch (Exception ex) {
    throw new RuntimeException("Could not stop embedded servlet container, " + ex.getMessage(), ex);
  }
}
项目:hadoop-2.6.0-cdh5.4.3    文件:TestJettyHelper.java   
private Server createJettyServer() {
  try {
    InetAddress localhost = InetAddress.getByName("localhost");
    String host = "localhost";
    ServerSocket ss = new ServerSocket(0, 50, localhost);
    int port = ss.getLocalPort();
    ss.close();
    Server server = new Server(0);
    if (!ssl) {
      server.getConnectors()[0].setHost(host);
      server.getConnectors()[0].setPort(port);
    } else {
      SslSocketConnector c = new SslSocketConnectorSecure();
      c.setHost(host);
      c.setPort(port);
      c.setNeedClientAuth(false);
      c.setKeystore(keyStore);
      c.setKeystoreType(keyStoreType);
      c.setKeyPassword(keyStorePassword);
      server.setConnectors(new Connector[] {c});
    }
    return server;
  } catch (Exception ex) {
    throw new RuntimeException("Could not stop embedded servlet container, " + ex.getMessage(), ex);
  }
}
项目:hadoop-oss    文件:MiniKMS.java   
private static Server createJettyServer(String keyStore, String password, int inPort) {
  try {
    boolean ssl = keyStore != null;
    String host = "localhost";
    Server server = new Server(inPort);
    if (!ssl) {
      server.getConnectors()[0].setHost(host);
    } else {
      SslSocketConnector c = new SslSocketConnectorSecure();
      c.setHost(host);
      c.setNeedClientAuth(false);
      c.setKeystore(keyStore);
      c.setKeystoreType("jks");
      c.setKeyPassword(password);
      server.setConnectors(new Connector[]{c});
    }
    return server;
  } catch (Exception ex) {
    throw new RuntimeException("Could not start embedded servlet container, "
        + ex.getMessage(), ex);
  }
}
项目:hadoop-oss    文件:MiniKMS.java   
private static URL getJettyURL(Server server) {
  boolean ssl = server.getConnectors()[0].getClass()
      == SslSocketConnectorSecure.class;
  try {
    String scheme = (ssl) ? "https" : "http";
    return new URL(scheme + "://" +
        server.getConnectors()[0].getHost() + ":" +
        server.getConnectors()[0].getLocalPort());
  } catch (MalformedURLException ex) {
    throw new RuntimeException("It should never happen, " + ex.getMessage(),
        ex);
  }
}
项目:hadoop    文件:MiniKMS.java   
private static Server createJettyServer(String keyStore, String password, int inPort) {
  try {
    boolean ssl = keyStore != null;
    InetAddress localhost = InetAddress.getByName("localhost");
    String host = "localhost";
    ServerSocket ss = new ServerSocket((inPort < 0) ? 0 : inPort, 50, localhost);
    int port = ss.getLocalPort();
    ss.close();
    Server server = new Server(0);
    if (!ssl) {
      server.getConnectors()[0].setHost(host);
      server.getConnectors()[0].setPort(port);
    } else {
      SslSocketConnector c = new SslSocketConnectorSecure();
      c.setHost(host);
      c.setPort(port);
      c.setNeedClientAuth(false);
      c.setKeystore(keyStore);
      c.setKeystoreType("jks");
      c.setKeyPassword(password);
      server.setConnectors(new Connector[]{c});
    }
    return server;
  } catch (Exception ex) {
    throw new RuntimeException("Could not start embedded servlet container, "
        + ex.getMessage(), ex);
  }
}
项目:hadoop    文件:MiniKMS.java   
private static URL getJettyURL(Server server) {
  boolean ssl = server.getConnectors()[0].getClass()
      == SslSocketConnectorSecure.class;
  try {
    String scheme = (ssl) ? "https" : "http";
    return new URL(scheme + "://" +
        server.getConnectors()[0].getHost() + ":" +
        server.getConnectors()[0].getPort());
  } catch (MalformedURLException ex) {
    throw new RuntimeException("It should never happen, " + ex.getMessage(),
        ex);
  }
}
项目:aliyun-oss-hadoop-fs    文件:MiniKMS.java   
private static URL getJettyURL(Server server) {
  boolean ssl = server.getConnectors()[0].getClass()
      == SslSocketConnectorSecure.class;
  try {
    String scheme = (ssl) ? "https" : "http";
    return new URL(scheme + "://" +
        server.getConnectors()[0].getHost() + ":" +
        server.getConnectors()[0].getLocalPort());
  } catch (MalformedURLException ex) {
    throw new RuntimeException("It should never happen, " + ex.getMessage(),
        ex);
  }
}
项目:big-c    文件:MiniKMS.java   
private static Server createJettyServer(String keyStore, String password, int inPort) {
  try {
    boolean ssl = keyStore != null;
    InetAddress localhost = InetAddress.getByName("localhost");
    String host = "localhost";
    ServerSocket ss = new ServerSocket((inPort < 0) ? 0 : inPort, 50, localhost);
    int port = ss.getLocalPort();
    ss.close();
    Server server = new Server(0);
    if (!ssl) {
      server.getConnectors()[0].setHost(host);
      server.getConnectors()[0].setPort(port);
    } else {
      SslSocketConnector c = new SslSocketConnectorSecure();
      c.setHost(host);
      c.setPort(port);
      c.setNeedClientAuth(false);
      c.setKeystore(keyStore);
      c.setKeystoreType("jks");
      c.setKeyPassword(password);
      server.setConnectors(new Connector[]{c});
    }
    return server;
  } catch (Exception ex) {
    throw new RuntimeException("Could not start embedded servlet container, "
        + ex.getMessage(), ex);
  }
}
项目:big-c    文件:MiniKMS.java   
private static URL getJettyURL(Server server) {
  boolean ssl = server.getConnectors()[0].getClass()
      == SslSocketConnectorSecure.class;
  try {
    String scheme = (ssl) ? "https" : "http";
    return new URL(scheme + "://" +
        server.getConnectors()[0].getHost() + ":" +
        server.getConnectors()[0].getPort());
  } catch (MalformedURLException ex) {
    throw new RuntimeException("It should never happen, " + ex.getMessage(),
        ex);
  }
}
项目:hadoop-2.6.0-cdh5.4.3    文件:MiniKMS.java   
private static Server createJettyServer(String keyStore, String password, int inPort) {
  try {
    boolean ssl = keyStore != null;
    InetAddress localhost = InetAddress.getByName("localhost");
    String host = "localhost";
    ServerSocket ss = new ServerSocket((inPort < 0) ? 0 : inPort, 50, localhost);
    int port = ss.getLocalPort();
    ss.close();
    Server server = new Server(0);
    if (!ssl) {
      server.getConnectors()[0].setHost(host);
      server.getConnectors()[0].setPort(port);
    } else {
      SslSocketConnector c = new SslSocketConnectorSecure();
      c.setHost(host);
      c.setPort(port);
      c.setNeedClientAuth(false);
      c.setKeystore(keyStore);
      c.setKeystoreType("jks");
      c.setKeyPassword(password);
      server.setConnectors(new Connector[]{c});
    }
    return server;
  } catch (Exception ex) {
    throw new RuntimeException("Could not start embedded servlet container, "
        + ex.getMessage(), ex);
  }
}
项目:hadoop-2.6.0-cdh5.4.3    文件:MiniKMS.java   
private static URL getJettyURL(Server server) {
  boolean ssl = server.getConnectors()[0].getClass()
      == SslSocketConnectorSecure.class;
  try {
    String scheme = (ssl) ? "https" : "http";
    return new URL(scheme + "://" +
        server.getConnectors()[0].getHost() + ":" +
        server.getConnectors()[0].getPort());
  } catch (MalformedURLException ex) {
    throw new RuntimeException("It should never happen, " + ex.getMessage(),
        ex);
  }
}
项目:aliyun-oss-hadoop-fs    文件:HttpServer2.java   
public HttpServer2 build() throws IOException {
  Preconditions.checkNotNull(name, "name is not set");
  Preconditions.checkState(!endpoints.isEmpty(), "No endpoints specified");

  if (hostName == null) {
    hostName = endpoints.get(0).getHost();
  }

  if (this.conf == null) {
    conf = new Configuration();
  }

  HttpServer2 server = new HttpServer2(this);

  if (this.securityEnabled) {
    server.initSpnego(conf, hostName, usernameConfKey, keytabConfKey);
  }

  for (URI ep : endpoints) {
    final Connector listener;
    String scheme = ep.getScheme();
    if ("http".equals(scheme)) {
      listener = HttpServer2.createDefaultChannelConnector();
    } else if ("https".equals(scheme)) {
      SslSocketConnector c = new SslSocketConnectorSecure();
      c.setHeaderBufferSize(1024*64);
      c.setNeedClientAuth(needsClientAuth);
      c.setKeyPassword(keyPassword);

      if (keyStore != null) {
        c.setKeystore(keyStore);
        c.setKeystoreType(keyStoreType);
        c.setPassword(keyStorePassword);
      }

      if (trustStore != null) {
        c.setTruststore(trustStore);
        c.setTruststoreType(trustStoreType);
        c.setTrustPassword(trustStorePassword);
      }
      listener = c;

    } else {
      throw new HadoopIllegalArgumentException(
          "unknown scheme for endpoint:" + ep);
    }
    listener.setHost(ep.getHost());
    listener.setPort(ep.getPort() == -1 ? 0 : ep.getPort());
    server.addListener(listener);
  }
  server.loadListeners();
  return server;
}
项目:big-c    文件:HttpServer2.java   
public HttpServer2 build() throws IOException {
  Preconditions.checkNotNull(name, "name is not set");
  Preconditions.checkState(!endpoints.isEmpty(), "No endpoints specified");

  if (hostName == null) {
    hostName = endpoints.get(0).getHost();
  }

  if (this.conf == null) {
    conf = new Configuration();
  }

  HttpServer2 server = new HttpServer2(this);

  if (this.securityEnabled) {
    server.initSpnego(conf, hostName, usernameConfKey, keytabConfKey);
  }

  for (URI ep : endpoints) {
    final Connector listener;
    String scheme = ep.getScheme();
    if ("http".equals(scheme)) {
      listener = HttpServer2.createDefaultChannelConnector();
    } else if ("https".equals(scheme)) {
      SslSocketConnector c = new SslSocketConnectorSecure();
      c.setHeaderBufferSize(1024*64);
      c.setNeedClientAuth(needsClientAuth);
      c.setKeyPassword(keyPassword);

      if (keyStore != null) {
        c.setKeystore(keyStore);
        c.setKeystoreType(keyStoreType);
        c.setPassword(keyStorePassword);
      }

      if (trustStore != null) {
        c.setTruststore(trustStore);
        c.setTruststoreType(trustStoreType);
        c.setTrustPassword(trustStorePassword);
      }
      listener = c;

    } else {
      throw new HadoopIllegalArgumentException(
          "unknown scheme for endpoint:" + ep);
    }
    listener.setHost(ep.getHost());
    listener.setPort(ep.getPort() == -1 ? 0 : ep.getPort());
    server.addListener(listener);
  }
  server.loadListeners();
  return server;
}
项目:hadoop-2.6.0-cdh5.4.3    文件:HttpServer2.java   
public HttpServer2 build() throws IOException {
  if (this.name == null) {
    throw new HadoopIllegalArgumentException("name is not set");
  }

  if (endpoints.size() == 0 && connector == null) {
    throw new HadoopIllegalArgumentException("No endpoints specified");
  }

  if (hostName == null) {
    hostName = endpoints.size() == 0 ? connector.getHost() : endpoints.get(
        0).getHost();
  }

  if (this.conf == null) {
    conf = new Configuration();
  }

  HttpServer2 server = new HttpServer2(this);

  if (this.securityEnabled) {
    server.initSpnego(conf, hostName, usernameConfKey, keytabConfKey);
  }

  if (connector != null) {
    server.addUnmanagedListener(connector);
  }

  for (URI ep : endpoints) {
    Connector listener = null;
    String scheme = ep.getScheme();
    if ("http".equals(scheme)) {
      listener = HttpServer2.createDefaultChannelConnector();
    } else if ("https".equals(scheme)) {
      SslSocketConnector c = new SslSocketConnectorSecure();
      c.setHeaderBufferSize(1024*64);
      c.setNeedClientAuth(needsClientAuth);
      c.setKeyPassword(keyPassword);

      if (keyStore != null) {
        c.setKeystore(keyStore);
        c.setKeystoreType(keyStoreType);
        c.setPassword(keyStorePassword);
      }

      if (trustStore != null) {
        c.setTruststore(trustStore);
        c.setTruststoreType(trustStoreType);
        c.setTrustPassword(trustStorePassword);
      }
      listener = c;

    } else {
      throw new HadoopIllegalArgumentException(
          "unknown scheme for endpoint:" + ep);
    }
    listener.setHost(ep.getHost());
    listener.setPort(ep.getPort() == -1 ? 0 : ep.getPort());
    server.addManagedListener(listener);
  }
  server.loadListeners();
  return server;
}