當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。