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


Java AssociationSessionType.isVersion2方法代码示例

本文整理汇总了Java中org.openid4java.association.AssociationSessionType.isVersion2方法的典型用法代码示例。如果您正苦于以下问题:Java AssociationSessionType.isVersion2方法的具体用法?Java AssociationSessionType.isVersion2怎么用?Java AssociationSessionType.isVersion2使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.openid4java.association.AssociationSessionType的用法示例。


在下文中一共展示了AssociationSessionType.isVersion2方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: AssociationRequest

import org.openid4java.association.AssociationSessionType; //导入方法依赖的package包/类
/**
 * Constructs an AssociationRequest message with the
 * specified association type and Diffie-Hellman session.
 *
 * @param dhSess    Diffie-Hellman session to be used for this association;
 *                  if null, a "no-encryption" session is created.
 */
protected AssociationRequest(AssociationSessionType type,
                             DiffieHellmanSession dhSess)
{
    if (DEBUG)
        _log.debug("Creating association request, type: " + type +
                   "DH session: " + dhSess);

    if (type.isVersion2())
        set("openid.ns", OPENID2_NS);

    set("openid.mode", MODE_ASSOC);
    set("openid.session_type", type.getSessionType());
    set("openid.assoc_type", type.getAssociationType());

    _dhSess = dhSess;

    if (dhSess != null )
    {
        set("openid.dh_consumer_public", _dhSess.getPublicKey());

        // send both diffie-hellman generator and modulus if either are not the default values
        // (this meets v1.1 spec and is compatible with v2.0 spec)

        if (!DiffieHellmanSession.DEFAULT_GENERATOR_BASE64.equals(_dhSess.getGenerator())
                || !DiffieHellmanSession.DEFAULT_MODULUS_BASE64.equals(_dhSess.getModulus()))
        {
            set("openid.dh_gen", _dhSess.getGenerator());
            set("openid.dh_modulus", _dhSess.getModulus());
        }
    }
}
 
开发者ID:jbufu,项目名称:openid4java,代码行数:39,代码来源:AssociationRequest.java

示例2: validate

import org.openid4java.association.AssociationSessionType; //导入方法依赖的package包/类
/**
 * Checks if the message is a valid OpenID Association Response..
 *
 * @throws MessageException if message validation failed.
 */
public void validate() throws MessageException
{
    // basic checks
    super.validate();

    // association / session type checks
    // (includes most of the compatibility stuff)
    AssociationSessionType type;
    try
    {
        // throws exception for invalid session / association types
        type = getType();

        // make sure compatibility mode is the same for type and message
        if (type.isVersion2() ^ isVersion2())
        {
            throw new MessageException(
                "Protocol verison mismatch between association " +
                "session type: " + type +
                " and AssociationResponse message type.",
                OpenIDException.ASSOC_ERROR);
        }

    }
    catch (AssociationException e)
    {
        throw new MessageException(
            "Error verifying association response validity.",
            OpenIDException.ASSOC_ERROR, e);
    }

    // additional compatibility checks
    if (! isVersion2() && getAssociationType() == null)
    {
        throw new MessageException(
            "assoc_type cannot be omitted in OpenID1 responses",
            OpenIDException.ASSOC_ERROR);
    }

    String macKey;
    if (type.getHAlgorithm() != null) // DH session
    {
        if ( ! hasParameter("dh_server_public") ||
                ! hasParameter("enc_mac_key") )
        {
            throw new MessageException(
                "DH public key or encrypted MAC key missing.",
                OpenIDException.ASSOC_ERROR);
        }
        else
            macKey = getParameterValue("enc_mac_key");
    } else // no-enc session
    {
        if ( !hasParameter("mac_key") )
        {
            throw new MessageException("Missing MAC key.",
                OpenIDException.ASSOC_ERROR);
        }
        else
            macKey = getParameterValue("mac_key");
    }

    // mac key size
    int macSize = Base64.decodeBase64(macKey.getBytes()).length * 8;

    if ( macSize != type.getKeySize())
    {
        throw new MessageException("MAC key size: " + macSize +
            " doesn't match the association/session type: " + type,
            OpenIDException.ASSOC_ERROR);
    }
}
 
开发者ID:jbufu,项目名称:openid4java,代码行数:78,代码来源:AssociationResponse.java

示例3: validate

import org.openid4java.association.AssociationSessionType; //导入方法依赖的package包/类
/**
 * Checks if the message is a valid OpenID Association Request.
 *
 * @throws MessageException if message validation failed.
 */
public void validate() throws MessageException
{
    // basic checks
    super.validate();

    // association / session type checks
    // (includes most of the compatibility stuff)
    AssociationSessionType type;
    try
    {
        // throws exception for invalid session / association types
        type = getType();

        // make sure compatibility mode is the same for type and message
        if (type.isVersion2() != isVersion2())
        {
            throw new MessageException("Protocol verison mismatch " +
                "between association session type: " + type +
                " and AssociationRequest message type.",
                OpenIDException.ASSOC_ERROR);
        }

    }
    catch (AssociationException e)
    {
        throw new MessageException(
            "Error verifying association request validity.",
            OpenIDException.ASSOC_ERROR, e);
    }

    // additional compatibility checks
    if (! isVersion2() && getSessionType() == null)
    {
        throw new MessageException(
            "sess_type cannot be omitted in OpenID1 association requests",
            OpenIDException.ASSOC_ERROR);
    }

    // DH seesion parameters
    if ( type.getHAlgorithm() != null && getDhPublicKey() == null)
    {
        throw new MessageException("DH consumer public key not specified.",
            OpenIDException.ASSOC_ERROR);
    }

    // no-enc session
    if (type.getHAlgorithm() == null && (getDhGen() != null ||
            getDhModulus() != null || getDhPublicKey() != null) )
    {
        throw new MessageException(
            "No-encryption session, but DH parameters specified.",
            OpenIDException.ASSOC_ERROR);
    }
}
 
开发者ID:jbufu,项目名称:openid4java,代码行数:60,代码来源:AssociationRequest.java


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