Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import org.jivesoftware.smack.SmackException.SmackSaslException;
import org.jivesoftware.smack.sasl.SASLMechanism;
import org.jivesoftware.smack.util.ByteUtils;
import org.jivesoftware.smack.util.SHA1;
import org.jivesoftware.smack.util.StringUtils;
import org.jivesoftware.smack.util.stringencoder.Base64;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@
import org.jivesoftware.smack.util.ByteUtils;
import org.jivesoftware.smack.util.TLSUtils;

import org.jxmpp.jid.DomainBareJid;

public abstract class SaslHtMechanism extends SASLMechanism {

public enum HashAlgorithm {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import java.io.IOException;
import java.util.List;
import java.util.UUID;

import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.XMPPException;
Expand All @@ -41,6 +42,21 @@ public class Sasl2Module extends ModularXmppClientToServerConnectionModule<Sasl2

private Sasl2AuthenticationResult sasl2AuthenticationResult;

/**
* A stable identifier for this connection's "client installation", per XEP-0388 § 2.3: "The contents of the
* 'id' attribute MUST be a UUID v4." Generated once per {@link Sasl2Module} instance (i.e. once per connection
* object) rather than fresh on every authentication attempt, since a FAST (XEP-0484) token requested under one
* id can only be redeemed under that same id: servers key stored tokens by (username, mechanism, clientId).
*/
private final String userAgentId = UUID.randomUUID().toString();

/**
* Returns this connection's stable SASL2 {@code <user-agent/>} 'id' value (see {@link #userAgentId}).
*/
public String getUserAgentId() {
return userAgentId;
}

protected Sasl2Module(Sasl2ModuleDescriptor moduleDescriptor,
ModularXmppClientToServerConnectionInternal connectionInternal) {
super(moduleDescriptor, connectionInternal);
Expand Down Expand Up @@ -121,7 +137,8 @@ public StateTransitionResult.AttemptResult transitionInto(WalkStateGraphContext
sasl2Extensions.add(new org.jivesoftware.smack.fast.element.FastElements.RequestToken(prefMech));
}
}
sasl2Extensions.add(new org.jivesoftware.smack.sasl.packet.Sasl2Nonza.UserAgent("smack-client-instance", "Smack", null));
Sasl2Module sasl2Module = connectionInternal.connection.getConnectionModuleFor(Sasl2ModuleDescriptor.class);
sasl2Extensions.add(new org.jivesoftware.smack.sasl.packet.Sasl2Nonza.UserAgent(sasl2Module.userAgentId, "Smack", null));
}

if (!useBind2) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,7 @@

import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.jxmpp.jid.DomainBareJid;
import org.jxmpp.jid.EntityFullJid;
import org.jxmpp.jid.impl.JidCreate;
import org.jxmpp.jid.parts.Resourcepart;

public class Sasl2FastAuthenticationTest extends SmackTestSuite {
Expand Down