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


Java Association.TYPE_HMAC_SHA1属性代码示例

本文整理汇总了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;
}
 
开发者ID:patka,项目名称:cognitor,代码行数:22,代码来源:AssociationStoreServiceImpl.java

示例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());
}
 
开发者ID:patka,项目名称:cognitor,代码行数:16,代码来源:AssociationStoreServiceImplTest.java


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