private static ActivityHandle StringToHandle(String base64) { ActivityHandle activityHandle = null; try { byte[] bytes = Base64.decode(base64); final ByteArrayInputStream bais = new ByteArrayInputStream(bytes); //final JBossObjectInputStream jbois = new JBossObjectInputStream(bais); final ObjectInputStream ois = new ObjectInputStream(bais); activityHandle = (ActivityHandle) ois.readObject(); } catch (Exception e) { e.printStackTrace(); } return activityHandle; }
/** * Converts base64Binary value into byte array. */ public static byte[] unmarshalBase64(String value) { byte[] valueBytes; try { valueBytes = value.getBytes("UTF-8"); } catch (UnsupportedEncodingException e) { valueBytes = value.getBytes(); } return Base64.decode(valueBytes, 0, valueBytes.length); }
/** * Get the user name and password passed in the basic authentication header. * @param request the http servlet request * @return user name and password, or null if not found. If there is no password, * the result may contain only one element, or two elements and the second element is null or empty. */ static public String[] getBasicAuthUsernameAndPassword(HttpServletRequest request){ String authorization = request.getHeader("Authorization"); if (authorization != null && authorization.startsWith("Basic")) { try{ // Authorization: Basic base64credentials String base64Credentials = authorization.substring("Basic".length()).trim(); String credentials = new String(Base64.decode(base64Credentials), "UTF-8"); // credentials = username:password String[] values = StringUtils.split(credentials, ':'); return values; }catch(Exception e){ // ignore } } return null; }
byte[] objBytes = decode(encodedObject);
bytes = decode(bytes, 0, bytes.length);
byte[] decodedPath = Base64.decode(encodedPath);
raw = Base64.decode(bytes, 0, bytes.length);
byte[] jbossBytes = org.jboss.util.Base64.decode(base64Str); if (print) { System.out.println("JBoss: " + toString(jbossBytes));