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


Java Base64.decodeBase64方法代码示例

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


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

示例1: lookupRouterMessage

import org.apache.commons.codec.binary.Base64; //导入方法依赖的package包/类
public ConsulRouterResp lookupRouterMessage(String serviceName, long lastConsulIndex) {
    QueryParams queryParams = new QueryParams(ConsulConstants.CONSUL_BLOCK_TIME_SECONDS, lastConsulIndex);
    Response<GetValue> orgResponse = client.getKVValue(serviceName, queryParams);
    GetValue getValue = orgResponse.getValue();
    if (getValue != null && StringUtils.isNoneBlank(getValue.getValue())) {
        String router = new String(Base64.decodeBase64(getValue.getValue()));
        ConsulRouterResp response = ConsulRouterResp.newResponse()//
                                                    .withValue(router)//
                                                    .withConsulIndex(orgResponse.getConsulIndex())//
                                                    .withConsulLastContact(orgResponse.getConsulLastContact())//
                                                    .withConsulKnowLeader(orgResponse.isConsulKnownLeader())//
                                                    .build();
        return response;
    }
    return null;
}
 
开发者ID:venus-boot,项目名称:saluki,代码行数:17,代码来源:ConsulClient.java

示例2: verify

import org.apache.commons.codec.binary.Base64; //导入方法依赖的package包/类
@Override
public void verify(DecodedJWT jwt, EncodeType encodeType) throws Exception {
    byte[] signatureBytes = null;
    String signature = jwt.getSignature();
    String urlDecoded = null;
    switch (encodeType) {
        case Base16:
            urlDecoded = URLDecoder.decode(signature, "UTF-8");
            signatureBytes = Hex.decodeHex(urlDecoded);
            break;
        case Base32:
            Base32 base32 = new Base32();
            urlDecoded = URLDecoder.decode(signature, "UTF-8");
            signatureBytes = base32.decode(urlDecoded);
            break;
        case Base64:
            signatureBytes = Base64.decodeBase64(signature);
            break;
    }
    if (signatureBytes.length > 0) {
        throw new SignatureVerificationException(this);
    }
}
 
开发者ID:GJWT,项目名称:javaOIDCMsg,代码行数:24,代码来源:NoneAlgorithm.java

示例3: setEncryptedByJS

import org.apache.commons.codec.binary.Base64; //导入方法依赖的package包/类
@Action(object = ObjectType.SELENIUM, desc = "Set encrypted data on [<Object>]", input=InputType.YES)
public void setEncryptedByJS() {
    if (Data != null && Data.matches(".* Enc")) {
        if (elementEnabled()) {
            try {
                Data = Data.substring(0, Data.lastIndexOf(" Enc"));
                byte[] valueDecoded = Base64.decodeBase64(Data);
                JavascriptExecutor js = (JavascriptExecutor) Driver;
                js.executeScript("arguments[0].value='" + new String(valueDecoded) + "'", Element);
                Report.updateTestLog(Action, "Entered Text '" + Data + "' on '" + ObjectName + "'", Status.DONE);
            } catch (Exception ex) {
                Report.updateTestLog(Action, ex.getMessage(), Status.FAIL);
                Logger.getLogger(JSCommands.class.getName()).log(Level.SEVERE, null, ex);
            }
        } else {
            throw new ElementException(ElementException.ExceptionType.Element_Not_Enabled, ObjectName);
        }
    } else {
        Report.updateTestLog(Action, "Data not encrypted '" + Data + "'", Status.DEBUG);
    }
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:22,代码来源:JSCommands.java

示例4: setConfigurationXML64

import org.apache.commons.codec.binary.Base64; //导入方法依赖的package包/类
/**
 * Sets the configuration in XML in a Base64 decode form.
 * @param configurationXML64 the new configuration xm l64
 */
public void setConfigurationXML64(String[] configurationXML64) {
	
	String[] configXML = new String[configurationXML64.length];
	for (int i = 0; i < configurationXML64.length; i++) {
		try {
			if (configurationXML64[i]==null || configurationXML64[i].equals("")) {
				configXML[i] = null;
			} else {
				configXML[i] = new String(Base64.decodeBase64(configurationXML64[i].getBytes()), "UTF8");	
			}
			
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		}
	}
	
	this.getDynForm().setOntoArgsXML(configXML);
	this.getDynTableJPanel().refreshTableModel();
	if (this.getSelectedIndex()==1) {
		this.setXMLText();
	}
	
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:28,代码来源:OntologyInstanceViewer.java

示例5: decrypt

import org.apache.commons.codec.binary.Base64; //导入方法依赖的package包/类
private String decrypt(String text) throws GeneralSecurityException {
    SecretKeySpec skeySpec = new SecretKeySpec(
            Base64.decodeBase64(ENCRYPTION_KEY), "AES");

    byte[] result;
    try {
        byte[] decoded = Base64.decodeBase64(text.getBytes());
        Cipher cipher = Cipher.getInstance("AES");
        cipher.init(Cipher.DECRYPT_MODE, skeySpec);
        result = cipher.doFinal(decoded);
    } catch (InvalidKeyException | NoSuchAlgorithmException
            | NoSuchPaddingException | IllegalBlockSizeException
            | BadPaddingException e) {
        throw new GeneralSecurityException(
                "unable to decrypt old encryption");
    }

    return new String(result);
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:20,代码来源:PasswordSetup.java

示例6: decrypt

import org.apache.commons.codec.binary.Base64; //导入方法依赖的package包/类
/**
 * Decrypts a given byte array.
 *
 * @param encrypted
 *            the encrypted
 *
 * @return the byte array
 */
public static byte[] decrypt(byte[] encrypted)
        throws GeneralSecurityException {

    SecretKeySpec skeySpec = new SecretKeySpec(
            Base64.decodeBase64(ENCRYPTION_KEY), "AES");

    byte[] decoded = Base64.decodeBase64(encrypted);
    Cipher cipher = Cipher.getInstance("AES");
    cipher.init(Cipher.DECRYPT_MODE, skeySpec);
    return cipher.doFinal(decoded);
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:20,代码来源:AESEncrypterCtmg.java

示例7: bucketFromBase64URN

import org.apache.commons.codec.binary.Base64; //导入方法依赖的package包/类
/**
 * Extracts the Bucket key from a Forge service Model URN.
 * It is possible the viewable is stored somewhere other than the Forge service in
 * which case there is no Bucket Key
 * @return Bucket key or ""
 */
public static String bucketFromBase64URN(
	String base64URN
) {
	String modelURN = "";
	if( base64URN.toLowerCase().startsWith( "urn:" ) )
	{
		base64URN = base64URN.substring( 4 ).trim();
	}
	modelURN = new String( Base64.decodeBase64( base64URN.getBytes() ) );
	return bucketFromModelURN( modelURN );
}
 
开发者ID:IBM,项目名称:MaximoForgeViewerPlugin,代码行数:18,代码来源:DataRESTAPI.java

示例8: encrypt

import org.apache.commons.codec.binary.Base64; //导入方法依赖的package包/类
/**
 * Encrypts a given byte array based on a shared secret.
 *
 * @param bytes
 * @return the encrypted bytes as Base64
 * @throws GeneralSecurityException
 *             on any problem during encryption
 */
public static byte[] encrypt(byte[] bytes) throws GeneralSecurityException {

    SecretKeySpec skeySpec = new SecretKeySpec(
            Base64.decodeBase64(ENCRYPTION_KEY), "AES");

    Cipher cipher = Cipher.getInstance("AES");
    cipher.init(Cipher.ENCRYPT_MODE, skeySpec);

    byte[] encrypted = cipher.doFinal(bytes);
    return Base64.encodeBase64(encrypted);
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:20,代码来源:AESEncrypter.java

示例9: WXBizMsgCrypt

import org.apache.commons.codec.binary.Base64; //导入方法依赖的package包/类
/**
 * 构造函数
 * @param token 公众平台上,开发者设置的token
 * @param encodingAesKey 公众平台上,开发者设置的EncodingAESKey
 * @param corpId 企业的corpid
 * 
 * @throws AesException 执行失败,请查看该异常的错误码和具体的错误信息
 */
public WXBizMsgCrypt(String token, String encodingAesKey, String corpId) throws AesException {
	if (encodingAesKey.length() != 43) {
		throw new AesException(AesException.IllegalAesKey);
	}

	this.token = token;
	this.corpId = corpId;
	aesKey = Base64.decodeBase64(encodingAesKey + "=");
}
 
开发者ID:guokezheng,项目名称:automat,代码行数:18,代码来源:WXBizMsgCrypt.java

示例10: writeFile

import org.apache.commons.codec.binary.Base64; //导入方法依赖的package包/类
protected void writeFile(String filePath, NodeList nodeList) throws EngineException {
	if (nodeList == null) {
		throw new EngineException("Unable to write to xml file: element is Null");
	}
	
	String fullPathName = getAbsoluteFilePath(filePath);
	ComputedFilePath = fullPathName;
	synchronized (Engine.theApp.filePropertyManager.getMutex(fullPathName)) {
		try {
			for (Node node : XMLUtils.toNodeArray(nodeList)) {
				try {
					String content = node instanceof Element ? ((Element) node).getTextContent() : node.getNodeValue();
					if (content != null && content.length() > 0) {
						byte[] bytes = Base64.decodeBase64(content);
						if (bytes != null && bytes.length > 0) {
							FileUtils.writeByteArrayToFile(new File(fullPathName), bytes);
							return;
						}
					}
				} catch (Exception e) {
					Engine.logBeans.info("(WriteBase64Step) Failed to decode and write base64 content : " + e.getClass().getCanonicalName());
				}
			}
		} finally {
			Engine.theApp.filePropertyManager.releaseMutex(fullPathName);
		}
	}
}
 
开发者ID:convertigo,项目名称:convertigo-engine,代码行数:29,代码来源:WriteBase64Step.java

示例11: shouldAddHeaderClaim

import org.apache.commons.codec.binary.Base64; //导入方法依赖的package包/类
@SuppressWarnings("Convert2Diamond")
@Test
public void shouldAddHeaderClaim() throws Exception {
    Map<String, Object> header = new HashMap<String, Object>();
    header.put("asd", 123);
    String signed = JWTCreator.init()
            .withHeader(header)
            .sign(Algorithm.HMAC256("secret"));

    assertThat(signed, is(notNullValue()));
    String[] parts = signed.split("\\.");
    String headerJson = new String(Base64.decodeBase64(parts[0]), StandardCharsets.UTF_8);
    assertThat(headerJson, JsonMatcher.hasEntry("asd", 123));
}
 
开发者ID:GJWT,项目名称:javaOIDCMsg,代码行数:15,代码来源:JWTCreatorTest.java

示例12: decodeBase64ToByteArray

import org.apache.commons.codec.binary.Base64; //导入方法依赖的package包/类
/**
 * Decode the byte[] in base64.
 *
 * @param data the data to encode
 * @return the base64 decoded byte[] or null
 */
public static byte[] decodeBase64ToByteArray(final byte[] data) {
    try {
        return Base64.decodeBase64(data);
    } catch (final Exception e) {
        LOGGER.error("Base64 decoding failed", e);
        return null;
    }
}
 
开发者ID:yuweijun,项目名称:cas-server-4.2.1,代码行数:15,代码来源:CompressionUtils.java

示例13: base64StringToBytes

import org.apache.commons.codec.binary.Base64; //导入方法依赖的package包/类
public static byte[] base64StringToBytes(String string) {
    try {
        return Base64.decodeBase64(string.getBytes("UTF-8"));
    } catch (UnsupportedEncodingException e) {
        throw new NestableRuntimeException(e);
    }
}
 
开发者ID:luoyaogui,项目名称:otter-G,代码行数:8,代码来源:ByteUtils.java

示例14: decodeBase64

import org.apache.commons.codec.binary.Base64; //导入方法依赖的package包/类
public static String decodeBase64(String base64String, String encoding) throws UnsupportedEncodingException {
    if (StringUtils.isEmpty(base64String)) {
        return null;
    }
    byte[] decodeArray = Base64.decodeBase64(base64String);
    return new String(decodeArray, encoding);
}
 
开发者ID:tong12580,项目名称:OutsourcedProject,代码行数:8,代码来源:Base64Util.java

示例15: SyncCall

import org.apache.commons.codec.binary.Base64; //导入方法依赖的package包/类
@Override
public byte[] SyncCall(byte[] res) throws IOException {
    String rpcData = Base64.encodeBase64String(res);
    String requestResponse = CupidRequestProxy.getInstance().cupidRequestRPC(rpcData, odps, lookupName);
    return Base64.decodeBase64(requestResponse);
}
 
开发者ID:aliyun,项目名称:aliyun-cupid-sdk,代码行数:7,代码来源:CupidHttpRpcChannelProxy.java


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