List of usage examples for org.apache.commons.codec.binary Base64 decodeBase64
public static byte[] decodeBase64(final byte[] base64Data)
From source file:net.arccotangent.pacchat.crypto.MsgCrypto.java
public static PacchatMessage decryptAndVerifyMessage(String cryptedMsg, PrivateKey privateKey, PublicKey publicKey) {//from w w w .j ava2s.c om mc_log.i("Decrypting and verifying message."); String[] messageComponents = cryptedMsg.split("\n"); String cryptedKeyB64 = messageComponents[0]; String cryptedTextB64 = messageComponents[1]; String signatureB64 = messageComponents[2]; boolean verified = RSA.verifyBytes(Base64.decodeBase64(cryptedKeyB64), Base64.decodeBase64(signatureB64), publicKey); if (verified) mc_log.i("Message authenticity verified!"); else { mc_log.w("**********************************************"); mc_log.w("Message authenticity NOT VERIFIED! Will continue decryption anyway."); mc_log.w( "Someone may be tampering with your connection! This is an unlikely, but not impossible scenario!"); mc_log.w( "If you are sure the connection was not tampered with, consider asking the sender to send out a key update."); mc_log.w("**********************************************"); } DecryptStatus rsa = RSA.decryptBytes(Base64.decodeBase64(cryptedKeyB64), privateKey); byte[] aesKey = rsa.getMessage(); SecretKey aes = new SecretKeySpec(aesKey, "AES"); DecryptStatus message = AES.decryptBytes(Base64.decodeBase64(cryptedTextB64), aes); byte[] msg = message.getMessage(); boolean decrypted = message.isDecryptedSuccessfully(); return new PacchatMessage(new String(msg), verified, decrypted); }
From source file:com.basho.riak.presto.SplitTask.java
public SplitTask(String data) throws OtpErlangDecodeException, DecoderException { byte[] binary = Base64.decodeBase64(Hex.decodeHex(data.toCharArray())); task = (OtpErlangTuple) binary2term(binary); // task = {vnode, filterVnodes} OtpErlangTuple vnode = (OtpErlangTuple) task.elementAt(0); // vnode = {index, node} OtpErlangAtom erlangNode = (OtpErlangAtom) vnode.elementAt(1); // "dev" @ "127.0.0.1" this.host = node2host(erlangNode.atomValue()); }
From source file:it.vige.greenarea.gtg.webservice.auth.LDAPauth.java
public static String doAuthentication(WebServiceContext wsContext) throws LDAPException { String result;//w w w . jav a 2 s. com MessageContext mctx = wsContext.getMessageContext(); Map<String, Object> http_headers = (Map) mctx.get(MessageContext.HTTP_REQUEST_HEADERS); List<Object> list = (List) http_headers.get("Authorization"); if (list == null || list.isEmpty()) { result = "Authentication failed! This WS needs BASIC Authentication!"; throw new LDAPException(ResultCode.AUTH_METHOD_NOT_SUPPORTED, result); } String userpass = (String) list.get(0); userpass = userpass.substring(5); byte[] buf = Base64.decodeBase64(userpass.getBytes());// decodeBase64(userpass.getBytes()); String credentials = StringUtils.newStringUtf8(buf); String username; String password; int p = credentials.indexOf(":"); if (p > -1) { username = credentials.substring(0, p); password = credentials.substring(p + 1); } else { result = "There was an error while decoding the Authentication!"; throw new LDAPException(ResultCode.DECODING_ERROR, result); } /* * Creazione di una "Identity" Se non mi serve un sottodominio, posso * anche usare il costruttore Identity(usr,pwd) */ logger.debug("*** LOG *** username: " + username + " pwd: " + password); logger.debug("*** LOG *** username: " + username + " AUTHORIZED!"); return username; }
From source file:com.streamsets.pipeline.lib.el.Base64EL.java
@ElFunction(prefix = "base64", name = "decodeBytes", description = "Returns a decoded byte array from a base64 encoded string argument.") public static byte[] base64Decode(@ElParam("string") String encoded) { return Base64.decodeBase64(encoded); }
From source file:com.comcast.cereal.convert.ByteArrayCerealizer.java
public byte[] deCerealize(String cereal, ObjectCache objectCache) throws CerealException { return Base64.decodeBase64(cereal); }
From source file:net.bryansaunders.jee6divelog.util.HashUtils.java
/** * Decodes a Base64 string./*from w w w . j a va 2s . co m*/ * * @param stringToDecode * String to decode * @return Decoded String */ public static String base64Decode(final String stringToDecode) { return new String(Base64.decodeBase64(stringToDecode)); }
From source file:com.useekm.types.GeoWkb.java
@Override public Geometry getGeo() { return binaryToGeometry(Base64.decodeBase64(getValue().getBytes())); }
From source file:ch.fork.AdHocRailway.ui.utils.ImageTools.java
/** * Decode string to image//from ww w.j a v a2s .c o m * * @param imageString The string to decode * @return decoded image */ public static BufferedImage decodeToImage(String imageString) { BufferedImage image = null; byte[] imageByte; try { imageByte = Base64.decodeBase64(imageString); ByteArrayInputStream bis = new ByteArrayInputStream(imageByte); image = ImageIO.read(bis); bis.close(); } catch (Exception e) { e.printStackTrace(); } return image; }
From source file:com.moz.fiji.hive.utils.FijiDataRequestSerializer.java
/** * Deserializes a data request.//from www.jav a 2 s. co m * * @param serialized A serialized data request. * @return A data request, or null if there is no data request in the given string. * @throws IOException If there is an IO error. */ public static FijiDataRequest deserialize(String serialized) throws IOException { final byte[] bytes = Base64.decodeBase64(serialized); final ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(bytes)); try { return (FijiDataRequest) ois.readObject(); } catch (ClassNotFoundException e) { throw new IOException(e); } finally { IOUtils.closeQuietly(ois); } }
From source file:edu.mit.ll.graphulo.util.SerializationUtil.java
public static Object deserializeBase64(String str) { byte[] b = Base64.decodeBase64(str); return deserialize(b); }