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


Java HashRequest.Builder方法代码示例

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


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

示例1: calculateHash

import org.apache.shiro.crypto.hash.HashRequest; //导入方法依赖的package包/类
private static Hash calculateHash(String password) {
    ByteSource privateSalt = ByteSource.Util.bytes(PRIVATE_SALT_BYTES);
    DefaultHashService hashService = new DefaultHashService();
    hashService.setPrivateSalt(privateSalt);
    hashService.setGeneratePublicSalt(true);
    hashService.setHashIterations(ITERATIONS);

    HashRequest.Builder builder = new HashRequest.Builder();
    builder.setSource(ByteSource.Util.bytes(password));

    Hash hash = hashService.computeHash(builder.build());

    log.info("Hash algorithm {}, iterations {}, public salt {}", hash.getAlgorithmName(), hash.getIterations(), hash.getSalt());

    return hash;
}
 
开发者ID:dschadow,项目名称:JavaSecurity,代码行数:17,代码来源:SHA512.java

示例2: verifyPassword

import org.apache.shiro.crypto.hash.HashRequest; //导入方法依赖的package包/类
private static boolean verifyPassword(byte[] originalHash, ByteSource publicSalt, String password) {
    ByteSource privateSalt = ByteSource.Util.bytes(PRIVATE_SALT_BYTES);
    DefaultHashService hashService = new DefaultHashService();
    hashService.setPrivateSalt(privateSalt);
    hashService.setHashIterations(ITERATIONS);

    HashRequest.Builder builder = new HashRequest.Builder();
    builder.setSource(ByteSource.Util.bytes(password));
    builder.setSalt(publicSalt);

    Hash comparisonHash = hashService.computeHash(builder.build());

    log.info("password: {}", password);
    log.info("1 hash: {}", Hex.encodeToString(originalHash));
    log.info("2 hash: {}", comparisonHash.toHex());

    return Arrays.equals(originalHash, comparisonHash.getBytes());
}
 
开发者ID:dschadow,项目名称:JavaSecurity,代码行数:19,代码来源:SHA512.java

示例3: createAuthenticationInfo

import org.apache.shiro.crypto.hash.HashRequest; //导入方法依赖的package包/类
@Override
protected AuthenticationInfo createAuthenticationInfo(AuthenticationToken token, 
      Object ldapPrincipal,
      Object ldapCredentials, LdapContext ldapContext) throws NamingException {
  HashRequest.Builder builder = new HashRequest.Builder();
  Hash credentialsHash = hashService
        .computeHash(builder.setSource(token.getCredentials())
              .setAlgorithmName(HASHING_ALGORITHM).build());
  return new SimpleAuthenticationInfo(token.getPrincipal(), 
        credentialsHash.toHex(), credentialsHash.getSalt(),
        getName());
}
 
开发者ID:apache,项目名称:zeppelin,代码行数:13,代码来源:LdapRealm.java


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