Search in sources :

Example 1 with WorkerTokenClientCallbackHandler

use of org.apache.storm.security.auth.workertoken.WorkerTokenClientCallbackHandler in project storm by apache.

the class KerberosSaslTransportPlugin method connect.

@Override
public TTransport connect(TTransport transport, String serverHost, String asUser) throws IOException, TTransportException {
    WorkerToken token = WorkerTokenClientCallbackHandler.findWorkerTokenInSubject(type);
    if (token != null) {
        CallbackHandler clientCallbackHandler = new WorkerTokenClientCallbackHandler(token);
        TSaslClientTransport wrapperTransport = new TSaslClientTransport(DIGEST, null, ClientAuthUtils.SERVICE, serverHost, null, clientCallbackHandler, transport);
        wrapperTransport.open();
        LOG.debug("SASL DIGEST-MD5 WorkerToken client transport has been established");
        return wrapperTransport;
    }
    return kerberosConnect(transport, serverHost, asUser);
}
Also used : WorkerToken(org.apache.storm.generated.WorkerToken) CallbackHandler(javax.security.auth.callback.CallbackHandler) WorkerTokenClientCallbackHandler(org.apache.storm.security.auth.workertoken.WorkerTokenClientCallbackHandler) SimpleSaslServerCallbackHandler(org.apache.storm.security.auth.sasl.SimpleSaslServerCallbackHandler) WorkerTokenClientCallbackHandler(org.apache.storm.security.auth.workertoken.WorkerTokenClientCallbackHandler) TSaslClientTransport(org.apache.storm.thrift.transport.TSaslClientTransport)

Example 2 with WorkerTokenClientCallbackHandler

use of org.apache.storm.security.auth.workertoken.WorkerTokenClientCallbackHandler in project storm by apache.

the class DigestSaslTransportPlugin method connect.

@Override
public TTransport connect(TTransport transport, String serverHost, String asUser) throws TTransportException, IOException {
    CallbackHandler clientCallbackHandler;
    WorkerToken token = WorkerTokenClientCallbackHandler.findWorkerTokenInSubject(type);
    if (token != null) {
        clientCallbackHandler = new WorkerTokenClientCallbackHandler(token);
    } else {
        Configuration loginConf = ClientAuthUtils.getConfiguration(conf);
        if (loginConf == null) {
            throw new IOException("Could not find any way to authenticate with the server.");
        }
        AppConfigurationEntry[] configurationEntries = loginConf.getAppConfigurationEntry(ClientAuthUtils.LOGIN_CONTEXT_CLIENT);
        if (configurationEntries == null) {
            String errorMessage = "Could not find a '" + ClientAuthUtils.LOGIN_CONTEXT_CLIENT + "' entry in this configuration: Client cannot start.";
            throw new IOException(errorMessage);
        }
        String username = "";
        String password = "";
        for (AppConfigurationEntry entry : configurationEntries) {
            Map options = entry.getOptions();
            username = (String) options.getOrDefault("username", username);
            password = (String) options.getOrDefault("password", password);
        }
        clientCallbackHandler = new SimpleSaslClientCallbackHandler(username, password);
    }
    TSaslClientTransport wrapperTransport = new TSaslClientTransport(DIGEST, null, ClientAuthUtils.SERVICE, serverHost, null, clientCallbackHandler, transport);
    wrapperTransport.open();
    LOG.debug("SASL DIGEST-MD5 client transport has been established");
    return wrapperTransport;
}
Also used : SimpleSaslClientCallbackHandler(org.apache.storm.security.auth.sasl.SimpleSaslClientCallbackHandler) SimpleSaslServerCallbackHandler(org.apache.storm.security.auth.sasl.SimpleSaslServerCallbackHandler) CallbackHandler(javax.security.auth.callback.CallbackHandler) WorkerTokenClientCallbackHandler(org.apache.storm.security.auth.workertoken.WorkerTokenClientCallbackHandler) WorkerToken(org.apache.storm.generated.WorkerToken) AppConfigurationEntry(javax.security.auth.login.AppConfigurationEntry) SimpleSaslClientCallbackHandler(org.apache.storm.security.auth.sasl.SimpleSaslClientCallbackHandler) Configuration(javax.security.auth.login.Configuration) WorkerTokenClientCallbackHandler(org.apache.storm.security.auth.workertoken.WorkerTokenClientCallbackHandler) TSaslClientTransport(org.apache.storm.thrift.transport.TSaslClientTransport) IOException(java.io.IOException) Map(java.util.Map)

Aggregations

CallbackHandler (javax.security.auth.callback.CallbackHandler)2 WorkerToken (org.apache.storm.generated.WorkerToken)2 SimpleSaslServerCallbackHandler (org.apache.storm.security.auth.sasl.SimpleSaslServerCallbackHandler)2 WorkerTokenClientCallbackHandler (org.apache.storm.security.auth.workertoken.WorkerTokenClientCallbackHandler)2 TSaslClientTransport (org.apache.storm.thrift.transport.TSaslClientTransport)2 IOException (java.io.IOException)1 Map (java.util.Map)1 AppConfigurationEntry (javax.security.auth.login.AppConfigurationEntry)1 Configuration (javax.security.auth.login.Configuration)1 SimpleSaslClientCallbackHandler (org.apache.storm.security.auth.sasl.SimpleSaslClientCallbackHandler)1