当前位置: 首页>>代码示例>>Java>>正文


Java SASLMechanism类代码示例

本文整理汇总了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;
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:22,代码来源:SASLAuthentication.java

示例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);
    }
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:12,代码来源:SASLAuthentication.java

示例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;
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:15,代码来源:SASLAuthentication.java

示例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;
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:21,代码来源:SASLAuthentication.java

示例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.");
    }
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:43,代码来源:SASLAuthentication.java

示例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;
}
 
开发者ID:abmargb,项目名称:jamppa,代码行数:15,代码来源:SASLAuthentication.java

示例7: newInstance

import org.jivesoftware.smack.sasl.SASLMechanism; //导入依赖的package包/类
@Override
protected SASLMechanism newInstance() {
    return new SASLExternalMechanism();
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:5,代码来源:SASLExternalMechanism.java

示例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);
}
 
开发者ID:abmargb,项目名称:jamppa,代码行数:14,代码来源:SASLAuthentication.java


注:本文中的org.jivesoftware.smack.sasl.SASLMechanism类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。