/** * Check if the given SASL mechansism is enabled in this connection configuration. * * @param saslMechanism * @return true if the given SASL mechanism is enabled, false otherwise. */ public boolean isEnabledSaslMechanism(String saslMechanism) { // If enabledSaslMechanisms is not set, then all mechanisms which are not blacklisted are enabled per default. if (enabledSaslMechanisms == null) { return !SASLAuthentication.getBlacklistedSASLMechanisms().contains(saslMechanism); } return enabledSaslMechanisms.contains(saslMechanism); }
/** * Enable the given SASL mechanisms. If you never add a mechanism to the set of enabled ones, <b>all mechanisms * known to Smack</b> will be enabled. Only explicitly enable particular SASL mechanisms if you want to limit * the used mechanisms to the enabled ones. * * @param saslMechanisms a collection of names of mechanisms to enable. * @return a reference to this builder. */ public B addEnabledSaslMechanism(Collection<String> saslMechanisms) { if (saslMechanismsSealed) { throw new IllegalStateException("The enabled SASL mechanisms are sealed, you can not add new ones"); } CollectionUtil.requireNotEmpty(saslMechanisms, "saslMechanisms"); Set<String> blacklistedMechanisms = SASLAuthentication.getBlacklistedSASLMechanisms(); for (String mechanism : saslMechanisms) { if (!SASLAuthentication.isSaslMechanismRegistered(mechanism)) { throw new IllegalArgumentException("SASL " + mechanism + " is not available. Consider registering it with Smack"); } if (blacklistedMechanisms.contains(mechanism)) { throw new IllegalArgumentException("SALS " + mechanism + " is blacklisted."); } } if (enabledSaslMechanisms == null) { enabledSaslMechanisms = new HashSet<>(saslMechanisms.size()); } enabledSaslMechanisms.addAll(saslMechanisms); return getThis(); }
/** * Check if the given SASL mechansism is enabled in this connection configuration. * * @param saslMechanism * @return true if the given SASL mechanism is enabled, false otherwise. */ public boolean isEnabledSaslMechanism(String saslMechanism) { // If enabledSaslMechanisms is not set, then all mechanisms which are not blacklisted are enabled per default. if (enabledSaslMechanisms == null) { return !SASLAuthentication.getBlacklistedSASLMechanisms().contains(saslMechanism); } return enabledSaslMechanisms.contains(saslMechanism); }
/** * Enable the given SASL mechanisms. If you never add a mechanism to the set of enabled ones, <b>all mechanisms * known to Smack</b> will be enabled. Only explicitly enable particular SASL mechanisms if you want to limit * the used mechanisms to the enabled ones. * * @param saslMechanisms a collection of names of mechanisms to enable. * @return a reference to this builder. */ public B addEnabledSaslMechanism(Collection<String> saslMechanisms) { if (saslMechanismsSealed) { throw new IllegalStateException("The enabled SASL mechanisms are sealed, you can not add new ones"); } CollectionUtil.requireNotEmpty(saslMechanisms, "saslMechanisms"); Set<String> blacklistedMechanisms = SASLAuthentication.getBlacklistedSASLMechanisms(); for (String mechanism : saslMechanisms) { if (!SASLAuthentication.isSaslMechanismRegistered(mechanism)) { throw new IllegalArgumentException("SASL " + mechanism + " is not available. Consider registering it with Smack"); } if (blacklistedMechanisms.contains(mechanism)) { throw new IllegalArgumentException("SALS " + mechanism + " is blacklisted."); } } if (enabledSaslMechanisms == null) { enabledSaslMechanisms = new HashSet<>(saslMechanisms.size()); } enabledSaslMechanisms.addAll(saslMechanisms); return getThis(); }