本文整理汇总了Java中org.openid4java.association.Association.TYPE_HMAC_SHA1属性的典型用法代码示例。如果您正苦于以下问题:Java Association.TYPE_HMAC_SHA1属性的具体用法?Java Association.TYPE_HMAC_SHA1怎么用?Java Association.TYPE_HMAC_SHA1使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.openid4java.association.Association
的用法示例。
在下文中一共展示了Association.TYPE_HMAC_SHA1属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: mapToAssociation
private Association mapToAssociation(OpenIdAssociation ssoAssociation) {
Association association;
String type = ssoAssociation.getType();
String handle = ssoAssociation.getHandle();
byte[] macKey = ssoAssociation.getKey();
DateTime expiration = ssoAssociation.getExpiry();
switch(type) {
case Association.TYPE_HMAC_SHA1:
association = Association.createHmacSha1(handle, macKey, expiration.toDate());
break;
case Association.TYPE_HMAC_SHA256:
association = Association.createHmacSha256(handle, macKey, expiration.toDate());
break;
default:
LOGGER.warn("Somehow a handle of type {0} managed to get into the persistent store.", type);
return null;
}
return association;
}
示例2: shouldReturnSsoAssociationWhenHandleExistingInPersistenceForSHA1Given
@Test
public void shouldReturnSsoAssociationWhenHandleExistingInPersistenceForSHA1Given() {
DateTime expiry = new DateTime(2012, 1, 1, 12, 0 );
byte[] key = new byte[] { 1, 2, 3 };
OpenIdAssociation ssoAssociation = new OpenIdAssociation("test-handle", Association.TYPE_HMAC_SHA1,
expiry, key);
when(daoMock.load("test-handle")).thenReturn(ssoAssociation);
Association association = store.load("test-handle");
assertNotNull(association);
assertEquals(association.getExpiry(), ssoAssociation.getExpiry().toDate());
assertEquals(association.getHandle(), ssoAssociation.getHandle());
assertEquals(association.getType(), ssoAssociation.getType());
assertArrayEquals(association.getMacKey().getEncoded(), ssoAssociation.getKey());
}