// Read the HAL
ReadableRepresentation rr = unmarshalHal(hal);
Map<String, Object> properties = rr.getProperties();
UserDto clientUser = new UserDto();
String apiKey = (String) properties.get("api_key");
String secretKey = (String) properties.get("secret_key");
if ("".equals(apiKey) || "".equals(secretKey)) {
return Optional.absent();
}
// Must assume that the authentication was successful
// Using the credentials later would mean failed authentication anyway
clientUser.setApiKey(apiKey);
clientUser.setSecretKey(secretKey);
clientUser.setCachedAuthorities(new Authority[] {Authority.ROLE_CUSTOMER});
return Optional.of(clientUser);
}