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


Java TSaslClientTransport类代码示例

本文整理汇总了Java中org.apache.thrift.transport.TSaslClientTransport的典型用法代码示例。如果您正苦于以下问题:Java TSaslClientTransport类的具体用法?Java TSaslClientTransport怎么用?Java TSaslClientTransport使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: connect

import org.apache.thrift.transport.TSaslClientTransport; //导入依赖的package包/类
@Override
public TTransport connect(TTransport transport, String serverHost, String asUser) throws TTransportException, IOException {
    ClientCallbackHandler client_callback_handler = new ClientCallbackHandler(login_conf);
    TSaslClientTransport wrapper_transport =
            new TSaslClientTransport(DIGEST, null, AuthUtils.SERVICE, serverHost, null, client_callback_handler, transport);

    wrapper_transport.open();
    LOG.debug("SASL DIGEST-MD5 client transport has been established");

    return wrapper_transport;
}
 
开发者ID:kkllwww007,项目名称:jstrom,代码行数:12,代码来源:DigestSaslTransportPlugin.java

示例2: main

import org.apache.thrift.transport.TSaslClientTransport; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
  Opts opts = new Opts();

  // Parse the options
  opts.parseArgs(Client.class, args);

  // Open up a socket to the server:port
  TTransport transport = new TSocket(opts.server, opts.port);
  Map<String,String> saslProperties = new HashMap<String,String>();
  // Use authorization and confidentiality
  saslProperties.put(Sasl.QOP, "auth-conf");

  log.info("Security is enabled: {}", UserGroupInformation.isSecurityEnabled());

  // Log in via UGI, ensures we have logged in with our KRB credentials
  UserGroupInformation currentUser = UserGroupInformation.getCurrentUser();
  log.info("Current user: {}", currentUser);

  // SASL client transport -- does the Kerberos lifting for us
  TSaslClientTransport saslTransport = new TSaslClientTransport(
      "GSSAPI", // tell SASL to use GSSAPI, which supports Kerberos
      null, // authorizationid - null
      opts.primary, // kerberos primary for server - "myprincipal" in myprincipal/[email protected]
      opts.instance, // kerberos instance for server - "my.server.com" in myprincipal/[email protected]
      saslProperties, // Properties set, above
      null, // callback handler - null
      transport); // underlying transport

  // Make sure the transport is opened as the user we logged in as
  TUGIAssumingTransport ugiTransport = new TUGIAssumingTransport(saslTransport, currentUser);

  // Setup our thrift client to our custom thrift service
  HdfsService.Client client = new HdfsService.Client(new TBinaryProtocol(ugiTransport));

  // Open the transport
  ugiTransport.open();

  // Invoke the RPC
  String response = client.ls(opts.dir);

  // Print out the result
  System.out.println("$ ls " + opts.dir + "\n" + response);

  // Close the transport (don't leak resources)
  transport.close();
}
 
开发者ID:joshelser,项目名称:krb-thrift,代码行数:47,代码来源:Client.java

示例3: getSocketTransport

import org.apache.thrift.transport.TSaslClientTransport; //导入依赖的package包/类
/**
 * Returns the socket transport backing transport.
 */
static TSocket getSocketTransport(TTransport transport) {
  if (transport instanceof TSaslClientTransport) {
    transport = ((TSaslClientTransport)transport).getUnderlyingTransport();
  }
  Preconditions.checkState(transport instanceof TSocket);
  return (TSocket)transport;
}
 
开发者ID:cloudera,项目名称:RecordServiceClient,代码行数:11,代码来源:ThriftUtils.java

示例4: connect

import org.apache.thrift.transport.TSaslClientTransport; //导入依赖的package包/类
public TTransport connect(TTransport transport, String serverHost) throws TTransportException, IOException {
    ClientCallbackHandler client_callback_handler = new ClientCallbackHandler(login_conf);
    TSaslClientTransport wrapper_transport = new TSaslClientTransport(DIGEST, 
            null, 
            AuthUtils.SERVICE, 
            serverHost,
            null,
            client_callback_handler, 
            transport);

    wrapper_transport.open();
    LOG.debug("SASL DIGEST-MD5 client transport has been established");

    return wrapper_transport;
}
 
开发者ID:metamx,项目名称:incubator-storm,代码行数:16,代码来源:DigestSaslTransportPlugin.java

示例5: getUnderlyingSocketFromTransport

import org.apache.thrift.transport.TSaslClientTransport; //导入依赖的package包/类
/**
 * Returns the underlying TSocket from the transport, or null of the transport type is unknown.
 */
private static TSocket getUnderlyingSocketFromTransport(TTransport transport) {
  Preconditions.checkNotNull(transport);
  if (transport instanceof TSaslServerTransport) {
    return (TSocket) ((TSaslServerTransport) transport).getUnderlyingTransport();
  } else if (transport instanceof TSaslClientTransport) {
    return (TSocket) ((TSaslClientTransport) transport).getUnderlyingTransport();
  } else if (transport instanceof TSocket) {
    return (TSocket) transport;
  }
  return null;
}
 
开发者ID:apache,项目名称:incubator-sentry,代码行数:15,代码来源:ThriftUtil.java


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