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.ddling.server.smtp.State.Login.java

public boolean process(SMTPThread smtpThread, String str) {
    if (currentState.equals(state[0])) {
        smtpThread.printToClient("334 " + Base64.encodeBase64String("password:".getBytes()));
        currentState = state[1];//from  w  ww. j a  v a  2 s  .  c  o m
    } else if (currentState.equals(state[1])) {
        // login
        smtpThread.printToClient("235 Authentication successful");
        return true;
    }
    return false;
}

From source file:com.aqnote.shared.cryptology.cert.tool.PrivateKeyTool.java

public static String coverPrivateKey2String(Key key) {
    String keyContent = Base64.encodeBase64String(key.getEncoded());
    return BEGIN_KEY + lineSeparator + keyContent + END_KEY;
}

From source file:com.exsoloscript.challonge.ChallongeCredentials.java

/**
 * Creates a HTTP basic auth String from the given credentials
 *
 * @return HTTP basic auth String/*from  w  w w.  j a  v a2  s  . com*/
 */
public String toHttpAuthString() {
    String credentials = this.username + ":" + this.apiKey;
    return "Basic " + Base64.encodeBase64String(credentials.getBytes());
}

From source file:name.martingeisse.common.util.HmacUtil.java

/**
 * Generates a HMAC, assuming UTF-8 encoding for all strings, and base64-encodes
 * the result./*from   w w  w. j a v a 2  s  . co m*/
 * 
 * @param payload the payload data
 * @param secret the secret to sign the HMAC
 * @param algorithm the HMAC algorithm to use
 * @return the HMAC, base64 encoded
 */
public static String generateHmacBase64(String payload, String secret, String algorithm) {
    return Base64.encodeBase64String(generateHmac(payload, secret, algorithm));
}

From source file:de.taimos.dvalin.interconnect.model.MessageCryptoUtil.java

/**
 *
 * @param data the data to encrypt/*ww w .  j a  v  a 2s.c o  m*/
 * @return the encrypted BASE64 data
 * @throws CryptoException on encryption error
 */
public static String crypt(final String data) throws CryptoException {
    if (data == null) {
        return null;
    }

    try {
        final Cipher cipher = MessageCryptoUtil.getCipher(Cipher.ENCRYPT_MODE);
        final byte[] encrypted = cipher.doFinal(data.getBytes(Charset.forName("UTF-8")));
        return Base64.encodeBase64String(encrypted);
    } catch (final Exception e) {
        throw new CryptoException("Encryption of data failed!", e);
    }
}

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

public String sha256(String data) {
    return Base64.encodeBase64String(DigestUtils.sha256(data));
}

From source file:com.monarchapis.client.authentication.BasicAuthRequestProcessor.java

@Override
public void processRequest(BaseClient<?> client) {
    client.addHeader("Authorization",
            "Basic " + Base64.encodeBase64String((username + ":" + password).getBytes()));
}

From source file:cd.go.authentication.ldap.executor.GetPluginIconExecutor.java

@Override
public GoPluginApiResponse execute() throws Exception {
    JsonObject jsonObject = new JsonObject();
    jsonObject.addProperty("content_type", "image/png");
    jsonObject.addProperty("data", Base64.encodeBase64String(Util.readResourceBytes("/gocd_72_72_icon.png")));
    DefaultGoPluginApiResponse defaultGoPluginApiResponse = new DefaultGoPluginApiResponse(200,
            GSON.toJson(jsonObject));//from  w  w w.j av  a  2 s.  co  m
    return defaultGoPluginApiResponse;

}

From source file:com.liferay.sync.engine.util.Encryptor.java

public static String encrypt(String value) throws Exception {
    if (value == null) {
        return "";
    }/*from   w  w  w  . j a  va 2 s. c  o m*/

    SecretKey secretKey = new SecretKeySpec(_PASSWORD, _ALGORITHM);

    Cipher cipher = Cipher.getInstance(_ALGORITHM);

    cipher.init(Cipher.ENCRYPT_MODE, secretKey);

    String salt = getSalt();

    String encryptedValue = value;

    for (int i = 0; i < _ITERATIONS; i++) {
        encryptedValue = salt.concat(encryptedValue);

        byte[] encryptedBytes = cipher.doFinal(encryptedValue.getBytes(_UTF8_CHARSET));

        encryptedValue = Base64.encodeBase64String(encryptedBytes);
    }

    return encryptedValue;
}

From source file:com.greenpepper.maven.plugin.EchoFixture.java

public String convertingToBase64gives(String input) {
    LOG.info("calling convertingToBase64gives()");
    return Base64.encodeBase64String(input.getBytes());
}