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

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

Introduction

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

Prototype

public static String encodeBase64String(final byte[] binaryData) 

Source Link

Document

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

Usage

From source file:com.bconomy.autobit.Encryption.java

public static String encrypt(char[] cleartext) {
    if (cleartext.length == 0)
        return "";
    return Base64.encodeBase64String(encrypt(charsToBytes(cleartext)));
}

From source file:com.microsoft.rest.credentials.BasicAuthenticationCredentialsInterceptor.java

@Override
public Response intercept(Chain chain) throws IOException {
    String auth = credentials.getUserName() + ":" + credentials.getPassword();
    auth = Base64.encodeBase64String(auth.getBytes("UTF8"));
    Request newRequest = chain.request().newBuilder().header("Authorization", "Basic " + auth).build();
    return chain.proceed(newRequest);
}

From source file:com.alu.e3.prov.restapi.util.Base64Adapter.java

public String marshal(String s) {
    if (s == null)
        return null;
    return Base64.encodeBase64String(s.getBytes());
}

From source file:ezbake.thrift.serializer.Base64Serializer.java

@Override
public String serialize(TBase<?, ?> thriftObject) throws TException {
    return Base64.encodeBase64String(serializer.serialize(thriftObject));
}

From source file:com.axelor.apps.account.ebics.certificate.KeyUtil.java

/**
 * Generates a random password//from  w w  w . ja v a2s  .c o  m
 *
 * @return the password
 */
public static String generatePassword() {
    SecureRandom random;

    try {
        random = SecureRandom.getInstance("SHA1PRNG");
        String pwd = Base64.encodeBase64String(random.generateSeed(5));

        return pwd.substring(0, pwd.length() - 2);
    } catch (NoSuchAlgorithmException e) {
        return "changeit";
    }
}

From source file:com.couchbase.client.http.HttpUtil.java

/**
 * Generate the payload of an authorization header given a username and
 * password.// w ww . j av a2s . c  om
 *
 * Since our HTTP needs are modest in this library and our dependencies
 * are lightweight enough to not carry all of the auth capabilities, this
 * method will generate the payload needed for an authorization header.
 *
 * @return a value for an HTTP Basic Auth Header
 */
public static String buildAuthHeader(String username, String password) throws UnsupportedEncodingException {
    // apparently netty isn't familiar with HTTP Basic Auth
    StringBuilder clearText = new StringBuilder(username);
    clearText.append(':');
    if (password != null) {
        clearText.append(password);
    }
    String headerResult;
    headerResult = "Basic " + Base64.encodeBase64String(clearText.toString().getBytes("UTF-8"));

    if (headerResult.endsWith("\r\n")) {
        headerResult = headerResult.substring(0, headerResult.length() - 2);
    }
    return headerResult;
}

From source file:com.nicohuysamen.fetchapp.RequestConstants.java

public static String generateAuthorizationKey(final String apiKey, final String apiToken) {
    return "Basic " + Base64.encodeBase64String((apiKey + ":" + apiToken).getBytes());
}

From source file:com.google.nigori.server.appengine.BytesRevision.java

@Override
public String toString() {
    return "" + Base64.encodeBase64String(revision);
}

From source file:com.aqnote.shared.cryptology.cert.util.KeyStoreUtil.java

public static String coverKeyStore2String(KeyStore keyStore, char[] passwd) throws CertException {

    try {/* w ww  .  j av a2s . c o m*/
        CircularByteBuffer cbb = new CircularByteBuffer(CircularByteBuffer.INFINITE_SIZE);
        keyStore.store(cbb.getOutputStream(), passwd);
        return Base64.encodeBase64String(StreamUtil.stream2Bytes(cbb.getInputStream()));
    } catch (KeyStoreException e) {
        throw new CertException(e);
    } catch (NoSuchAlgorithmException e) {
        throw new CertException(e);
    } catch (CertificateException e) {
        throw new CertException(e);
    } catch (IOException e) {
        throw new CertException(e);
    }
}

From source file:com.xebialabs.overthere.cifs.winrm.tokengenerator.BasicTokenGenerator.java

@Override
public String generateToken() {
    String credentials = String.format("%s:%s", username, password);
    return "Basic " + Base64.encodeBase64String(credentials.getBytes());
}