• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java AssociationSessionType类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: reconnectToMxID

import org.openid4java.association.AssociationSessionType; //导入依赖的package包/类
private void reconnectToMxID() {
	LOG.info("Starting OpenId handler ... OpenIDReturnURL = " + OPENID_RETURN_URL + "; OpenIdProvider: " + OPENID_PROVIDER);
	try {

		manager = new ConsumerManager();
		manager.setAssociations(new InMemoryConsumerAssociationStore());
		manager.setNonceVerifier(new InMemoryNonceVerifier(5000));
		manager.setMinAssocSessEnc(AssociationSessionType.DH_SHA256);
		manager.getRealmVerifier().setEnforceRpId(true);

		discoveries = manager.discover(OPENID_PROVIDER);
		discovered = manager.associate(discoveries);

		started = true;
		LOG.info("Starting OpenId handler ... DONE");

	} catch (DiscoveryException e) {
		LOG.error("Failed to discover OpenId service: " + e.getMessage(), e);
	}
}
 
开发者ID:mendix,项目名称:IBM-Watson-Connector-Suite,代码行数:21,代码来源:OpenIDHandler.java


示例2: createAssociationError

import org.openid4java.association.AssociationSessionType; //导入依赖的package包/类
public static AssociationError createAssociationError(
        String msg, AssociationSessionType type)
{
    AssociationError err = new AssociationError(msg, type);

    try
    {
        err.validate();
    }
    catch (MessageException e)
    {
        _log.error("Invalid association error message created, " +
                   "type: " + type + " message: " + msg, e);
    }

    return err;
}
 
开发者ID:jbufu,项目名称:openid4java,代码行数:18,代码来源:AssociationError.java


示例3: createAssociationRequest

import org.openid4java.association.AssociationSessionType; //导入依赖的package包/类
public static AssociationRequest createAssociationRequest(
        AssociationSessionType type, DiffieHellmanSession dhSess)
        throws MessageException
{
    AssociationRequest req = new AssociationRequest(type, dhSess);

    // make sure the association / session type matches the dhSess
    if ( type == null ||
            (dhSess == null && type.getHAlgorithm() != null) ||
            (dhSess != null && ! dhSess.getType().equals(type) ) )
        throw new MessageException(
                "Invalid association / session combination specified: " +
                        type + "DH session: " + dhSess);

    req.validate();

    if (DEBUG) _log.debug("Created association request:\n"
                          + req.keyValueFormEncoding());

    return req;
}
 
开发者ID:jbufu,项目名称:openid4java,代码行数:22,代码来源:AssociationRequest.java


示例4: ConsumerManager

import org.openid4java.association.AssociationSessionType; //导入依赖的package包/类
@Inject
public ConsumerManager(RealmVerifierFactory realmFactory, Discovery discovery,
    HttpFetcherFactory httpFetcherFactory)
{
    _realmVerifier = realmFactory.getRealmVerifierForConsumer();
    // don't verify own (RP) identity, disable RP discovery
    _realmVerifier.setEnforceRpId(false);

    _discovery = discovery;
    _httpFetcher = httpFetcherFactory.createFetcher(HttpRequestOptions.getDefaultOptionsForOpCalls());

    if (Association.isHmacSha256Supported())
        _prefAssocSessEnc = AssociationSessionType.DH_SHA256;
    else
        _prefAssocSessEnc = AssociationSessionType.DH_SHA1;
}
 
开发者ID:jbufu,项目名称:openid4java,代码行数:17,代码来源:ConsumerManager.java


示例5: init

import org.openid4java.association.AssociationSessionType; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
public void init(ServletConfig config) throws ServletException {
	super.init(config);

	context = config.getServletContext();

	LOG.debug("context: " + context);

	// --- Forward proxy setup (only if needed) ---
	ProxyProperties proxyProps = getProxyProperties(config);
	if (proxyProps != null) {
		LOG.debug("ProxyProperties: " + proxyProps);
		HttpClientFactory.setProxyProperties(proxyProps);
	}

	this.manager = new ConsumerManager();
	manager.setAssociations(new InMemoryConsumerAssociationStore());
	manager.setNonceVerifier(new InMemoryNonceVerifier(5000));
	manager.setMinAssocSessEnc(AssociationSessionType.DH_SHA256);
}
 
开发者ID:jbufu,项目名称:openid4java,代码行数:23,代码来源:ConsumerServlet.java


示例6: reconnectToMxID

import org.openid4java.association.AssociationSessionType; //导入依赖的package包/类
private void reconnectToMxID() {
	log.info("Starting OpenId handler ... OpenIDReturnURL = " + OpenIDReturnURL + "; OpenIdProvider: " + OPENID_PROVIDER);
	try {

		manager = new ConsumerManager();
		manager.setAssociations(new InMemoryConsumerAssociationStore());
		manager.setNonceVerifier(new InMemoryNonceVerifier(5000));
		manager.setMinAssocSessEnc(AssociationSessionType.DH_SHA256);
		manager.getRealmVerifier().setEnforceRpId(true);

		discoveries = manager.discover(OPENID_PROVIDER);
		discovered = manager.associate(discoveries);

		started = true;
		log.info("Starting OpenId handler ... DONE");

	} catch (Exception e) {
		log.error("Failed to discover OpenId service: " + e.getMessage(), e);
	}
}
 
开发者ID:mendix,项目名称:EmailModuleWithTemplates,代码行数:21,代码来源:OpenIDHandler.java


示例7: init

import org.openid4java.association.AssociationSessionType; //导入依赖的package包/类
public void init(FilterConfig config) throws ServletException {
    super.init(config);
    try 
    {
        this.manager = new ConsumerManager();
    } catch (ConsumerException ex) {
        throw new ServletException(ex);
    }
    manager.setAssociations(new InMemoryConsumerAssociationStore());
    manager.setNonceVerifier(new InMemoryNonceVerifier(5000));
    manager.setMinAssocSessEnc(AssociationSessionType.DH_SHA256);
    manager.setImmediateAuth(true);
}
 
开发者ID:resteasy,项目名称:resteasy-examples,代码行数:14,代码来源:OpenIdFilter.java


示例8: AssociationResponse

import org.openid4java.association.AssociationSessionType; //导入依赖的package包/类
/**
 * Constructs an AssociationResponse for a given association request.
 *
 * @param assocReq      The association request that needs to be responded.
 * @param assoc         The association which will be used to sign
 *                      authentication responses.
 */
protected AssociationResponse(AssociationRequest assocReq, Association assoc)
        throws AssociationException
{
    if (DEBUG)
        _log.debug("Creating association response, type: " + assocReq.getType()
                   + " association handle: " + assoc.getHandle());

    if (assocReq.isVersion2()) set("ns", OPENID2_NS);

    AssociationSessionType type = assocReq.getType();
    setType(type);

    setAssocHandle(assoc.getHandle());

    Long expiryIn = new Long( ( assoc.getExpiry().getTime() -
                                System.currentTimeMillis() ) / 1000 );
    setExpire(expiryIn);

    if (type.getHAlgorithm() != null) // DH session, encrypt the MAC key
    {
        DiffieHellmanSession dhSess = DiffieHellmanSession.create(
                type, assocReq.getDhModulus(), assocReq.getDhGen() );

        setPublicKey(dhSess.getPublicKey());

        setMacKeyEnc(dhSess.encryptMacKey(
                assoc.getMacKey().getEncoded(),
                assocReq.getDhPublicKey() ));
    }
    else // no-encryption session, unecrypted MAC key
    {
        setMacKey(new String(
                Base64.encodeBase64(assoc.getMacKey().getEncoded())));
    }
}
 
开发者ID:jbufu,项目名称:openid4java,代码行数:43,代码来源:AssociationResponse.java


示例9: AssociationError

import org.openid4java.association.AssociationSessionType; //导入依赖的package包/类
protected AssociationError(String msg, AssociationSessionType type)
{
    super(msg);

    set("ns", OPENID2_NS);
    set("error_code", ASSOC_ERR);
    set("session_type", type.getSessionType());
    set("assoc_type", type.getAssociationType());
}
 
开发者ID:jbufu,项目名称:openid4java,代码行数:10,代码来源:AssociationError.java


示例10: 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


示例11: createAssociationRequest

import org.openid4java.association.AssociationSessionType; //导入依赖的package包/类
/**
 * Constructs an Association Request message of the specified session and
 * association type, taking into account the user preferences (encryption
 * level, default Diffie-Hellman parameters).
 *
 * @param type      The type of the association (session and association)
 * @param opUrl    The OP for which the association request is created
 * @return          An AssociationRequest message ready to be sent back
 *                  to the OpenID Provider, or null if an association
 *                  of the requested type cannot be built.
 */
private AssociationRequest createAssociationRequest(
        AssociationSessionType type, URL opUrl)
{
    try
    {
        if (_minAssocSessEnc.isBetter(type))
            return null;

        AssociationRequest assocReq = null;

        DiffieHellmanSession dhSess;
        if (type.getHAlgorithm() != null) // DH session
        {
            dhSess = DiffieHellmanSession.create(type, _dhParams);
            if (DiffieHellmanSession.isDhSupported(type)
                && Association.isHmacSupported(type.getAssociationType()))
                assocReq = AssociationRequest.createAssociationRequest(type, dhSess);
        }

        else if ( opUrl.getProtocol().equals("https") && // no-enc sess
                 Association.isHmacSupported(type.getAssociationType()))
                assocReq = AssociationRequest.createAssociationRequest(type);

        if (assocReq == null)
            _log.warn("Could not create association of type: " + type);

        return assocReq;
    }
    catch (OpenIDException e)
    {
        _log.error("Error trying to create association request.", e);
        return null;
    }
}
 
开发者ID:jbufu,项目名称:openid4java,代码行数:46,代码来源:ConsumerManager.java


示例12: setPrefAssocSessEnc

import org.openid4java.association.AssociationSessionType; //导入依赖的package包/类
/**
 * Sets the preferred association / session type.
 *
 * @see AssociationSessionType
 */
public void setPrefAssocSessEnc(AssociationSessionType type)
        throws ServerException
{
    if (! Association.isHmacSupported(type.getAssociationType()) ||
        ! DiffieHellmanSession.isDhSupported(type) )
        throw new ServerException("Unsupported association / session type: "
        + type.getSessionType() + " : " + type.getAssociationType());

    if (_minAssocSessEnc.isBetter(type) )
        throw new ServerException(
                "Minimum encryption settings cannot be better than the preferred");

    this._prefAssocSessEnc = type;
}
 
开发者ID:jbufu,项目名称:openid4java,代码行数:20,代码来源:ServerManager.java


示例13: testPerferredAssociation

import org.openid4java.association.AssociationSessionType; //导入依赖的package包/类
public void testPerferredAssociation() throws Exception {
	manager.setPrefAssocSessEnc(AssociationSessionType.DH_SHA1);
	DiscoveryInformation disc = new DiscoveryInformation(new URL(server.createAbsoluteUrl("/op/endpoint")), null);
	DiscoveryInformation info = manager.associate(Collections.singletonList(disc));
	assertEquals(1,server.getRequestParams().size());
	Map request = (Map)server.getRequestParams().get(0);
	assertEquals(manager.getPrefAssocSessEnc().getAssociationType(),((String[])request.get("openid.assoc_type"))[0]);
	assertEquals(manager.getPrefAssocSessEnc().getSessionType(),((String[])request.get("openid.session_type"))[0]);
}
 
开发者ID:jbufu,项目名称:openid4java,代码行数:10,代码来源:ConsumerManagerTest.java


示例14: setType

import org.openid4java.association.AssociationSessionType; //导入依赖的package包/类
/**
 * Sets the association / session type for the association response.
 */
public void setType(AssociationSessionType type)
{
    set("session_type", type.getSessionType());
    set("assoc_type", type.getAssociationType());
}
 
开发者ID:jbufu,项目名称:openid4java,代码行数:9,代码来源:AssociationResponse.java


示例15: getType

import org.openid4java.association.AssociationSessionType; //导入依赖的package包/类
/**
 * Gets the association / session type of the association response.
 *
 * @throws AssociationException
 */
public AssociationSessionType getType() throws AssociationException
{
    return AssociationSessionType.create(
            getSessionType(), getAssociationType(), ! isVersion2() );
}
 
开发者ID:jbufu,项目名称:openid4java,代码行数:11,代码来源:AssociationResponse.java


示例16: 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


示例17: getAssociation

import org.openid4java.association.AssociationSessionType; //导入依赖的package包/类
/**
 * Generates an Association object from an Association Response.
 *
 * @param dhSess        The Diffie-Helman session containing the private key
 *                      used to encrypt / decrypt the MAC key exchange.
 *                      Should be null for no-encryption sessions.
 */
public Association getAssociation(DiffieHellmanSession dhSess)
        throws AssociationException
{
    if (DEBUG) _log.debug("Retrieving MAC key from association response...");

    String handle = getParameterValue("assoc_handle");
    int expiresIn = Integer.parseInt(
            getParameterValue("expires_in") );

    // get (and decrypt) the MAC key
    byte[] macKey;

    AssociationSessionType type = getType();

    if ( type.getHAlgorithm() != null )
    {
        macKey = dhSess.decryptMacKey(
                getParameterValue("enc_mac_key"),
                getParameterValue("dh_server_public") );
        if (DEBUG) _log.debug("Decrypted MAC key (base64): " +
                              new String(Base64.encodeBase64(macKey)));
    }
    else
    {
        macKey = Base64.decodeBase64(
                getParameterValue("mac_key").getBytes() );

        if (DEBUG) _log.debug("Unencrypted MAC key (base64): "
                              + getParameterValue("mac_key"));
    }

    Association assoc;

    if (Association.TYPE_HMAC_SHA1.equals(type.getAssociationType()))
        assoc = Association.createHmacSha1(handle, macKey, expiresIn);

    else if (Association.TYPE_HMAC_SHA256.equals(type.getAssociationType()))
        assoc = Association.createHmacSha256(handle, macKey, expiresIn);

    else
        throw new AssociationException("Unknown association type: " + type);

    if (DEBUG) _log.debug("Created association for handle: " + handle);

    return assoc;
}
 
开发者ID:jbufu,项目名称:openid4java,代码行数:54,代码来源:AssociationResponse.java


示例18: setAssociationSessionType

import org.openid4java.association.AssociationSessionType; //导入依赖的package包/类
public void setAssociationSessionType(AssociationSessionType type)
{
    set("session_type", type.getSessionType());
    set("assoc_type", type.getAssociationType());
}
 
开发者ID:jbufu,项目名称:openid4java,代码行数:6,代码来源:AssociationError.java


示例19: getType

import org.openid4java.association.AssociationSessionType; //导入依赖的package包/类
/**
 * Gets the association / session type of the association request.
 *
 * @throws AssociationException
 */
public AssociationSessionType getType() throws AssociationException
{
    return AssociationSessionType.create(
            getSessionType(), getAssociationType(), ! isVersion2() );
}
 
开发者ID:jbufu,项目名称:openid4java,代码行数:11,代码来源:AssociationRequest.java


示例20: 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类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java StandardProtectionPolicy类代码示例发布时间:2022-05-22
下一篇:
Java SMIMESigned类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap