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

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

Introduction

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

Prototype

public static byte[] decodeBase64(final byte[] base64Data) 

Source Link

Document

Decodes Base64 data into octets

Usage

From source file:aiai.apps.commons.utils.SecUtils.java

public static PrivateKey getPrivateKey(String keyBase64)
        throws NoSuchAlgorithmException, InvalidKeySpecException {
    byte[] keyBytes = Base64.decodeBase64(keyBase64);
    PKCS8EncodedKeySpec spec = new PKCS8EncodedKeySpec(keyBytes);
    KeyFactory kf = KeyFactory.getInstance("RSA");
    return kf.generatePrivate(spec);
}

From source file:mitm.common.util.Base64Utils.java

/**
 * Base64 decodes the input//w w  w. j  a v a2  s .  c  om
 */
public static byte[] decode(String base64) {
    return Base64.decodeBase64(MiscStringUtils.toAsciiBytes(base64));
}

From source file:com.cliqset.magicsig.encoding.Base64URLMagicSigEncoding.java

public byte[] decode(String armoredData) {
    //remove whitespace
    armoredData = armoredData.replace("\\s", "");

    //pad so length is divisible by 4
    while (armoredData.length() % 4 != 0) {
        armoredData += (char) 61;
    }/* w w  w .java 2 s .c  o m*/

    return Base64.decodeBase64(armoredData);
}

From source file:cn.lynx.emi.license.ViewLicense.java

public static final LicenseBean retrieveLicense(String license) throws UnsupportedEncodingException {
    String decryptedLicense = _decrypt(license);
    try {/*from w  w w .j  a  v a 2s .  c o m*/
        ObjectInputStream ois = new ObjectInputStream(
                new ByteArrayInputStream(Base64.decodeBase64(decryptedLicense)));
        LicenseBean bean = (LicenseBean) ois.readObject();
        return bean;
    } catch (IOException e) {
        e.printStackTrace();
        return null;
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
        return null;
    }
}

From source file:com.cloud.utils.ssh.SSHKeysHelper.java

public static String getPublicKeyFingerprint(String publicKey) {
    String key[] = publicKey.split(" ");
    if (key.length < 2) {
        throw new RuntimeException("Incorrect public key is passed in");
    }//from   www . jav  a  2s.c o m
    byte[] keyBytes = Base64.decodeBase64(key[1]);

    MessageDigest md5 = null;
    try {
        md5 = MessageDigest.getInstance("MD5");
    } catch (NoSuchAlgorithmException e) {
        e.printStackTrace();
    }

    String sumString = toHexString(md5.digest(keyBytes));
    String rString = "";

    for (int i = 2; i <= sumString.length(); i += 2) {
        rString += sumString.substring(i - 2, i);
        if (i != sumString.length())
            rString += ":";
    }

    return rString;
}

From source file:com.evolveum.midpoint.web.util.Base64Model.java

@Override
public String getObject() {
    byte[] obj = model.getObject();
    if (obj == null) {
        return null;
    }//  w  w w . j  a  va 2s  .c om

    try {
        return new String(Base64.decodeBase64(obj), "utf-8");
    } catch (UnsupportedEncodingException e) {
        throw new SystemException(e);
    }
}

From source file:de.kbs.acavis.service.SerializationHelper.java

public static PublicationIdentifier deserializePublicationIdentifierBase64(String serialization)
        throws ClassNotFoundException, IOException {
    return deserializePublicationIdentifier(
            new String(Base64.decodeBase64(serialization.getBytes("UTF-8")), "UTF-8"));
}

From source file:com.epam.wilma.compression.base64.Base64Decoder.java

/**
 * Decodes a string from base64.//from  w  ww.  j  av a2s .  c  om
 * @param base64Content the string to be decoded
 * @return the result of the decoding
 */
public byte[] decode(final String base64Content) {
    return Base64.decodeBase64(base64Content);
}

From source file:com.connorbrezinsky.msg.security.Hash.java

/**
 * Checks whether given plaintext password corresponds to a stored salted
 * hash of the password./*  ww  w. j a  v a  2  s  .c om*/
 */
public static boolean check(String password, String stored) throws Exception {
    String[] saltAndPass = stored.split("\\$");
    if (saltAndPass.length != 2) {
        throw new IllegalStateException("The stored password have the form 'salt$hash'");
    }
    String hashOfInput = hash(password, Base64.decodeBase64(saltAndPass[0]));
    return hashOfInput.equals(saltAndPass[1]);
}

From source file:com.inmobi.messaging.consumer.util.DatabusUtil.java

private static ByteBuffer decodeByteBuffer(byte[] line) {
    byte[] data = Base64.decodeBase64(line);
    return AuditUtil.removeHeader(data);

}