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.domain.Authentication;
20 import com.atlassian.jira.rest.client.domain.LoginInfo;
21 import com.atlassian.jira.rest.client.domain.SessionCookie;
22 import org.codehaus.jettison.json.JSONException;
23 import org.codehaus.jettison.json.JSONObject;
24
25 public class AuthenticationJsonParser implements JsonParser<Authentication> {
26
27 private final SessionCookieJsonParser sessionCookieJsonParser = new SessionCookieJsonParser();
28 private final LoginInfoJsonParser loginInfoJsonParser = new LoginInfoJsonParser();
29 @Override
30 public Authentication parse(JSONObject json) throws JSONException {
31 final SessionCookie sessionCookie = sessionCookieJsonParser.parse(json.getJSONObject("session"));
32 final LoginInfo loginInfo = loginInfoJsonParser.parse(json.getJSONObject("loginInfo"));
33 return new Authentication(loginInfo, sessionCookie);
34 }
35 }