@Test public final void testDecodeBase64ZippedString() throws IOException, NoSuchAlgorithmException { String enc64 = this.canonicalBase64Encode( STANDART ); String decoded = HttpUtil.decodeBase64ZippedString( enc64 ); Assert.assertEquals( "Strings are the same after transformation", STANDART, decoded ); }
public static String decodeBase64ZippedString( String loggingString64 ) throws IOException { if ( loggingString64 == null || loggingString64.isEmpty() ) { return ""; } StringWriter writer = new StringWriter(); byte[] bytes64 = Base64.decodeBase64( loggingString64.getBytes() ); ByteArrayInputStream zip = new ByteArrayInputStream( bytes64 ); GZIPInputStream unzip = null; InputStreamReader reader = null; BufferedInputStream in = null; try { unzip = new GZIPInputStream( zip, HttpUtil.ZIP_BUFFER_SIZE ); in = new BufferedInputStream( unzip, HttpUtil.ZIP_BUFFER_SIZE ); reader = new InputStreamReader( in, Const.XML_ENCODING ); writer = new StringWriter(); char[] buff = new char[ HttpUtil.ZIP_BUFFER_SIZE ]; for ( int length = 0; ( length = reader.read( buff ) ) > 0; ) { writer.write( buff, 0, length ); } } finally { if ( reader != null ) { try { reader.close(); } catch ( IOException e ) { } } if ( in != null ) { try { in.close(); } catch ( IOException e ) { } } if ( unzip != null ) { try { unzip.close(); } catch ( IOException e ) { } } } return writer.toString(); }
HttpUtil { public static String decodeBase64ZippedString( String loggingString64 ) throws IOException { if ( loggingString64 == null || loggingString64.isEmpty() ) { return ""; } StringWriter writer = new StringWriter(); byte[] bytes64 = Base64.decodeBase64( loggingString64.getBytes() ); ByteArrayInputStream zip = new ByteArrayInputStream( bytes64 ); GZIPInputStream unzip = null; InputStreamReader reader = null; BufferedInputStream in = null; try { unzip = new GZIPInputStream( zip, HttpUtil.ZIP_BUFFER_SIZE ); in = new BufferedInputStream( unzip, HttpUtil.ZIP_BUFFER_SIZE ); reader = new InputStreamReader( in, Const.XML_ENCODING ); writer = new StringWriter(); char[] buff = new char[ HttpUtil.ZIP_BUFFER_SIZE ]; for ( int length = 0; ( length = reader.read( buff ) ) > 0; ) { writer.write( buff, 0, length ); } } finally { if ( reader != null ) { try { reader.close(); } catch ( IOException e ) { } } if ( in != null ) { try { in.close(); } catch ( IOException e ) { } } if ( unzip != null ) { try { unzip.close(); } catch ( IOException e ) { } } } return writer.toString(); } }
HttpUtil { public static String decodeBase64ZippedString( String loggingString64 ) throws IOException { if ( loggingString64 == null || loggingString64.isEmpty() ) { return ""; } StringWriter writer = new StringWriter(); byte[] bytes64 = Base64.decodeBase64( loggingString64.getBytes() ); ByteArrayInputStream zip = new ByteArrayInputStream( bytes64 ); GZIPInputStream unzip = null; InputStreamReader reader = null; BufferedInputStream in = null; try { unzip = new GZIPInputStream( zip, HttpUtil.ZIP_BUFFER_SIZE ); in = new BufferedInputStream( unzip, HttpUtil.ZIP_BUFFER_SIZE ); reader = new InputStreamReader( in, Const.XML_ENCODING ); writer = new StringWriter(); char[] buff = new char[ HttpUtil.ZIP_BUFFER_SIZE ]; for ( int length = 0; ( length = reader.read( buff ) ) > 0; ) { writer.write( buff, 0, length ); } } finally { if ( reader != null ) { try { reader.close(); } catch ( IOException e ) { } } if ( in != null ) { try { in.close(); } catch ( IOException e ) { } } if ( unzip != null ) { try { unzip.close(); } catch ( IOException e ) { } } } return writer.toString(); }  }
HttpUtil { public static String decodeBase64ZippedString( String loggingString64 ) throws IOException { if ( loggingString64 == null || loggingString64.isEmpty() ) { return ""; } StringWriter writer = new StringWriter(); byte[] bytes64 = Base64.decodeBase64( loggingString64.getBytes() ); ByteArrayInputStream zip = new ByteArrayInputStream( bytes64 ); GZIPInputStream unzip = null; InputStreamReader reader = null; BufferedInputStream in = null; try { unzip = new GZIPInputStream( zip, HttpUtil.ZIP_BUFFER_SIZE ); in = new BufferedInputStream( unzip, HttpUtil.ZIP_BUFFER_SIZE ); reader = new InputStreamReader( in, Const.XML_ENCODING ); writer = new StringWriter(); char[] buff = new char[ HttpUtil.ZIP_BUFFER_SIZE ]; for ( int length = 0; ( length = reader.read( buff ) ) > 0; ) { writer.write( buff, 0, length ); } } finally { if ( reader != null ) { try { reader.close(); } catch ( IOException e ) { } } if ( in != null ) { try { in.close(); } catch ( IOException e ) { } } if ( unzip != null ) { try { unzip.close(); } catch ( IOException e ) { } } } return writer.toString(); }  static String constructUrl( VariableSpace space, String hostname, String port, String webAppName,
                                     String serviceAndArguments ); static String constructUrl( VariableSpace space, String hostname, String port, String webAppName,
                                     String serviceAndArguments, boolean isSecure ); static String getPortSpecification( VariableSpace space, String port ); static String decodeBase64ZippedString( String loggingString64 ); static String encodeBase64ZippedString( String in ); }
HttpUtil { public static String decodeBase64ZippedString( String loggingString64 ) throws IOException { if ( loggingString64 == null || loggingString64.isEmpty() ) { return ""; } StringWriter writer = new StringWriter(); byte[] bytes64 = Base64.decodeBase64( loggingString64.getBytes() ); ByteArrayInputStream zip = new ByteArrayInputStream( bytes64 ); GZIPInputStream unzip = null; InputStreamReader reader = null; BufferedInputStream in = null; try { unzip = new GZIPInputStream( zip, HttpUtil.ZIP_BUFFER_SIZE ); in = new BufferedInputStream( unzip, HttpUtil.ZIP_BUFFER_SIZE ); reader = new InputStreamReader( in, Const.XML_ENCODING ); writer = new StringWriter(); char[] buff = new char[ HttpUtil.ZIP_BUFFER_SIZE ]; for ( int length = 0; ( length = reader.read( buff ) ) > 0; ) { writer.write( buff, 0, length ); } } finally { if ( reader != null ) { try { reader.close(); } catch ( IOException e ) { } } if ( in != null ) { try { in.close(); } catch ( IOException e ) { } } if ( unzip != null ) { try { unzip.close(); } catch ( IOException e ) { } } } return writer.toString(); }  static String constructUrl( VariableSpace space, String hostname, String port, String webAppName,
                                     String serviceAndArguments ); static String constructUrl( VariableSpace space, String hostname, String port, String webAppName,
                                     String serviceAndArguments, boolean isSecure ); static String getPortSpecification( VariableSpace space, String port ); static String decodeBase64ZippedString( String loggingString64 ); static String encodeBase64ZippedString( String in ); static final int ZIP_BUFFER_SIZE; }