本文整理汇总了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;
}
示例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();
}
示例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;
}
示例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;
}
示例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;
}