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


Java Association.generate方法代码示例

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


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

示例1: verifyExpiredAssociationGetResponse

import org.openid4java.association.Association; //导入方法依赖的package包/类
@Test
public void verifyExpiredAssociationGetResponse() {
    request.addParameter("openid.assoc_handle", "test");
    openIdService = OpenIdService.createServiceFrom(request, null);
    Association association = null;
    try {
        association = Association.generate(Association.TYPE_HMAC_SHA1, "test", 2);
    } catch (final Exception e) {
        fail("Could not generate association");
    }
    when(sharedAssociations.load("test")).thenReturn(association);
    synchronized (this) {
        try {
            this.wait(3000);
        } catch (final InterruptedException ie) {
            fail("Could not wait long enough to check association expiry date");
        }
    }
    final Response response = this.openIdService.getResponse("test");
    request.removeParameter("openid.assoc_handle");
    assertNotNull(response);

    assertEquals(1, response.getAttributes().size());
    assertEquals("cancel", response.getAttributes().get("openid.mode"));
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:26,代码来源:OpenIdServiceTests.java

示例2: generate

import org.openid4java.association.Association; //导入方法依赖的package包/类
public synchronized Association generate(String type, int expiryIn)
        throws AssociationException
{
    removeExpired();

    String handle = _timestamp + "-" + _counter++;

    Association association = Association.generate(type, handle, expiryIn);

    _handleMap.put(handle, association);

    if (DEBUG) _log.debug("Generated association, handle: " + handle +
                          " type: " + type +
                          " expires in: " + expiryIn + " seconds.");

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

示例3: generate

import org.openid4java.association.Association; //导入方法依赖的package包/类
/**
 * Super will generate the association and it will be persisted by the DAO.
 *
 * @param type     association type defined in the OpenID 2.0
 * @param expiryIn date
 * @return <code>Association</code>
 */
@Override
public Association generate(String type, int expiryIn)
        throws AssociationException {
    String handle = storeId + timestamp + "-" + getCounter();
    final Association association = Association.generate(type, handle, expiryIn);
    cache.addToCache(association);
    // Asynchronous write to database
    Thread thread = new Thread() {
        @Override
        public void run() {
            if(log.isDebugEnabled()) {
                log.debug("Storing association " + association.getHandle() + " in the database.");
            }
            dao.storeAssociation(association);
        }
    };
    thread.start();
    return association;
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:27,代码来源:OpenIDServerAssociationStore.java

示例4: testExpiredAssociationGetResponse

import org.openid4java.association.Association; //导入方法依赖的package包/类
@Test
public void testExpiredAssociationGetResponse() {
    request.addParameter("openid.assoc_handle", "test");
    openIdService = OpenIdService.createServiceFrom(request);
    Association association = null;
    try {
        association = Association.generate(Association.TYPE_HMAC_SHA1, "test", 2);
    } catch (final Exception e) {
        fail("Could not generate association");
    }
    when(context.getBean("serverManager")).thenReturn(manager);
    when(context.getBean("centralAuthenticationService")).thenReturn(cas);
    when(sharedAssociations.load("test")).thenReturn(association);
    synchronized (this) {
        try {
            this.wait(3000);
        } catch (final InterruptedException ie) {
            fail("Could not wait long enough to check association expiry date");
        }
    }
    final Response response = this.openIdService.getResponse("test");
    request.removeParameter("openid.assoc_handle");
    assertNotNull(response);

    assertEquals(1, response.getAttributes().size());
    assertEquals("cancel", response.getAttributes().get("openid.mode"));
}
 
开发者ID:luotuo,项目名称:cas4.0.x-server-wechat,代码行数:28,代码来源:OpenIdServiceTests.java

示例5: generate

import org.openid4java.association.Association; //导入方法依赖的package包/类
@Override
public synchronized Association generate(String type, int expiryIn)
  throws AssociationException {
    removeExpired();

    String handle;
    // If this is the first, just use the prefix
    handle = associationPrefix;
    while (_handleMap.containsKey(handle)) {
        // Otherwise, use prefix plus counter
        ++counter;
        handle = associationPrefix + "-" + counter;
    }

    Association association = Association.generate(type, handle, expiryIn);

    _handleMap.put(handle, association);

    if (DEBUG) {
        LOG.debug("Generated association, handle: " + handle
          + " type: " + type
          + " expires in: " + expiryIn + " seconds.");
    }
    removeExpired();

    return association;
}
 
开发者ID:RUB-NDS,项目名称:OpenID-Attacker,代码行数:28,代码来源:CustomInMemoryServerAssociationStore.java

示例6: generate

import org.openid4java.association.Association; //导入方法依赖的package包/类
public Association generate(String type, int expiryIn) throws AssociationException {
    String handle = storeId + timestamp + "-" + getCounter();
    Association association = Association.generate(type, handle, expiryIn);

    // replicating association using cluster messages
    if(log.isDebugEnabled()) {
        log.debug("Storing association " + association.getHandle() + " in the map.");
    }
    OpenIDAssociationReplicationManager.getPersistenceManager().addAssociation(association);

    return association;
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:13,代码来源:PrivateAssociationReplicationStore.java

示例7: generate

import org.openid4java.association.Association; //导入方法依赖的package包/类
@Override
public Association generate(final String type, final int expiryIn) throws AssociationException {
    String handle = createAssociationHandle();
    Association association = Association.generate(type, handle, expiryIn);
    OpenIdAssociation ssoAssociation = mapFromAssociation(association);
    openIdAssociationDao.save(ssoAssociation);
    return association;
}
 
开发者ID:patka,项目名称:cognitor,代码行数:9,代码来源:AssociationStoreServiceImpl.java

示例8: generate

import org.openid4java.association.Association; //导入方法依赖的package包/类
public Association generate(String type, int expiryIn)
        throws AssociationException
{
    cleanupExpired();
    
    String sql = "INSERT INTO " + _tableName +
            " (handle, type, mackey, expdate) VALUES (?,?,?,?)";

    JdbcTemplate jdbcTemplate = getJdbcTemplate();

    int attemptsLeft = 5;

    while (attemptsLeft > 0)
    {
        try
        {
            String handle = Long.toHexString(_random.nextLong());

            Association association =
                    Association.generate(type, handle, expiryIn);

            int cnt = jdbcTemplate.update(sql,
                    new Object[] {
                            association.getHandle(),
                            association.getType(),
                            new String(Base64.encodeBase64(
                                    association.getMacKey().getEncoded())),
                            association.getExpiry()
                    });

            if (cnt == 1)
            {
                if (DEBUG)
                    _log.debug("Generated association, handle: " + handle +
                               " type: " + type +
                               " expires in: " + expiryIn + " seconds.");

                return association;
            }
        }
        catch (DataAccessException e)
        {
            _log.error("Error generating association; attempts left: "
                       + (attemptsLeft-1), e);
        }

        attemptsLeft--;
    }

    throw new AssociationException(
            "JDBCServerAssociationStore: Error generating association.");
}
 
开发者ID:jbufu,项目名称:openid4java,代码行数:53,代码来源:JdbcServerAssociationStore.java


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