protected Context parseOriginatingIdentity(String originatingIdentityString) { if (originatingIdentityString == null) { return null; } String[] parts = originatingIdentityString.split(" ", 2); if (parts.length != 2) { throw new HttpMessageNotReadableException("Expected platform and properties values in " + ORIGINATING_IDENTITY_HEADER + " header in request"); } String platform = parts[0]; String encodedProperties; try { encodedProperties = new String(Base64.decode(parts[1].getBytes())); } catch (Exception e) { throw new HttpMessageNotReadableException("Error decoding JSON properties from " + ORIGINATING_IDENTITY_HEADER + " header in request", e); } Map<String, Object> properties; try { properties = readJsonFromString(encodedProperties); } catch (IOException e) { throw new HttpMessageNotReadableException("Error parsing JSON properties from " + ORIGINATING_IDENTITY_HEADER + " header in request", e); } return new Context(platform, properties); }