1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-12-23 04:57:58 +01:00

Disable AccountManager over insecure connections

SMACK-644
This commit is contained in:
Florian Schmaus 2016-04-14 23:19:55 +02:00
parent 92968e1630
commit 9b250475ec

View file

@ -22,7 +22,6 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.WeakHashMap;
import java.util.logging.Logger;
import org.jivesoftware.smack.Manager;
import org.jivesoftware.smack.PacketCollector;
@ -45,8 +44,6 @@ import org.jxmpp.jid.parts.Localpart;
*/
public final class AccountManager extends Manager {
private static final Logger LOGGER = Logger.getLogger(AccountManager.class.getName());
private static final Map<XMPPConnection, AccountManager> INSTANCES = new WeakHashMap<XMPPConnection, AccountManager>();
/**
@ -267,9 +264,7 @@ public final class AccountManager extends Manager {
public void createAccount(Localpart username, String password, Map<String, String> attributes)
throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
if (!connection().isSecureConnection() && !allowSensitiveOperationOverInsecureConnection) {
// TODO throw exception in newer Smack versions
LOGGER.warning("Creating account over insecure connection. "
+ "This will throw an exception in future versions of Smack if AccountManager.sensitiveOperationOverInsecureConnection(true) is not set");
throw new IllegalStateException("Creating account over insecure connection");
}
if (username == null) {
throw new IllegalArgumentException("Username must not be null");
@ -299,9 +294,7 @@ public final class AccountManager extends Manager {
*/
public void changePassword(String newPassword) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
if (!connection().isSecureConnection() && !allowSensitiveOperationOverInsecureConnection) {
// TODO throw exception in newer Smack versions
LOGGER.warning("Changing password over insecure connection. "
+ "This will throw an exception in future versions of Smack if AccountManager.sensitiveOperationOverInsecureConnection(true) is not set");
throw new IllegalStateException("Changing password over insecure connection.");
}
Map<String, String> map = new HashMap<String, String>();
map.put("username", connection().getUser().getLocalpart().toString());