コード例 #1
0
 public void authenticate(String username, String host, CallbackHandler cbh)
     throws IOException, XMPPException {
   String[] mechanisms = {"DIGEST-MD5"};
   Map<String, String> props = new HashMap<String, String>();
   sc = Sasl.createSaslClient(mechanisms, null, "xmpp", host, props, cbh);
   authenticate();
 }
コード例 #2
0
  public void authenticate(String apiKeyAndSessionKey, String host, String sessionSecret)
      throws IOException, XMPPException {
    if (apiKeyAndSessionKey == null || sessionSecret == null) {
      throw new IllegalStateException("Invalid parameters!");
    }

    String[] keyArray = apiKeyAndSessionKey.split("\\|");

    if (keyArray == null || keyArray.length != 2) {
      throw new IllegalStateException("Api key or session key is not present!");
    }

    this.apiKey = keyArray[0];
    this.sessionKey = keyArray[1];
    this.sessionSecret = sessionSecret;

    this.authenticationId = sessionKey;
    this.password = sessionSecret;
    this.hostname = host;

    String[] mechanisms = {"DIGEST-MD5"};
    Map<String, String> props = new HashMap<String, String>();
    sc = Sasl.createSaslClient(mechanisms, null, "xmpp", host, props, this);
    authenticate();
  }