1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2025-09-09 00:59:39 +02:00

SASL Proxy Auth support

This adds the ability to provide a distinct authorization identifier for use
by SASL mechanisms. Not all SASL mechanisms support this operation, in
particular CRAM-MD5.

Both the javax and provided SASL implementations are extended, and an authzid
parameter added to the authenticate method.

The authorization identifier is passed as a EntityBareJid in order to assure the
correct form.

Resolves SMACK-677.

Minor-Modifications-By: Florian Schmaus <flo@geekplace.eu>
This commit is contained in:
Dave Cridland 2015-06-16 17:50:30 +01:00 committed by Florian Schmaus
parent a00331dbb4
commit 9c772add93
18 changed files with 182 additions and 32 deletions

View file

@ -25,6 +25,11 @@ public class SASLDigestMD5Mechanism extends SASLJavaXMechanism {
public static final String NAME = DIGESTMD5;
@Override
public boolean authzidSupported() {
return true;
}
public String getName() {
return NAME;
}

View file

@ -46,6 +46,11 @@ public class SASLExternalMechanism extends SASLJavaXMechanism {
public static final String NAME = EXTERNAL;
@Override
public boolean authzidSupported() {
return true;
}
@Override
public String getName() {
return EXTERNAL;

View file

@ -34,6 +34,11 @@ public class SASLGSSAPIMechanism extends SASLJavaXMechanism {
System.setProperty("java.security.auth.login.config","gss.conf");
}
@Override
public boolean authzidSupported() {
return true;
}
@Override
public String getName() {
return NAME;

View file

@ -53,8 +53,12 @@ public abstract class SASLJavaXMechanism extends SASLMechanism {
throws SmackException {
String[] mechanisms = { getName() };
Map<String, String> props = getSaslProps();
String authzid = null;
if (authorizationId != null) {
authzid = authorizationId.toString();
}
try {
sc = Sasl.createSaslClient(mechanisms, null, "xmpp", getServerName().toString(), props,
sc = Sasl.createSaslClient(mechanisms, authzid, "xmpp", getServerName().toString(), props,
new CallbackHandler() {
@Override
public void handle(Callback[] callbacks) throws IOException,

View file

@ -29,6 +29,11 @@ public class SASLPlainMechanism extends SASLJavaXMechanism {
return NAME;
}
@Override
public boolean authzidSupported() {
return true;
}
@Override
public int getPriority() {
return 400;

View file

@ -30,6 +30,11 @@ public class SASLDigestMD5Test extends DigestMd5SaslTest {
@Test
public void testDigestMD5() throws NotConnectedException, SmackException, InterruptedException, XmppStringprepException {
runTest();
runTest(false);
}
@Test
public void testDigestMD5Authzid() throws NotConnectedException, SmackException, InterruptedException, XmppStringprepException {
runTest(true);
}
}