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


Java Base64.decodeToString方法代码示例

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


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

示例1: onPreHandle

import org.apache.shiro.codec.Base64; //导入方法依赖的package包/类
@Override
protected boolean onPreHandle(ServletRequest request, ServletResponse response, Object mappedValue) throws Exception {
   	Subject subject = SecurityUtils.getSubject();
	if (!subject.isAuthenticated()) {
        HttpServletRequest httpRequest = WebUtils.toHttp(request);
        String authzHeader = httpRequest.getHeader(AUTHORIZATION_HEADER);
        if (authzHeader != null) {
            if (authzHeader.toLowerCase(Locale.ENGLISH).startsWith("basic") 
            		|| authzHeader.toLowerCase(Locale.ENGLISH).startsWith("token")) {
            	String authToken = StringUtils.substringAfter(authzHeader, " ");
                String decoded = Base64.decodeToString(authToken);
                String userName = StringUtils.substringBefore(decoded, ":").trim();
                String password = StringUtils.substringAfter(decoded, ":").trim();
                if (userName.length() != 0 && password.length() != 0) {
	                UsernamePasswordToken token = new UsernamePasswordToken(userName, password);
                    subject.login(token);
                }
            }
        } 
	} 
	
	return true;
}
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:24,代码来源:BasicAuthenticationFilter.java

示例2: testBase64

import org.apache.shiro.codec.Base64; //导入方法依赖的package包/类
@Test
public void testBase64(){
    String str = "hello";
    String base64Encode = Base64.encodeToString(str.getBytes());
    String str2 = Base64.decodeToString(base64Encode);
    Assert.assertEquals(str, str2);
}
 
开发者ID:l81893521,项目名称:shiro-demo,代码行数:8,代码来源:CodecAndCryptoTest.java

示例3: getPrincipalsAndCredentials

import org.apache.shiro.codec.Base64; //导入方法依赖的package包/类
/**
 * <p>Returns the username obtained from the authorization header.</p>
 * <p>
 * Once the header is split per the RFC (based on the space character ' '), the resulting split tokens
 * are translated into the username/password pair.</p>
 *
 * @param authorizationHeader the authorization header obtained from the request.
 * @return the username (index 0)/password pair (index 1) submitted by the user for the given header value and request.
 */
protected String[] getPrincipalsAndCredentials(String authorizationHeader) {
    String[] authTokens = authorizationHeader.split(" ", 2);
    if (authTokens.length < 2) {
        return null;
    }
    String decoded = Base64.decodeToString(authTokens[1]);
    return decoded.split(":", 2);
}
 
开发者ID:ManyDesigns,项目名称:Portofino,代码行数:18,代码来源:HttpBasicAuthenticationFilter.java

示例4: decryptBase64

import org.apache.shiro.codec.Base64; //导入方法依赖的package包/类
/**
 * base64进制解密
 *
 * @param content
 * @return
 */
public static String decryptBase64(String content) {
    Preconditions.checkArgument(!Strings.isNullOrEmpty(content), "消息摘要不能为空");
    return Base64.decodeToString(content);
}
 
开发者ID:melonlee,项目名称:LazyREST,代码行数:11,代码来源:EndecryptUtil.java

示例5: decryptBase64

import org.apache.shiro.codec.Base64; //导入方法依赖的package包/类
/** 
 * base64进制解密 
 * @param cipherText 
 * @return 
 */ 
public static String decryptBase64(String cipherText) { 
    return Base64.decodeToString(cipherText); 
}
 
开发者ID:wjggwm,项目名称:webside,代码行数:9,代码来源:EndecryptUtils.java

示例6: getPrincipalsAndCredentials

import org.apache.shiro.codec.Base64; //导入方法依赖的package包/类
/**
 * Returns the username and password pair based on the specified <code>encoded</code> String obtained from
 * the request's authorization header.
 * <p/>
 * Per RFC 2617, the default implementation first Base64 decodes the string and then splits the resulting decoded
 * string into two based on the ":" character.  That is:
 * <p/>
 * <code>String decoded = Base64.decodeToString(encoded);<br/>
 * return decoded.split(":");</code>
 *
 * @param scheme  the {@link #getAuthcScheme() authcScheme} found in the request
 *                {@link #getAuthzHeader(javax.servlet.ServletRequest) authzHeader}.  It is ignored by this implementation,
 *                but available to overriding implementations should they find it useful.
 * @param encoded the Base64-encoded username:password value found after the scheme in the header
 * @return the username (index 0)/password (index 1) pair obtained from the encoded header data.
 */
protected String[] getPrincipalsAndCredentials(String scheme, String encoded) {
    String decoded = Base64.decodeToString(encoded);
    return decoded.split(":", 2);
}
 
开发者ID:xuegongzi,项目名称:rabbitframework,代码行数:21,代码来源:BasicHttpAuthenticationFilter.java


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