org.apache.shiro.codec.Base64.decode()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(5.6k)|赞(0)|评价(0)|浏览(147)

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

Base64.decode介绍

[英]Converts the specified UTF-8 Base64 encoded String and decodes it to a raw Base64 decoded byte array.
[中]转换指定的UTF-8 Base64编码字符串,并将其解码为原始Base64解码字节数组。

代码示例

代码示例来源:origin: shuzheng/zheng

public static Session deserialize(String sessionStr) {
  if (StringUtils.isBlank(sessionStr)) {
    return null;
  }
  try {
    ByteArrayInputStream bis = new ByteArrayInputStream(Base64.decode(sessionStr));
    ObjectInputStream ois = new ObjectInputStream(bis);
    return (Session) ois.readObject();
  } catch (Exception e) {
    throw new RuntimeException("deserialize session error", e);
  }
}

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

/**
 * Decodes the specified Base64 encoded byte array and returns the decoded result as a UTF-8 encoded.
 *
 * @param base64Encoded a Base64 encoded byte array
 * @return the decoded String, UTF-8 encoded.
 */
public static String decodeToString(byte[] base64Encoded) {
  byte[] decoded = decode(base64Encoded);
  return CodecSupport.toString(decoded);
}

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

/**
 * Converts the specified UTF-8 Base64 encoded String and decodes it to a raw Base64 decoded byte array.
 *
 * @param base64Encoded a UTF-8 Base64 encoded String
 * @return the raw Base64 decoded byte array.
 */
public static byte[] decode(String base64Encoded) {
  byte[] bytes = CodecSupport.toBytes(base64Encoded);
  return decode(bytes);
}

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

protected byte[] toBytes(String sValue) {
  if (sValue == null) {
    return null;
  }
  byte[] bytes;
  if (sValue.startsWith(HEX_BEGIN_TOKEN)) {
    String hex = sValue.substring(HEX_BEGIN_TOKEN.length());
    bytes = Hex.decode(hex);
  } else {
    //assume base64 encoded:
    bytes = Base64.decode(sValue);
  }
  return bytes;
}

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

public static Sha512Hash fromBase64String(String base64) {
    Sha512Hash hash = new Sha512Hash();
    hash.setBytes(Base64.decode(base64));
    return hash;
  }
}

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

public static Sha384Hash fromBase64String(String base64) {
    Sha384Hash hash = new Sha384Hash();
    hash.setBytes(Base64.decode(base64));
    return hash;
  }
}

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

public static Sha1Hash fromBase64String(String base64) {
    Sha1Hash hash = new Sha1Hash();
    hash.setBytes(Base64.decode(base64));
    return hash;
  }
}

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

public static Md5Hash fromBase64String(String base64) {
    Md5Hash hash = new Md5Hash();
    hash.setBytes(Base64.decode(base64));
    return hash;
  }
}

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

public static Sha256Hash fromBase64String(String base64) {
    Sha256Hash hash = new Sha256Hash();
    hash.setBytes(Base64.decode(base64));
    return hash;
  }
}

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

public static Md2Hash fromBase64String(String base64) {
    Md2Hash hash = new Md2Hash();
    hash.setBytes(Base64.decode(base64));
    return hash;
  }
}

代码示例来源:origin: stylefeng/Guns

/**
 * rememberMe管理器, cipherKey生成见{@code Base64Test.java}
 */
@Bean
public CookieRememberMeManager rememberMeManager(SimpleCookie rememberMeCookie) {
  CookieRememberMeManager manager = new CookieRememberMeManager();
  manager.setCipherKey(Base64.decode("Z3VucwAAAAAAAAAAAAAAAA=="));
  manager.setCookie(rememberMeCookie);
  return manager;
}

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

String algorithmName = parts[i];
byte[] digest = Base64.decode(digestBase64);
ByteSource salt = null;
  byte[] saltBytes = Base64.decode(saltBase64);
  salt = ByteSource.Util.bytes(saltBytes);

代码示例来源:origin: killbill/killbill

@Override
  public AuthenticationInfo inTransaction(final EntitySqlDaoWrapperFactory entitySqlDaoWrapperFactory) throws Exception {
    final TenantModelDao tenantModelDao = entitySqlDaoWrapperFactory.become(TenantSqlDao.class).getSecrets(id.toString());
    final SimpleAuthenticationInfo authenticationInfo = new SimpleAuthenticationInfo(tenantModelDao.getApiKey(), tenantModelDao.getApiSecret().toCharArray(), getClass().getSimpleName());
    authenticationInfo.setCredentialsSalt(ByteSource.Util.bytes(Base64.decode(tenantModelDao.getApiSalt())));
    return authenticationInfo;
  }
});

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

bytes = Base64.decode(value);
} else {
  bytes = Hex.decode(value);

代码示例来源:origin: wuyouzhuguli/FEBS-Shiro

/**
 * cookie管理对象
 *
 * @return CookieRememberMeManager
 */
private CookieRememberMeManager rememberMeManager() {
  CookieRememberMeManager cookieRememberMeManager = new CookieRememberMeManager();
  cookieRememberMeManager.setCookie(rememberMeCookie());
  // rememberMe cookie 加密的密钥
  cookieRememberMeManager.setCipherKey(Base64.decode("4AvVhmFLUs0KTA3Kprsdag=="));
  return cookieRememberMeManager;
}

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

log.trace("Acquired Base64 encoded identity [" + base64 + "]");
byte[] decoded = Base64.decode(base64);
if (log.isTraceEnabled()) {
  log.trace("Base64 decoded byte array length: " + (decoded != null ? decoded.length : 0) + " bytes.");

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

storedBytes = Hex.decode(storedBytes);
} else {
  storedBytes = Base64.decode(storedBytes);

代码示例来源:origin: magefree/mage

public boolean doCredentialsMatch(String name, String password) {
  HashedCredentialsMatcher matcher = new HashedCredentialsMatcher(this.hashAlgorithm);
  matcher.setHashIterations(this.hashIterations);
  AuthenticationToken token = new UsernamePasswordToken(name, password);
  AuthenticationInfo info = new SimpleAuthenticationInfo(this.name,
      ByteSource.Util.bytes(Base64.decode(this.password)),
      ByteSource.Util.bytes(Base64.decode(this.salt)), "");
  return matcher.doCredentialsMatch(token, info);
}

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

storedBytes = Hex.decode(storedBytes);
} else {
  storedBytes = Base64.decode(storedBytes);

代码示例来源:origin: java-aodeng/hope-plus

/***
 * cookid管理对象,记住我功能
 * @return
 */
public CookieRememberMeManager rememberMeManager(){
  CookieRememberMeManager cookieRememberMeManager=new CookieRememberMeManager();
  cookieRememberMeManager.setCookie(simpleCookie());
  //rememberMe cookie加密的密钥 建议每个项目都不一样 默认AES算法 密钥长度(128 256 512 位)
  cookieRememberMeManager.setCipherKey(Base64.decode("1QWLxg+NYmxraMoxAXu/Iw=="));
  return cookieRememberMeManager;
}

相关文章