Package org.apache.commons.codec.binary

Examples of org.apache.commons.codec.binary.Base64


        }
    }

    public static final byte[] decode(byte[] bytes)
    {
          return new Base64().decode(bytes);
    }
View Full Code Here


        {
            _iv = ctx.getInitParameter(INIT_ALGORITHM_IV.toLowerCase());
        }
       
        if (_iv != null)
            iv = new Base64().decode(_iv.getBytes());
       
        return iv;
    }
View Full Code Here

                    log.debug("generated random password of length " + length);
            }
        }
        else
        {
            bytes = new Base64().decode(secret.getBytes());
        }
       
        return bytes;
    }
View Full Code Here

                    log.debug("generated random mac password of length " + length);
            }
        }
        else
        {
            bytes = new Base64().decode(secret.getBytes());
        }
       
        return bytes;
    }
View Full Code Here

            }
        }

        if(_username != null)
        {
            String encoded = new String(new Base64().encode((_username + ":" + _password).getBytes()));
            httpCon.setRequestProperty("Authorization", "Basic " + encoded);
        }

        httpCon.setDoOutput(true);
        httpCon.setRequestMethod(method);
View Full Code Here

    public void sendInput(byte[] buf) throws IOException {
        logger.debug("Sending WinRM Send Input request for command {} in shell {}", commandId, shellId);

        final Element bodyContent = DocumentHelper.createElement(QName.get("Send", Namespaces.NS_WIN_SHELL));
        final Base64 base64 = new Base64();
        bodyContent.addElement(QName.get("Stream", Namespaces.NS_WIN_SHELL)).addAttribute("Name", "stdin").addAttribute("CommandId", commandId).addText(base64.encodeAsString(buf));
        final Document requestDocument = getRequestDocument(Action.WS_SEND, ResourceURI.RESOURCE_URI_CMD, null, bodyContent);
        sendRequest(requestDocument, SoapAction.SEND);

        logger.debug("Sent WinRM Send Input request for command {} in shell {}", commandId, shellId);
    }
View Full Code Here

    }

    private static void handleStream(Document responseDocument, ResponseExtractor stream, OutputStream out) throws IOException {
        @SuppressWarnings("unchecked") final List<Element> streams = stream.getXPath().selectNodes(responseDocument);
        if (!streams.isEmpty()) {
            final Base64 base64 = new Base64();
            Iterator<Element> itStreams = streams.iterator();
            while (itStreams.hasNext()) {
                Element e = itStreams.next();
                // TODO check performance with http://www.iharder.net/current/java/base64/
                final byte[] decode = base64.decode(e.getText());
                out.write(decode);
            }
        }

    }
View Full Code Here

     */
    public static String unzipString(String s)
    {
        try
        {
          Base64 base64Codec = new Base64();
            ByteArrayInputStream decodedStream = new ByteArrayInputStream( base64Codec.decode( s.getBytes(ZIP_CHARSET) ) );
            InputStream unzippedStream = new GZIPInputStream(decodedStream);

            StringBuffer buf = new StringBuffer();
            int c;
            while ((c = unzippedStream.read()) != -1)
View Full Code Here

            writer.close();
            zos.close();
            baos.close();

            Base64 base64Codec = new Base64();
            return new String(base64Codec.encode( baos.toByteArray() ), ZIP_CHARSET);
        }
        catch (IOException e)
        {
            throw new RuntimeException(e);
        }
View Full Code Here

            close(oos);
            close(gos);
            close(bos);
        }

        Base64 base64 = new Base64();

        try {
            byte[] byteData = base64.encode(bos.toByteArray());

            return new String(byteData);

        } catch (Throwable t) {
            String message =
View Full Code Here

TOP

Related Classes of org.apache.commons.codec.binary.Base64

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.