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


Java Base64.decode方法代码示例

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


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

示例1: getCredentials

import org.apache.shiro.codec.Base64; //导入方法依赖的package包/类
/**
 *
 * @param info the AuthenticationInfo from which to retrieve the credentials which assumed to be in already-hashed form.
 * @return a {@link Hash Hash} instance representing the given AuthenticationInfo's stored credentials.
 */
protected Object getCredentials(AuthenticationInfo info) {
    Object credentials = info.getCredentials();

    byte[] storedBytes = toBytes(credentials);

    if (credentials instanceof String || credentials instanceof char[]) {
        //account.credentials were a char[] or String, so
        //we need to do text decoding first:
        if (isStoredCredentialsHexEncoded()) {
            storedBytes = Hex.decode(storedBytes);
        } else {
            storedBytes = Base64.decode(storedBytes);
        }
    }
    AbstractHash hash = newHashInstance();
    hash.setBytes(storedBytes);
    return hash;
}
 
开发者ID:nano-projects,项目名称:nano-framework,代码行数:24,代码来源:HashedCredentialsMatcher.java

示例2: main

import org.apache.shiro.codec.Base64; //导入方法依赖的package包/类
public static void main(String[] args) {
	String base64="zGkG0zevFbnIioooS3MfnnbWeBUeiZrScKVJms0CZAdJ2MYTddPkvBHGmMhvgdKA5QJk8FSb9T1Y1tFlUnnCsIvcK+iX4cfrwD7voGdU5bW9AWjwNvl3BDrAgRf+hvjrI3T5nBTFeW7uI6GzfFrIx92qER9lQ97g19Dn555uwIzf0ULvc8jICZTraLLrf2avh1hy2kUJJblO6u5IHiBbAXBNitZ6W1yjLEWmSFnb+EsEWAGB3WwV1u1HZO045LB4G57UIH4QGM0xfJjWWeahiTS4j9IAEJBbghwfL1A5pdzFiXJzzA5GF85vtP+6jLwQfGaQJyv35PvNNsDmCqFe8eUSBLji5z5y/y+yKfZk9izXiEvFjKQ5kqMqKfLMp+Vn5OuO+syc4CfJL4PLI16vwVUPV1EWAzyxUhK7DtD5OMVcLPwVtwZ11dG88wkZtjXvBymLyGCj5/Tk8gTWYsdcNKD5i8WvbMLT45S4iWsZxa/5offIiCipkkqoqvxCppJLTzBoaR/wlqoa1Bc/cvpijiJTIbSCj+iFloQRdax1mMQ";
	 base64 = ensurePadding(base64);
	  byte[] decoded = Base64.decode(base64);
	  
	  
	   byte[] serialized = decoded;
        CipherService cipherService = new AesCipherService();
        if (cipherService != null) {
            ByteSource byteSource = cipherService.decrypt(decoded, new byte[]{-112, -15, -2, 108, -116, 100, -28, 61, -99, 121, -104, -120, -59, -58, -102, 104});
            serialized = byteSource.getBytes();
        }
        Serializer<PrincipalCollection> serializer = new DefaultSerializer<PrincipalCollection>();
        ;
        System.out.println(serializer.deserialize(serialized));
        
        	SimplePrincipalCollection p=(SimplePrincipalCollection) serializer.deserialize(serialized);	

	  System.out.println(p.getPrimaryPrincipal());
	  System.out.println(p.getRealmNames());
	  System.out.println(p);
}
 
开发者ID:ushelp,项目名称:EasyEE,代码行数:23,代码来源:ShiroTest.java

示例3: checkPaybox

import org.apache.shiro.codec.Base64; //导入方法依赖的package包/类
/**
	 *
	 * @param signature
	 * 			La signature contenu dans l'url
	 * @param urlParam
	 * 			Liste des paramètres contenus dans l'url, privé du dernier : la signature
	 * @param pubKeyPath
	 * 			Le chemin de la clé publique Paybox
	 * @return
	 * @throws Exception
	 */
	public boolean checkPaybox(String signature, List<String> urlParam, String pubKeyPath) throws Exception {

    	String payboxParams = StringUtils.join(urlParam, "&");
    	log.debug("Liste des variables Paybox signées : {}",payboxParams);

//	 		Déjà décodée par le framework
//	     	String decoded = URLDecoder.decode(sign, this.CHARSET);

        byte[] sigBytes = Base64.decode(signature.getBytes(this.CHARSET));

        // lecture de la cle publique
        PublicKey pubKey = this.getPubKey(pubKeyPath);

        /**
         * Dans le cas où le clé est au format .der
         *
         * PublicKey pubKey = this.getPubKeyDer(pubKeyPath);
 		 */

        // verification signature
        return this.verify(payboxParams.getBytes(), sigBytes, this.HASH_ENCRYPTION_ALGORITHM, pubKey);

     }
 
开发者ID:axelor,项目名称:axelor-business-suite,代码行数:35,代码来源:PayboxService.java

示例4: getRememberedSerializedIdentity

import org.apache.shiro.codec.Base64; //导入方法依赖的package包/类
protected byte[] getRememberedSerializedIdentity(SubjectContext subjectContext) {
  RequestWrapper requestWrapper = getRequestWrapper(subjectContext);
  ResponseWrapper responseWrapper = getResponseWrapper(subjectContext);

  String base64 = getCookie().readValue(requestWrapper, responseWrapper);
  if (Cookie.DELETED_COOKIE_VALUE.equals(base64)) {
    return null;
  }

  if (base64 != null) {
    base64 = ensurePadding(base64);
    if (LOGGER.isTraceEnabled()) {
      LOGGER.trace("Acquired Base64 encoded identity [" + base64 + "]");
    }
    byte[] decoded = Base64.decode(base64);
    if (LOGGER.isTraceEnabled()) {
      LOGGER.trace("Base64 decoded byte array length: " + (decoded != null ? decoded.length : 0) + " bytes.");
    }
    return decoded;
  } else {
    //no cookie set - new site visitor?
    return null;
  }
}
 
开发者ID:orctom,项目名称:laputa,代码行数:25,代码来源:CookieRememberMeManager.java

示例5: getRememberedSerializedIdentity

import org.apache.shiro.codec.Base64; //导入方法依赖的package包/类
@Override
protected byte[] getRememberedSerializedIdentity(SubjectContext subjectContext) {
    if (isIdentityRemoved()) {
        return null;
    }

    Cookie cookie = Requests.getCookies().get(getCookie().getName());
    //no cookie set - new site visitor?
    if (cookie == null) return null;
    String base64 = cookie.getValue();
    if (Cookies.DELETED_COOKIE_VALUE.equals(base64)) return null;

    if (base64 != null) {
        base64 = ensurePadding(base64);
        logger.trace("Acquired Base64 encoded identity [" + base64 + "]");
        byte[] decoded = Base64.decode(base64);
        logger.trace("Base64 decoded byte array length: " + (decoded != null ? decoded.length : 0) + " bytes.");
        return decoded;
    } else {
        //no cookie set - new site visitor?
        return null;
    }
}
 
开发者ID:icode,项目名称:ameba-shiro,代码行数:24,代码来源:CookieRememberMeManager.java

示例6: getAccountByUsernameTest

import org.apache.shiro.codec.Base64; //导入方法依赖的package包/类
/**
 * This test checks if the admin user exists in an initial database created by liquibase scripts.
 *
 * <p>The test also checks functionality of {@link AccountRepositoryImpl#getAccountByUsername(String)}
 * method.
 *
 * <p>Admin user must be found.
 */
@Test
public void getAccountByUsernameTest() {
    AccountEntity account = accountRepository.getAccountByUsername(entityManager, ADMIN_USERNAME);

    // must be admin
    assertNotNull(account);
    assertNotNull(account.getId());
    assertEquals(ADMIN_USERNAME, account.getUsername());
    assertNotNull(account.getPassword());
    assertNotNull(account.getPasswordSalt());
    assertEquals(true, account.getIsCredentialsExpired());

    // check password
    byte[] salt = Base64.decode(account.getPasswordSalt());
    String hashedPasswordBase64 = new SimpleHash(PersistenceRealm.HASH_ALGORITHM, ADMIN_PASSWORD, salt, PersistenceRealm.HASH_ITERATIONS).toBase64();
    assertEquals(hashedPasswordBase64, account.getPassword());
}
 
开发者ID:panifex,项目名称:panifex-platform,代码行数:26,代码来源:AccountRepositoryImplTest.java

示例7: deserialize

import org.apache.shiro.codec.Base64; //导入方法依赖的package包/类
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);
    }
}
 
开发者ID:youngMen1,项目名称:-Spring-SpringMVC-Mybatis-,代码行数:13,代码来源:SerializableUtil.java

示例8: deserializeFromString

import org.apache.shiro.codec.Base64; //导入方法依赖的package包/类
public static <T> T deserializeFromString(String base64){
    try{
        byte[] objectData = Base64.decode(base64);
        return deserialize(objectData);
    } catch (Exception e){
        throw new ResultException("deserialize session error");
    }
}
 
开发者ID:ZhuXS,项目名称:Spring-Shiro-Spark,代码行数:9,代码来源:SerializeUtils.java

示例9: deserializeFromStrings

import org.apache.shiro.codec.Base64; //导入方法依赖的package包/类
public static <T> Collection<T> deserializeFromStrings(Collection<String> base64s){
    try{
        List<T> list = Lists.newLinkedList();
        for(String base64 : base64s){
            byte[] objectData = Base64.decode(base64);
            T t = deserialize(objectData);
            list.add(t);
        }
        return list;
    }catch (Exception e){
        throw new ResultException("deserialize session error");
    }
}
 
开发者ID:ZhuXS,项目名称:Spring-Shiro-Spark,代码行数:14,代码来源:SerializeUtils.java

示例10: SearchOptionEditor

import org.apache.shiro.codec.Base64; //导入方法依赖的package包/类
public SearchOptionEditor(String markupId) {
	super("searchOptions", markupId, AdvancedSearchPanel.this);
	
	WebRequest request = (WebRequest) RequestCycle.get().getRequest();
	Cookie cookie = request.getCookie(option.getClass().getName());
	if (cookie != null) {
		try {
			byte[] bytes = Base64.decode(cookie.getValue());
			option = (SearchOption) SerializationUtils.deserialize(bytes);
		} catch (Exception e) {
			logger.debug("Error restoring search option from cookie", e);
		}
	} 
}
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:15,代码来源:AdvancedSearchPanel.java

示例11: deserialize

import org.apache.shiro.codec.Base64; //导入方法依赖的package包/类
public static<T> T deserialize(String sessionStr,Class<T> clazz) {
    try {
        ByteArrayInputStream bis = new ByteArrayInputStream(Base64.decode(sessionStr));
        ObjectInputStream ois = new ObjectInputStream(bis);
        return ReflectionUtil.convertObjectToBean(ois.readObject(),clazz);
    } catch (Exception e) {
        throw new RuntimeException("deserialize session error", e);
    }
}
 
开发者ID:leiyong0326,项目名称:phone,代码行数:10,代码来源:SerializableUtils.java

示例12: toBytes

import org.apache.shiro.codec.Base64; //导入方法依赖的package包/类
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;
}
 
开发者ID:xuegongzi,项目名称:rabbitframework,代码行数:15,代码来源:ReflectionBuilder.java

示例13: doGetAuthenticationInfo

import org.apache.shiro.codec.Base64; //导入方法依赖的package包/类
@Override
protected SaltedAuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {
    String principal = (String) token.getPrincipal();

    return new SimpleAuthenticationInfo(principal, userService.getPassword(principal),
            new SimpleByteSource(Base64.decode(userService.getPasswordSalt(principal))), "JdbcSaltedRealm");
}
 
开发者ID:Zabrimus,项目名称:vdr-jonglisto,代码行数:8,代码来源:JdbcSaltedRealm.java

示例14: getRememberedSerializedIdentity

import org.apache.shiro.codec.Base64; //导入方法依赖的package包/类
/**
     * Returns a previously serialized identity byte array or {@code null} if the byte array could not be acquired.
     * This implementation retrieves an HTTP cookie, Base64-decodes the cookie value, and returns the resulting byte
     * array.
     * <p>
     * The {@code SubjectContext} instance is expected to be a {@link WebSubjectContext} instance with an HTTP
     * Request/Response pair so an HTTP cookie can be retrieved from the incoming request.  If it is not a
     * {@code WebSubjectContext} or that {@code WebSubjectContext} does not have an HTTP Request/Response pair, this
     * implementation returns {@code null}.
     *
     * @param subjectContext the contextual data, usually provided by a {@link Subject.Builder} implementation, that
     *                       is being used to construct a {@link Subject} instance.  To be used to assist with data
     *                       lookup.
     * @return a previously serialized identity byte array or {@code null} if the byte array could not be acquired.
     */
    @Override
    protected byte[] getRememberedSerializedIdentity(SubjectContext subjectContext) {
        // no need to check for HTTP-aware context - jawn is always in a web environment
        if (! (subjectContext instanceof ContextSource)) {
//            if (log.isDebugEnabled()) {
//                String msg = "SubjectContext argument is not an HTTP-aware instance.  This is required to obtain a " +
//                        "servlet request and response in order to retrieve the rememberMe cookie. Returning " +
//                        "immediately and ignoring rememberMe operation.";
//                log.debug(msg);
//            }
            return null;
        }
            
        Context context = ((ContextSource) subjectContext).getContext();
        
        if (context == null || isIdentityRemoved(context))
            return null;
        
        String base64 = readCookieValue(context);
        // Browsers do not always remove cookies immediately (SHIRO-183)
        // ignore cookies that are scheduled for removal
        // TODO not yet implemented
        //if (Cookie.DELETED_COOKIE_VALUE.equals(base64)) return null;
        
        if (base64 != null) {
            base64 = ensurePadding(base64);
//            if (log.isTraceEnabled()) {
//                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.");
//            }
            return decoded;
        } else {
            //no cookie set - new site visitor?
            return null;
        }
    }
 
开发者ID:MTDdk,项目名称:jawn,代码行数:55,代码来源:JawnRememberMeManager.java

示例15: doGetAuthenticationInfo

import org.apache.shiro.codec.Base64; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override
protected AuthenticationInfo doGetAuthenticationInfo(final AuthenticationToken authenticationToken) throws AuthenticationException {

    // DEBUG: Print Security configuration
    logger.debug("!!! CredentialsMatcher: {}", this.getCredentialsMatcher().toString());
    logger.debug("!!! HashAlgorithmName: {}", ((HashedCredentialsMatcher) getCredentialsMatcher()).getHashAlgorithmName());
    logger.debug("!!! HashIterations: {}", ((HashedCredentialsMatcher) getCredentialsMatcher()).getHashIterations());
    logger.debug("!!! StoredCredentialsHexEncoded: {}", ((HashedCredentialsMatcher) getCredentialsMatcher()).isStoredCredentialsHexEncoded());

    final UsernamePasswordToken usernamePasswordToken = (UsernamePasswordToken) authenticationToken;
    if (usernamePasswordToken.getUsername() == null || usernamePasswordToken.getUsername().isEmpty()) {
        throw new UnknownAccountException("Authentication failed");
    }

    // Find the thing that stores your user's credentials. This may be the
    // same or different than
    // the thing that stores the roles.
    final UserProfile principal = lookup(UserManagementService.class).findUserByLogin(usernamePasswordToken.getUsername());
    if (principal == null) {
        logger.info("Principal not found for user with username: {}", usernamePasswordToken.getUsername());
        return null;
    } else if (principal.isBlocked()) {
        logger.info("Access for user with username {} is forbidden", usernamePasswordToken.getUsername());
        throw new LockedAccountException();
    }

    logger.info("Principal found for authenticating user with username: {}", usernamePasswordToken.getUsername());

    final ByteSource hashedCredentials = new SimpleByteSource(Base64.decode(principal.getPassword()));
    final ByteSource credentialsSalt = new SimpleByteSource(Base64.decode(principal.getPasswordSalt()));
    final SimpleAuthenticationInfo authenticationInfo = new SimpleAuthenticationInfo(
            principal.getLogin(),
            hashedCredentials,
            credentialsSalt,
            getName());
    return authenticationInfo;
}
 
开发者ID:ExtaSoft,项目名称:extacrm,代码行数:39,代码来源:UserRealm.java


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