List of usage examples for org.apache.commons.codec.binary Base64 decodeBase64
public static byte[] decodeBase64(final byte[] base64Data)
From source file:com.mastfrog.acteur.util.BasicCredentials.java
public static BasicCredentials parse(String header) { Matcher m = HEADER.matcher(header); if (m.matches()) { String base64 = m.group(1); // byte[] decoded = Base64.getDecoder().decode(base64); // String s = new String(decoded, UTF_8); byte[] bytes = base64.getBytes(UTF_8); if (Base64.isArrayByteBase64(bytes)) { bytes = Base64.decodeBase64(bytes); }//from w ww. j ava2 s . c o m String s = new String(bytes, US_ASCII); m = UNPW.matcher(s); if (m.matches()) { String username = m.group(1); String password = m.group(2); return new BasicCredentials(username, password); } } return null; }
From source file:com.netsteadfast.greenstep.util.EncryptorUtils.java
public static String decrypt(String key1, String iv1, String encrypted) { try {/*from ww w. j a v a 2s. c om*/ IvParameterSpec iv = new IvParameterSpec(iv1.getBytes(Constants.BASE_ENCODING)); SecretKeySpec skeySpec = new SecretKeySpec(key1.getBytes(Constants.BASE_ENCODING), "AES"); Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5PADDING"); cipher.init(Cipher.DECRYPT_MODE, skeySpec, iv); byte[] original = cipher.doFinal(Base64.decodeBase64(encrypted)); return new String(original); } catch (Exception ex) { ex.printStackTrace(); } return null; }
From source file:ca.uhn.fhir.model.primitive.Base64BinaryDt.java
@Override protected byte[] parse(String theValue) { return Base64.decodeBase64(theValue.getBytes(Constants.CHARSET_UTF8)); }
From source file:com.apitrary.orm.codec.image.ImageJPGCodec.java
/** {@inheritDoc} */ @Override/*from w ww .j a v a 2s. c om*/ public Image decode(String value) { if (value == null || value.isEmpty()) { return null; } byte[] buffer = Base64.decodeBase64(value); InputStream in = new ByteArrayInputStream(buffer); BufferedImage bImageFromConvert; try { bImageFromConvert = ImageIO.read(in); return bImageFromConvert; } catch (IOException e) { throw new RuntimeException(e); } }
From source file:com.zxy.commons.codec.utils.Base64Utils.java
/** * ?/*w w w.ja v a2 s. c o m*/ * * @param base64Str ? * @param charset * @return ? */ public static String decode(String base64Str, String charset) { if (StringUtils.isBlank(base64Str)) { return null; } return new String(Base64.decodeBase64(base64Str.getBytes(Charset.forName(charset)))); }
From source file:com.kylinolap.rest.security.PasswordPlaceholderConfigurer.java
public static String decrypt(String strToDecrypt) { try {// w w w . ja v a 2 s.c o m Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5PADDING"); final SecretKeySpec secretKey = new SecretKeySpec(key, "AES"); cipher.init(Cipher.DECRYPT_MODE, secretKey); final String decryptedString = new String(cipher.doFinal(Base64.decodeBase64(strToDecrypt))); return decryptedString; } catch (Exception e) { } return null; }
From source file:de.schierla.jbeagle.BeagleBook.java
private String base64_decode(String text) { return new String(Base64.decodeBase64(text), utf8); }
From source file:io.druid.query.aggregation.datasketches.theta.SketchOperations.java
public static Sketch deserializeFromBase64EncodedString(String str) { return deserializeFromByteArray(Base64.decodeBase64(str.getBytes(Charsets.UTF_8))); }
From source file:com.mirth.connect.plugins.rtfviewer.RTFViewer.java
@Override public void viewAttachments(List<String> attachmentIds) { // do viewing code Frame frame = new Frame("RTF Viewer"); frame.setLayout(new BorderLayout()); try {/*w ww.ja v a 2 s .c o m*/ Attachment attachment = parent.mirthClient.getAttachment(attachmentIds.get(0)); byte[] rawRTF = Base64.decodeBase64(attachment.getData()); JEditorPane jEditorPane = new JEditorPane("text/rtf", new String(rawRTF)); if (jEditorPane.getDocument().getLength() == 0) { // decoded when it should not have been. i.e.) the attachment data was not encoded. jEditorPane.setText(new String(attachment.getData())); } jEditorPane.setEditable(false); JScrollPane scrollPane = new javax.swing.JScrollPane(); scrollPane.setViewportView(jEditorPane); frame.add(scrollPane); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { e.getWindow().dispose(); } }); frame.setSize(600, 800); Dimension dlgSize = frame.getSize(); Dimension frmSize = parent.getSize(); Point loc = parent.getLocation(); if ((frmSize.width == 0 && frmSize.height == 0) || (loc.x == 0 && loc.y == 0)) { frame.setLocationRelativeTo(null); } else { frame.setLocation((frmSize.width - dlgSize.width) / 2 + loc.x, (frmSize.height - dlgSize.height) / 2 + loc.y); } frame.setVisible(true); } catch (Exception e) { parent.alertException(parent, e.getStackTrace(), e.getMessage()); } }
From source file:ezbake.thrift.serializer.Base64Serializer.java
@Override public <U extends TBase<?, ?>> U deserialize(Class<U> thriftClass, String serializedObject) throws TException { return serializer.deserialize(thriftClass, Base64.decodeBase64(serializedObject)); }