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