javax.security.sasl.Sasl类的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(10.2k)|赞(0)|评价(0)|浏览(140)

本文整理了Java中javax.security.sasl.Sasl类的一些代码示例,展示了Sasl类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Sasl类的具体详情如下:
包路径:javax.security.sasl.Sasl
类名称:Sasl

Sasl介绍

暂无

代码示例

代码示例来源: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/avro

public SaslServer getServer() throws SaslException {
  return Sasl.createSaslServer(mechanism, protocol, serverName,
                props, cbh);
 }
});

代码示例来源:origin: org.apache.hadoop/hadoop-common

FastSaslServerFactory(Map<String,?> props) {
 final Enumeration<SaslServerFactory> factories =
   Sasl.getSaslServerFactories();
 while (factories.hasMoreElements()) {
  SaslServerFactory factory = factories.nextElement();
  for (String mech : factory.getMechanismNames(props)) {
   if (!factoryCache.containsKey(mech)) {
    factoryCache.put(mech, new ArrayList<SaslServerFactory>());
   }
   factoryCache.get(mech).add(factory);
  }
 }
}

代码示例来源:origin: camunda/camunda-bpm-platform

@SuppressWarnings("unchecked")
  Map<String, ?> propsMap = (Map) props;
  sc = Sasl.createSaslClient(mechs, authzid, name, host,
        propsMap, cbh);
} catch (SaslException sex) {
  logger.fine("SASL client " + sc.getMechanismName());
  args.writeAtom(sc.getMechanismName());
  if (pr.hasCapability("SASL-IR") && sc.hasInitialResponse()) {
  String irs;
  byte[] ba = sc.evaluateChallenge(new byte[0]);

代码示例来源:origin: org.apache.qpid/qpid-jms-client

@Override
  public byte[] run() throws Exception {
    Map<String, String> props = new HashMap<>();
    props.put("javax.security.sasl.server.authentication", "true");
    saslClient = Sasl.createSaslClient(new String[]{NAME}, null, protocol, serverName, props, null);
    if (saslClient.hasInitialResponse()) {
      return saslClient.evaluateChallenge(new byte[0]);
    }
    return null;
  }
});

代码示例来源:origin: com.axway.ats.gnu.classpath.ext/inetlib

p.put("gnu.crypto.sasl.password", password);
SaslClient sasl =
 Sasl.createSaslClient(m, null, "smtp",
             socket.getInetAddress().getHostName(),
             p, ch);
cmd.append(' ');
cmd.append(mechanism);
if (sasl.hasInitialResponse())
  byte[] init = sasl.evaluateChallenge(new byte[0]);
  cmd.append(new String(init, "US-ASCII"));
  String qop = (String) sasl.getNegotiatedProperty(Sasl.QOP);
  if ("auth-int".equalsIgnoreCase(qop)
    || "auth-conf".equalsIgnoreCase(qop))

代码示例来源:origin: killme2008/xmemcached

private Command startAuth() throws SaslException {
 // destroy previous client.
 destroySaslClient();
 this.saslClient = Sasl.createSaslClient(authInfo.getMechanisms(), null, "memcached",
   memcachedTCPSession.getRemoteSocketAddress().toString(), null,
   this.authInfo.getCallbackHandler());
 byte[] response =
   saslClient.hasInitialResponse() ? saslClient.evaluateChallenge(EMPTY_BYTES) : EMPTY_BYTES;
 CountDownLatch latch = new CountDownLatch(1);
 Command command =
   this.commandFactory.createAuthStartCommand(saslClient.getMechanismName(), latch, response);
 if (!this.memcachedTCPSession.isClosed())
  this.memcachedTCPSession.write(command);
 else {
  log.error("Authentication fail,because the connection has been closed");
  throw new RuntimeException("Authentication fai,connection has been close");
 }
 return command;
}

代码示例来源:origin: org.apache.kerby/kerb-admin

String protocol = adminConfig.getProtocol();
  String serverName = adminConfig.getServerName();
  saslClient = Sasl.createSaslClient(new String[]{"GSSAPI"}, null,
    protocol, serverName, props, null);
} catch (SaslException e) {
  response = saslClient.hasInitialResponse()
    ? saslClient.evaluateChallenge(EMPTY) : EMPTY;
} catch (SaslException e) {
  LOG.error("Sasl client evaluate challenge failed." + e);
while (!saslClient.isComplete()) {
  int ssComplete = message.getInt();
  if (ssComplete == 0) {

代码示例来源:origin: com.github.jiayuhan-it/hadoop-common

private void runNegotiation(CallbackHandler clientCbh,
              CallbackHandler serverCbh)
                throws SaslException {
 String mechanism = AuthMethod.PLAIN.getMechanismName();
 SaslClient saslClient = Sasl.createSaslClient(
   new String[]{ mechanism }, null, null, null, null, clientCbh);
 assertNotNull(saslClient);
 SaslServer saslServer = Sasl.createSaslServer(
   mechanism, null, "localhost", null, serverCbh);
 assertNotNull("failed to find PLAIN server", saslServer);
 
 byte[] response = saslClient.evaluateChallenge(new byte[0]);
 assertNotNull(response);
 assertTrue(saslClient.isComplete());
 response = saslServer.evaluateResponse(response);
 assertNull(response);
 assertTrue(saslServer.isComplete());
 assertNotNull(saslServer.getAuthorizationID());
}

代码示例来源:origin: com.axway.ats.gnu.classpath.ext/inetlib

p.put("gnu.crypto.sasl.password", password);
SaslClient sasl =
 Sasl.createSaslClient(m, null, "pop3",
            socket.getInetAddress().getHostName(),
            p, ch);
    String qop = (String) sasl.getNegotiatedProperty(Sasl.QOP);
    if ("auth-int".equalsIgnoreCase(qop)
      || "auth-conf".equalsIgnoreCase(qop))
      byte[] r0 = sasl.evaluateChallenge(c1);
      byte[] r1 = BASE64.encode(r0);       // response
      out.write(r1);

代码示例来源:origin: com.google.code.simple-spring-memcached/spymemcached

@Override
public void initialize() {
 try {
  SaslClient sc = Sasl.createSaslClient(mech, null, "memcached",
    serverName, props, cbh);
  byte[] response = buildResponse(sc);
  String mechanism = sc.getMechanismName();
  prepareBuffer(mechanism, 0, response);
 } catch (SaslException e) {
  // XXX: Probably something saner can be done here.
  throw new RuntimeException("Can't make SASL go.", e);
 }
}

代码示例来源:origin: org.tmatesoft.svnkit/svnkit

private static SaslClientFactory getSaslClientFactory(String mechName, Map props) {
  if (mechName == null) {
    return null;
  }
  if ("ANONYMOUS".equals(mechName)) {
    mechName = "PLAIN";
  }
  for(Enumeration factories = Sasl.getSaslClientFactories(); factories.hasMoreElements();) {
    SaslClientFactory factory = (SaslClientFactory) factories.nextElement();
    String[] mechs = factory.getMechanismNames(props);
    for (int i = 0; mechs != null && i < mechs.length; i++) {
      if (mechName.endsWith(mechs[i])) {
        return factory; 
      }
    }
  }
  return null;
}

代码示例来源:origin: com.sun.mail/javax.mail

@SuppressWarnings("unchecked")
  Map<String, ?> propsMap = (Map) props;
  sc = Sasl.createSaslClient(mechs, authzid, name, host,
        propsMap, cbh);
} catch (SaslException sex) {
  logger.fine("SASL client " + sc.getMechanismName());
  args.writeAtom(sc.getMechanismName());
  if (pr.hasCapability("SASL-IR") && sc.hasInitialResponse()) {
  String irs;
  byte[] ba = sc.evaluateChallenge(new byte[0]);

代码示例来源:origin: apache/qpid-jms

@Override
  public byte[] run() throws Exception {
    Map<String, String> props = new HashMap<>();
    props.put("javax.security.sasl.server.authentication", "true");
    saslClient = Sasl.createSaslClient(new String[]{NAME}, null, protocol, serverName, props, null);
    if (saslClient.hasInitialResponse()) {
      return saslClient.evaluateChallenge(new byte[0]);
    }
    return null;
  }
});

代码示例来源:origin: com.axway.ats.framework/ats-actionlibrary

p.put("gnu.crypto.sasl.username", username);
p.put("gnu.crypto.sasl.password", password);
SaslClient sasl = Sasl.createSaslClient(m,
                    null,
                    "smtp",
cmd.append(' ');
cmd.append(mechanism);
if (sasl.hasInitialResponse()) {
  cmd.append(' ');
  byte[] init = sasl.evaluateChallenge(new byte[0]);
  if (init.length == 0) {
    cmd.append('=');
        byte[] c0 = response.getBytes("US-ASCII");
        byte[] c1 = BASE64.decode(c0); // challenge
        byte[] r0 = sasl.evaluateChallenge(c1);
        byte[] r1 = BASE64.encode(r0); // response
        out.write(r1);

代码示例来源:origin: com.googlecode.xmemcached/xmemcached

private Command startAuth() throws SaslException {
 // destroy previous client.
 destroySaslClient();
 this.saslClient = Sasl.createSaslClient(authInfo.getMechanisms(), null, "memcached",
   memcachedTCPSession.getRemoteSocketAddress().toString(), null,
   this.authInfo.getCallbackHandler());
 byte[] response =
   saslClient.hasInitialResponse() ? saslClient.evaluateChallenge(EMPTY_BYTES) : EMPTY_BYTES;
 CountDownLatch latch = new CountDownLatch(1);
 Command command =
   this.commandFactory.createAuthStartCommand(saslClient.getMechanismName(), latch, response);
 if (!this.memcachedTCPSession.isClosed())
  this.memcachedTCPSession.write(command);
 else {
  log.error("Authentication fail,because the connection has been closed");
  throw new RuntimeException("Authentication fai,connection has been close");
 }
 return command;
}

代码示例来源:origin: apache/directory-kerby

String protocol = adminConfig.getProtocol();
  String serverName = adminConfig.getServerName();
  saslClient = Sasl.createSaslClient(new String[]{"GSSAPI"}, null,
    protocol, serverName, props, null);
} catch (SaslException e) {
  response = saslClient.hasInitialResponse()
    ? saslClient.evaluateChallenge(EMPTY) : EMPTY;
} catch (SaslException e) {
  LOG.error("Sasl client evaluate challenge failed." + e);
while (!saslClient.isComplete()) {
  int ssComplete = message.getInt();
  if (ssComplete == 0) {

代码示例来源:origin: ch.cern.hadoop/hadoop-common

private void runNegotiation(CallbackHandler clientCbh,
              CallbackHandler serverCbh)
                throws SaslException {
 String mechanism = AuthMethod.PLAIN.getMechanismName();
 SaslClient saslClient = Sasl.createSaslClient(
   new String[]{ mechanism }, null, null, null, null, clientCbh);
 assertNotNull(saslClient);
 SaslServer saslServer = Sasl.createSaslServer(
   mechanism, null, "localhost", null, serverCbh);
 assertNotNull("failed to find PLAIN server", saslServer);
 
 byte[] response = saslClient.evaluateChallenge(new byte[0]);
 assertNotNull(response);
 assertTrue(saslClient.isComplete());
 response = saslServer.evaluateResponse(response);
 assertNull(response);
 assertTrue(saslServer.isComplete());
 assertNotNull(saslServer.getAuthorizationID());
}

代码示例来源:origin: com.axway.ats.gnu.classpath.ext/inetlib

p.put("gnu.crypto.sasl.username", username);
p.put("gnu.crypto.sasl.password", password);
SaslClient sasl = Sasl.createSaslClient(m, null, "imap",
                    socket.getInetAddress().
                    getHostName(), p, ch);
       (String) sasl.getNegotiatedProperty(Sasl.QOP);
      if ("auth-int".equalsIgnoreCase(qop)
        || "auth-conf".equalsIgnoreCase(qop))
      byte[] r0 = sasl.evaluateChallenge(c1);
      byte[] r1 = BASE64.encode(r0);       // response
      out.write(r1);

代码示例来源:origin: com.google.code.maven-play-plugin.spy/spymemcached

@Override
public void initialize() {
  try {
    SaslClient sc=Sasl.createSaslClient(mech, null,
        "memcached", serverName, props, cbh);
    byte[] response = buildResponse(sc);
    String mechanism = sc.getMechanismName();
    prepareBuffer(mechanism, 0, response);
  } catch(SaslException e) {
    // XXX:  Probably something saner can be done here.
    throw new RuntimeException("Can't make SASL go.", e);
  }
}

相关文章