Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Gets the fiesta username
- *
- * @param SSOtoken the authentication token
- */
- private User getUserByCookie(String SSOtoken) {
- /**
- * Create a Jersey client to GET the user id information from the
- * Session using a POST call to the OpenAM idm API.
- */
- Client client = Client.create();
- WebResource webResourceOpenAM = client.resource(AUTHENTICATION_URL);
- ClientResponse responseAuth = webResourceOpenAM.type("application/json").header(IPLANETDIRECTORYPRO, SSOtoken)
- .post(ClientResponse.class, "{}");
- if (responseAuth.getStatus() != 200) {
- throw new RuntimeException("Failed : HTTP error code : " + responseAuth.getStatus());
- }
- String userObject = responseAuth.getEntity(String.class);
- User dto = null;
- ObjectMapper objectUser = new ObjectMapper();
- JsonNode userNode;
- try {
- userNode = objectUser.readValue(userObject, JsonNode.class);
- String id = userNode.get("id").asText();
- dto = new User();
- dto.setId(id);
- } catch (JsonParseException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (JsonMappingException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return dto;
- }
Advertisement
Add Comment
Please, Sign In to add comment