本文整理汇总了Java中org.jivesoftware.smack.sasl.SASLMechanism类的典型用法代码示例。如果您正苦于以下问题:Java SASLMechanism类的具体用法?Java SASLMechanism怎么用?Java SASLMechanism使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SASLMechanism类属于org.jivesoftware.smack.sasl包,在下文中一共展示了SASLMechanism类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: selectMechanism
import org.jivesoftware.smack.sasl.SASLMechanism; //导入依赖的package包/类
private SASLMechanism selectMechanism() {
// Locate the SASLMechanism to use
SASLMechanism selectedMechanism = null;
Iterator<SASLMechanism> it = REGISTERED_MECHANISMS.iterator();
// Iterate in SASL Priority order over registered mechanisms
while (it.hasNext()) {
SASLMechanism mechanism = it.next();
String mechanismName = mechanism.getName();
synchronized (BLACKLISTED_MECHANISMS) {
if (BLACKLISTED_MECHANISMS.contains(mechanismName)) {
continue;
}
}
if (serverMechanisms().contains(mechanismName)) {
// Create a new instance of the SASLMechanism for every authentication attempt.
selectedMechanism = mechanism.instanceForAuthentication(connection);
break;
}
}
return selectedMechanism;
}
示例2: registerSASLMechanism
import org.jivesoftware.smack.sasl.SASLMechanism; //导入依赖的package包/类
/**
* Registers a new SASL mechanism
*
* @param mechanism a SASLMechanism subclass.
*/
public static void registerSASLMechanism(SASLMechanism mechanism) {
synchronized (REGISTERED_MECHANISMS) {
REGISTERED_MECHANISMS.add(mechanism);
Collections.sort(REGISTERED_MECHANISMS);
}
}
示例3: getRegisterdSASLMechanisms
import org.jivesoftware.smack.sasl.SASLMechanism; //导入依赖的package包/类
/**
* Returns the registered SASLMechanism sorted by the level of preference.
*
* @return the registered SASLMechanism sorted by the level of preference.
*/
public static Map<String, String> getRegisterdSASLMechanisms() {
Map<String, String> answer = new HashMap<String, String>();
synchronized (REGISTERED_MECHANISMS) {
for (SASLMechanism mechanism : REGISTERED_MECHANISMS) {
answer.put(mechanism.getClass().getName(), mechanism.getName());
}
}
return answer;
}
示例4: unregisterSASLMechanism
import org.jivesoftware.smack.sasl.SASLMechanism; //导入依赖的package包/类
/**
* Unregister a SASLMechanism by it's full class name. For example
* "org.jivesoftware.smack.sasl.javax.SASLCramMD5Mechanism".
*
* @param clazz the SASLMechanism class's name
* @return true if the given SASLMechanism was removed, false otherwise
*/
public static boolean unregisterSASLMechanism(String clazz) {
synchronized (REGISTERED_MECHANISMS) {
Iterator<SASLMechanism> it = REGISTERED_MECHANISMS.iterator();
while (it.hasNext()) {
SASLMechanism mechanism = it.next();
if (mechanism.getClass().getName().equals(clazz)) {
it.remove();
return true;
}
}
}
return false;
}
示例5: authenticate
import org.jivesoftware.smack.sasl.SASLMechanism; //导入依赖的package包/类
/**
* Performs SASL authentication of the specified user. If SASL authentication was successful
* then resource binding and session establishment will be performed. This method will return
* the full JID provided by the server while binding a resource to the connection.<p>
*
* The server may assign a full JID with a username or resource different than the requested
* by this method.
*
* @param resource the desired resource.
* @param cbh the CallbackHandler used to get information from the user
* @throws IOException
* @throws XMPPErrorException
* @throws SASLErrorException
* @throws SmackException
*/
public void authenticate(String resource, CallbackHandler cbh) throws IOException,
XMPPErrorException, SASLErrorException, SmackException {
SASLMechanism selectedMechanism = selectMechanism();
if (selectedMechanism != null) {
currentMechanism = selectedMechanism;
synchronized (this) {
currentMechanism.authenticate(connection.getHost(), connection.getServiceName(), cbh);
try {
// Wait until SASL negotiation finishes
wait(connection.getPacketReplyTimeout());
}
catch (InterruptedException e) {
// Ignore
}
}
maybeThrowException();
if (!authenticationSuccessful) {
throw NoResponseException.newWith(connection);
}
}
else {
throw new SmackException(
"SASL Authentication failed. No known authentication mechanisims.");
}
}
示例6: getRegisterSASLMechanisms
import org.jivesoftware.smack.sasl.SASLMechanism; //导入依赖的package包/类
/**
* Returns the registerd SASLMechanism classes sorted by the level of
* preference.
*
* @return the registerd SASLMechanism classes sorted by the level of
* preference.
*/
public static List<Class<? extends SASLMechanism>> getRegisterSASLMechanisms() {
List<Class<? extends SASLMechanism>> answer = new ArrayList<Class<? extends SASLMechanism>>();
for (String mechanismsPreference : mechanismsPreferences) {
answer.add(implementedMechanisms.get(mechanismsPreference));
}
return answer;
}
示例7: newInstance
import org.jivesoftware.smack.sasl.SASLMechanism; //导入依赖的package包/类
@Override
protected SASLMechanism newInstance() {
return new SASLExternalMechanism();
}
示例8: registerSASLMechanism
import org.jivesoftware.smack.sasl.SASLMechanism; //导入依赖的package包/类
/**
* Registers a new SASL mechanism
*
* @param name
* common name of the SASL mechanism. E.g.: PLAIN, DIGEST-MD5 or
* KERBEROS_V4.
* @param mClass
* a SASLMechanism subclass.
*/
public static void registerSASLMechanism(String name,
Class<? extends SASLMechanism> mClass) {
implementedMechanisms.put(name, mClass);
}