public static String base64decode(String base64Str) throws Base64Exception { if(!Base64.isBase64(base64Str)) { throw new Base64Exception("Provided string is not Base64 encoded"); } byte[] out = base64decodeByteArray(base64Str); CharsetDecoder decoder = Charsets.UTF_8.newDecoder(); try { decoder.onMalformedInput(CodingErrorAction.REPORT); decoder.onUnmappableCharacter(CodingErrorAction.REPORT); CharBuffer buffer = decoder.decode( ByteBuffer.wrap(Arrays.copyOf(out, out.length))); return buffer.toString(); } catch(MalformedInputException ex) { throw new Base64Exception("Input is malformed", ex); } catch(UnmappableCharacterException ex) { throw new Base64Exception("Unmappable characters found", ex); } catch(CharacterCodingException ex) { throw new Base64Exception(ex); } }
byte[] body = Util.base64decodeByteArray(e.getValue()); return new ReqEntityByteArrayBean(body, ct);
responseBean.setResponseBody(Util.base64decodeByteArray(base64body)); } else if ("test-result".equals(nodeName)) { TestResultBean testResultBean = new TestResultBean();
private ResponseBean getDefaultResponseBean(){ ResponseBean expResult = new ResponseBean(); expResult.setStatusLine("HTTP/1.1 200 OK"); expResult.setStatusCode(200); expResult.addHeader("Content-Type", "text/plain; charset=utf-8"); expResult.addHeader("Transfer-Encoding", "chunked"); expResult.addHeader("Server", "Jetty(6.1.25)"); expResult.setResponseBody(Util.base64decodeByteArray("KipSRVNUQ2xpZW50IFRyYWNlU2VydmxldCoqCgoqTWV0aG9kKgoJR0VUCgoqUGF0aCBJbmZvKgoJLwoKKkhlYWRlcnMqCglIb3N0OiBsb2NhbGhvc3Q6MTAxMDEKCUNvbm5lY3Rpb246IEtlZXAtQWxpdmUKCVVzZXItQWdlbnQ6IEFwYWNoZS1IdHRwQ2xpZW50LzQuMi4xIChqYXZhIDEuNSkKCipRdWVyeSBTdHJpbmcqCgludWxsCgoqUGFyYW1ldGVycyoKCipCb2R5IChGaXJzdCAxMDAgY2hhcmFjdGVycyBvbmx5KSoKCQoK")); return expResult; }