Example usage for java.util Base64 getDecoder

List of usage examples for java.util Base64 getDecoder

Introduction

In this page you can find the example usage for java.util Base64 getDecoder.

Prototype

public static Decoder getDecoder() 

Source Link

Document

Returns a Decoder that decodes using the Basic type base64 encoding scheme.

Usage

From source file:com.thoughtworks.go.websocket.MessageEncoding.java

public static Work decodeWork(String data) {
    try {/* ww  w  .ja  va 2  s.c o  m*/
        byte[] binary = Base64.getDecoder().decode(data.getBytes(StandardCharsets.UTF_8));
        try (ObjectInputStream objectStream = new ObjectInputStream(new ByteArrayInputStream(binary))) {
            return (Work) objectStream.readObject();
        }
    } catch (ClassNotFoundException | IOException e) {
        throw bomb(e);
    }
}

From source file:org.mylab.consulclient.utility.ConsulKey.java

public String getValue() {
    return new String(Base64.getDecoder().decode(this.value));
}

From source file:com.netflix.spinnaker.clouddriver.artifacts.embedded.EmbeddedArtifactCredentials.java

public EmbeddedArtifactCredentials(EmbeddedArtifactAccount account) {
    name = account.getName();
    base64Decoder = Base64.getDecoder();
}

From source file:org.hyperledger.jackson.ScriptDeserializer.java

@Override
public Script deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
    JsonToken t = jp.getCurrentToken();//from w  w w .jav a  2  s  .com
    if (t == JsonToken.VALUE_STRING) {
        String scriptString = jp.getText().trim();
        if (scriptString.length() == 0) {
            return null;
        }

        return new Script(Base64.getDecoder().decode(scriptString));
    }

    throw ctxt.mappingException(handledType());
}

From source file:br.com.ufjf.labredes.rest.EleitorResource.java

@POST
@Path("/{eleitor}")
//3. Envia Credenciais
public String login(@PathParam("eleitor") String elector) {
    byte[] elector_decoded = Base64.getDecoder().decode(elector);
    SealedObject aux = (SealedObject) SerializationUtils.deserialize(elector_decoded);
    Eleitor eleitor = (Eleitor) rsa.decrypt(aux, client_aes);
    eleitor = eleitorService.getEleitor(eleitor.getCpf(), eleitor.getSenha());

    Response ans = new Response();
    CandidatoList candidatos = new CandidatoList();

    if (eleitor != null) {
        //3.1 Responde
        candidatos.setCandidatos(candidatoService.getAll());
        byte[] data = SerializationUtils.serialize(rsa.encrypt(candidatos, client_aes));
        String retorno = Base64.getEncoder().encodeToString(data);
        return retorno;
    } else {//from w w w  .  ja  v a  2 s  .com
        ans.Error("Erro ao decriptar chave");
        //3.1 Responde
        byte[] data = SerializationUtils.serialize(rsa.encrypt(ans, client_aes));
        String retorno = Base64.getEncoder().encodeToString(data);
        return retorno;
    }

}

From source file:io.viewserver.core.Utils.java

public static String parse(String value) {
    return new String(getBytes(Base64.getDecoder().decode(value)), Charsets.UTF_8);
}

From source file:org.neo4j.ogm.typeconversion.ByteArrayWrapperBase64Converter.java

@Override
public Byte[] toEntityAttribute(String value) {
    if (value == null)
        return null;
    byte[] bytes = Base64.getDecoder().decode(value);
    Byte[] wrapper = new Byte[bytes.length];
    for (int i = 0; i < bytes.length; i++) {
        wrapper[i] = bytes[i]; // preferable to new Byte(..) hence not using Apache toObject()
    }//from  ww w . j a  v a2 s.  c  o m
    return wrapper;
}

From source file:org.opencb.commons.utils.CryptoUtils.java

public static String decryptAES(String strToDecrypt, byte[] key)
        throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException {
    try {/*from w w  w  .  j a v a  2s .  com*/
        Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5PADDING");
        SecretKeySpec secretKey = new SecretKeySpec(key, "AES");
        cipher.init(Cipher.DECRYPT_MODE, secretKey);
        return new String(Base64.getDecoder().decode(strToDecrypt));
    } catch (NoSuchAlgorithmException | NoSuchPaddingException ex) {
        Logger.getLogger(CryptoUtils.class.getName()).log(Level.SEVERE, null, ex);
        throw ex;
    }
}

From source file:br.com.ufjf.labredes.rest.ConectaResource.java

@POST
@Path("/{client_pk}")
//2.Envia PK Criptografada
public String answer(@PathParam("client_pk") String client_pk) {
    Response ans = new Response();

    if (!client_pk.equals("")) {
        byte[] client = Base64.getDecoder().decode(client_pk);
        client_aes = rsa.decrypt(client, sever_privateKey);
        ans.Ok("Conexo aceita");
        //2.1 Responde
        byte[] data = SerializationUtils.serialize(rsa.encrypt(ans, client_aes));
        String aux = Base64.getEncoder().encodeToString(data);
        return aux;
    } else {//from  ww w .  ja v a  2 s. com
        ans.Error("Erro ao decriptar chave");
        //2.1 Responde
        byte[] data = SerializationUtils.serialize(rsa.encrypt(ans, client_aes));
        String aux = Base64.getEncoder().encodeToString(data);
        return aux;
    }
}

From source file:org.dbflute.intro.app.model.client.ExtlibFile.java

public ExtlibFile(String filePath, String fileDataBase64) {
    this.fileData = Base64.getDecoder().decode(fileDataBase64);
    this.file = new File(filePath);
}