/** * Converts a Base64-encoded string to the original byte data. * * @param b64Data * a Base64-encoded string to decode. * * @return bytes decoded from a Base64 string. */ public static byte[] fromBase64(String b64Data) { return b64Data == null ? null : Base64.decode(b64Data); }
@Override public byte[] decode(String encoded) { return Base64.decode(encoded); } },
public ByteBuffer unmarshall(StaxUnmarshallerContext unmarshallerContext) throws Exception { String base64EncodedString = unmarshallerContext.readText(); byte[] decodedBytes = Base64.decode(base64EncodedString); return ByteBuffer.wrap(decodedBytes); }
public ByteBuffer unmarshall(JsonUnmarshallerContext unmarshallerContext) throws Exception { String base64EncodedString = unmarshallerContext.readText(); if (base64EncodedString == null) { return null; } byte[] decodedBytes = Base64.decode(base64EncodedString); return ByteBuffer.wrap(decodedBytes); }
public String unmarshall(JsonUnmarshallerContext unmarshallerContext) throws Exception { String stringValue = super.unmarshall(unmarshallerContext); return !unmarshallerContext.isInsideResponseHeader() ? stringValue : new String(Base64.decode(stringValue), Charset.forName("utf-8")); }
/** * Does the actual Java cryptographic verification of the signature. This * method does no handling of the many rare exceptions it is required to * catch. * * This can also be used to verify the signature from the x-amz-sns-signature http header * * @param message * Exact string that was signed. In the case of the x-amz-sns-signature header the * signing string is the entire post body * @param signature * Base64-encoded signature of the message * @return */ public boolean verifySignature(String message, String signature, PublicKey publicKey){ boolean result = false; try { byte[] sigbytes = Base64.decode(signature.getBytes()); Signature sigChecker = SIG_CHECKER.get(); sigChecker.initVerify(publicKey); sigChecker.update(message.getBytes()); result = sigChecker.verify(sigbytes); } catch (InvalidKeyException e) { // Rare exception: The private key was incorrectly formatted } catch (SignatureException e) { // Rare exception: Catch-all exception for the signature checker } return result; }
if (line.indexOf(endMarker) != -1) { new PEMObject(beginMarker, Base64.decode(sb .toString()))); readingContent = false;
/** * Same as {@link #asByteBuffer(String, Node)} but allows an xpath to be * passed in explicitly for reuse. */ public static ByteBuffer asByteBuffer(String expression, Node node, XPath xpath) throws XPathExpressionException { String base64EncodedString = evaluateAsString(expression, node, xpath); if (isEmptyString(base64EncodedString)) return null; if (!isEmpty(node)) { byte[] decodedBytes = Base64.decode(base64EncodedString); return ByteBuffer.wrap(decodedBytes); } return null; }
/** * Process the result of invoking a remote function. If the response includes server-side * logs, dump them into our logs; if it includes a server-side error indication, parse it * into a corresponding {@code Exception} type, otherwise parse the result payload into a * Java object suitable for returning from this method. */ private Object processInvokeResult(Method method, InvokeResult invokeResult) throws Throwable { if (invokeResult.getLogResult() != null && log.isInfoEnabled()) { try { String decoded = new String(Base64.decode(invokeResult.getLogResult()), StringUtils.UTF8); log.info(method.getName() + " log:\n\t" + decoded.replaceAll("\n", "\n\t")); } catch (Exception ex) { log.warn("Error decoding log result '" + invokeResult.getLogResult() + "'", ex); } } String functionError = invokeResult.getFunctionError(); if (functionError == null) { // Success. return getObjectFromPayload(method, invokeResult); } else { throw getExceptionFromPayload(method, invokeResult); } }
if (String.class == getTypeOf(attrName)) { String b64 = getString(attrName); Base64.decode(b64); } else { Set<String> b64s = getStringSet(attrName); for (String b64: b64s) Base64.decode(b64); if (String.class == getTypeOf(attrName)) { String b64 = getString(attrName); byte[] bytes = Base64.decode(b64); withBinary(attrName, bytes); } else { Set<byte[]> binarySet = new LinkedHashSet<byte[]>(b64s.size()); for (String b64: b64s) binarySet.add(Base64.decode(b64)); withBinarySet(attrName, binarySet);
@Override public byte[] decode(String encoded) { return Base64.decode(encoded); } };
/** * Converts a Base64-encoded string to the original byte data. * * @param b64Data * a Base64-encoded string to decode. * * @return bytes decoded from a Base64 string. */ public static byte[] fromBase64(String b64Data) { return b64Data == null ? null : Base64.decode(b64Data); }
private static void populateSourceSSE_C(Request<?> request, SSECustomerKey sseKey) { if (sseKey == null) return; // Populate the SSE-C parameters for the source object addHeaderIfNotNull(request, Headers.COPY_SOURCE_SERVER_SIDE_ENCRYPTION_CUSTOMER_ALGORITHM, sseKey.getAlgorithm()); addHeaderIfNotNull(request, Headers.COPY_SOURCE_SERVER_SIDE_ENCRYPTION_CUSTOMER_KEY, sseKey.getKey()); addHeaderIfNotNull(request, Headers.COPY_SOURCE_SERVER_SIDE_ENCRYPTION_CUSTOMER_KEY_MD5, sseKey.getMd5()); // Calculate the MD5 hash of the encryption key and fill it in the // header, if the user didn't specify it in the metadata if (sseKey.getKey() != null && sseKey.getMd5() == null) { String encryptionKey_b64 = sseKey.getKey(); byte[] encryptionKey = Base64.decode(encryptionKey_b64); request.addHeader(Headers.COPY_SOURCE_SERVER_SIDE_ENCRYPTION_CUSTOMER_KEY_MD5, Md5Utils.md5AsBase64(encryptionKey)); } }
flowFile = session.putAttribute(flowFile, AWS_LAMBDA_RESULT_LOG, new String(Base64.decode(result.getLogResult()),Charset.defaultCharset()));
&& sseKey.getMd5() == null) { String encryptionKey_b64 = sseKey.getKey(); byte[] encryptionKey = Base64.decode(encryptionKey_b64); request.addHeader(Headers.SERVER_SIDE_ENCRYPTION_CUSTOMER_KEY_MD5, Md5Utils.md5AsBase64(encryptionKey));
public ByteBuffer unmarshall(StaxUnmarshallerContext unmarshallerContext) throws Exception { String base64EncodedString = unmarshallerContext.readText(); byte[] decodedBytes = Base64.decode(base64EncodedString); return ByteBuffer.wrap(decodedBytes); }
public String unmarshall(JsonUnmarshallerContext unmarshallerContext) throws Exception { String stringValue = super.unmarshall(unmarshallerContext); return !unmarshallerContext.isInsideResponseHeader() ? stringValue : new String(Base64.decode(stringValue), Charset.forName("utf-8")); }
@Test public void testClientContext() throws JSONException { ClientContext clientContext = new ClientContext(activity); String base64 = clientContext.toBase64String(); assertNotNull(base64); String jsonString = new String(Base64.decode(base64), StringUtils.UTF8); JSONObject json = new JSONObject(jsonString); assertNotNull("has client info", json.getJSONObject("client")); assertNotNull("has device info", json.getJSONObject("env")); }