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


Java Base64.isBase64方法代码示例

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


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

示例1: base64DecodeString

import org.apache.commons.codec.binary.Base64; //导入方法依赖的package包/类
public static String base64DecodeString(String string) {
	String base64String = string;
	if (StringUtils.isNotEmpty(string)) {
		if (Base64.isBase64(string)) {
			try {
				base64String = new String(Base64.decodeBase64(string), "UTF-8");
			} catch (UnsupportedEncodingException e) {
				logger.debug(e);
			}
		}
	}
	if (isMessyCode(base64String)) {
		logger.debug("侦测到base64解码后乱码,返回原始信息");
		base64String = string;
	}
	return base64String;
}
 
开发者ID:cnldw,项目名称:APITools,代码行数:18,代码来源:PubUtils.java

示例2: configureUsernameAttributeProvider

import org.apache.commons.codec.binary.Base64; //导入方法依赖的package包/类
/**
 * Configure username attribute provider.
 *
 * @param provider the provider
 * @param uBean the u bean
 */
private static void configureUsernameAttributeProvider(final RegisteredServiceUsernameAttributeProvider provider,
                                                       final RegisteredServiceUsernameAttributeProviderEditBean uBean) {
    if (provider instanceof DefaultRegisteredServiceUsernameProvider) {
        uBean.setType(RegisteredServiceUsernameAttributeProviderEditBean.Types.DEFAULT.toString());
    } else if (provider instanceof AnonymousRegisteredServiceUsernameAttributeProvider) {
        final AnonymousRegisteredServiceUsernameAttributeProvider anonymous =
                (AnonymousRegisteredServiceUsernameAttributeProvider) provider;
        uBean.setType(RegisteredServiceUsernameAttributeProviderEditBean.Types.ANONYMOUS.toString());
        final PersistentIdGenerator generator = anonymous.getPersistentIdGenerator();
        if (generator instanceof ShibbolethCompatiblePersistentIdGenerator) {
            final ShibbolethCompatiblePersistentIdGenerator sh =
                    (ShibbolethCompatiblePersistentIdGenerator) generator;

            String salt = new String(sh.getSalt(), Charset.defaultCharset());
            if (Base64.isBase64(salt)) {
                salt = new String(Base64.decodeBase64(salt));
            }

            uBean.setValue(salt);
        }
    } else if (provider instanceof PrincipalAttributeRegisteredServiceUsernameProvider) {
        final PrincipalAttributeRegisteredServiceUsernameProvider p =
                (PrincipalAttributeRegisteredServiceUsernameProvider) provider;
        uBean.setType(RegisteredServiceUsernameAttributeProviderEditBean.Types.ATTRIBUTE.toString());
        uBean.setValue(p.getUsernameAttribute());
    }
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:34,代码来源:RegisteredServiceEditBean.java

示例3: viewableDownload

import org.apache.commons.codec.binary.Base64; //导入方法依赖的package包/类
public Result viewableDownload(
	String derivitiveURN,
	String dirName
) 	
	throws IOException, 
		   URISyntaxException 
{
	String urn;
	String base64urn;
	if( Base64.isBase64(derivitiveURN) )
	{
		urn       = new String( Base64.decodeBase64( derivitiveURN ) );
		base64urn = derivitiveURN;
	}
	else
	{
		urn       = derivitiveURN;
		base64urn = new String( Base64.encodeBase64URLSafe( derivitiveURN.getBytes() ));
	}
	
	ResultViewerService result = _service.viewableQuery( urn );
	if( result.isError() )
	{
		return result;
	}

	List<String> files = new LinkedList<String>();
	result.listDerivativeFiles( files );
	
	Iterator<String> itr = files.iterator();
	while( itr.hasNext() )
	{
		String fileName = itr.next();
		Result dr = _service.viewableDownload( base64urn, dirName, fileName );
		if( dr.isError() )
		{
			System.out.println( dr.toString() );
		}
		else
		{
			System.out.println( dirName + "/" + fileName );;
		}
	}

	return result;
}
 
开发者ID:IBM,项目名称:MaximoForgeViewerPlugin,代码行数:47,代码来源:ViewableDownloadBubble.java

示例4: securityOperation

import org.apache.commons.codec.binary.Base64; //导入方法依赖的package包/类
private void securityOperation(String filePath, boolean cover, SecurityOperation operation) throws Exception {
    File file = FileUtils.getFile(filePath);
    Collection<File> files;
    if (file.exists()) {
        if (file.isDirectory()) {
            files = FileUtils.listFiles(file, LEGAL_EXTENSION, true);
        } else if (file.isFile()) {
            files = Collections.singletonList(file);
        } else {
            System.err.println("Invalid file or directory");
            return;
        }
    } else {
        System.err.println("Current os is " + SystemUtils.OS_NAME + " and " + filePath + " not exists");
        return;
    }
    for (File f : files) {
        String fileContent = FileUtils.readFileToString(f, StandardCharsets.UTF_8);
        final boolean isBase64 = Base64.isBase64(fileContent);
        // 防止一个文件多次被编码
        if (isBase64 && operation == SecurityOperation.ENCODE) {
            System.out.println(f.getName() + "是Base64编码,忽略加密操作...");
        } else if (!isBase64 && operation == SecurityOperation.DECODE) {
            System.out.println(f.getName() + "是明文文件,忽略解密操作...");
        } else {
            String transformString;
            switch (operation) {
                case DECODE:
                    transformString = decode(fileContent);
                    break;
                case ENCODE:
                    transformString = encode(fileContent);
                    break;
                default:
                    System.err.println("not have this security operation");
                    return;
            }
            if (cover) {
                FileUtils.writeStringToFile(f, transformString, StandardCharsets.UTF_8);
                System.out.println(f.getPath() + " 操作完成");
            } else {
                String bakFilePath = f.getAbsolutePath() + ".bak";
                File bakFile = FileUtils.getFile(bakFilePath);
                FileUtils.writeStringToFile(bakFile, transformString, StandardCharsets.UTF_8);
                System.out.println("创建" + bakFile.getPath() + " 操作完成");
            }
        }
    }
}
 
开发者ID:runhwguo,项目名称:GeneratePasswordWithOneKey,代码行数:50,代码来源:Util.java

示例5: decodeBase64

import org.apache.commons.codec.binary.Base64; //导入方法依赖的package包/类
public static String decodeBase64(String base64String) {
	if (base64String != null && base64String.length() > 0 && Base64.isBase64(base64String)) {
		try {
			return new String(Base64.decodeBase64(base64String), BASE64_CHARSET);
		} catch (UnsupportedEncodingException e) {
		}
	}
	return "";
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:10,代码来源:JsUtil.java

示例6: getSignatureValue

import org.apache.commons.codec.binary.Base64; //导入方法依赖的package包/类
public byte[] getSignatureValue() {
  if (!Base64.isBase64(signatureValueInBase64)) {
    throw new TechnicalErrorException("Failed to parse signature value in base64. Probably incorrectly encoded base64 string: '" + signatureValueInBase64);
  }
  return Base64.decodeBase64(signatureValueInBase64);
}
 
开发者ID:SK-EID,项目名称:smart-id-java-client,代码行数:7,代码来源:SmartIdAuthenticationResponse.java

示例7: getValue

import org.apache.commons.codec.binary.Base64; //导入方法依赖的package包/类
public byte[] getValue() {
  if (!Base64.isBase64(valueInBase64)) {
    throw new TechnicalErrorException("Failed to parse signature value in base64. Probably incorrectly encoded base64 string: '" + valueInBase64);
  }
  return Base64.decodeBase64(valueInBase64);
}
 
开发者ID:SK-EID,项目名称:smart-id-java-client,代码行数:7,代码来源:SmartIdSignature.java


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