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:
parent
a00331dbb4
commit
9c772add93
18 changed files with 182 additions and 32 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -29,6 +29,11 @@ public class SASLPlainMechanism extends SASLJavaXMechanism {
|
|||
return NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean authzidSupported() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPriority() {
|
||||
return 400;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue