use of org.apache.commons.codec.binary.Base64.encodeBase64String in project camel by apache.
the class Base64DataFormat method marshalUrlSafe.
private void marshalUrlSafe(Exchange exchange, Object graph, OutputStream stream) throws Exception {
byte[] decoded = ExchangeHelper.convertToMandatoryType(exchange, byte[].class, graph);
Base64 codec = new Base64(lineLength, lineSeparator, true);
byte[] encoded = codec.encode(decoded);
stream.write(encoded);
stream.flush();
}
use of org.apache.commons.codec.binary.Base64.encodeBase64String in project adempiere by adempiere.
the class DigestOfFile method digestAsBase64.
/**
* @author rlemeill
* @param file
* @return hash (base64 encoded)
* @throws Exception
*/
public synchronized String digestAsBase64(File file) throws Exception {
byte[] digest = digestAsByteArray(file);
Base64 encoder = new Base64();
String digestAsBase64 = new String(encoder.encode(digest), "ASCII");
return digestAsBase64;
}
use of org.apache.commons.codec.binary.Base64.encodeBase64String in project oxCore by GluuFederation.
the class Response method loadXmlFromBase64.
public void loadXmlFromBase64(String response) throws ParserConfigurationException, SAXException, IOException {
Base64 base64 = new Base64();
byte[] decodedResponse = base64.decode(response);
String decodedS = new String(decodedResponse);
loadXml(decodedS);
}
use of org.apache.commons.codec.binary.Base64.encodeBase64String in project karaf by apache.
the class DigestPasswordLoginModule method doPasswordDigest.
public String doPasswordDigest(String nonce, String created, byte[] password) {
String passwdDigest = null;
try {
byte[] b1 = nonce != null ? new Base64().decode(nonce) : new byte[0];
byte[] b2 = created != null ? created.getBytes("UTF-8") : new byte[0];
byte[] b3 = password;
byte[] b4 = new byte[b1.length + b2.length + b3.length];
int offset = 0;
System.arraycopy(b1, 0, b4, offset, b1.length);
offset += b1.length;
System.arraycopy(b2, 0, b4, offset, b2.length);
offset += b2.length;
System.arraycopy(b3, 0, b4, offset, b3.length);
byte[] digestBytes = generateDigest(b4);
passwdDigest = new String(new Base64().encodeBase64(digestBytes));
} catch (Exception e) {
LOGGER.debug(e.getMessage(), e);
}
return passwdDigest;
}
use of org.apache.commons.codec.binary.Base64.encodeBase64String in project nhin-d by DirectProject.
the class LdapCertUtilImpl_LdapSearch_Test method testCertificateFormatIsX509_CertificateIsAddedCorrectly.
/**
*
* @throws Exception
*/
public void testCertificateFormatIsX509_CertificateIsAddedCorrectly() throws Exception {
new TestPlan() {
protected Object nextElement_Internal() {
BufferedInputStream f = null;
try {
File fl = new File("testfile");
int idx = fl.getAbsolutePath().lastIndexOf("testfile");
String path = fl.getAbsolutePath().substring(0, idx);
byte[] buffer = new byte[(int) new File(path + "src/test/resources/certs/bob.der").length() + 100];
f = new BufferedInputStream(new FileInputStream(path + "src/test/resources/certs/bob.der"));
f.read(buffer);
Base64 base64 = new Base64();
theNextElement = new String(base64.encode(buffer));
} catch (Exception e) {
e.printStackTrace();
fail();
IOUtils.closeQuietly(f);
}
return theNextElement;
}
protected String createCertificateFormat() {
theCreateCertificateFormat = "X509";
return theCreateCertificateFormat;
}
protected void doAssertions(Collection<X509Certificate> ldapSearch) throws Exception {
assertEquals(1, nextElementCalls);
assertNotNull(ldapSearch);
assertEquals(1, ldapSearch.size());
X509Certificate cert = ldapSearch.iterator().next();
assertTrue(cert instanceof X509Certificate);
assertEquals("EMAILADDRESS=bob@nhind.hsgincubator.com, CN=Bob Patel, OU=Incubator, O=HSG, L=Redmond, ST=WA, C=US", cert.getSubjectX500Principal().toString());
}
}.perform();
}
Aggregations