From dde68aa8d509745bd0cd53e8a394d7f2eb0ed0c7 Mon Sep 17 00:00:00 2001 From: chkp-yaelg <44432942+chkp-yaelg@users.noreply.github.com> Date: Tue, 25 Dec 2018 17:52:28 +0200 Subject: [PATCH] Add session information to the output Json Add session information to the output Json when running the tool with --published-session-uid. The option will be supported only for customers with specific HF installed --- .../mgmt_api/objects/IndexView.java | 14 ++-- .../checkpoint/mgmt_api/objects/Session.java | 64 +++++++++++++++++++ 2 files changed, 72 insertions(+), 6 deletions(-) create mode 100644 src/main/java/com/checkpoint/mgmt_api/objects/Session.java diff --git a/src/main/java/com/checkpoint/mgmt_api/objects/IndexView.java b/src/main/java/com/checkpoint/mgmt_api/objects/IndexView.java index 6113d33..c39ccd1 100644 --- a/src/main/java/com/checkpoint/mgmt_api/objects/IndexView.java +++ b/src/main/java/com/checkpoint/mgmt_api/objects/IndexView.java @@ -10,7 +10,7 @@ */ public class IndexView { - private String publishedSessionUid; + private Session session; private String domain; private List policyPackages = new ArrayList<>(); @@ -34,14 +34,14 @@ public List getPolicyPackages() return policyPackages; } - public String getPublishedSessionUid() + public Session getSession() { - return publishedSessionUid; + return session; } - public void setPublishedSessionUid(String publishedSessionUid) + public void setSession(Session session) { - this.publishedSessionUid = publishedSessionUid; + this.session = session; } /** @@ -54,7 +54,9 @@ public JSONObject toJson(){ JSONObject jsonIndex = new JSONObject(); - jsonIndex.put("published-session-uid",publishedSessionUid); + if(session != null){ + jsonIndex.put("published-session",session.toJson()); + } jsonIndex.put("domain",domain); JSONArray policy = new JSONArray(); for( PolicyPackage policyPackage : policyPackages){ diff --git a/src/main/java/com/checkpoint/mgmt_api/objects/Session.java b/src/main/java/com/checkpoint/mgmt_api/objects/Session.java new file mode 100644 index 0000000..86f729f --- /dev/null +++ b/src/main/java/com/checkpoint/mgmt_api/objects/Session.java @@ -0,0 +1,64 @@ +package com.checkpoint.mgmt_api.objects; + +import org.json.simple.JSONObject; + +public class Session +{ + private String uid; + private String name; + private String publishTime; + private Boolean lastPublishedSession; + + public String getUid() + { + return uid; + } + + public void setUid(String uid) + { + this.uid = uid; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public String getPublishTime() + { + return publishTime; + } + + public void setPublishTime(String publishTime) + { + this.publishTime = publishTime; + } + + public Boolean getLastPublishedSession() + { + return lastPublishedSession; + } + + public void setLastPublishedSession(Boolean lastPublishedSession) + { + this.lastPublishedSession = lastPublishedSession; + } + + public JSONObject toJson(){ + + JSONObject jsonObject = new JSONObject(); + jsonObject.put("uid",getUid()); + jsonObject.put("name",getName()); + jsonObject.put("publish-time",getPublishTime()); + jsonObject.put("last-published-session", getLastPublishedSession()); + + return jsonObject; + } + + +}