From e6074d4d434f6e475f8b9040cf79b6107d4722ec Mon Sep 17 00:00:00 2001
From: L <letitia.li@telecom-paristech.fr>
Date: Fri, 10 Nov 2017 14:41:01 +0100
Subject: [PATCH] Fixed autogeneration bug

---
 src/main/java/ui/GTURTLEModeling.java         |  8 +++--
 .../window/JDialogProverifVerification.java   | 35 +++++++++++++++----
 2 files changed, 34 insertions(+), 9 deletions(-)

diff --git a/src/main/java/ui/GTURTLEModeling.java b/src/main/java/ui/GTURTLEModeling.java
index 476f727a65..6762cce897 100755
--- a/src/main/java/ui/GTURTLEModeling.java
+++ b/src/main/java/ui/GTURTLEModeling.java
@@ -2034,10 +2034,12 @@ public class GTURTLEModeling {
             HashMap<AvatarPragmaAuthenticity, ProVerifQueryAuthResult> authResults = pvoa.getAuthenticityResults();
             for (AvatarPragmaAuthenticity pragma: authResults.keySet()) {
                 if (authResults.get(pragma).isProved() && !authResults.get(pragma).isSatisfied()) {
-                    nonAuthChans.add(pragma.getAttrA().getAttribute().getBlock().getName() + "__" + pragma.getAttrA().getState().getName().replaceAll("_chData", ""));
-                    nonAuthChans.add(pragma.getAttrB().getAttribute().getBlock().getName() + "__" + pragma.getAttrB().getState().getName().replaceAll("_chData", ""));
+                    nonAuthChans.add(pragma.getAttrA().getAttribute().getBlock().getName() + "__" + pragma.getAttrA().getAttribute().getName().replaceAll("_chData", ""));
+                    nonAuthChans.add(pragma.getAttrB().getAttribute().getBlock().getName() + "__" + pragma.getAttrB().getAttribute().getName().replaceAll("_chData", ""));
                 }
             }
+			TraceManager.addDev("nonsecchans " + nonSecChans);
+			TraceManager.addDev("nonauthchans " + nonAuthChans);
             TraceManager.addDev("all results displayed");
 
         }
@@ -2123,7 +2125,7 @@ public class GTURTLEModeling {
                         TMLChannel chan = tmlmodel.getChannelByName(tabName+"__"+writeChannel.getChannelName());
                         //System.out.println("channel " + chan);
                         if (chan!=null){
-                            if (chan.checkConf){
+                            if (chan.checkConf && autoConf){
                                 //        System.out.println(chan.getOriginTask().getName().split("__")[1]);
                                 if (nonSecChans.contains(chan.getOriginTask().getName().split("__")[1]+"__"+writeChannel.getChannelName()+"_chData") && !secInChannels.get(chan.getDestinationTask()).contains(writeChannel.getChannelName())){
                                     //                                                                                            if (!securePath(map, chan.getOriginTask(), chan.getDestinationTask())){
diff --git a/src/main/java/ui/window/JDialogProverifVerification.java b/src/main/java/ui/window/JDialogProverifVerification.java
index 72d4aa56d5..b2076a7d1f 100644
--- a/src/main/java/ui/window/JDialogProverifVerification.java
+++ b/src/main/java/ui/window/JDialogProverifVerification.java
@@ -59,6 +59,9 @@ import proverifspec.ProVerifOutputListener;
 import ui.AvatarDesignPanel;
 import ui.util.IconManager;
 import ui.MainGUI;
+import ui.TURTLEPanel;
+import ui.TMLArchiPanel;
+
 import ui.interactivesimulation.JFrameSimulationSDPanel;
 import tmltranslator.*;
 
@@ -104,6 +107,10 @@ public class JDialogProverifVerification extends JDialog implements ActionListen
     public final static int REACHABILITY_SELECTED   = 2;
     public final static int REACHABILITY_NONE       = 3;
 
+
+	TURTLEPanel currPanel;
+		
+
     int mode;
     
     
@@ -132,7 +139,8 @@ public class JDialogProverifVerification extends JDialog implements ActionListen
     
     //security generation buttons
     ButtonGroup secGroup;
-    protected JCheckBox autoConf, autoWeakAuth, autoStrongAuth, autoMapKeys, custom, addHSM;
+	
+    protected JCheckBox autoSec, autoConf, autoWeakAuth, autoStrongAuth, autoMapKeys, custom, addHSM;
 
     protected JTextField encTime, decTime, secOverhead;
 	protected JComboBox<String> addtoCPU;
@@ -209,6 +217,8 @@ public class JDialogProverifVerification extends JDialog implements ActionListen
 				taskCpuMap.put(task,cpu);
 			}
 		}
+		currPanel = mgui.getCurrentTURTLEPanel();
+		
         initComponents();
         myInitComponents();
         pack();
@@ -270,9 +280,13 @@ public class JDialogProverifVerification extends JDialog implements ActionListen
 
         //genJava.addActionListener(this);
 		secGroup=new ButtonGroup(); 
+        autoSec= new JCheckBox("Add security");
+		jp02.add(autoSec, c01);
+		autoSec.addActionListener(this);
+		secGroup.add(autoSec);
         autoConf= new JCheckBox("Add security (Confidentiality)");
-		secGroup.add(autoConf);
         jp02.add(autoConf, c01);
+		autoConf.setEnabled(false);
 		autoConf.addActionListener(this);
         autoWeakAuth= new JCheckBox("Add security (Weak Authenticity)");
 		autoWeakAuth.setEnabled(false);
@@ -500,8 +514,10 @@ public class JDialogProverifVerification extends JDialog implements ActionListen
 
         jp1.add("Security Verification", jp01);
         
-        jp1.add("Automated Security", jp02);
-        
+		if (currPanel instanceof TMLArchiPanel){
+			//Can only secure a mapping
+	        jp1.add("Automated Security", jp02);
+		}        
         c.add(jp1, BorderLayout.NORTH);
         c.add(jp2, BorderLayout.SOUTH);
 
@@ -657,9 +673,16 @@ public class JDialogProverifVerification extends JDialog implements ActionListen
 			if (evt.getSource() == addHSM){
 				listPanel.setEnabled(addHSM.isSelected());
 			}
-			if (evt.getSource() == autoConf || evt.getSource() == autoMapKeys || evt.getSource() == addHSM || evt.getSource()==autoWeakAuth){	
-				autoWeakAuth.setEnabled(autoConf.isSelected());
+			if (evt.getSource() == autoConf || evt.getSource() == autoSec ||evt.getSource() == autoMapKeys || evt.getSource() == addHSM || evt.getSource()==autoWeakAuth){	
+				//autoWeakAuth.setEnabled(autoConf.isSelected());
+				autoConf.setEnabled(autoSec.isSelected());
+				autoWeakAuth.setEnabled(autoSec.isSelected());
 				autoStrongAuth.setEnabled(autoWeakAuth.isSelected());
+				if (!autoSec.isSelected()){
+					autoConf.setSelected(false);
+					autoWeakAuth.setSelected(false);
+					autoStrongAuth.setSelected(false);
+				}
 			}
 			if (evt.getSource() == custom){
 				encTime.setEnabled(custom.isSelected());
-- 
GitLab