2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.policy.controller;
24 import java.io.BufferedReader;
26 import java.io.FileReader;
27 import java.io.IOException;
28 import java.io.PrintWriter;
29 import java.nio.file.Path;
30 import java.nio.file.Paths;
31 import java.util.ArrayList;
32 import java.util.HashMap;
33 import java.util.HashSet;
34 import java.util.Iterator;
35 import java.util.LinkedHashMap;
36 import java.util.List;
39 import java.util.UUID;
41 import javax.servlet.http.HttpServletRequest;
42 import javax.servlet.http.HttpServletResponse;
44 import org.hibernate.SQLQuery;
45 import org.hibernate.Session;
46 import org.hibernate.SessionFactory;
47 import org.hibernate.Transaction;
48 import org.json.JSONObject;
49 import org.openecomp.policy.adapter.AddressGroupJson;
50 import org.openecomp.policy.adapter.AddressJson;
51 import org.openecomp.policy.adapter.AddressMembers;
52 import org.openecomp.policy.adapter.DeployNowJson;
53 import org.openecomp.policy.adapter.PolicyAdapter;
54 import org.openecomp.policy.adapter.PrefixIPList;
55 import org.openecomp.policy.adapter.ServiceGroupJson;
56 import org.openecomp.policy.adapter.ServiceListJson;
57 import org.openecomp.policy.adapter.ServiceMembers;
58 import org.openecomp.policy.adapter.ServicesJson;
59 import org.openecomp.policy.adapter.Term;
60 import org.openecomp.policy.adapter.TermCollector;
61 import org.openecomp.policy.admin.PolicyNotificationMail;
62 import org.openecomp.policy.admin.RESTfulPAPEngine;
63 import org.openecomp.policy.dao.PolicyVersionDao;
64 import org.openecomp.policy.dao.RuleAlgorithmsDao;
65 import org.openecomp.policy.dao.WatchPolicyNotificationDao;
66 import org.openecomp.policy.elk.client.PolicyElasticSearchController;
67 import org.openecomp.policy.rest.dao.AddressGroupDao;
68 import org.openecomp.policy.rest.dao.FirewallDictionaryListDao;
69 import org.openecomp.policy.rest.dao.PrefixListDao;
70 import org.openecomp.policy.rest.dao.SecurityZoneDao;
71 import org.openecomp.policy.rest.dao.ServiceGroupDao;
72 import org.openecomp.policy.rest.dao.ServiceListDao;
73 import org.openecomp.policy.rest.dao.TermListDao;
74 import org.openecomp.policy.rest.jpa.AddressGroup;
75 import org.openecomp.policy.rest.jpa.FirewallDictionaryList;
76 import org.openecomp.policy.rest.jpa.GroupServiceList;
77 import org.openecomp.policy.rest.jpa.PREFIXLIST;
78 import org.openecomp.policy.rest.jpa.PolicyVersion;
79 import org.openecomp.policy.rest.jpa.RuleAlgorithms;
80 import org.openecomp.policy.rest.jpa.SecurityZone;
81 import org.openecomp.policy.rest.jpa.ServiceList;
82 import org.openecomp.policy.rest.jpa.TermList;
83 import org.openecomp.portalsdk.core.controller.RestrictedBaseController;
84 import org.openecomp.portalsdk.core.web.support.JsonMessage;
85 import org.openecomp.portalsdk.core.web.support.UserUtils;
86 import org.springframework.beans.factory.annotation.Autowired;
87 import org.springframework.http.MediaType;
88 import org.springframework.stereotype.Controller;
89 import org.springframework.web.bind.annotation.RequestMapping;
90 import org.springframework.web.servlet.ModelAndView;
92 import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
93 import org.openecomp.policy.common.logging.flexlogger.Logger;
95 import com.att.research.xacml.api.XACML3;
96 import org.openecomp.policy.xacml.api.XACMLErrorConstants;
97 import org.openecomp.policy.xacml.util.XACMLPolicyScanner;
98 import com.fasterxml.jackson.core.JsonGenerationException;
99 import com.fasterxml.jackson.databind.DeserializationFeature;
100 import com.fasterxml.jackson.databind.JsonMappingException;
101 import com.fasterxml.jackson.databind.JsonNode;
102 import com.fasterxml.jackson.databind.ObjectMapper;
103 import com.fasterxml.jackson.databind.ObjectWriter;
104 import com.google.common.base.Joiner;
106 import oasis.names.tc.xacml._3_0.core.schema.wd_17.AllOfType;
107 import oasis.names.tc.xacml._3_0.core.schema.wd_17.AnyOfType;
108 import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType;
109 import oasis.names.tc.xacml._3_0.core.schema.wd_17.MatchType;
110 import oasis.names.tc.xacml._3_0.core.schema.wd_17.PolicyType;
111 import oasis.names.tc.xacml._3_0.core.schema.wd_17.TargetType;
115 public class CreateFirewallController extends RestrictedBaseController {
116 private static Logger logger = FlexLogger.getLogger(CreateFirewallController.class);
118 private static RuleAlgorithmsDao ruleAlgorithmsDao;
119 private static PolicyVersionDao policyVersionDao;
120 private static PrefixListDao prefixListDao;
121 private static ServiceListDao serviceListDao;
122 private static TermListDao termListDao;
123 private static ServiceGroupDao serviceGroupDao;
124 private static AddressGroupDao addressGroupDao;
125 private static SecurityZoneDao securityZoneDao;
126 private static SessionFactory sessionFactory;
127 private static FirewallDictionaryListDao fwDictionaryListDao;
128 private static WatchPolicyNotificationDao policyNotificationDao;
130 List<String> expandablePrefixIPList = new ArrayList<String>();
131 List<String> expandableServicesList= new ArrayList<String>();
133 private String parentSecurityZone;
136 public String getParentSecurityZone() {
137 return parentSecurityZone;
140 public void setParentSecurityZone(String parentSecurityZone) {
141 this.parentSecurityZone = parentSecurityZone;
147 private CreateFirewallController(RuleAlgorithmsDao ruleAlgorithmsDao, PolicyVersionDao policyVersionDao, PrefixListDao prefixListDao,
148 ServiceListDao serviceListDao, TermListDao termListDao, ServiceGroupDao serviceGroupDao, AddressGroupDao addressGroupDao, SecurityZoneDao securityZoneDao, SessionFactory sessionFactory
149 ,FirewallDictionaryListDao fwDictionaryListDao, WatchPolicyNotificationDao policyNotificationDao){
150 CreateFirewallController.addressGroupDao = addressGroupDao;
151 CreateFirewallController.ruleAlgorithmsDao = ruleAlgorithmsDao;
152 CreateFirewallController.policyVersionDao = policyVersionDao;
153 CreateFirewallController.prefixListDao = prefixListDao;
154 CreateFirewallController.serviceListDao = serviceListDao;
155 CreateFirewallController.termListDao = termListDao;
156 CreateFirewallController.serviceGroupDao = serviceGroupDao;
157 CreateFirewallController.securityZoneDao = securityZoneDao;
158 CreateFirewallController.sessionFactory = sessionFactory;
159 CreateFirewallController.fwDictionaryListDao = fwDictionaryListDao;
160 CreateFirewallController.policyNotificationDao = policyNotificationDao;
163 public CreateFirewallController(){}
164 protected PolicyAdapter policyAdapter = null;
165 private List<String> termCollectorList;
166 private List<FirewallDictionaryList> parentDictionaryList;
167 private String ruleID = "";
168 private String jsonBody;
169 private ArrayList<Object> attributeList;
170 private ArrayList<Object> fwAttributeList;
172 public String newPolicyID() {
173 return Joiner.on(':').skipNulls().join((PolicyController.getDomain().startsWith("urn") ? null: "urn"),
174 PolicyController.getDomain().replaceAll("[/\\\\.]", ":"), "xacml", "policy", "id", UUID.randomUUID());
177 @RequestMapping(value={"/get_FWParentListDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
178 public void getFWParentListEntityDataByName(HttpServletRequest request, HttpServletResponse response){
180 Map<String, Object> model = new HashMap<String, Object>();
181 ObjectMapper mapper = new ObjectMapper();
182 String query= "select distinct parent from fwparent";
183 model.put("fwParentListDictionaryDatas", mapper.writeValueAsString(queryToDatabase(query)));
185 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
186 JSONObject j = new JSONObject(msg);
187 response.getWriter().write(j.toString());
194 @SuppressWarnings("unchecked")
195 private List<String> queryToDatabase(String query) {
196 Session session = sessionFactory.openSession();
197 Transaction tx = session.beginTransaction();
198 List<String> data = null;
200 SQLQuery sqlquery=session.createSQLQuery(query);
201 //Query hbquery = session.createQuery(query);
202 data = sqlquery.list();
204 } catch (Exception e) {
205 logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Qurying Parent Child Table"+e);
209 }catch(Exception e1){
210 logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1);
217 @SuppressWarnings("unchecked")
218 private void updateToDatabase(String updateQuery) {
219 Session session = sessionFactory.openSession();
220 Transaction tx = session.beginTransaction();
221 List<String> data = null;
223 SQLQuery sqlquery=session.createSQLQuery(updateQuery);
224 sqlquery.executeUpdate();
226 } catch (Exception e) {
227 logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Updating FWChildParent Table"+e);
231 }catch(Exception e1){
232 logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1);
239 @RequestMapping(value={"/policyController/save_FirewallPolicy.htm"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
240 public ModelAndView saveFirewallPolicy(HttpServletRequest request, HttpServletResponse response) throws Exception{
241 termCollectorList = new ArrayList<String>();
242 parentDictionaryList= new ArrayList<FirewallDictionaryList>();
244 String userId = UserUtils.getUserIdFromCookie(request);
245 RESTfulPAPEngine engine = (RESTfulPAPEngine) PolicyController.getPapEngine();
246 ObjectMapper mapper = new ObjectMapper();
247 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
248 JsonNode root = mapper.readTree(request.getReader());
249 PolicyAdapter policyData = (PolicyAdapter)mapper.readValue(root.get("policyData").get("policy").toString(), PolicyAdapter.class);
250 policyData.setDomainDir(root.get("policyData").get("model").get("name").toString().replace("\"", ""));
251 if(root.get("policyData").get("model").get("type").toString().replace("\"", "").equals("file")){
252 policyData.isEditPolicy = true;
254 this.policyAdapter = policyData;
255 if(root.get("policyData").get("model").get("path").size() != 0){
257 for(int i = 0; i < root.get("policyData").get("model").get("path").size(); i++){
258 dirName = dirName.replace("\"", "") + root.get("policyData").get("model").get("path").get(i).toString().replace("\"", "") + File.separator;
260 policyData.setDomainDir(dirName.substring(0, dirName.lastIndexOf(File.separator)));
262 policyData.setDomainDir(root.get("policyData").get("model").get("name").toString().replace("\"", ""));
265 if (policyData.getTtlDate()==null){
266 policyData.setTtlDate("NA");
268 String dateTTL = policyData.getTtlDate();
269 String newDate = convertDate(dateTTL);
270 policyData.setTtlDate(newDate);
274 int highestVersion = 0;
275 int descriptionVersion = 0;
276 //get the highest version of policy from policy version table.
277 //getting the sub scope domain where the policy is created or updated
278 String dbCheckPolicyName = policyData.getDomainDir() + File.separator + "Config_FW_" + policyData.getPolicyName();
279 List<PolicyVersion> policyVersionList = policyVersionDao.getPolicyVersionEntityByName(dbCheckPolicyName);
280 if (policyVersionList.size() > 0) {
281 for(int i = 0; i < policyVersionList.size(); i++) {
282 PolicyVersion entityItem = policyVersionList.get(i);
283 if(entityItem.getPolicyName().equals(dbCheckPolicyName)){
284 highestVersion = entityItem.getHigherVersion();
288 if(highestVersion != 0){
289 version = highestVersion;
290 descriptionVersion = highestVersion +1;
293 descriptionVersion = 1;
296 //set policy adapter values for Building JSON object containing policy data
297 String createdBy = "";
298 String modifiedBy = userId;
299 if(descriptionVersion == 1){
302 String policyName = PolicyController.getGitPath().toAbsolutePath().toString() + File.separator + policyData.getDomainDir() + File.separator + policyData.getOldPolicyFileName() + ".xml";
303 File policyPath = new File(policyName);
305 createdBy = XACMLPolicyScanner.getCreatedBy(policyPath.toPath());
306 } catch (IOException e) {
311 if(policyData.getFwPolicyType().equalsIgnoreCase("Parent Policy")){
312 String comboNames="";
314 for(Object fwattribute : policyData.getFwattributes()){
315 if(fwattribute instanceof LinkedHashMap<?, ?>){
316 String key = ((LinkedHashMap<?, ?>) fwattribute).get("option").toString();
318 comboNames = comboNames+","+ key;
326 policyData.setPolicyDescription(policyData.getPolicyDescription()+ "@CreatedBy:" +createdBy + "@CreatedBy:" + "@ModifiedBy:" +modifiedBy + "@ModifiedBy:"+"@comboList:"+comboNames);
329 policyData.setPolicyDescription(policyData.getPolicyDescription()+ "@CreatedBy:" +createdBy + "@CreatedBy:" + "@ModifiedBy:" +modifiedBy + "@ModifiedBy:");
332 //policyData.setPolicyDescription(policyData.getPolicyDescription()+ "@CreatedBy:" +createdBy + "@CreatedBy:" + "@ModifiedBy:" +modifiedBy + "@ModifiedBy:");
333 Map<String, String> successMap = new HashMap<String, String>();
335 //set the Rule Combining Algorithm Id to be sent to PAP-REST via JSON
336 List<RuleAlgorithms> ruleAlgorithmsList = ruleAlgorithmsDao.getRuleAlgorithms();
337 for (int i = 0; i < ruleAlgorithmsList.size(); i++) {
338 RuleAlgorithms a = ruleAlgorithmsList.get(i);
339 if (a.getXacmlId().equals(XACML3.ID_RULE_PERMIT_OVERRIDES.stringValue())) {
340 policyData.setRuleCombiningAlgId(a.getXacmlId());
345 if(policyData.getAttributes().size() > 0){
346 for(Object attribute : policyData.getAttributes()){
347 if(attribute instanceof LinkedHashMap<?, ?>){
348 String key = ((LinkedHashMap<?, ?>) attribute).get("option").toString();
349 termCollectorList.add(key);
353 if(policyData.getFwattributes()!=null){
354 if(policyData.getFwattributes().size() > 0){
355 for(Object fwattribute : policyData.getFwattributes()){
356 if(fwattribute instanceof LinkedHashMap<?, ?>){
357 String key = ((LinkedHashMap<?, ?>) fwattribute).get("option").toString();
358 FirewallDictionaryList fwDictValue = fwDictionaryListDao.getFWDictionaryDataById(key);
359 parentDictionaryList.add(fwDictValue);
360 if(fwDictValue.getAddressList().contains(",")) {
361 for(String individualAddressObject:fwDictValue.getAddressList().split(",") ){
362 expandablePrefixIPList.add(individualAddressObject);
366 expandablePrefixIPList.add(fwDictValue.getAddressList());
369 if(fwDictValue.getServiceList().contains(",")) {
370 for(String individualAddressObject:fwDictValue.getServiceList().split(",") ){
371 expandableServicesList.add(individualAddressObject);
375 expandableServicesList.add(fwDictValue.getServiceList());
382 jsonBody = constructJson();
383 if (jsonBody != null || jsonBody.equalsIgnoreCase("")) {
384 policyAdapter.setJsonBody(jsonBody);
387 policyAdapter.setJsonBody("{}");
389 policyData.setJsonBody(jsonBody);
392 if (policyData.isEditPolicy()){
393 //increment the version and set in policyAdapter
394 policyData.setVersion(String.valueOf(version));
395 policyData.setHighestVersion(version);
396 policyData.setPolicyID(this.newPolicyID());
397 policyData.setRuleID(ruleID);
398 successMap = engine.updatePolicyRequest(policyData);
400 //send it for policy creation
401 policyData.setVersion(String.valueOf(version));
402 policyData.setHighestVersion(version);
403 successMap = engine.createPolicyRequest(policyData);
407 if (successMap.containsKey("success")) {
408 // Add it into our tree
409 Path finalPolicyPath = null;
410 finalPolicyPath = Paths.get(successMap.get("success"));
411 PolicyElasticSearchController controller = new PolicyElasticSearchController();
412 controller.updateElk(finalPolicyPath.toString());
413 File file = finalPolicyPath.toFile();
415 String policyName = file.toString();
416 String removePath = policyName.substring(policyName.indexOf("repository")+11);
417 String removeXml = removePath.replace(".xml", "");
418 String removeExtension = removeXml.substring(0, removeXml.indexOf("."));
419 List<PolicyVersion> versionList = policyVersionDao.getPolicyVersionEntityByName(removeExtension);
420 if (versionList.size() > 0) {
421 for(int i = 0; i < versionList.size(); i++) {
422 PolicyVersion entityItem = versionList.get(i);
423 if(entityItem.getPolicyName().equals(removeExtension)){
424 version = entityItem.getHigherVersion() +1;
425 entityItem.setActiveVersion(version);
426 entityItem.setHigherVersion(version);
427 entityItem.setModifiedBy(userId);
428 policyVersionDao.update(entityItem);
429 if(policyData.isEditPolicy){
430 PolicyNotificationMail email = new PolicyNotificationMail();
431 String mode = "EditPolicy";
432 String policyNameForEmail = policyData.getDomainDir() + File.separator + policyData.getOldPolicyFileName() + ".xml";
433 email.sendMail(entityItem, policyNameForEmail, mode, policyNotificationDao);
438 PolicyVersion entityItem = new PolicyVersion();
439 entityItem.setActiveVersion(version);
440 entityItem.setHigherVersion(version);
441 entityItem.setPolicyName(removeExtension);
442 entityItem.setCreatedBy(userId);
443 entityItem.setModifiedBy(userId);
444 policyVersionDao.Save(entityItem);
446 removeExtension=removeExtension.replace(File.separator, ".");
448 if(policyAdapter.getFwPolicyType().equalsIgnoreCase("Parent Policy")){
449 //Reads the SecurityZone from the Parent UI and then gets the value from the DB
450 //Stores the Parent Policy Name and securityZone value to the fwparent table.
451 String parentSecurityZoneValue= getParentSecurityZone();
452 String parentQuery= "INSERT INTO FWPARENT(PARENT,SECURITYZONE) VALUES ('";
453 parentQuery=parentQuery+removeExtension+"','"+ parentSecurityZoneValue +"')";
454 updateToDatabase(parentQuery);
457 String updateQuery = "";
458 if(policyAdapter.isEditPolicy()){
459 updateQuery= "UPDATE FWCHILDTOPARENT SET PARENT='"+policyAdapter.getParentForChild()+"' WHERE CHILD='"+removeExtension+"'";
462 updateQuery= "INSERT INTO FWCHILDTOPARENT(CHILD,PARENT) VALUES ('";
463 updateQuery =updateQuery+removeExtension+"','"+ policyAdapter.getParentForChild() +"')";
465 updateToDatabase(updateQuery);
469 response.setCharacterEncoding("UTF-8");
470 response.setContentType("application / json");
471 request.setCharacterEncoding("UTF-8");
473 PrintWriter out = response.getWriter();
474 String responseString = mapper.writeValueAsString(successMap);
475 JSONObject j = new JSONObject("{policyData: " + responseString + "}");
476 out.write(j.toString());
480 response.setCharacterEncoding("UTF-8");
481 request.setCharacterEncoding("UTF-8");
482 PrintWriter out = response.getWriter();
483 out.write(e.getMessage());
488 private String convertDate(String dateTTL) {
489 String formateDate = null;
490 String[] date = dateTTL.split("T");
491 String[] parts = date[0].split("-");
493 formateDate = parts[2] + "-" + parts[1] + "-" + parts[0];
497 private String constructJson() {
499 //Maps to assosciate the values read from the TermList dictionary
500 Map<Integer, String> srcIP_map =null;
501 Map<Integer, String> destIP_map=null;
502 Map<Integer, String> srcPort_map =null;
503 Map<Integer, String> destPort_map =null;
504 Map<Integer, String> action_map=null;
505 Map<Integer, String> fromZone_map=null;
506 Map<Integer, String> toZone_map=null;
508 String ruleDesc=null;
509 String ruleFromZone=null;
510 String ruleToZone=null;
511 String ruleSrcPrefixList=null;
512 String ruleDestPrefixList=null;
513 String ruleSrcPort=null;
514 String ruleDestPort=null;
515 String ruleAction=null;
520 List<String> expandableList = new ArrayList<String>();
521 TermList jpaTermList;
522 SecurityZone jpaSecurityZone;
523 List<Term> termList = new ArrayList<Term>();
525 ServiceListJson targetSl=null;
528 for (int tl = 0 ; tl< termCollectorList.size(); tl++) {
529 expandableList.add(termCollectorList.get(tl));
530 Term targetTerm = new Term();
531 //targetSl= new ServiceListJson();
532 targetTerm.setRuleName(termCollectorList.get(tl));
533 List<TermList> termListData = termListDao.getTermListData();
534 for (int j =0; j < termListData.size(); j++) {
535 jpaTermList = termListData.get(j);
536 if (jpaTermList.getTermName().equals(termCollectorList.get(tl))){
537 ruleDesc=jpaTermList.getTermDescription();
538 if ((ruleDesc!=null)&& (!ruleDesc.isEmpty())){
539 targetTerm.setDescription(ruleDesc);
541 ruleFromZone=jpaTermList.getFromZone();
543 if ((ruleFromZone != null) && (!ruleFromZone.isEmpty())){
544 fromZone_map = new HashMap<Integer, String>();
545 fromZone_map.put(tl, ruleFromZone);
547 ruleToZone=jpaTermList.getToZone();
549 if ((ruleToZone != null) && (!ruleToZone.isEmpty())){
550 toZone_map = new HashMap<Integer, String>();
551 toZone_map.put(tl, ruleToZone);
553 ruleSrcPrefixList=jpaTermList.getSrcIPList();
555 if ((ruleSrcPrefixList != null) && (!ruleSrcPrefixList.isEmpty())){
556 srcIP_map = new HashMap<Integer, String>();
557 srcIP_map.put(tl, ruleSrcPrefixList);
560 ruleDestPrefixList= jpaTermList.getDestIPList();
561 if ((ruleDestPrefixList != null) && (!ruleDestPrefixList.isEmpty())){
562 destIP_map = new HashMap<Integer, String>();
563 destIP_map.put(tl, ruleDestPrefixList);
566 ruleSrcPort=jpaTermList.getSrcPortList();
568 if (ruleSrcPort != null && (!ruleSrcPort.isEmpty())){
569 srcPort_map = new HashMap<Integer, String>();
570 srcPort_map.put(tl, ruleSrcPort);
573 ruleDestPort= jpaTermList.getDestPortList();
575 if (ruleDestPort!= null && (!jpaTermList.getDestPortList().isEmpty())){
576 destPort_map = new HashMap<Integer, String>();
577 destPort_map.put(tl, ruleDestPort);
580 ruleAction=jpaTermList.getAction();
582 if (( ruleAction!= null) && (!ruleAction.isEmpty())){
583 action_map = new HashMap<Integer, String>();
584 action_map.put(tl, ruleAction);
588 targetTerm.setEnabled(true);
589 targetTerm.setLog(true);
590 targetTerm.setNegateSource(false);
591 targetTerm.setNegateDestination(false);
593 if(action_map!=null){
594 targetTerm.setAction(action_map.get(tl));
598 if(fromZone_map!=null){
599 List<String> fromZone= new ArrayList<String>();
600 for(String fromZoneStr:fromZone_map.get(tl).split(",") ){
601 fromZone.add(fromZoneStr);
603 targetTerm.setFromZones(fromZone);
607 if(toZone_map!=null){
608 List<String> toZone= new ArrayList<String>();
609 for(String toZoneStr:toZone_map.get(tl).split(",") ){
610 toZone.add(toZoneStr);
612 targetTerm.setToZones(toZone);
615 //Destination Services.
616 if(destPort_map!=null){
617 Set<ServicesJson> destServicesJsonList= new HashSet<ServicesJson>();
618 for(String destServices:destPort_map.get(tl).split(",") ){
619 ServicesJson destServicesJson= new ServicesJson();
620 destServicesJson.setType("REFERENCE");
621 if(destServices.equals("ANY")){
622 destServicesJson.setName("any");
623 destServicesJsonList.add(destServicesJson);
626 if(destServices.startsWith("Group_")){
627 destServicesJson.setName(destServices.substring(6,destServices.length()));
629 destServicesJson.setName(destServices);
631 destServicesJsonList.add(destServicesJson);
634 targetTerm.setDestServices(destServicesJsonList);
636 //ExpandableServicesList
637 if((srcPort_map!=null) && (destPort_map!=null)){
638 String servicesCollateString = (srcPort_map.get(tl) + "," + destPort_map.get(tl));
639 expandableServicesList.add(servicesCollateString);
640 }else if (srcPort_map!=null){
641 expandableServicesList.add(srcPort_map.get(tl));
642 }else if (destPort_map!=null){
643 expandableServicesList.add(destPort_map.get(tl));
648 List<AddressJson> sourceListArrayJson= new ArrayList<AddressJson>();
649 for(String srcList:srcIP_map.get(tl).split(",") ){
650 AddressJson srcListJson= new AddressJson();
651 if(srcList.equals("ANY")){
652 srcListJson.setType("any");
653 sourceListArrayJson.add(srcListJson);
656 srcListJson.setType("REFERENCE");
657 if(srcList.startsWith("Group_")){
658 srcListJson.setValue(srcList.substring(6,srcList.length()));
660 srcListJson.setValue(srcList);
662 sourceListArrayJson.add(srcListJson);
665 targetTerm.setSourceList(sourceListArrayJson);
667 if(destIP_map!=null){
669 List<AddressJson> destListArrayJson= new ArrayList<AddressJson>();
670 for(String destList:destIP_map.get(tl).split(",")){
671 AddressJson destListJson= new AddressJson();
672 if(destList.equals("ANY")){
673 destListJson.setType("any");
674 destListArrayJson.add(destListJson);
677 destListJson.setType("REFERENCE");
678 if(destList.startsWith("Group_")){
679 destListJson.setValue(destList.substring(6,destList.length()));
681 destListJson.setValue(destList);
683 destListArrayJson.add(destListJson);
686 targetTerm.setDestinationList(destListArrayJson);
688 //ExpandablePrefixIPList
689 if ((srcIP_map!=null) && (destIP_map!=null))
691 String collateString = (srcIP_map.get(tl) + "," + destIP_map
693 expandablePrefixIPList.add(collateString);
695 else if(srcIP_map!=null){
696 expandablePrefixIPList.add(srcIP_map.get(tl));
698 else if(destIP_map!=null){
699 expandablePrefixIPList.add(destIP_map.get(tl));
701 termList.add(targetTerm);
702 targetTerm.setPosition("" + (ruleCount++));
704 TermCollector tc = new TermCollector();
705 List<SecurityZone> securityZoneData = securityZoneDao.getSecurityZoneData();
706 for (int j =0 ; j< securityZoneData.size() ; j++){
707 jpaSecurityZone = securityZoneData.get(j);
708 if (jpaSecurityZone.getZoneName().equals(policyAdapter.getSecurityZone())){
709 tc.setSecurityZoneId(jpaSecurityZone.getZoneValue());
710 setParentSecurityZone(jpaSecurityZone.getZoneValue());//For storing the securityZone IDs to the DB
715 tc.setServiceTypeId("/v0/firewall/pan");
716 tc.setConfigName(policyAdapter.getConfigName());
718 if(policyAdapter.getFwPolicyType().equalsIgnoreCase("Child Policy")){
719 String securityZoneQuery="SELECT SECURITYZONE FROM FWPARENT WHERE PARENT='";
720 securityZoneQuery=securityZoneQuery+policyAdapter.getParentForChild()+"'";
721 List<String> securityZoneValue= queryToDatabase(securityZoneQuery);
722 tc.setPrimaryParentZoneId(securityZoneValue.get(0));
724 //Astra is rejecting the packet when it sees a new JSON field, so removing it for now.
725 //tc.setTemplateVersion(XACMLProperties.getProperty(XACMLRestProperties.TemplateVersion_FW));
727 DeployNowJson deployNow= new DeployNowJson();
728 deployNow.setDeployNow(false);
730 tc.setDeploymentOption(deployNow);
732 Set<ServiceListJson> servListArray = new HashSet<ServiceListJson>();
733 Set<ServiceGroupJson> servGroupArray= new HashSet<ServiceGroupJson>();
734 Set<AddressGroupJson> addrGroupArray= new HashSet<AddressGroupJson>();
736 ServiceGroupJson targetSg= null;
737 AddressGroupJson addressSg=null;
738 ServiceListJson targetAny= null;
739 ServiceListJson targetAnyTcp=null;
740 ServiceListJson targetAnyUdp=null;
742 for(String serviceList:expandableServicesList){
743 for(String t: serviceList.split(",")){
744 if((!t.startsWith("Group_"))){
745 if(!t.equals("ANY")){
746 ServiceList sl = new ServiceList();
747 targetSl= new ServiceListJson();
748 sl= mappingServiceList(t);
749 targetSl.setName(sl.getServiceName());
750 targetSl.setDescription(sl.getServiceDescription());
751 targetSl.setTransportProtocol(sl.getServiceTransProtocol());
752 targetSl.setType(sl.getServiceType());
753 targetSl.setPorts(sl.getServicePorts());
754 servListArray.add(targetSl);
756 //Any for destinationServices.
757 //Add names any, any-tcp, any-udp to the serviceGroup object.
758 targetAny= new ServiceListJson();
759 targetAny.setName("any");
760 targetAny.setType("SERVICE");
761 targetAny.setTransportProtocol("any");
762 targetAny.setPorts("any");
764 servListArray.add(targetAny);
766 targetAnyTcp= new ServiceListJson();
767 targetAnyTcp.setName("any-tcp");
768 targetAnyTcp.setType("SERVICE");
769 targetAnyTcp.setTransportProtocol("tcp");
770 targetAnyTcp.setPorts("any");
772 servListArray.add(targetAnyTcp);
774 targetAnyUdp= new ServiceListJson();
775 targetAnyUdp.setName("any-udp");
776 targetAnyUdp.setType("SERVICE");
777 targetAnyUdp.setTransportProtocol("udp");
778 targetAnyUdp.setPorts("any");
780 servListArray.add(targetAnyUdp);
782 }else{//This is a group
783 GroupServiceList sg= new GroupServiceList();
784 targetSg= new ServiceGroupJson();
785 sg= mappingServiceGroup(t);
787 String name=sg.getGroupName();
788 //Removing the "Group_" prepending string before packing the JSON
789 targetSg.setName(name.substring(6,name.length()));
790 List<ServiceMembers> servMembersList= new ArrayList<ServiceMembers>();
792 for(String groupString: sg.getServiceList().split(",")){
793 ServiceMembers serviceMembers= new ServiceMembers();
794 serviceMembers.setType("REFERENCE");
795 serviceMembers.setName(groupString);
796 servMembersList.add(serviceMembers);
797 //Expand the group Name
798 ServiceList expandGroupSl = new ServiceList();
799 targetSl= new ServiceListJson();
800 expandGroupSl= mappingServiceList(groupString);
802 targetSl.setName(expandGroupSl.getServiceName());
803 targetSl.setDescription(expandGroupSl.getServiceDescription());
804 targetSl.setTransportProtocol(expandGroupSl.getServiceTransProtocol());
805 targetSl.setType(expandGroupSl.getServiceType());
806 targetSl.setPorts(expandGroupSl.getServicePorts());
807 servListArray.add(targetSl);
810 targetSg.setMembers(servMembersList);
811 servGroupArray.add(targetSg);
817 Set<PrefixIPList> prefixIPList = new HashSet<PrefixIPList>();
818 for(String prefixList:expandablePrefixIPList){
819 for(String prefixIP: prefixList.split(",")){
820 if((!prefixIP.startsWith("Group_"))){
821 if(!prefixIP.equals("ANY")){
822 List<AddressMembers> addMembersList= new ArrayList<AddressMembers>();
823 List<String> valueDesc= new ArrayList<String>();
824 PrefixIPList targetAddressList = new PrefixIPList();
825 AddressMembers addressMembers= new AddressMembers();
826 targetAddressList.setName(prefixIP);
828 valueDesc = mapping(prefixIP);
829 targetAddressList.setDescription(valueDesc.get(1));
831 addressMembers.setType("SUBNET");
832 addressMembers.setValue(valueDesc.get(0));
834 addMembersList.add(addressMembers);
836 targetAddressList.setMembers(addMembersList);
837 prefixIPList.add(targetAddressList);
840 else{//This is a group
841 AddressGroup ag= new AddressGroup();
842 addressSg= new AddressGroupJson();
843 ag= mappingAddressGroup(prefixIP);
845 String name=ag.getGroupName();
846 //Removing the "Group_" prepending string before packing the JSON
847 addressSg.setName(name.substring(6,name.length()));
849 List<AddressMembers> addrMembersList= new ArrayList<AddressMembers>();
850 for(String groupString: ag.getPrefixList().split(",")){
851 List<String> valueDesc= new ArrayList<String>();
852 AddressMembers addressMembers= new AddressMembers();
853 valueDesc= mapping (groupString);
854 if(valueDesc.size() > 0){
855 addressMembers.setValue(valueDesc.get(0));
857 addressMembers.setType("SUBNET");
858 addrMembersList.add(addressMembers);
859 //Expand the group Name
861 addressSg.setMembers(addrMembersList);
862 addrGroupArray.add(addressSg);
869 Set<Object> serviceGroup= new HashSet<Object>();
871 for(Object obj1:servGroupArray){
872 serviceGroup.add(obj1);
875 for(Object obj:servListArray){
876 serviceGroup.add(obj);
879 Set<Object> addressGroup= new HashSet<Object>();
881 for(Object addObj:prefixIPList){
882 addressGroup.add(addObj);
885 for(Object addObj1:addrGroupArray){
886 addressGroup.add(addObj1);
889 tc.setServiceGroups(serviceGroup);
890 tc.setAddressGroups(addressGroup);
891 tc.setFirewallRuleList(termList);
894 ObjectWriter om = new ObjectMapper().writer();
896 json = om.writeValueAsString(tc);
897 } catch (JsonGenerationException e) {
899 } catch (JsonMappingException e) {
901 } catch (IOException e) {
905 }catch (Exception e) {
912 private List<String> mapping(String expandableList) {
913 String value = new String();
914 String desc = new String();
915 List <String> valueDesc= new ArrayList<String>();
916 List<PREFIXLIST> prefixListData = prefixListDao.getPREFIXLISTData();
917 for (int i = 0; i< prefixListData.size(); i++) {
918 PREFIXLIST prefixList = prefixListData.get(i);
919 if (prefixList.getPrefixListName().equals(expandableList)) {
920 value = prefixList.getPrefixListValue();
921 valueDesc.add(value);
922 desc= prefixList.getDescription();
930 private ServiceList mappingServiceList(String expandableList) {
931 ServiceList serviceList=null;
932 List<ServiceList> serviceListData = serviceListDao.getServiceListData();
933 for (int i = 0; i< serviceListData.size(); i++) {
934 serviceList = serviceListData.get(i);
935 if (serviceList.getServiceName().equals(expandableList)) {
942 private GroupServiceList mappingServiceGroup(String expandableList) {
944 GroupServiceList serviceGroup=null;
945 List<GroupServiceList> serviceGroupData = serviceGroupDao.getGroupServiceListData();
946 for (int i = 0; i< serviceGroupData.size(); i++) {
947 serviceGroup = serviceGroupData.get(i);
948 if (serviceGroup.getGroupName().equals(expandableList)) {
955 private AddressGroup mappingAddressGroup(String expandableList) {
957 AddressGroup addressGroup=null;
958 List<AddressGroup> addressGroupData = addressGroupDao.getAddressGroupData();
959 for (int i = 0; i< addressGroupData.size(); i++) {
960 addressGroup = addressGroupData.get(i);
961 if (addressGroup.getGroupName().equals(expandableList)) {
968 public void PrePopulateFWPolicyData(PolicyAdapter policyAdapter) {
969 attributeList = new ArrayList<Object>();
970 fwAttributeList = new ArrayList<Object>();
971 if (policyAdapter.getPolicyData() instanceof PolicyType) {
972 Object policyData = policyAdapter.getPolicyData();
973 PolicyType policy = (PolicyType) policyData;
974 // policy name value is the policy name without any prefix and Extensions.
975 policyAdapter.setOldPolicyFileName(policyAdapter.getPolicyName());
976 String policyNameValue = policyAdapter.getPolicyName().substring(policyAdapter.getPolicyName().indexOf("FW_") +3, policyAdapter.getPolicyName().lastIndexOf("."));
977 if (logger.isDebugEnabled()) {
978 logger.debug("Prepopulating form data for Config Policy selected:"+ policyAdapter.getPolicyName());
980 policyAdapter.setPolicyName(policyNameValue);
981 String description = "";
983 description = policy.getDescription().substring(0, policy.getDescription().indexOf("@CreatedBy:"));
985 description = policy.getDescription();
987 policyAdapter.setPolicyDescription(description);
989 ObjectMapper mapper = new ObjectMapper();
991 TermCollector tc1=null;
992 BufferedReader br=null;
996 SecurityZone jpaSecurityZone;
997 File file = new File(PolicyController.getConfigHome()+ File.separator+ policyAdapter.getDirPath().replace(File.separator, ".")+"."+ policyAdapter.getOldPolicyFileName() +".json");
998 // Get data from this file using a file reader.
999 FileReader fr = new FileReader(file);
1000 // To store the contents read via File Reader
1001 br = new BufferedReader(fr);
1002 // Read br and store a line in 'data', print data
1003 data = br.readLine();
1004 tc1 = (TermCollector)mapper.readValue(data, TermCollector.class);
1005 List<SecurityZone> securityZoneData = securityZoneDao.getSecurityZoneData();
1006 for (int i = 0; i < securityZoneData.size() ; i++) {
1007 jpaSecurityZone = securityZoneData.get(i);
1008 if (jpaSecurityZone.getZoneValue().equals(tc1.getSecurityZoneId())){
1009 policyAdapter.setSecurityZone(jpaSecurityZone.getZoneName());
1013 if(tc1.getPrimaryParentZoneId()!=null)//Child policy
1015 policyAdapter.setFwPolicyType("Child Policy");
1017 String pathName=policyAdapter.getParentPath().toString();
1018 String scope= pathName.substring(pathName.lastIndexOf(File.separator)+1);
1019 String fullPathName=scope+".Config_FW_"+policyNameValue;
1021 String query= "select parent from FWChildToParent where child='";
1022 query=query+fullPathName+"'";
1024 List<String> parentName=queryToDatabase(query);
1025 policyAdapter.setParentForChild(parentName.get(0));
1028 else{//Parent Policy
1029 policyAdapter.setFwPolicyType("Parent Policy");
1030 //Retrieving the Dictionary combo list.
1031 String desc = policy.getDescription();
1032 String descripComboList = desc.substring(desc.indexOf("@comboList:")+11,desc.length()) ;
1033 Map<String, String> parentMap = new HashMap<String, String>();
1034 for(String value : descripComboList.split(",")){
1035 parentMap.put("option", value);
1036 fwAttributeList.add(parentMap);
1038 policyAdapter.setFwattributes(fwAttributeList);
1041 catch(Exception e) {
1042 logger.error("Exception Caused while Retriving the JSON body data" +e);
1046 if (br != null)br.close();
1047 } catch (IOException ex) {
1048 ex.printStackTrace();
1052 for (Term t : tc1.getFirewallRuleList()) {
1053 Map<String, String> termMap = new HashMap<String, String>();
1054 termMap.put("option", t.getRuleName());
1055 attributeList.add(termMap);
1057 policyAdapter.setAttributes(attributeList);
1058 // Get the target data under policy.
1059 TargetType target = policy.getTarget();
1060 if (target != null) {
1061 // Under target we have AnyOFType
1062 List<AnyOfType> anyOfList = target.getAnyOf();
1063 if (anyOfList != null) {
1065 Iterator<AnyOfType> iterAnyOf = anyOfList.iterator();
1066 while (iterAnyOf.hasNext()) {
1067 AnyOfType anyOf = iterAnyOf.next();
1068 // Under AnyOFType we have AllOFType
1069 List<AllOfType> allOfList = anyOf.getAllOf();
1070 if (allOfList != null) {
1071 Iterator<AllOfType> iterAllOf = allOfList.iterator();
1072 while (iterAllOf.hasNext()) {
1073 AllOfType allOf = iterAllOf.next();
1074 // Under AllOFType we have Match
1075 List<MatchType> matchList = allOf.getMatch();
1076 if (matchList != null) {
1078 Iterator<MatchType> iterMatch = matchList.iterator();
1079 while (iterMatch.hasNext()) {
1080 MatchType match = iterMatch.next();
1082 // Under the match we have attribute value and
1083 // attributeDesignator. So,finally down to the actual attribute.
1085 AttributeValueType attributeValue = match.getAttributeValue();
1086 String value = (String) attributeValue.getContent().get(0);
1088 policyAdapter.setConfigName(value);
1091 policyAdapter.setRiskType(value);
1095 policyAdapter.setRiskLevel(value);
1099 policyAdapter.setGuard(value);
1101 if (index == 5 && !value.contains("NA")){
1102 String newDate = convertDate(value, true);
1103 policyAdapter.setTtlDate(newDate);
1116 private String convertDate(String dateTTL, boolean portalType) {
1117 String formateDate = null;
1122 parts = dateTTL.split("-");
1123 formateDate = parts[2] + "-" + parts[1] + "-" + parts[0] + "T05:00:00.000Z";
1125 date = dateTTL.split("T");
1126 parts = date[0].split("-");
1127 formateDate = parts[2] + "-" + parts[1] + "-" + parts[0];
1132 @RequestMapping(value={"/policyController/ViewFWPolicyRule.htm"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
1133 public ModelAndView setFWViewRule(HttpServletRequest request, HttpServletResponse response) throws Exception{
1135 termCollectorList = new ArrayList<String>();
1136 ObjectMapper mapper = new ObjectMapper();
1137 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1138 JsonNode root = mapper.readTree(request.getReader());
1139 PolicyAdapter policyData = (PolicyAdapter)mapper.readValue(root.get("policyData").toString(), PolicyAdapter.class);
1140 if(policyData.getAttributes().size() > 0){
1141 for(Object attribute : policyData.getAttributes()){
1142 if(attribute instanceof LinkedHashMap<?, ?>){
1143 String key = ((LinkedHashMap<?, ?>) attribute).get("option").toString();
1144 termCollectorList.add(key);
1148 TermList jpaTermList;
1149 String ruleSrcList=null;
1150 String ruleDestList=null;
1151 String ruleSrcPort=null;
1152 String ruleDestPort=null;
1153 String ruleAction=null;
1154 List <String> valueDesc= new ArrayList<String>();
1155 StringBuffer displayString = new StringBuffer();
1156 for (String id : termCollectorList) {
1157 jpaTermList = termListDao.getTermListValueByName(id);
1158 if (jpaTermList != null){
1159 ruleSrcList= ((TermList) jpaTermList).getSrcIPList();
1160 if ((ruleSrcList!= null) && (!ruleSrcList.isEmpty()) && !ruleSrcList.equals("null")){
1161 displayString.append("Source IP List: " + ((TermList) jpaTermList).getSrcIPList());
1162 displayString.append(" ; \t\n");
1163 for(String srcList:ruleSrcList.split(",")){
1164 if(srcList.startsWith("Group_")){
1165 AddressGroup ag= new AddressGroup();
1166 ag= mappingAddressGroup(srcList);
1167 displayString.append("\n\t"+"Group has :"+ag.getPrefixList()+"\n");
1168 for(String groupItems:ag.getPrefixList().split(",")){
1169 valueDesc=mapping(groupItems);
1170 displayString.append("\n\t"+"Name: "+groupItems);
1171 if(!valueDesc.isEmpty()){
1172 displayString.append("\n\t"+"Description: "+valueDesc.get(1));
1173 displayString.append("\n\t"+"Value: "+valueDesc.get(0));
1175 displayString.append("\n");
1178 if(!srcList.equals("ANY")){
1179 valueDesc=mapping(srcList);
1180 displayString.append("\n\t"+"Name: "+srcList);
1181 displayString.append("\n\t"+"Description: "+valueDesc.get(1));
1182 displayString.append("\n\t"+"Value: "+valueDesc.get(0));
1183 displayString.append("\n");
1187 displayString.append("\n");
1189 ruleDestList= ((TermList) jpaTermList).getDestIPList();
1190 if ( ruleDestList!= null && (!ruleDestList.isEmpty())&& !ruleDestList.equals("null")){
1191 displayString.append("Destination IP List: " + ((TermList) jpaTermList).getDestIPList());
1192 displayString.append(" ; \t\n");
1193 for(String destList:ruleDestList.split(",")){
1194 if(destList.startsWith("Group_")){
1195 AddressGroup ag= new AddressGroup();
1196 ag= mappingAddressGroup(destList);
1197 displayString.append("\n\t"+"Group has :"+ag.getPrefixList()+"\n");
1198 for(String groupItems:ag.getPrefixList().split(",")){
1199 valueDesc=mapping(groupItems);
1200 displayString.append("\n\t"+"Name: "+groupItems);
1201 displayString.append("\n\t"+"Description: "+valueDesc.get(1));
1202 displayString.append("\n\t"+"Value: "+valueDesc.get(0));
1203 displayString.append("\n\t");
1206 if(!destList.equals("ANY")){
1207 valueDesc=mapping(destList);
1208 displayString.append("\n\t"+"Name: "+destList);
1209 displayString.append("\n\t"+"Description: "+valueDesc.get(1));
1210 displayString.append("\n\t"+"Value: "+valueDesc.get(0));
1211 displayString.append("\n\t");
1215 displayString.append("\n");
1218 ruleSrcPort=((TermList) jpaTermList).getSrcPortList();
1219 if ( ruleSrcPort!= null && (!ruleSrcPort.isEmpty())&& !ruleSrcPort.equals("null")) {
1220 displayString.append("\n"+"Source Port List:"
1222 displayString.append(" ; \t\n");
1225 ruleDestPort= ((TermList) jpaTermList).getDestPortList();
1226 if (ruleDestPort != null && (!ruleDestPort.isEmpty())&& !ruleDestPort.equals("null")) {
1227 displayString.append("\n"+"Destination Port List:"
1229 displayString.append(" ; \t\n");
1230 for(String destServices:ruleDestPort.split(",")){
1231 if(destServices.startsWith("Group_")){
1232 GroupServiceList sg= new GroupServiceList();
1233 sg= mappingServiceGroup(destServices);
1234 displayString.append("\n\t"+"Service Group has :"+sg.getServiceList()+"\n");
1235 for(String groupItems:sg.getServiceList().split(",")){
1236 ServiceList sl= new ServiceList();
1237 sl= mappingServiceList(groupItems);
1238 displayString.append("\n\t"+"Name: "+
1239 sl.getServiceName());
1240 displayString.append("\n\t"+"Description: "+
1241 sl.getServiceDescription());
1242 displayString.append("\n\t"+"Transport-Protocol: "+
1243 sl.getServiceTransProtocol());
1244 displayString.append("\n\t"+"Ports: "+
1245 sl.getServicePorts());
1246 displayString.append("\n");
1250 if(!destServices.equals("ANY")){
1251 ServiceList sl= new ServiceList();
1252 sl= mappingServiceList(destServices);
1253 displayString.append("\n\t"+"Name: "+
1254 sl.getServiceName());
1255 displayString.append("\n\t"+"Description: "+
1256 sl.getServiceDescription());
1257 displayString.append("\n\t"+"Transport-Protocol: "+
1258 sl.getServiceTransProtocol());
1259 displayString.append("\n\t"+"Ports: "+
1260 sl.getServicePorts());
1261 displayString.append("\n");
1265 displayString.append("\n");
1268 ruleAction=(jpaTermList).getAction();
1269 if ( ruleAction!= null && (!ruleAction.isEmpty())) {
1270 displayString.append("\n"+"Action List:"
1272 displayString.append(" ; \t\n");
1276 response.setCharacterEncoding("UTF-8");
1277 response.setContentType("application / json");
1278 request.setCharacterEncoding("UTF-8");
1280 PrintWriter out = response.getWriter();
1281 String responseString = mapper.writeValueAsString(displayString);
1282 JSONObject j = new JSONObject("{policyData: " + responseString + "}");
1283 out.write(j.toString());
1285 } catch (Exception e) {
1286 logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);