mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-09-09 17:19:39 +02:00
Merge branch '4.2'
This commit is contained in:
commit
08c228ef99
21 changed files with 3190 additions and 59 deletions
|
@ -472,7 +472,16 @@ public abstract class ConnectionConfiguration {
|
|||
return enabledSaslMechanisms.contains(saslMechanism);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the explicitly enabled SASL mechanisms. May return <code>null</code> if no SASL mechanisms where
|
||||
* explicitly enabled, i.e. all SALS mechanisms supported and announced by the service will be considered.
|
||||
*
|
||||
* @return the enabled SASL mechanisms or <code>null</code>.
|
||||
*/
|
||||
public Set<String> getEnabledSaslMechanisms() {
|
||||
if (enabledSaslMechanisms == null) {
|
||||
return null;
|
||||
}
|
||||
return Collections.unmodifiableSet(enabledSaslMechanisms);
|
||||
}
|
||||
|
||||
|
|
|
@ -34,9 +34,9 @@ import javax.security.auth.callback.CallbackHandler;
|
|||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
@ -90,10 +90,10 @@ public final class SASLAuthentication {
|
|||
* @return the registered SASLMechanism sorted by the level of preference.
|
||||
*/
|
||||
public static Map<String, String> getRegisterdSASLMechanisms() {
|
||||
Map<String, String> answer = new HashMap<String, String>();
|
||||
Map<String, String> answer = new LinkedHashMap<String, String>();
|
||||
synchronized (REGISTERED_MECHANISMS) {
|
||||
for (SASLMechanism mechanism : REGISTERED_MECHANISMS) {
|
||||
answer.put(mechanism.getClass().getName(), mechanism.getName());
|
||||
answer.put(mechanism.getClass().getName(), mechanism.toString());
|
||||
}
|
||||
}
|
||||
return answer;
|
||||
|
|
|
@ -226,6 +226,16 @@ public class SynchronizationPoint<E extends Exception> {
|
|||
}
|
||||
}
|
||||
|
||||
public E getFailureException() {
|
||||
connectionLock.lock();
|
||||
try {
|
||||
return failureException;
|
||||
}
|
||||
finally {
|
||||
connectionLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Wait for the condition to become something else as {@link State#RequestSent} or {@link State#Initial}.
|
||||
* {@link #reportSuccess()}, {@link #reportFailure()} and {@link #reportFailure(Exception)} will either set this
|
||||
|
|
|
@ -279,6 +279,11 @@ public abstract class SASLMechanism implements Comparable<SASLMechanism> {
|
|||
*/
|
||||
public abstract String getName();
|
||||
|
||||
/**
|
||||
* Get the priority of this SASL mechanism. Lower values mean higher priority.
|
||||
*
|
||||
* @return the priority of this SASL mechanism.
|
||||
*/
|
||||
public abstract int getPriority();
|
||||
|
||||
public abstract void checkIfSuccessfulOrThrow() throws SmackException;
|
||||
|
@ -314,4 +319,9 @@ public abstract class SASLMechanism implements Comparable<SASLMechanism> {
|
|||
}
|
||||
return string;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String toString() {
|
||||
return "SASL Mech: " + getName() + ", Prio: " + getPriority();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2014-2016 Florian Schmaus
|
||||
* Copyright 2014-2017 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -23,6 +23,8 @@ import org.jivesoftware.smack.util.MAC;
|
|||
|
||||
public class SCRAMSHA1Mechanism extends ScramMechanism {
|
||||
|
||||
static final int PRIORITY = 110;
|
||||
|
||||
static {
|
||||
SHA_1_SCRAM_HMAC = new ScramHmac() {
|
||||
@Override
|
||||
|
@ -47,7 +49,7 @@ public class SCRAMSHA1Mechanism extends ScramMechanism {
|
|||
|
||||
@Override
|
||||
public int getPriority() {
|
||||
return 110;
|
||||
return PRIORITY;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -249,6 +249,9 @@ public abstract class ScramMechanism extends SASLMechanism {
|
|||
}
|
||||
|
||||
protected String getChannelBindingName() {
|
||||
// Check if we are using TLS and if a "-PLUS" variant of this mechanism is enabled. Assuming that the "-PLUS"
|
||||
// variants always have precedence before the non-"-PLUS" variants this means that the server did not announce
|
||||
// the "-PLUS" variant, as otherwise we would have tried it.
|
||||
if (sslSession != null && connectionConfiguration.isEnabledSaslMechanism(getName() + "-PLUS")) {
|
||||
// Announce that we support Channel Binding, i.e., the '-PLUS' flavor of this SASL mechanism, but that we
|
||||
// believe the server does not.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2016 Florian Schmaus
|
||||
* Copyright 2016-2017 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -32,7 +32,7 @@ public class ScramSha1PlusMechanism extends ScramPlusMechanism {
|
|||
|
||||
@Override
|
||||
public int getPriority() {
|
||||
return 110;
|
||||
return SCRAMSHA1Mechanism.PRIORITY - 10;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue