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.github.restdriver.serverdriver.http.BasicAuth.java

private static String base64(String username, String password) {
    return new String(Base64.encodeBase64((username + ":" + password).getBytes()));
}

From source file:jp.go.nict.langrid.commons.ws.util.Base64Util.java

/**
 * 
 * 
 */
public static byte[] encode(byte[] src) {
    return Base64.encodeBase64(src);
}

From source file:com.gvmax.common.util.growl.Howl.java

public static void notify(String username, String password, String application, String title,
        String description, String hostname, String iconName) throws IOException {
    Map<String, String> params = new HashMap<String, String>();
    params.put("name", "GVMax");
    params.put("application", application);
    params.put("title", title);
    params.put("description", description);
    params.put("icon-name", iconName);
    params.put("hostname", "www.gvmax.com");

    String userPassword = username + ":" + password;
    String encoded = StringUtil.toString(Base64.encodeBase64(StringUtil.getBytes(userPassword)));
    Map<String, String> properties = new HashMap<String, String>();
    properties.put("Authorization", "Application " + encoded);

    NetUtil.doPost("https://howlapp.com/public/api/notification", params, properties);
}

From source file:com.honnix.yaacs.util.StringUtil.java

public static String encodeBase64(byte[] byteArray) {
    byte[] encodedByteArray = Base64.encodeBase64(byteArray);
    String encodedString = null;/*from ww w  . ja va  2 s  . c  om*/

    try {
        encodedString = new String(encodedByteArray, UNDERLYING_CHARSET);
    } catch (UnsupportedEncodingException e) {
        // Should not happen.
        encodedString = "";
    }

    return encodedString;
}

From source file:edu.vt.middleware.ldap.LdapUtil.java

/**
 * This will convert the supplied value to a base64 encoded string. Returns
 * null if the bytes cannot be encoded.//from   www . ja  v a 2  s  . c  om
 *
 * @param  value  to base64 encode
 *
 * @return  base64 encoded value
 */
public static String base64Encode(final byte[] value) {
    return value != null ? new String(Base64.encodeBase64(value), UTF8_CHARSET) : null;
}

From source file:Main.java

public static void appendChildToRoot(Document doc, String childName, byte[] childContents) {
    appendChild(doc, doc.getFirstChild(), childName, new String(Base64.encodeBase64(childContents)));
}

From source file:com.amazonaws.sqs.util.AwsSignature.java

public static String calculate(String stringToSign, String secretKey) throws Exception {
    // get an hmac_sha1 key from the raw key bytes
    SecretKeySpec signingKey = new SecretKeySpec(secretKey.getBytes(), HMAC_SHA1_ALGORITHM);

    // get an hmac_sha1 Mac instance and initialize with the signing key
    Mac mac = Mac.getInstance(HMAC_SHA1_ALGORITHM);
    mac.init(signingKey);/*from w  w w.  j av a 2s.c o m*/

    // compute the hmac on input data bytes
    byte[] rawHmac = mac.doFinal(stringToSign.getBytes());

    // base64-encode the hmac
    String result = new String(Base64.encodeBase64(rawHmac));
    return result;
}

From source file:core.module.codec.GetParameterEncryptionKeyAck.java

public String getSecretKeyBase64() {
    return new String(Base64.encodeBase64(secretKey));
}

From source file:hh.learnj.test.license.test.alps.base64.ApacheBaseCoder.java

@Override
public String encode(byte[] src) {
    try {// ww  w  .  jav a  2 s .  c  om
        return new String(Base64.encodeBase64(src), CODE);
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
        throw new UnsupportedOperationException(e.getMessage());
    }
}

From source file:llc.rockford.webcast.StringUtils.java

public static String encodeBase64BinaryFile(InputStream is) {
    String base64EncodedFile = "";
    try {// w  w w .  j a v a  2s.  co m
        byte[] bytesFromFile = IOUtils.toByteArray(is);
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        ObjectOutputStream stream = new ObjectOutputStream(baos);
        stream.write(bytesFromFile);
        stream.flush();
        stream.close();
        base64EncodedFile = new String(Base64.encodeBase64(baos.toByteArray()));
    } catch (Exception ex) {
        ex.printStackTrace();
    }
    return base64EncodedFile;
}