public void logout(RestClient client) throws JiraException { if (token != null) { try { client.delete(Resource.getAuthUri() + "session"); } catch (Exception e) { throw new JiraException("Failed to logout", e); } } }
public void initialize(RestClient client) throws JiraException { if (token==null) { try { JSONObject req = new JSONObject(); req.put("username", username); req.put("password", password); JSON json = client.post(Resource.getAuthUri() + "session", req); if (json instanceof JSONObject) { JSONObject jso = (JSONObject) json; jso = (JSONObject) jso.get("session"); cookieName = (String)jso.get("name"); token = (String)jso.get("value"); } } catch (Exception ex) { throw new JiraException("Failed to login", ex); } } }