当前位置: 首页>>代码示例>>Java>>正文


Java SSLFactory.createSSLServerSocketFactory方法代码示例

本文整理汇总了Java中org.apache.hadoop.security.ssl.SSLFactory.createSSLServerSocketFactory方法的典型用法代码示例。如果您正苦于以下问题:Java SSLFactory.createSSLServerSocketFactory方法的具体用法?Java SSLFactory.createSSLServerSocketFactory怎么用?Java SSLFactory.createSSLServerSocketFactory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.security.ssl.SSLFactory的用法示例。


在下文中一共展示了SSLFactory.createSSLServerSocketFactory方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addSslListener

import org.apache.hadoop.security.ssl.SSLFactory; //导入方法依赖的package包/类
/**
 * Configure an ssl listener on the server for shuffle.
 *
 * @param addr address to listen on.
 * @param sslFactory SSLFactory to use.
 */
public void addSslListener(InetSocketAddress addr, final SSLFactory sslFactory)
  throws IOException {
  if (webServer.isStarted()) {
    throw new IOException("Failed to add ssl listener");
  }

  SslSocketConnector sslListener = new SslSocketConnector() {
    @Override
    protected SSLServerSocketFactory createFactory() throws Exception {
      return sslFactory.createSSLServerSocketFactory();
    }
  };

  sslListener.setHost(addr.getHostName());
  sslListener.setPort(addr.getPort());
  webServer.addConnector(sslListener);
}
 
开发者ID:Nextzero,项目名称:hadoop-2.6.0-cdh5.4.3,代码行数:24,代码来源:TaskTracker.java

示例2: getSecureResources

import org.apache.hadoop.security.ssl.SSLFactory; //导入方法依赖的package包/类
@VisibleForTesting
public static SecureResources getSecureResources(final SSLFactory sslFactory,
                                Configuration conf) throws Exception {
  // Obtain secure port for data streaming to datanode
  InetSocketAddress streamingAddr  = DataNode.getStreamingAddr(conf);
  int socketWriteTimeout = conf.getInt(DFSConfigKeys.DFS_DATANODE_SOCKET_WRITE_TIMEOUT_KEY,
      HdfsServerConstants.WRITE_TIMEOUT);
  
  ServerSocket ss = (socketWriteTimeout > 0) ? 
      ServerSocketChannel.open().socket() : new ServerSocket();
  ss.bind(streamingAddr, 0);
  
  // Check that we got the port we need
  if (ss.getLocalPort() != streamingAddr.getPort()) {
    throw new RuntimeException("Unable to bind on specified streaming port in secure " +
        "context. Needed " + streamingAddr.getPort() + ", got " + ss.getLocalPort());
  }

  // Obtain secure listener for web server
  Connector listener;
  if (HttpConfig.isSecure()) {
    try {
      sslFactory.init();
    } catch (GeneralSecurityException ex) {
      throw new IOException(ex);
    }
    SslSocketConnector sslListener = new SslSocketConnector() {
      @Override
      protected SSLServerSocketFactory createFactory() throws Exception {
        return sslFactory.createSSLServerSocketFactory();
      }
    };
    listener = sslListener;
  } else {
    listener = HttpServer.createDefaultChannelConnector();
  }

  InetSocketAddress infoSocAddr = DataNode.getInfoAddr(conf);
  listener.setHost(infoSocAddr.getHostName());
  listener.setPort(infoSocAddr.getPort());
  // Open listener here in order to bind to port as root
  listener.open();
  if (listener.getPort() != infoSocAddr.getPort()) {
    throw new RuntimeException("Unable to bind on specified info port in secure " +
        "context. Needed " + streamingAddr.getPort() + ", got " + ss.getLocalPort());
  }
  System.err.println("Successfully obtained privileged resources (streaming port = "
      + ss + " ) (http listener port = " + listener.getConnection() +")");
  
  if ((ss.getLocalPort() > 1023 || listener.getPort() > 1023) &&
      UserGroupInformation.isSecurityEnabled()) {
    throw new RuntimeException("Cannot start secure datanode with unprivileged ports");
  }
  System.err.println("Opened streaming server at " + streamingAddr);
  System.err.println("Opened info server at " + infoSocAddr);
  return new SecureResources(ss, listener);
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:58,代码来源:SecureDataNodeStarter.java

示例3: getSecureResources

import org.apache.hadoop.security.ssl.SSLFactory; //导入方法依赖的package包/类
@VisibleForTesting
public static SecureResources getSecureResources(final SSLFactory sslFactory,
    Configuration conf) throws Exception {
  // Obtain secure port for data streaming to datanode
  InetSocketAddress streamingAddr = DataNode.getStreamingAddr(conf);
  int socketWriteTimeout =
      conf.getInt(DFSConfigKeys.DFS_DATANODE_SOCKET_WRITE_TIMEOUT_KEY,
          HdfsServerConstants.WRITE_TIMEOUT);
  
  ServerSocket ss =
      (socketWriteTimeout > 0) ? ServerSocketChannel.open().socket() :
          new ServerSocket();
  ss.bind(streamingAddr, 0);
  
  // Check that we got the port we need
  if (ss.getLocalPort() != streamingAddr.getPort()) {
    throw new RuntimeException(
        "Unable to bind on specified streaming port in secure " +
            "context. Needed " + streamingAddr.getPort() + ", got " +
            ss.getLocalPort());
  }

  // Obtain secure listener for web server
  Connector listener;
  if (HttpConfig2.isSecure()) {
    try {
      sslFactory.init();
    } catch (GeneralSecurityException ex) {
      throw new IOException(ex);
    }
    SslSocketConnector sslListener = new SslSocketConnector() {
      @Override
      protected SSLServerSocketFactory createFactory() throws Exception {
        return sslFactory.createSSLServerSocketFactory();
      }
    };
    listener = sslListener;
  } else {
    listener = HttpServer.createDefaultChannelConnector();
  }

  InetSocketAddress infoSocAddr = DataNode.getInfoAddr(conf);
  listener.setHost(infoSocAddr.getHostName());
  listener.setPort(infoSocAddr.getPort());
  // Open listener here in order to bind to port as root
  listener.open();
  if (listener.getPort() != infoSocAddr.getPort()) {
    throw new RuntimeException(
        "Unable to bind on specified info port in secure " +
            "context. Needed " + streamingAddr.getPort() + ", got " +
            ss.getLocalPort());
  }
  System.err.println(
      "Successfully obtained privileged resources (streaming port = " + ss +
          " ) (http listener port = " + listener.getConnection() + ")");
  
  if ((ss.getLocalPort() > 1023 || listener.getPort() > 1023) &&
      UserGroupInformation.isSecurityEnabled()) {
    throw new RuntimeException(
        "Cannot start secure datanode with unprivileged ports");
  }
  System.err.println("Opened streaming server at " + streamingAddr);
  System.err.println("Opened info server at " + infoSocAddr);
  return new SecureResources(ss, listener);
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:66,代码来源:SecureDataNodeStarter.java


注:本文中的org.apache.hadoop.security.ssl.SSLFactory.createSSLServerSocketFactory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。