Example usage for org.apache.commons.codec.binary Base64 encodeBase64

List of usage examples for org.apache.commons.codec.binary Base64 encodeBase64

Introduction

In this page you can find the example usage for org.apache.commons.codec.binary Base64 encodeBase64.

Prototype

public static byte[] encodeBase64(final byte[] binaryData) 

Source Link

Document

Encodes binary data using the base64 algorithm but does not chunk the output.

Usage

From source file:com.enonic.cms.core.portal.instruction.PostProcessInstruction.java

public final String serialize() throws IOException {
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    ObjectOutputStream dout = new ObjectOutputStream(out);

    writeExternal(dout);//from w  w w  .j a  v a2  s.  co m

    dout.close();
    out.close();

    return new String(Base64.encodeBase64(out.toByteArray()));
}

From source file:com.intuit.wasabi.authentication.impl.UserCredential.java

public String toBase64Encode() {
    return new String(Base64.encodeBase64((this.username + ":" + this.password).getBytes()));
}

From source file:com.tripit.auth.WebAuthCredential.java

public void authorize(HttpRequestBase request) throws Exception {
    request.addHeader("Authorization", "Basic "
            + new String(Base64.encodeBase64(new String(this.username + ":" + this.password).getBytes())));
}

From source file:com.vmware.o11n.plugin.crypto.service.CryptoEncodingService.java

/**
 *
 * @param data/*  ww  w .  j av a  2  s .  c  o m*/
 * @return
 * @throws UnsupportedEncodingException
 */
public String base64Encode(String data) throws UnsupportedEncodingException {
    String encoded = new String(Base64.encodeBase64(data.getBytes(StandardCharsets.UTF_8)));
    return encoded;
}

From source file:it.unipmn.di.dcs.common.conversion.Convert.java

/**
 * Converts a byte array to a Base64 string.
 *///from   w w w. jav  a 2 s .c o m
public static String BytesToBase64(byte[] bytes) {
    if (bytes == null) {
        return null;
    }

    //return Base64.Encode( bytes ); // deprecated
    return new String(Base64.encodeBase64(bytes));
}

From source file:com.db4o.sync4o.SyncKey.java

static public String toEncodedString(SyncKey key) throws Exception {

    ByteArrayOutputStream bs = new ByteArrayOutputStream();
    ObjectOutputStream os = new ObjectOutputStream(bs);
    os.writeObject(key);//from   ww  w . j a  v  a  2  s  .co m
    os.flush();
    os.close();

    return new String(Base64.encodeBase64(bs.toByteArray()));

}

From source file:disko.utils.DiscoProxySettings.java

/**
 * /*from  w w w.  j  a v a  2s. c  o m*/
 * <p>
 * Convenience method to open a URL connection by using the
 * proxy settings. If proxyHost is null, the default is to  just
 * call <code>url.openConnection</code>.
 * </p>
 *
 * @param url
 * @return
 */
public static URLConnection newConnection(URL url) throws IOException {
    URLConnection connection;
    String externalForm = url.toExternalForm();
    url = new URL(externalForm.replace(" ", "%20"));
    if (DiscoProxySettings.proxyHost != null) {
        connection = url.openConnection(new Proxy(Proxy.Type.HTTP,
                new InetSocketAddress(DiscoProxySettings.proxyHost, DiscoProxySettings.proxyPort)));
        if (DiscoProxySettings.proxyUser != null) {
            String enc = new String(Base64.encodeBase64(
                    new String(DiscoProxySettings.proxyUser + ":" + DiscoProxySettings.proxyPassword)
                            .getBytes()));
            connection.setRequestProperty("Proxy-Authorization", "Basic " + enc);
        }
    } else
        connection = url.openConnection();
    return connection;
}

From source file:com.vss.ogc.types.WkbSerializer.java

@Override
public String toLiteral(Geometry geometry) {
    return new String(Base64.encodeBase64(new WKBWriter().write(geometry)));
}

From source file:com.shenit.commons.codec.Base64Utils.java

/**
 * To base64 hex//from   ww  w.ja  va  2 s. co  m
 * @param data
 * @param enc
 * @return
 */
public static String base64EncodeHex(byte[] data, String enc) {
    if (data == null)
        return null;
    enc = enc == null ? HttpUtils.ENC_UTF8 : enc;
    try {
        return new String(Base64.encodeBase64(data), enc);
    } catch (UnsupportedEncodingException e) {
        if (LOG.isWarnEnabled())
            LOG.warn("[base64EncodeHex] ", e);
    }
    return null;
}

From source file:com.vss.ogc.types.WkbGzSerializer.java

@Override
public String toLiteral(Geometry geometry) {
    return new String(Base64.encodeBase64(AbstractGeo.gzip(new WKBWriter().write(geometry))));
}