本文整理汇总了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"));
}
示例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;
}
示例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;
}
示例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"));
}
示例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;
}
示例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;
}
示例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;
}
示例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.");
}