diff --git a/src/ui/GTURTLEModeling.java b/src/ui/GTURTLEModeling.java index e504644f7133ebf01456e2cde0ca09c9572c35d3..ef3d4415a8bb003d5f1d94788f9f18f61e6151e2 100755 --- a/src/ui/GTURTLEModeling.java +++ b/src/ui/GTURTLEModeling.java @@ -1089,7 +1089,56 @@ public class GTURTLEModeling { return map; } + public void addHSM(MainGUI gui, String compName){ + List<String> hsmInChans = new ArrayList<String>(); + String name="hsm"; + if (tmap==null){ + return; + } + //Clone diagrams + int arch = gui.tabs.indexOf(tmap.tmlap); + gui.cloneRenameTab(arch,"enc"); + TMLArchiPanel newarch = (TMLArchiPanel) gui.tabs.get(gui.tabs.size()-1); + TMLComponentDesignPanel tmlcdp = tmap.getTMLCDesignPanel(); + int ind = gui.tabs.indexOf(tmlcdp); + String tabName = gui.getTitleAt(tmlcdp); + gui.cloneRenameTab(ind, name); + TMLComponentDesignPanel t = (TMLComponentDesignPanel) gui.tabs.get(gui.tabs.size()-1); + TMLComponentTaskDiagramPanel tcdp = t.tmlctdp; + //Create clone of architecture panel and map tasks to it + newarch.renameMapping(tabName, tabName+"_"+name); + + TMLCPrimitiveComponent comp =null; + for (TGComponent tg: tcdp.getComponentList()){ + if (tg instanceof TMLCPrimitiveComponent){ + if (tg.getValue().equals(compName)){ + comp = (TMLCPrimitiveComponent) tg; + } + } + } + if (comp==null){ + return; + } + TMLCPrimitiveComponent hsm = new TMLCPrimitiveComponent(0, 500, tcdp.getMinX(), tcdp.getMaxX(), tcdp.getMinY(), tcdp.getMaxY(), false, null, tcdp); + hsm.setValue("HSM"); + tcdp.addComponent(hsm, 0,500,false,true); + + for (String hsmChan: hsmInChans){ + TMLCChannelOutPort originPort =new TMLCChannelOutPort(comp.getX(), comp.getY(), tcdp.getMinX(), tcdp.getMaxX(), tcdp.getMinY(), tcdp.getMaxX(), true, hsm, tcdp); + TMLCChannelOutPort destPort = new TMLCChannelOutPort(comp.getX(), comp.getY(), tcdp.getMinX(), tcdp.getMaxX(), tcdp.getMinY(), tcdp.getMaxX(), true, comp, tcdp); + originPort.commName=hsmChan; + tcdp.addComponent(originPort,comp.getX(), comp.getY(),true,true); + + destPort.isOrigin=false; + destPort.commName=hsmChan; + tcdp.addComponent(destPort,comp.getX(), comp.getY(),true,true); + + TMLCPortConnector conn = new TMLCPortConnector(0, 0, tcdp.getMinX(), tcdp.getMaxX(), tcdp.getMinY(), tcdp.getMaxX(), true, null, tcdp, originPort.getTGConnectingPointAtIndex(0), destPort.getTGConnectingPointAtIndex(0), new Vector()); + tcdp.addComponent(conn, 0,0,false,true); + } + + } public TMLMapping autoSecure(MainGUI gui, boolean autoConf, boolean autoAuth){ //TODO add more options diff --git a/src/ui/window/JDialogDSE.java b/src/ui/window/JDialogDSE.java index cbc5500bfb14ff728178fb35a06697a2f93e1475..287e1774daff0f9043340e5eb669531f2fc8af4a 100644 --- a/src/ui/window/JDialogDSE.java +++ b/src/ui/window/JDialogDSE.java @@ -89,7 +89,7 @@ public class JDialogDSE extends javax.swing.JDialog implements ActionListener, R protected JButton close; String simulator; - protected JCheckBox autoConf, autoAuth, autoMapKeys, custom, outputTXT, outputHTML; + protected JCheckBox autoConf, autoAuth, autoMapKeys, custom, outputTXT, outputHTML, addHSM; protected JTextField encTime, decTime, secOverhead; @@ -147,7 +147,7 @@ public class JDialogDSE extends javax.swing.JDialog implements ActionListener, R } protected void myInitComponents() { - mode = NOT_SELECTED; + mode = NOT_STARTED; setButtons(); } @@ -175,11 +175,17 @@ public class JDialogDSE extends javax.swing.JDialog implements ActionListener, R //genJava.addActionListener(this); autoConf= new JCheckBox("Add security (Confidentiality)"); jp01.add(autoConf, c01); + autoConf.addActionListener(this); autoAuth= new JCheckBox("Add security (Authenticity)"); jp01.add(autoAuth, c01); + autoAuth.addActionListener(this); autoMapKeys= new JCheckBox("Add Keys"); + autoMapKeys.addActionListener(this); jp01.add(autoMapKeys, c01); + addHSM = new JCheckBox("Add HSM"); + jp01.add(addHSM,c01); + custom = new JCheckBox("Custom performance attributes"); jp01.add(custom,c01); @@ -603,11 +609,16 @@ public class JDialogDSE extends javax.swing.JDialog implements ActionListener, R if (mode != NOT_STARTED && mode != NOT_SELECTED) { return; } + if (jp1.getSelectedIndex() !=1){ + mode = NOT_STARTED; + setButtons(); + return; + } boolean oneResult, oneAction; oneResult = outputHTML.isSelected() || outputTXT.isSelected(); oneAction = dseButton.isSelected() || simButton.isSelected(); - if ((oneAction == false || oneResult == false) && jp1.getSelectedIndex() == 1) { + if (oneAction == false || oneResult == false) { mode = NOT_SELECTED; } else { mode = NOT_STARTED; @@ -619,16 +630,15 @@ public class JDialogDSE extends javax.swing.JDialog implements ActionListener, R public void actionPerformed(ActionEvent evt) { String command = evt.getActionCommand(); - if (command.equals("Start")) { startProcess(); } else if (command.equals("Stop")) { stopProcess(); } else if (command.equals("Close")) { closeDialog(); - } else if ((evt.getSource() == dseButton) || (evt.getSource() == simButton) || (evt.getSource() == outputHTML) || (evt.getSource() == outputTXT)) { + } else if ((evt.getSource() == dseButton) || (evt.getSource() == simButton) || (evt.getSource() == outputHTML) || (evt.getSource() == outputTXT) || (evt.getSource() == autoAuth) || (evt.getSource() == autoConf) || (evt.getSource() == autoMapKeys)) { handleStartButton(); - } + } } public void closeDialog() { @@ -698,9 +708,13 @@ public class JDialogDSE extends javax.swing.JDialog implements ActionListener, R map = mgui.gtm.autoSecure(mgui,autoConf.isSelected(), autoAuth.isSelected()); } } + else if (addHSM.isSelected()){ + mgui.gtm.addHSM(mgui, "comp0"); + } if (autoMapKeys.isSelected()){ mgui.gtm.autoMapKeys(); } + mode = NOT_STARTED; } else if (jp1.getSelectedIndex()==1){ encCC=encTime2.getText();