org.apache.shiro.authc.credential.HashedCredentialsMatcher.getCredentials()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(4.5k)|赞(0)|评价(0)|浏览(133)

本文整理了Java中org.apache.shiro.authc.credential.HashedCredentialsMatcher.getCredentials()方法的一些代码示例,展示了HashedCredentialsMatcher.getCredentials()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HashedCredentialsMatcher.getCredentials()方法的具体详情如下:
包路径:org.apache.shiro.authc.credential.HashedCredentialsMatcher
类名称:HashedCredentialsMatcher
方法名:getCredentials

HashedCredentialsMatcher.getCredentials介绍

[英]Returns a Hash instance representing the already-hashed AuthenticationInfo credentials stored in the system.

This method reconstructs a Hash instance based on a info.getCredentials call, but it does not hash that value - it is expected that method call will return an already-hashed value.

This implementation's reconstruction effort functions as follows:

  1. Convert account.getCredentials() to a byte array via the #toBytes method.
  2. If account.getCredentials() was originally a String or char[] before toBytes was called, check for encoding:
  3. If #storedCredentialsHexEncoded, Hex decode that byte array, otherwise Base64 decode the byte array
  4. Set the byte[] array directly on the Hash implementation and return it.
    [中]返回表示存储在系统中的已哈希AuthenticationInfo凭据的哈希实例。
    此方法基于信息重建哈希实例。getCredentials调用,但它不*散列该值-方法调用应返回已散列的值。
    该实施的重建工作如下所示:
    1.转换帐户。通过#toBytes方法将getCredentials()转换为字节数组。
    1.如有需要,请说明。getCredentials()在调用toBytes之前最初是字符串或字符[],请检查编码:
    1.如果#storedCredentialsHexEncoded,则十六进制解码该字节数组,否则Base64解码该字节数组
    1.直接在哈希实现上设置byte[]数组并返回它。

代码示例

代码示例来源:origin: apache/shiro

/**
 * This implementation first hashes the {@code token}'s credentials, potentially using a
 * {@code salt} if the {@code info} argument is a
 * {@link org.apache.shiro.authc.SaltedAuthenticationInfo SaltedAuthenticationInfo}.  It then compares the hash
 * against the {@code AuthenticationInfo}'s
 * {@link #getCredentials(org.apache.shiro.authc.AuthenticationInfo) already-hashed credentials}.  This method
 * returns {@code true} if those two values are {@link #equals(Object, Object) equal}, {@code false} otherwise.
 *
 * @param token the {@code AuthenticationToken} submitted during the authentication attempt.
 * @param info  the {@code AuthenticationInfo} stored in the system matching the token principal
 * @return {@code true} if the provided token credentials hash match to the stored account credentials hash,
 *         {@code false} otherwise
 * @since 1.1
 */
@Override
public boolean doCredentialsMatch(AuthenticationToken token, AuthenticationInfo info) {
  Object tokenHashedCredentials = hashProvidedCredentials(token, info);
  Object accountCredentials = getCredentials(info);
  return equals(tokenHashedCredentials, accountCredentials);
}

代码示例来源:origin: org.apache.shiro/shiro-core

/**
 * This implementation first hashes the {@code token}'s credentials, potentially using a
 * {@code salt} if the {@code info} argument is a
 * {@link org.apache.shiro.authc.SaltedAuthenticationInfo SaltedAuthenticationInfo}.  It then compares the hash
 * against the {@code AuthenticationInfo}'s
 * {@link #getCredentials(org.apache.shiro.authc.AuthenticationInfo) already-hashed credentials}.  This method
 * returns {@code true} if those two values are {@link #equals(Object, Object) equal}, {@code false} otherwise.
 *
 * @param token the {@code AuthenticationToken} submitted during the authentication attempt.
 * @param info  the {@code AuthenticationInfo} stored in the system matching the token principal
 * @return {@code true} if the provided token credentials hash match to the stored account credentials hash,
 *         {@code false} otherwise
 * @since 1.1
 */
@Override
public boolean doCredentialsMatch(AuthenticationToken token, AuthenticationInfo info) {
  Object tokenHashedCredentials = hashProvidedCredentials(token, info);
  Object accountCredentials = getCredentials(info);
  return equals(tokenHashedCredentials, accountCredentials);
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.shiro

/**
 * This implementation first hashes the {@code token}'s credentials, potentially using a
 * {@code salt} if the {@code info} argument is a
 * {@link org.apache.shiro.authc.SaltedAuthenticationInfo SaltedAuthenticationInfo}.  It then compares the hash
 * against the {@code AuthenticationInfo}'s
 * {@link #getCredentials(org.apache.shiro.authc.AuthenticationInfo) already-hashed credentials}.  This method
 * returns {@code true} if those two values are {@link #equals(Object, Object) equal}, {@code false} otherwise.
 *
 * @param token the {@code AuthenticationToken} submitted during the authentication attempt.
 * @param info  the {@code AuthenticationInfo} stored in the system matching the token principal
 * @return {@code true} if the provided token credentials hash match to the stored account credentials hash,
 *         {@code false} otherwise
 * @since 1.1
 */
@Override
public boolean doCredentialsMatch(AuthenticationToken token, AuthenticationInfo info) {
  Object tokenHashedCredentials = hashProvidedCredentials(token, info);
  Object accountCredentials = getCredentials(info);
  return equals(tokenHashedCredentials, accountCredentials);
}

相关文章