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


Java Base64.isBase64方法代码示例

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


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

示例1: decodeAccessToken

import org.springframework.security.crypto.codec.Base64; //导入方法依赖的package包/类
String[] decodeAccessToken(String token) {
  if(!Base64.isBase64(token.getBytes())) {
    throw new IllegalArgumentException("Access token was not Base64 encoded; value was \'" + token + "\'");
  } else {
    String base64Decoded = new String(Base64.decode(token.getBytes()));
    return StringUtils.delimitedListToStringArray(base64Decoded, ":");
  }
}
 
开发者ID:adrobisch,项目名称:putput,代码行数:9,代码来源:AccessTokenService.java

示例2: extractNonceValue

import org.springframework.security.crypto.codec.Base64; //导入方法依赖的package包/类
private long extractNonceValue(final String nonce) {
    // Check nonce was Base64 encoded (as sent by the filter)
    if (!Base64.isBase64(nonce.getBytes())) {
        throw new BadCredentialsException(messages.getMessage("DigestAuthenticationFilter.nonceEncoding",
                new Object[]{nonce}, "Nonce is not encoded in Base64; received nonce {0}"));
    }

    // Decode nonce from Base64
    // format of nonce is:
    // base64(expirationTime + ":" + md5Hex(expirationTime + ":" + key))
    final String nonceAsPlainText = new String(Base64.decode(nonce.getBytes()));
    final String[] nonceTokens = org.springframework.util.StringUtils.delimitedListToStringArray(nonceAsPlainText, NONCE_FIELD_SEPARATOR);

    if (nonceTokens.length != 2) {
        throw new BadCredentialsException(messages.getMessage("DigestAuthenticationFilter.nonceNotTwoTokens",
                new Object[]{nonceAsPlainText}, "Nonce should have yielded two tokens but was {0}"));
    }

    // Extract expiry time from nonce
    long nonceExpiryTime;
    try {
        nonceExpiryTime = Long.valueOf(nonceTokens[0]);
    } catch (NumberFormatException nfe) {
        throw new BadCredentialsException(messages.getMessage("DigestAuthenticationFilter.nonceNotNumeric",
                new Object[]{nonceAsPlainText},
                "Nonce token should have yielded a numeric first token, but was {0}"), nfe);
    }

    // Check signature of nonce matches this expiry time
    final String expectedNonceSignature = md5Hex(nonceExpiryTime + NONCE_FIELD_SEPARATOR + key);

    if (!expectedNonceSignature.equals(nonceTokens[1])) {
        throw new BadCredentialsException(messages.getMessage("DigestAuthenticationFilter.nonceCompromised",
                new Object[]{nonceAsPlainText}, "Nonce token compromised {0}"));
    }

    return nonceExpiryTime;
}
 
开发者ID:jestevez,项目名称:autenticacion-as400-spring-security,代码行数:39,代码来源:CustomAuthenticationProvider.java


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