本文整理汇总了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, ":");
}
}
示例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