List of usage examples for org.apache.commons.codec.binary Base64 encodeBase64
public static byte[] encodeBase64(final byte[] binaryData)
From source file:architecture.common.license.io.LicenseWriter.java
public void write(Writer writer, int columns) throws IOException { String xml = document.asXML(); String base64 = new String(Base64.encodeBase64(xml.getBytes(ApplicationConstants.DEFAULT_CHAR_ENCODING))); if (columns > 0) base64 = addLineBreaks(base64, columns); StringReader reader = new StringReader(base64); char buffer[] = new char[32768]; int len;//from ww w . ja v a2 s . co m while ((len = reader.read(buffer)) != -1) writer.write(buffer, 0, len); writer.flush(); }
From source file:com.networknt.client.oauth.TokenHelper.java
public static String encodeCredentials(String clientId, String clientSecret) { String cred = ""; if (clientSecret != null) { cred = clientId + ":" + clientSecret; } else {/* w w w .j av a2 s .c o m*/ cred = clientId; } String encodedValue = null; byte[] encodedBytes = Base64.encodeBase64(cred.getBytes()); encodedValue = new String(encodedBytes); return encodedValue; }
From source file:com.qut.middleware.esoe.sso.plugins.artifact.data.impl.ArtifactDaoBase.java
public void storeArtifact(Artifact artifact) throws ArtifactBindingException { try {// ww w .ja v a2 s. c o m byte[] base64Bytes = Base64.encodeBase64(artifact.getMessageHandle()); String messageHandle = new String(base64Bytes, "UTF-8"); storeArtifact(artifact, messageHandle); } catch (UnsupportedEncodingException e) { throw new ArtifactBindingException( "Unable to create message handle base64 string, the required encoding is not supported. Error: " + e.getMessage(), e); } }
From source file:cn.ctyun.amazonaws.util.StringUtils.java
/** * Base64 encodes the data in the specified byte buffer and returns it as a * base64 encoded string./*from ww w . j a v a 2s. c o m*/ * * @param byteBuffer * The data to base64 encode and return as a string. * * @return The base64 encoded contents of the specified byte buffer. */ public static String fromByteBuffer(ByteBuffer byteBuffer) { byte[] encodedBytes = null; if (byteBuffer.hasArray()) { encodedBytes = Base64.encodeBase64(byteBuffer.array()); } else { byte[] binaryData = new byte[byteBuffer.limit()]; byteBuffer.get(binaryData); encodedBytes = Base64.encodeBase64(binaryData); } return new String(encodedBytes); }
From source file:com.davidcode.code.util.ErrorBuffer.java
/** * Inserts a Base64 encded string into the buffer * * @param input/*www. j av a 2 s. co m*/ */ public void pstrb64(String input) { byte[] encoded = Base64.encodeBase64(input.getBytes()); p4(encoded.length); pdata(encoded); }
From source file:hudson.remoting.BinarySafeStreamTest.java
public void testChunkedWrites() throws IOException { byte[] ds = getDataSet(65536); String master = new String(Base64.encodeBase64(ds)); Random r = new Random(0); for (int i = 0; i < 16; i++) { ByteArrayOutputStream buf = new ByteArrayOutputStream(); OutputStream o = BinarySafeStream.wrap(buf); randomCopy(r, new ByteArrayInputStream(ds), o, false); assertEquals(buf.toString(), master); }//w w w. j a v a 2 s. c om }
From source file:com.alu.e3.common.tools.WsseTools.java
public static String getNonce(byte[] nonceBytes) { return new String(Base64.encodeBase64(nonceBytes)); }
From source file:com.marintek.isis.wicket.popupbox.applib.PopupWicketBoxSemanticsProvider.java
static String toString(Serializable serializable) { final ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = null; try {//from w w w . j av a 2 s . com oos = new ObjectOutputStream(baos); oos.writeObject(serializable); return new String(Base64.encodeBase64(baos.toByteArray())); } catch (IOException e) { throw new Base64Serializer.Exception(e); } finally { try { if (oos != null) { oos.close(); } } catch (IOException e) { throw new Base64Serializer.Exception(e); } } }
From source file:com.yahoo.yos.AccessToken.java
public Cookie getCookie() throws UnsupportedEncodingException, JSONException { return new Cookie("yosdk_at", new String(Base64.encodeBase64(toJSONObject().toString().getBytes("UTF-8")), "UTF-8")); }
From source file:net.duckling.ddl.util.EncodeUtil.java
public static String getDisplayURL(Invitation instance) { String all = instance.getEncode() + instance.getId(); return new String(Base64.encodeBase64(all.getBytes())).trim(); }