1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package com.atlassian.jira.rest.client.internal.json;
18
19 import com.atlassian.jira.rest.client.api.domain.Authentication;
20 import com.atlassian.jira.rest.client.api.domain.LoginInfo;
21 import com.atlassian.jira.rest.client.api.domain.SessionCookie;
22 import org.codehaus.jettison.json.JSONException;
23 import org.codehaus.jettison.json.JSONObject;
24
25 public class AuthenticationJsonParser implements JsonObjectParser<Authentication> {
26
27 private final SessionCookieJsonParser sessionCookieJsonParser = new SessionCookieJsonParser();
28 private final LoginInfoJsonParser loginInfoJsonParser = new LoginInfoJsonParser();
29
30 @Override
31 public Authentication parse(JSONObject json) throws JSONException {
32 final SessionCookie sessionCookie = sessionCookieJsonParser.parse(json.getJSONObject("session"));
33 final LoginInfo loginInfo = loginInfoJsonParser.parse(json.getJSONObject("loginInfo"));
34 return new Authentication(loginInfo, sessionCookie);
35 }
36 }