本文整理汇总了Java中net.iharder.Base64.decode方法的典型用法代码示例。如果您正苦于以下问题:Java Base64.decode方法的具体用法?Java Base64.decode怎么用?Java Base64.decode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.iharder.Base64
的用法示例。
在下文中一共展示了Base64.decode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deserialize
import net.iharder.Base64; //导入方法依赖的package包/类
@BotCommandHandler
private void deserialize(Message message, String content) throws IOException {
outputChannel.set((TextChannel) message.getChannel());
connectToFirstVoiceChannel(guild.getAudioManager());
byte[] bytes = Base64.decode(content);
MessageInput inputStream = new MessageInput(new ByteArrayInputStream(bytes));
DecodedTrackHolder holder;
while ((holder = manager.decodeTrack(inputStream)) != null) {
if (holder.decodedTrack != null) {
scheduler.addToQueue(holder.decodedTrack);
}
}
}
示例2: verify
import net.iharder.Base64; //导入方法依赖的package包/类
/**
* 校验传入的plaintextbyte数组,与原加签的字符串验证运算是否验证通过.
*
* @param pubKeyBytes 公钥
* @param plainText 待验证的字符串
* @param signText 通过私钥数字签名后的密文(Base64编码)
* @return true:验证通过 false:验证失败
*/
private static boolean verify(byte[] pubKeyBytes, String signText, String plainText) {
try {
// 取公钥匙对象
PublicKey pubKey = RsaUtil.getPublicKey(pubKeyBytes);
// 解密由base64编码的数字签名
byte[] signed = Base64.decode(signText);
Signature signatureChecker = Signature.getInstance("MD5withRSA");
signatureChecker.initVerify(pubKey);
signatureChecker.update(plainText.getBytes());
// 验证签名是否正常
return signatureChecker.verify(signed);
} catch (Exception e) {
throw new BaseSecurityException("E-BASE-SECURITY-000002").initCause(e);
}
}
示例3: decryptValue
import net.iharder.Base64; //导入方法依赖的package包/类
private static String decryptValue( final String value, final String key )
{
try
{
if ( value == null || value.length() < 1 )
{
return "";
}
final SecretKey secretKey = makeKey( key );
final byte[] decoded = Base64.decode( value, Base64.URL_SAFE | Base64.GZIP );
final Cipher cipher = Cipher.getInstance( "AES" );
cipher.init( Cipher.DECRYPT_MODE, secretKey );
final byte[] decrypted = cipher.doFinal( decoded );
return new String( decrypted );
}
catch ( Exception e )
{
final String errorMsg = "unexpected error performing helpdesk answer decrypt operation: " + e.getMessage();
throw new IllegalArgumentException( errorMsg );
}
}
示例4: testCDataNodes
import net.iharder.Base64; //导入方法依赖的package包/类
public void testCDataNodes() throws Exception {
String text = "Text data -- left as it is";
String textForBytes = "Byte data is automatically base64-encoded";
String textEncoded = Base64.encodeBytes(textForBytes.getBytes("UTF-8"));
BaseXMLBuilder builder = XMLBuilder_create("TestCDataNodes")
.elem("CDataTextElem")
.cdata(text)
.up()
.elem("CDataBytesElem")
.cdata(textForBytes.getBytes("UTF-8"));
Node cdataTextNode = builder.xpathFind("//CDataTextElem")
.getElement().getChildNodes().item(0);
assertEquals(Node.CDATA_SECTION_NODE, cdataTextNode.getNodeType());
assertEquals(text, cdataTextNode.getNodeValue());
Node cdataBytesNode = builder.xpathFind("//CDataBytesElem")
.getElement().getChildNodes().item(0);
assertEquals(Node.CDATA_SECTION_NODE, cdataBytesNode.getNodeType());
assertEquals(textEncoded, cdataBytesNode.getNodeValue());
String base64Decoded = new String(Base64.decode(cdataBytesNode.getNodeValue()));
assertEquals(textForBytes, base64Decoded);
}
示例5: parse
import net.iharder.Base64; //导入方法依赖的package包/类
public static Base64Value parse(String value) throws PersistenceException {
try {
return new Base64Value(Base64.decode(value));
} catch (IOException e) {
throw new PersistenceException("Cannot Base64-decode: " + value);
}
}
示例6: decodeBase64
import net.iharder.Base64; //导入方法依赖的package包/类
@Override
public byte[] decodeBase64(byte[] data) {
try {
return Base64.decode(data);
} catch (IOException ex) {
ex.printStackTrace();
}
return null;
}
示例7: readPrivateKey
import net.iharder.Base64; //导入方法依赖的package包/类
/**
* Read the private key from the file
*
* @param is
* the InputStream for the key file
* @return the PrivateKey
*/
@SneakyThrows
public static PrivateKey readPrivateKey(InputStream is) {
byte[] keyBytes = Base64.decode(IoUtils.readBytes(is));
PKCS8EncodedKeySpec spec = new PKCS8EncodedKeySpec(keyBytes);
KeyFactory kf = KeyFactory.getInstance(RSA_ALGORITHM);
return kf.generatePrivate(spec);
}
示例8: readPublicKey
import net.iharder.Base64; //导入方法依赖的package包/类
/**
* Read the public key from the file
*
* @param is
* the InputStream for the key file
* @return the PublicKey
*/
@SneakyThrows
public static PublicKey readPublicKey(InputStream is) {
byte[] keyBytes = Base64.decode(IoUtils.readBytes(is));
X509EncodedKeySpec spec = new X509EncodedKeySpec(keyBytes);
KeyFactory kf = KeyFactory.getInstance(RSA_ALGORITHM);
return kf.generatePublic(spec);
}
示例9: decode
import net.iharder.Base64; //导入方法依赖的package包/类
public byte[] decode( String data )
{
byte[] dataBytes = null;
if ( data != null && !data.isEmpty() )
try { dataBytes = Base64.decode( data ); }
catch ( Exception ex )
{
logger.error("Failed to decode byte data: " + ex.getMessage(), ex);
}
return dataBytes;
}
示例10: getByteArrayProperty
import net.iharder.Base64; //导入方法依赖的package包/类
private byte[] getByteArrayProperty(ObjectNode node, String property) {
try {
String string = JsonUtil.getString(node, property, null);
if (string == null)
return null;
return Base64.decode(string);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
示例11: getId
import net.iharder.Base64; //导入方法依赖的package包/类
@Override
protected I getId(JSONObject vertexObject) throws IOException {
try {
byte[] decodedWritable = Base64.decode(
vertexObject.getString(JsonBase64VertexFormat.VERTEX_ID_KEY));
DataInput input = new DataInputStream(
new ByteArrayInputStream(decodedWritable));
I vertexId = getConf().createVertexId();
vertexId.readFields(input);
return vertexId;
} catch (JSONException e) {
throw new IllegalArgumentException(
"next: Failed to get vertex id", e);
}
}
示例12: getValue
import net.iharder.Base64; //导入方法依赖的package包/类
@Override
protected V getValue(JSONObject vertexObject) throws IOException {
try {
byte[] decodedWritable = Base64.decode(
vertexObject.getString(JsonBase64VertexFormat.VERTEX_VALUE_KEY));
DataInputStream input = new DataInputStream(
new ByteArrayInputStream(decodedWritable));
V vertexValue = getConf().createVertexValue();
vertexValue.readFields(input);
return vertexValue;
} catch (JSONException e) {
throw new IllegalArgumentException(
"next: Failed to get vertex value", e);
}
}
示例13: base64decode
import net.iharder.Base64; //导入方法依赖的package包/类
@Nonnull
public static byte [] base64decode(@Nonnull final String text) throws IOException {
return Base64.decode(text);
}
示例14: initialize
import net.iharder.Base64; //导入方法依赖的package包/类
/**
* Initialize the Content Management System Interface
*/
@PostConstruct
public void initialize() {
this.geoCodingEnabled = StringUtils.toBoolean(this.geoCodingEnabledStringValue, false);
if (this.geoCodingEnabled) {
log.info("Activating GeoCoding Service Provider Interface - Google Maps Rest Services Implementation.");
log.info("Configured Allowed Requests Per Day:[" +
((this.geoCodingServiceProviderAllowedRequestsPerDay != null) &&
(this.geoCodingServiceProviderAllowedRequestsPerDay > 0) ?
this.geoCodingServiceProviderAllowedRequestsPerDay :
"OFF")
+ "]");
log.info("Configured Allowed Requests Per Second:[" +
((this.geoCodingServiceProviderAllowedRequestsPerSecond != null) &&
(this.geoCodingServiceProviderAllowedRequestsPerSecond > 0) ?
this.geoCodingServiceProviderAllowedRequestsPerSecond :
"OFF")
+ "]");
log.info("Configured Throttle Wait:[" +
((this.geoCodingServiceProviderThrottleSecondsWaitPerRequest != null) &&
(this.geoCodingServiceProviderThrottleSecondsWaitPerRequest > 0) ?
this.geoCodingServiceProviderThrottleSecondsWaitPerRequest + " seconds" :
"OFF")
+ "]");
// Determine if I have a Signature or Not.
if (StringUtils.isNotEmpty(this.geoCodingServiceProviderClientSignature)) {
// Convert the key from 'web safe' base 64 to binary
String keyString = this.geoCodingServiceProviderClientSignature.replace('-', '+');
keyString = keyString.replace('_', '/');
try {
this.binaryClientSignature = Base64.decode(keyString);
} catch (IOException ioe) {
log.error("Base64 decoding Exception occurred for Client Signature, removing Client Information so GMap Requests will not be Signed!");
this.geoCodingServiceProviderClientSignature = null;
this.geoCodingServiceProviderClientId = null;
}
} else {
log.warn("No Client Signature Supplied, GMap Requests will not be Signed!");
}
// ***********************************************
// Now Prepare Internal Cache for all Geo
// Queries
//
// TODO - Have Geo Coding service Provider use Memcached as Internal cache for Queries.
//
// Initialized.
this.initialized = true;
} else {
log.info("GeoCoding Service Provider Interface has been Disabled.");
this.initialized = false;
}
}
示例15: decodeStringWithBase64
import net.iharder.Base64; //导入方法依赖的package包/类
/** Returns a string decoded from a base64 encoded string
* @param stringToBeDecoded the string to be decoded with base64
* @return the string which is decoded using base64, or null if an error occurs!
* @throws IOException */
public static String decodeStringWithBase64(String stringToBeDecoded) throws IOException {
byte[] decodedBytes = Base64.decode(stringToBeDecoded);
return new String(decodedBytes);
}