congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
Sasl.createSaslClient
Code IndexAdd Tabnine to your IDE (free)

How to use
createSaslClient
method
in
javax.security.sasl.Sasl

Best Java code snippets using javax.security.sasl.Sasl.createSaslClient (Showing top 20 results out of 720)

origin: apache/hbase

protected SaslClient createDigestSaslClient(String[] mechanismNames, String saslDefaultRealm,
  CallbackHandler saslClientCallbackHandler) throws IOException {
 return Sasl.createSaslClient(mechanismNames, null, null, saslDefaultRealm, saslProps,
  saslClientCallbackHandler);
}
origin: apache/hbase

protected SaslClient createKerberosSaslClient(String[] mechanismNames, String userFirstPart,
  String userSecondPart) throws IOException {
 return Sasl.createSaslClient(mechanismNames, null, userFirstPart, userSecondPart, saslProps,
  null);
}
origin: apache/kafka

private SaslClient createSaslClient() {
  try {
    return Subject.doAs(subject, (PrivilegedExceptionAction<SaslClient>) () -> {
      String[] mechs = {mechanism};
      LOG.debug("Creating SaslClient: client={};service={};serviceHostname={};mechs={}",
        clientPrincipalName, servicePrincipal, host, Arrays.toString(mechs));
      return Sasl.createSaslClient(mechs, clientPrincipalName, servicePrincipal, host, configs, callbackHandler);
    });
  } catch (PrivilegedActionException e) {
    throw new SaslAuthenticationException("Failed to create SaslClient with mechanism " + mechanism, e.getCause());
  }
}
origin: apache/storm

  public SaslClient run() {
    try {
      Map<String, String> props = new TreeMap<String, String>();
      props.put(Sasl.QOP, "auth");
      props.put(Sasl.SERVER_AUTH, "false");
      return Sasl.createSaslClient(
        new String[]{ SaslUtils.KERBEROS },
        fPrincipalName,
        fServiceName,
        fHost,
        props, fch);
    } catch (Exception e) {
      LOG.error("Subject failed to create sasl client.", e);
      return null;
    }
  }
});
origin: apache/zookeeper

  public SaslClient run() throws SaslException {
    LOG.info("{} will use GSSAPI as SASL mechanism.", entity);
    String[] mechs = { "GSSAPI" };
    LOG.debug("creating sasl client: {}={};service={};serviceHostname={}",
        new Object[] { entity, clientPrincipalName, serviceName, serviceHostname });
    SaslClient saslClient = Sasl.createSaslClient(
        mechs, clientPrincipalName, serviceName,
        serviceHostname, null,
        new SaslClientCallbackHandler(null, entity));
    return saslClient;
  }
});
origin: apache/hbase

public SaslNegotiateHandler(Configuration conf, String username, char[] password,
  Map<String, String> saslProps, int timeoutMs, Promise<Void> promise,
  DFSClient dfsClient) throws SaslException {
 this.conf = conf;
 this.saslProps = saslProps;
 this.saslClient = Sasl.createSaslClient(new String[] { MECHANISM }, username, PROTOCOL,
  SERVER_NAME, saslProps, new SaslClientCallbackHandler(username, password));
 this.timeoutMs = timeoutMs;
 this.promise = promise;
 this.dfsClient = dfsClient;
}
origin: org.apache.zookeeper/zookeeper

  public SaslClient run() throws SaslException {
    LOG.info("{} will use GSSAPI as SASL mechanism.", entity);
    String[] mechs = { "GSSAPI" };
    LOG.debug("creating sasl client: {}={};service={};serviceHostname={}",
        new Object[] { entity, clientPrincipalName, serviceName, serviceHostname });
    SaslClient saslClient = Sasl.createSaslClient(
        mechs, clientPrincipalName, serviceName,
        serviceHostname, null,
        new SaslClientCallbackHandler(null, entity));
    return saslClient;
  }
});
origin: apache/storm

/**
 * Create a SaslNettyClient for authentication with servers.
 */
public SaslNettyClient(String topologyName, byte[] token) {
  try {
    LOG.debug("SaslNettyClient: Creating SASL {} client to authenticate to server ",
         SaslUtils.AUTH_DIGEST_MD5);
    saslClient = Sasl.createSaslClient(
      new String[]{ SaslUtils.AUTH_DIGEST_MD5 }, null, null,
      SaslUtils.DEFAULT_REALM, SaslUtils.getSaslProps(),
      new SaslClientCallbackHandler(topologyName, token));
  } catch (IOException e) {
    LOG.error("SaslNettyClient: Could not obtain topology token for Netty "
         + "Client to use to authenticate with a Netty Server.");
    saslClient = null;
  }
}
origin: Alluxio/alluxio

@Override
public SaslClient createSaslClient(String username, String password, String impersonationUser)
  throws UnauthenticatedException {
 try {
  return Sasl.createSaslClient(new String[] {PlainSaslServerProvider.MECHANISM},
    impersonationUser, null, null, new HashMap<String, String>(),
    new PlainSaslClientCallbackHandler(username, password));
 } catch (SaslException e) {
  throw new UnauthenticatedException(e.getMessage(), e);
 }
}
origin: apache/hive

SaslClientHandler(
  RpcConfiguration config,
  String clientId,
  Promise<Rpc> promise,
  ScheduledFuture<?> timeout,
  String secret,
  RpcDispatcher dispatcher)
  throws IOException {
 super(config);
 this.clientId = clientId;
 this.promise = promise;
 this.timeout = timeout;
 this.secret = secret;
 this.dispatcher = dispatcher;
 this.client = Sasl.createSaslClient(new String[] { config.getSaslMechanism() },
  null, SASL_PROTOCOL, SASL_REALM, config.getSaslOptions(), this);
}
origin: igniterealtime/Smack

@Override
protected void authenticateInternal(CallbackHandler cbh)
        throws SmackException {
  String[] mechanisms = { getName() };
  Map<String, String> props = getSaslProps();
  try {
    sc = Sasl.createSaslClient(mechanisms, null, "xmpp", host, props, cbh);
  }
  catch (SaslException e) {
    throw new SmackException(e);
  }
}
origin: apache/zookeeper

    .toArray()[0]);
saslClient = Sasl.createSaslClient(mechs, username, protocol,
    serverName, null, new SaslClientCallbackHandler(password, entity));
return saslClient;
origin: igniterealtime/Smack

sc = Sasl.createSaslClient(mechanisms, authzid, "xmpp", getServerName().toString(), props,
        new CallbackHandler() {
          @Override
origin: org.apache.zookeeper/zookeeper

    .toArray()[0]);
saslClient = Sasl.createSaslClient(mechs, username, protocol,
    serverName, null, new SaslClientCallbackHandler(password, entity));
return saslClient;
origin: org.apache.hadoop/hadoop-common

   + " client to authenticate to service at " + saslServerName);
return Sasl.createSaslClient(
  new String[] { mechanism }, saslUser, saslProtocol, saslServerName,
  saslProperties, saslCallback);
origin: org.mongodb/mongo-java-driver

@Override
protected SaslClient createSaslClient(final ServerAddress serverAddress) {
  MongoCredential credential = getMongoCredential();
  try {
    Map<String, Object> saslClientProperties = credential.getMechanismProperty(JAVA_SASL_CLIENT_PROPERTIES_KEY, null);
    if (saslClientProperties == null) {
      saslClientProperties = new HashMap<String, Object>();
      saslClientProperties.put(Sasl.MAX_BUFFER, "0");
      saslClientProperties.put(Sasl.CREDENTIALS, getGSSCredential(credential.getUserName()));
    }
    SaslClient saslClient = Sasl.createSaslClient(new String[]{GSSAPI.getMechanismName()}, credential.getUserName(),
        credential.getMechanismProperty(SERVICE_NAME_KEY, SERVICE_NAME_DEFAULT_VALUE),
        getHostName(serverAddress), saslClientProperties, null);
    if (saslClient == null) {
      throw new MongoSecurityException(credential, String.format("No platform support for %s mechanism", GSSAPI));
    }
    return saslClient;
  } catch (SaslException e) {
    throw new MongoSecurityException(credential, "Exception initializing SASL client", e);
  } catch (GSSException e) {
    throw new MongoSecurityException(credential, "Exception initializing GSSAPI credentials", e);
  } catch (UnknownHostException e) {
    throw new MongoSecurityException(credential, "Unable to canonicalize host name + " + serverAddress);
  }
}
origin: org.apache.hbase/hbase-client

protected SaslClient createDigestSaslClient(String[] mechanismNames, String saslDefaultRealm,
  CallbackHandler saslClientCallbackHandler) throws IOException {
 return Sasl.createSaslClient(mechanismNames, null, null, saslDefaultRealm, saslProps,
  saslClientCallbackHandler);
}
origin: apache/avro

@Before
public void testStartServer() throws Exception {
 if (server != null) return;
 server = new SaslSocketServer
  (new TestResponder(), new InetSocketAddress(0), DIGEST_MD5_MECHANISM,
   SERVICE, HOST, DIGEST_MD5_PROPS, new TestSaslCallbackHandler());
 server.start();
 SaslClient saslClient = Sasl.createSaslClient
  (new String[]{DIGEST_MD5_MECHANISM}, PRINCIPAL, SERVICE, HOST,
   DIGEST_MD5_PROPS, new TestSaslCallbackHandler());
 client = new SaslSocketTransceiver(new InetSocketAddress(server.getPort()),
                   saslClient);
 requestor = new GenericRequestor(PROTOCOL, client);
}
origin: org.mongodb/mongo-java-driver

  @Override
  protected SaslClient createSaslClient(final ServerAddress serverAddress) {
    final MongoCredential credential = getMongoCredential();
    isTrue("mechanism is PLAIN", credential.getAuthenticationMechanism() == PLAIN);
    try {
      return Sasl.createSaslClient(new String[]{PLAIN.getMechanismName()},
                     credential.getUserName(),
                     DEFAULT_PROTOCOL,
                     serverAddress.getHost(),
                     null,
                     new CallbackHandler() {
                       @Override
                       public void handle(final Callback[] callbacks)
                         throws IOException, UnsupportedCallbackException {
                         for (final Callback callback : callbacks) {
                           if (callback instanceof PasswordCallback) {
                             ((PasswordCallback) callback).setPassword(credential.getPassword());
                           } else if (callback instanceof NameCallback) {
                             ((NameCallback) callback).setName(credential.getUserName());
                           }
                         }
                       }
                     });
    } catch (SaslException e) {
      throw new MongoSecurityException(credential, "Exception initializing SASL client", e);
    }
  }
}
origin: apache/avro

@Test(expected=SaslException.class)
public void testWrongPassword() throws Exception {
 Server s = new SaslSocketServer
  (new TestResponder(), new InetSocketAddress(0), DIGEST_MD5_MECHANISM,
   SERVICE, HOST, DIGEST_MD5_PROPS, new TestSaslCallbackHandler());
 s.start();
 SaslClient saslClient = Sasl.createSaslClient
  (new String[]{DIGEST_MD5_MECHANISM}, PRINCIPAL, SERVICE, HOST,
   DIGEST_MD5_PROPS, new WrongPasswordCallbackHandler());
 Transceiver c = new SaslSocketTransceiver
  (new InetSocketAddress(server.getPort()), saslClient);
 GenericRequestor requestor = new GenericRequestor(PROTOCOL, c);
 GenericRecord params =
  new GenericData.Record(PROTOCOL.getMessages().get("hello").getRequest());
 params.put("greeting", "bob");
 Utf8 response = (Utf8)requestor.request("hello", params);
 assertEquals(new Utf8("goodbye"), response);
 s.close();
 c.close();
}
javax.security.saslSaslcreateSaslClient

Popular methods of Sasl

  • createSaslServer
  • getSaslServerFactories
  • getSaslClientFactories

Popular in Java

  • Reading from database using SQL prepared statement
  • setRequestProperty (URLConnection)
  • getApplicationContext (Context)
  • compareTo (BigDecimal)
  • Table (com.google.common.collect)
    A collection that associates an ordered pair of keys, called a row key and a column key, with a sing
  • BufferedImage (java.awt.image)
    The BufferedImage subclass describes an java.awt.Image with an accessible buffer of image data. All
  • PrintStream (java.io)
    Fake signature of an existing Java class.
  • Iterator (java.util)
    An iterator over a sequence of objects, such as a collection.If a collection has been changed since
  • UUID (java.util)
    UUID is an immutable representation of a 128-bit universally unique identifier (UUID). There are mul
  • Manifest (java.util.jar)
    The Manifest class is used to obtain attribute information for a JarFile and its entries.
  • 21 Best IntelliJ Plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now