public static Exception getCause(BuiltResponse resp) { if (resp == null || resp.getStatus() != Status.EXPECTATION_FAILED.getStatusCode()) return null; String exceptionClass = resp.getHeaderString(EXCEPTION_HEADER); if (!StringUtils.isBlank(exceptionClass)) { String body = resp.readEntity(String.class); resp.close(); try { ByteArrayInputStream bais = new ByteArrayInputStream( Base64.decode(body.getBytes(MotanConstants.DEFAULT_CHARACTER))); ObjectInputStream ois = new ObjectInputStream(bais); return (Exception) ois.readObject(); } catch (Exception e) { LoggerUtil.error("deserialize " + exceptionClass + " error", e); } } return null; }
/** * Decodes data from Base64 notation, automatically * detecting gzip-compressed data and decompressing it. * * @param s the string to decode * @return the decoded data * @throws java.io.IOException If there is a problem * @since 1.4 */ public static byte[] decode(String s) throws java.io.IOException { return decode(s, NO_OPTIONS); }
/** * Low-level access to decoding ASCII characters in * the form of a byte array. <strong>Ignores GUNZIP option, if * it's set.</strong> This is not generally a recommended method, * although it is used internally as part of the decoding process. * Special case: if len = 0, an empty array is returned. Still, * if you need more speed and reduced memory footprint (and aren't * gzipping), consider this method. * * @param source The Base64 encoded data * @return decoded data * @throws IOException If bogus characters exist in source data * @since 2.3.1 */ public static byte[] decode(byte[] source) throws java.io.IOException { byte[] decoded = null; // try { decoded = decode(source, 0, source.length, Base64.NO_OPTIONS); // } catch( java.io.IOException ex ) { // assert false : "IOExceptions only come from GZipping, which is turned off: " + ex.getMessage(); // } return decoded; }
/** * Decode a PEM string to DER format. * * @param pem PEM encoded string * @return decoded bytes * @throws java.io.IOException if I/O error occurred */ public static byte[] pemToDer(String pem) throws java.io.IOException { pem = removeBeginEnd(pem); return Base64.decode(pem); }
protected void extractAttributes() { String heads = attributes.get(HEADERS); if (heads != null) { headers = Arrays.asList(heads.split(":")); } String sig = attributes.get(SIGNATURE); try { if (sig != null) signature = Base64.decode(sig); } catch (IOException e) { throw new RuntimeException(e); } }
/** * Base64 encoded pks bytes. * * @param base64 Base64 encoded string */ public PKCS7SignatureInput(final String base64) { try { byte[] bytes = Base64.decode(base64); this.data = new CMSSignedData(bytes); } catch (Exception e) { throw new RuntimeException(e); } }
public static byte[] decode(String s) { s = s.replace('-', '+'); // 62nd char of encoding s = s.replace('_', '/'); // 63rd char of encoding switch (s.length() % 4) // Pad with trailing '='s { case 0: break; // No pad chars in this case case 2: s += "=="; break; // Two pad chars case 3: s += "="; break; // One pad char default: throw new RuntimeException(Messages.MESSAGES.illegalBase64UrlString()); } try { return Base64.decode(s); } catch (Exception e) { throw new RuntimeException(e); } }
byte[] objBytes = decode(encodedObject, options);
bytes = decode(bytes, 0, bytes.length, options);
byte[] der = Base64.decode(pem);
try enclosedBh = Base64.decode(encodedBh);
/** * Decodes data from Base64 notation, automatically * detecting gzip-compressed data and decompressing it. * * @param s the string to decode * @return the decoded data * @throws java.io.IOException If there is a problem * @since 1.4 */ public static byte[] decode(String s) throws java.io.IOException { return decode(s, NO_OPTIONS); }
/** * Decodes data from Base64 notation, automatically * detecting gzip-compressed data and decompressing it. * * @param s the string to decode * @return the decoded data * @throws java.io.IOException If there is a problem * @since 1.4 */ public static byte[] decode(String s) throws java.io.IOException { return decode(s, NO_OPTIONS); }
/** * Low-level access to decoding ASCII characters in * the form of a byte array. <strong>Ignores GUNZIP option, if * it's set.</strong> This is not generally a recommended method, * although it is used internally as part of the decoding process. * Special case: if len = 0, an empty array is returned. Still, * if you need more speed and reduced memory footprint (and aren't * gzipping), consider this method. * * @param source The Base64 encoded data * @return decoded data * @since 2.3.1 */ public static byte[] decode(byte[] source) throws java.io.IOException { byte[] decoded = null; // try { decoded = decode(source, 0, source.length, Base64.NO_OPTIONS); // } catch( java.io.IOException ex ) { // assert false : "IOExceptions only come from GZipping, which is turned off: " + ex.getMessage(); // } return decoded; }
public static String decode(String str) { byte[] bt = null; try { bt = Base64.decode(str); } catch (Exception e) { e.printStackTrace(); } return new String(bt); }
public static String decodeId(String encodedId) throws IOException { String key64 = URLDecoder.decode(encodedId, "UTF-8"); byte[] bKey = Base64.decode(key64); return new String(bKey); } }
public static String decode(String str) { byte[] bt = null; try { bt = Base64.decode(str); } catch (Exception e) { e.printStackTrace(); } return new String(bt); }
/** * Decode a PEM string to DER format * * @param pem * @return * @throws java.io.IOException */ public static byte[] pemToDer(String pem) throws IOException { pem = removeBeginEnd(pem); return Base64.decode(pem); }
private Key deserializeKey(String k) throws Exception { String key64 = URLDecoder.decode(k, "UTF-8"); byte[] bKey = Base64.decode(key64); ByteArrayInputStream bais = new ByteArrayInputStream(bKey); DataInputStream in = new DataInputStream(bais); Key key = new Key(); key.readFields(in); return key; }
public static byte[] decode(String s) { s = s.replace('-', '+'); // 62nd char of encoding s = s.replace('_', '/'); // 63rd char of encoding switch (s.length() % 4) // Pad with trailing '='s { case 0: break; // No pad chars in this case case 2: s += "=="; break; // Two pad chars case 3: s += "="; break; // One pad char default: throw new RuntimeException(Messages.MESSAGES.illegalBase64UrlString()); } try { return Base64.decode(s); } catch (Exception e) { throw new RuntimeException(e); } }