Revision 114

View differences:

tags/0.5.23/modelio3.8.x/pom.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3
  <modelVersion>4.0.0</modelVersion>
4

  
5
  <!-- definition -->
6
  <groupId>org.modelio.module</groupId>
7
  <artifactId>attacktreedesigner</artifactId>
8
  <version>0.05.23</version>
9
  <name>AttackTreeDesigner</name>
10
  <repositories>
11
      <repository>
12
          <id>modelio</id>
13
          <url>https://repository.modelio.org</url>
14
      </repository>
15
  </repositories>
16

  
17
  <pluginRepositories>
18
      <pluginRepository>
19
          <id>modelio-plugins</id>
20
          <url>https://repository.modelio.org</url>
21
      </pluginRepository>
22
  </pluginRepositories>
23

  
24
    <!-- properties -->
25
    <properties>
26
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
27
    </properties>
28

  
29
    <dependencies>
30
        <!-- api modelio -->
31
        <dependency>
32
            <groupId>org.modelio</groupId>
33
            <artifactId>MDAKit</artifactId>
34
            <version>[3.8.0,3.8.1)</version>
35
            <type>pom</type>
36
            <scope>provided</scope>
37
        </dependency>
38

  
39
    </dependencies>
40

  
41
    <!-- // Build // -->
42
    <build>
43
        <sourceDirectory>src/main/java</sourceDirectory>
44
        <plugins>
45
            <!-- Use JVM 1.8 -->
46
            <plugin>
47
                <groupId>org.apache.maven.plugins</groupId>
48
                <artifactId>maven-compiler-plugin</artifactId>
49
                <version>2.3.2</version>
50
                <configuration>
51
                    <source>1.8</source>
52
                    <target>1.8</target>
53
                    <encoding>${project.build.sourceEncoding}</encoding>
54
                </configuration>
55
            </plugin>
56

  
57
            <plugin>
58
                <groupId>org.modelio</groupId>
59
                <artifactId>modelio-maven-plugin</artifactId>
60
                <version>3.8.0.02</version>
61
                <executions>
62
                    <execution>
63
                        <id>ModuleValidation</id>
64
                        <phase>validate</phase>
65
                        <goals>
66
                            <goal>module-validation</goal>
67
                        </goals>
68
                    </execution>
69
                    <execution>
70
                        <id>ResourceManagement</id>
71
                        <phase>generate-resources</phase>
72
                        <goals>
73
                            <goal>module-configuration</goal>
74
                        </goals>
75
                    </execution>
76
                </executions>
77
                <configuration>
78
                    <moduleFile>${project.basedir}/src/main/conf/module.xml</moduleFile>
79
                    <sourceBasedir>src/main/java</sourceBasedir>
80
                </configuration>
81
            </plugin>
82

  
83
            <!-- Copy maven dependencies -->
84
            <plugin>
85
                <groupId>org.apache.maven.plugins</groupId>
86
                <artifactId>maven-dependency-plugin</artifactId>
87
                <version>2.4</version>
88
                <configuration>
89
                    <outputDirectory>${project.basedir}/target/lib</outputDirectory>
90
                    <overWriteReleases>false</overWriteReleases>
91
                    <overWriteSnapshots>false</overWriteSnapshots>
92
                    <overWriteIfNewer>true</overWriteIfNewer>
93
                    <excludeScope>provided</excludeScope>
94
                </configuration>
95
                <executions>
96
                    <execution>
97
                        <id>copy-dependencies</id>
98
                        <phase>package</phase>
99
                        <goals>
100
                            <goal>copy-dependencies</goal>
101
                        </goals>
102
                    </execution>
103
                </executions>
104
            </plugin>
105

  
106
            <!-- Build zip -->
107
            <plugin>
108
                <groupId>org.apache.maven.plugins</groupId>
109
                <artifactId>maven-assembly-plugin</artifactId>
110
                <version>2.3</version>
111
                <configuration>
112
                    <encoding>${project.build.sourceEncoding}</encoding>
113
                    <descriptors>
114
                        <descriptor>assembly.xml</descriptor>
115
                    </descriptors>
116
                    <finalName>${project.name}_${project.version}</finalName>
117
                    <attach>false</attach>
118
                    <appendAssemblyId>false</appendAssemblyId>
119
                </configuration>
120
                <executions>
121
                    <execution>
122
                        <id>make-assembly</id>
123
                        <phase>package</phase>
124
                        <goals>
125
                            <goal>single</goal>
126
                        </goals>
127
                    </execution>
128
                </executions>
129
            </plugin>
130

  
131
            <!-- Rename zip into jmdac -->
132
            <plugin>
133
                <groupId>org.apache.maven.plugins</groupId>
134
                <artifactId>maven-antrun-plugin</artifactId>
135
                <version>1.7</version>
136
                <executions>
137
                    <execution>
138
                        <id>rename</id>
139
                        <phase>package</phase>
140
                        <configuration>
141
                            <target>
142
                                <move file="${project.basedir}/target/${project.name}_${project.version}.zip" tofile="${project.basedir}/target/${project.name}_${project.version}.jmdac" />
143

  
144
                                </target>
145
                            </configuration>
146
                            <goals>
147
                                <goal>run</goal>
148
                            </goals>
149
                        </execution>
150
                    </executions>
151
                </plugin>
152
            </plugins>
153

  
154
            <pluginManagement>
155
                <plugins>
156
                    <!-- ignore plugin goal -> tells m2e to silently ignore the plugin execution. -->
157
                    <plugin>
158
                        <groupId>org.eclipse.m2e</groupId>
159
                       <artifactId>lifecycle-mapping</artifactId>
160
                        <version>1.0.0</version>
161
                        <configuration>
162
                            <lifecycleMappingMetadata>
163
                                <pluginExecutions>
164
                                    <pluginExecution>
165
                                        <pluginExecutionFilter>
166
                                            <groupId>org.apache.maven.plugins</groupId>
167
                                            <artifactId>maven-dependency-plugin</artifactId>
168
                                            <versionRange>[1.0.0,)</versionRange>
169
                                            <goals>
170
                                                <goal>copy-dependencies</goal>
171
                                            </goals>
172
                                        </pluginExecutionFilter>
173
                                        <action>
174
                                            <ignore />
175
                                        </action>
176
                                    </pluginExecution>
177
                                    <pluginExecution>
178
                                        <pluginExecutionFilter>
179
                                            <groupId>org.modelio</groupId>
180
                                            <artifactId>
181
                                                modelio-maven-plugin
182
                                            </artifactId>
183
                                            <versionRange>
184
                                                [3.8.0.02,)
185
                                            </versionRange>
186
                                            <goals>
187
                                                <goal>
188
                                                    module-validation
189
                                                </goal>
190
                                                <goal>
191
                                                    module-configuration
192
                                                </goal>
193
                                            </goals>
194
                                        </pluginExecutionFilter>
195
                                        <action>
196
                                            <ignore></ignore>
197
                                        </action>
198
                                    </pluginExecution>
199
                                </pluginExecutions>
200
                            </lifecycleMappingMetadata>
201
                        </configuration>
202
                    </plugin>
203
                </plugins>
204
            </pluginManagement>
205
        </build>
206
    <description>Attack Tree Designer offers an easy and practical environment for users to design attack trees, add AND/OR connections between attacks, add tags and counter measures to attacks, detect countered attacks, etc</description>
207
    </project>
0 208

  
tags/0.5.23/modelio3.8.x/README.md
1
Attack Tree Designer
2
====
3
“Attack Tree Designer” is a Modelio module developed by Softeam that allows Modelio users to design attack trees diagrams showing how an asset or a target might be attacked. These diagrams are intended for security specialists for modelling the attacks that occur on IT systems or cyber physical systems and describe the events that lead to the attack in the form of a tree in which the attack is represented by the root element which is related with “OR” and “AND” conditions to the children that represent the sequence of events that lead to the root attack. Figure XYZ depicts an example of the attack tree diagram of the security attack “Steal a member of a swarm of cyber-physical systems. The module offers an ergonomic environment for designers and contains additional set of features that allow users to configure security attributes for the attacks such as the severity and the likelihood of the attack. It allows users to attach counter-measures to their attacks and to detect uncountered attacks. Moreover it allows referencing other trees, importing and exporting attack trees.
4

  
5

  
6
Attack Tree Designer - User Manual
7
----
8

  
9
See the link of the wiki page below.
10
[Attack Tree Designer - User Manual](http://forge.modelio.org/projects/attack-tree-modelio38-user-manual-english/wiki/Wiki)
11

  
tags/0.5.23/modelio3.8.x/assembly.xml
1
<assembly
2
	xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.0.0.1-SNAPSHOT"
3
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
	xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.0.0.1-SNAPSHOT http://maven.apache.org/xsd/assembly-1.0.0.1-SNAPSHOT.xsd">
5
	<id>bin</id>
6
	<formats>
7
		<format>zip</format>
8
	</formats>
9
	<includeBaseDirectory>false</includeBaseDirectory>
10
	<fileSets>
11
		<!-- Copy DataSheet HTML files -->
12
		<fileSet>
13
			<directory>${project.basedir}</directory>
14
			<outputDirectory>/${project.name}</outputDirectory>
15
			<includes>
16
				<include>DataSheet*.html</include>
17
			</includes>
18
			<filtered>true</filtered>
19
		</fileSet>
20
		<!-- Copy XML resources -->
21
		<fileSet>
22
			<directory>${project.basedir}/src/main/conf</directory>
23
			<outputDirectory>/${project.name}</outputDirectory>
24
			<includes>
25
				<include>**/*.xml</include>
26
			</includes>
27
			<filtered>true</filtered>
28
		</fileSet>
29
		<!-- Copy other ressources -->
30
		<fileSet>
31
			<directory>${project.basedir}/src/main/conf</directory>
32
			<outputDirectory>/${project.name}</outputDirectory>
33
			<excludes>
34
				<exclude>**/*.xml</exclude>
35
			</excludes>
36
			<filtered>false</filtered>
37
		</fileSet>
38
		<!-- Copy module's jar file -->
39
		<fileSet>
40
			<directory>${project.build.directory}</directory>
41
			<outputDirectory>${project.name}/lib</outputDirectory>
42
			<includes>
43
				<include>${project.artifactId}-${project.version}.jar</include>		
44
			</includes>
45
		</fileSet>
46
		<!-- Copy java dependencies needed by the module -->
47
		<fileSet>
48
			<directory>${project.build.directory}/lib</directory>
49
			<outputDirectory>${project.name}/lib</outputDirectory>
50
			<includes>
51
				<include>*.jar</include>				
52
			</includes>			
53
		</fileSet>
54
	</fileSets>
55
</assembly>
0 56

  
tags/0.5.23/modelio3.8.x/LICENSE.txt
1
  Apache License
2
                           Version 2.0, January 2004
3
                        http://www.apache.org/licenses/
4

  
5
   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6

  
7
   1. Definitions.
8

  
9
      "License" shall mean the terms and conditions for use, reproduction,
10
      and distribution as defined by Sections 1 through 9 of this document.
11

  
12
      "Licensor" shall mean the copyright owner or entity authorized by
13
      the copyright owner that is granting the License.
14

  
15
      "Legal Entity" shall mean the union of the acting entity and all
16
      other entities that control, are controlled by, or are under common
17
      control with that entity. For the purposes of this definition,
18
      "control" means (i) the power, direct or indirect, to cause the
19
      direction or management of such entity, whether by contract or
20
      otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
      outstanding shares, or (iii) beneficial ownership of such entity.
22

  
23
      "You" (or "Your") shall mean an individual or Legal Entity
24
      exercising permissions granted by this License.
25

  
26
      "Source" form shall mean the preferred form for making modifications,
27
      including but not limited to software source code, documentation
28
      source, and configuration files.
29

  
30
      "Object" form shall mean any form resulting from mechanical
31
      transformation or translation of a Source form, including but
32
      not limited to compiled object code, generated documentation,
33
      and conversions to other media types.
34

  
35
      "Work" shall mean the work of authorship, whether in Source or
36
      Object form, made available under the License, as indicated by a
37
      copyright notice that is included in or attached to the work
38
      (an example is provided in the Appendix below).
39

  
40
      "Derivative Works" shall mean any work, whether in Source or Object
41
      form, that is based on (or derived from) the Work and for which the
42
      editorial revisions, annotations, elaborations, or other modifications
43
      represent, as a whole, an original work of authorship. For the purposes
44
      of this License, Derivative Works shall not include works that remain
45
      separable from, or merely link (or bind by name) to the interfaces of,
46
      the Work and Derivative Works thereof.
47

  
48
      "Contribution" shall mean any work of authorship, including
49
      the original version of the Work and any modifications or additions
50
      to that Work or Derivative Works thereof, that is intentionally
51
      submitted to Licensor for inclusion in the Work by the copyright owner
52
      or by an individual or Legal Entity authorized to submit on behalf of
53
      the copyright owner. For the purposes of this definition, "submitted"
54
      means any form of electronic, verbal, or written communication sent
55
      to the Licensor or its representatives, including but not limited to
56
      communication on electronic mailing lists, source code control systems,
57
      and issue tracking systems that are managed by, or on behalf of, the
58
      Licensor for the purpose of discussing and improving the Work, but
59
      excluding communication that is conspicuously marked or otherwise
60
      designated in writing by the copyright owner as "Not a Contribution."
61

  
62
      "Contributor" shall mean Licensor and any individual or Legal Entity
63
      on behalf of whom a Contribution has been received by Licensor and
64
      subsequently incorporated within the Work.
65

  
66
   2. Grant of Copyright License. Subject to the terms and conditions of
67
      this License, each Contributor hereby grants to You a perpetual,
68
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
      copyright license to reproduce, prepare Derivative Works of,
70
      publicly display, publicly perform, sublicense, and distribute the
71
      Work and such Derivative Works in Source or Object form.
72

  
73
   3. Grant of Patent License. Subject to the terms and conditions of
74
      this License, each Contributor hereby grants to You a perpetual,
75
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
      (except as stated in this section) patent license to make, have made,
77
      use, offer to sell, sell, import, and otherwise transfer the Work,
78
      where such license applies only to those patent claims licensable
79
      by such Contributor that are necessarily infringed by their
80
      Contribution(s) alone or by combination of their Contribution(s)
81
      with the Work to which such Contribution(s) was submitted. If You
82
      institute patent litigation against any entity (including a
83
      cross-claim or counterclaim in a lawsuit) alleging that the Work
84
      or a Contribution incorporated within the Work constitutes direct
85
      or contributory patent infringement, then any patent licenses
86
      granted to You under this License for that Work shall terminate
87
      as of the date such litigation is filed.
88

  
89
   4. Redistribution. You may reproduce and distribute copies of the
90
      Work or Derivative Works thereof in any medium, with or without
91
      modifications, and in Source or Object form, provided that You
92
      meet the following conditions:
93

  
94
      (a) You must give any other recipients of the Work or
95
          Derivative Works a copy of this License; and
96

  
97
      (b) You must cause any modified files to carry prominent notices
98
          stating that You changed the files; and
99

  
100
      (c) You must retain, in the Source form of any Derivative Works
101
          that You distribute, all copyright, patent, trademark, and
102
          attribution notices from the Source form of the Work,
103
          excluding those notices that do not pertain to any part of
104
          the Derivative Works; and
105

  
106
      (d) If the Work includes a "NOTICE" text file as part of its
107
          distribution, then any Derivative Works that You distribute must
108
          include a readable copy of the attribution notices contained
109
          within such NOTICE file, excluding those notices that do not
110
          pertain to any part of the Derivative Works, in at least one
111
          of the following places: within a NOTICE text file distributed
112
          as part of the Derivative Works; within the Source form or
113
          documentation, if provided along with the Derivative Works; or,
114
          within a display generated by the Derivative Works, if and
115
          wherever such third-party notices normally appear. The contents
116
          of the NOTICE file are for informational purposes only and
117
          do not modify the License. You may add Your own attribution
118
          notices within Derivative Works that You distribute, alongside
119
          or as an addendum to the NOTICE text from the Work, provided
120
          that such additional attribution notices cannot be construed
121
          as modifying the License.
122

  
123
      You may add Your own copyright statement to Your modifications and
124
      may provide additional or different license terms and conditions
125
      for use, reproduction, or distribution of Your modifications, or
126
      for any such Derivative Works as a whole, provided Your use,
127
      reproduction, and distribution of the Work otherwise complies with
128
      the conditions stated in this License.
129

  
130
   5. Submission of Contributions. Unless You explicitly state otherwise,
131
      any Contribution intentionally submitted for inclusion in the Work
132
      by You to the Licensor shall be under the terms and conditions of
133
      this License, without any additional terms or conditions.
134
      Notwithstanding the above, nothing herein shall supersede or modify
135
      the terms of any separate license agreement you may have executed
136
      with Licensor regarding such Contributions.
137

  
138
   6. Trademarks. This License does not grant permission to use the trade
139
      names, trademarks, service marks, or product names of the Licensor,
140
      except as required for reasonable and customary use in describing the
141
      origin of the Work and reproducing the content of the NOTICE file.
142

  
143
   7. Disclaimer of Warranty. Unless required by applicable law or
144
      agreed to in writing, Licensor provides the Work (and each
145
      Contributor provides its Contributions) on an "AS IS" BASIS,
146
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
      implied, including, without limitation, any warranties or conditions
148
      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
      PARTICULAR PURPOSE. You are solely responsible for determining the
150
      appropriateness of using or redistributing the Work and assume any
151
      risks associated with Your exercise of permissions under this License.
152

  
153
   8. Limitation of Liability. In no event and under no legal theory,
154
      whether in tort (including negligence), contract, or otherwise,
155
      unless required by applicable law (such as deliberate and grossly
156
      negligent acts) or agreed to in writing, shall any Contributor be
157
      liable to You for damages, including any direct, indirect, special,
158
      incidental, or consequential damages of any character arising as a
159
      result of this License or out of the use or inability to use the
160
      Work (including but not limited to damages for loss of goodwill,
161
      work stoppage, computer failure or malfunction, or any and all
162
      other commercial damages or losses), even if such Contributor
163
      has been advised of the possibility of such damages.
164

  
165
   9. Accepting Warranty or Additional Liability. While redistributing
166
      the Work or Derivative Works thereof, You may choose to offer,
167
      and charge a fee for, acceptance of support, warranty, indemnity,
168
      or other liability obligations and/or rights consistent with this
169
      License. However, in accepting such obligations, You may act only
170
      on Your own behalf and on Your sole responsibility, not on behalf
171
      of any other Contributor, and only if You agree to indemnify,
172
      defend, and hold each Contributor harmless for any liability
173
      incurred by, or claims asserted against, such Contributor by reason
174
      of your accepting any such warranty or additional liability.
175

  
176
   END OF TERMS AND CONDITIONS
177

  
178
   APPENDIX: How to apply the Apache License to your work.
179

  
180
      To apply the Apache License to your work, attach the following
181
      boilerplate notice, with the fields enclosed by brackets "[]"
182
      replaced with your own identifying information. (Don't include
183
      the brackets!)  The text should be enclosed in the appropriate
184
      comment syntax for the file format. We also recommend that a
185
      file or class name and description of purpose be included on the
186
      same "printed page" as the copyright notice for easier
187
      identification within third-party archives.
188

  
189
   Copyright 2019 Lakeside Labs GmbH
190

  
191
   Licensed under the Apache License, Version 2.0 (the "License");
192
   you may not use this file except in compliance with the License.
193
   You may obtain a copy of the License at
194

  
195
       http://www.apache.org/licenses/LICENSE-2.0
196

  
197
   Unless required by applicable law or agreed to in writing, software
198
   distributed under the License is distributed on an "AS IS" BASIS,
199
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
   See the License for the specific language governing permissions and
201
   limitations under the License.
0 202

  
tags/0.5.23/modelio3.8.x/conversion_schema/AttackTree-V0.3.xsd
1
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" 
2
    xmlns:xs="http://www.w3.org/2001/XMLSchema">
3

  
4
    <xs:element name="attackTree" type="attackTreeType"/>
5

  
6
    <xs:complexType name="attackTreeType">
7
        <xs:sequence>
8
            <xs:element type="treeDiagramType" name="treeDiagram" minOccurs="1" maxOccurs="1"/>
9
            <xs:element type="attackType" name="attack" minOccurs="1" maxOccurs="1"/>
10
        </xs:sequence>
11
    </xs:complexType>
12

  
13
    <xs:complexType name="treeDiagramType">
14
        <xs:attribute name="name" type="xs:string" use="required"/>
15
    </xs:complexType>
16

  
17
    <xs:complexType name="attackType">
18
        <xs:sequence>
19
            <xs:element type="tagType" name="tag" maxOccurs="unbounded" minOccurs="0"/>
20
            <xs:element type="counterMeasureType" name="counterMeasure" maxOccurs="unbounded" minOccurs="0"/>
21
            <xs:element type="operatorType" name="operator" minOccurs="0" maxOccurs="1"/>
22
        </xs:sequence>
23
        <xs:attribute type="xs:string" name="name" use="required"/>
24
    </xs:complexType>
25

  
26
    <xs:complexType name="tagType">
27
        <xs:simpleContent>
28
            <xs:extension base="xs:string">
29
                <xs:attribute type="xs:string" name="name" use="required"/>
30
            </xs:extension>
31
        </xs:simpleContent>
32
    </xs:complexType>
33

  
34
    <xs:complexType name="counterMeasureType">
35
        <xs:attribute type="xs:string" name="content" use="required"/>
36
    </xs:complexType>
37

  
38
    <xs:complexType name="treeReferenceType">
39
        <xs:attribute type="xs:string" name="ref"/>
40
    </xs:complexType>
41

  
42
    <xs:complexType name="operatorType">
43
        <xs:sequence>
44
            <xs:choice minOccurs="2" maxOccurs="unbounded">
45
                <xs:element type="attackType" name="attack"/>
46
                <xs:element type="treeReferenceType" name="treeReference"/>
47
            </xs:choice>
48
        </xs:sequence>
49
        <xs:attribute type="operationType" name="type" use="required"/>
50
    </xs:complexType>
51

  
52
    <xs:simpleType name="operationType">
53
        <xs:restriction base="xs:string">
54
            <xs:enumeration value="AND" />
55
            <xs:enumeration value="OR" />
56
        </xs:restriction>
57
    </xs:simpleType>
58

  
59
</xs:schema>
0 60

  
tags/0.5.23/modelio3.8.x/conversion_schema/AttackTree-V0.4.xsd
1
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" 
2
    xmlns:xs="http://www.w3.org/2001/XMLSchema">
3

  
4
    <xs:element name="attackTree" type="attackTreeType"/>
5

  
6
    <xs:complexType name="attackTreeType">
7
        <xs:sequence>
8
            <xs:element type="treeDiagramType" name="treeDiagram" minOccurs="1" maxOccurs="1"/>
9
            <xs:element type="attackType" name="attack" minOccurs="1" maxOccurs="1"/>
10
        </xs:sequence>
11
    </xs:complexType>
12

  
13
    <xs:complexType name="treeDiagramType">
14
        <xs:attribute name="name" type="xs:string" use="required"/>
15
    </xs:complexType>
16

  
17
    <xs:complexType name="attackType">
18
        <xs:sequence>
19
            <xs:element type="tagType" name="tag" maxOccurs="unbounded" minOccurs="0"/>
20
            <xs:element type="counterMeasureType" name="counterMeasure" maxOccurs="unbounded" minOccurs="0"/>
21
            <xs:element type="operatorType" name="operator" minOccurs="0" maxOccurs="1"/>
22
        </xs:sequence>
23
        <xs:attribute type="xs:string" name="name" use="required"/>
24
    </xs:complexType>
25

  
26
    <xs:complexType name="tagType">
27
        <xs:simpleContent>
28
            <xs:extension base="xs:string">
29
                <xs:attribute type="xs:string" name="name" use="required"/>
30
            </xs:extension>
31
        </xs:simpleContent>
32
    </xs:complexType>
33

  
34
    <xs:complexType name="counterMeasureType">
35
        <xs:attribute type="xs:string" name="content" use="required"/>
36
    </xs:complexType>
37

  
38
    <xs:complexType name="treeReferenceType">
39
        <xs:attribute type="xs:string" name="ref"/>
40
    </xs:complexType>
41

  
42
    <xs:complexType name="operatorType">
43
        <xs:sequence>
44
            <xs:choice minOccurs="0" maxOccurs="unbounded">
45
                <xs:element type="attackType" name="attack"/>
46
                <xs:element type="treeReferenceType" name="treeReference"/>
47
                <xs:element type="operatorType" name="operator"/>
48
            </xs:choice>
49
        </xs:sequence>
50
        <xs:attribute type="operationType" name="type" use="required"/>
51
    </xs:complexType>
52

  
53
    <xs:simpleType name="operationType">
54
        <xs:restriction base="xs:string">
55
            <xs:enumeration value="AND" />
56
            <xs:enumeration value="OR" />
57
        </xs:restriction>
58
    </xs:simpleType>
59

  
60
</xs:schema>
0 61

  
tags/0.5.23/modelio3.8.x/conversion_schema/Tree1.xml
1
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2
<attackTree>
3
    <treeDiagram name="Tree1 Diagram"/>
4
    <attack name="Tree1">
5
        <tag name="Severity">MEDIUM</tag>
6
        <tag name="Probability">MEDIUM</tag>
7
        <tag name="Security related">false</tag>
8
        <tag name="Safety related">false</tag>
9
        <tag name="Out of scope">false</tag>
10
        <tag name="Countered attack">false</tag>
11
        <operator type="AND">
12
            <attack name="Attack">
13
                <tag name="Severity">MEDIUM</tag>
14
                <tag name="Probability">MEDIUM</tag>
15
                <tag name="Security related">false</tag>
16
                <tag name="Safety related">false</tag>
17
                <tag name="Out of scope">false</tag>
18
                <tag name="Countered attack">false</tag>
19
            </attack>
20
            <attack name="Attack1">
21
                <tag name="Severity">MEDIUM</tag>
22
                <tag name="Probability">MEDIUM</tag>
23
                <tag name="Security related">false</tag>
24
                <tag name="Safety related">false</tag>
25
                <tag name="Out of scope">false</tag>
26
                <tag name="Countered attack">false</tag>
27
            </attack>
28
        </operator>
29
    </attack>
30
</attackTree>
0 31

  
tags/0.5.23/modelio3.8.x/src/main/resources/org/modelio/module/attacktreedesigner/i18n/messages_fr.properties
1

  
2
AttackTreePaletteGroup.AttackTree          = Attack Tree
3
AttackTreePaletteGroup.Freedrawing         = Free Drawing
4
AttackTreePaletteGroup.NotesAndConstraints = Notes and Constraints
5

  
6
Info.Session.Create      = Create {0}
7
Info.Session.UpdateModel = Update Model
8

  
9
Ui.Command.AttackTreeDiagramExplorerCommand.Label = Attack Tree Diagram
10
Ui.Command.AttackTreeDiagramExplorerCommand.Name  = Attack Tree Diagram
11
Ui.Property.Name.Name                             = Name
12
Ui.Property.Reference.Name                        = Reference
13
Ui.Property.TypeCondition.Name                    = Type
14

  
15
Ui.Dialog.SelectXMLFileImport.Label = Select an XML file to import
16

  
17
Ui.Dialog.SelectDirectoryImport.Label = Select a directory to import
18

  
19
Ui.Dialog.SelectDirectoryExport.Label = Select a directory to export
20

  
0 21

  
tags/0.5.23/modelio3.8.x/src/main/resources/org/modelio/module/attacktreedesigner/i18n/messages.properties
1

  
2
AttackTreePaletteGroup.AttackTree          = Attack Tree
3
AttackTreePaletteGroup.Freedrawing         = Free Drawing
4
AttackTreePaletteGroup.NotesAndConstraints = Notes and Constraints
5

  
6
Info.Session.Create      = Create {0}
7
Info.Session.UpdateModel = Update Model
8

  
9
Ui.Command.AttackTreeDiagramExplorerCommand.Label = Attack Tree Diagram
10
Ui.Command.AttackTreeDiagramExplorerCommand.Name  = Attack Tree Diagram
11
Ui.Property.Name.Name                             = Name
12
Ui.Property.Reference.Name                        = Reference
13
Ui.Property.TypeCondition.Name                    = Type
14

  
15

  
16
Ui.Dialog.SelectXMLFileImport.Label = Select an XML file to import
17

  
18
Ui.Dialog.SelectDirectoryImport.Label = Select a directory to import
19

  
20
Ui.Dialog.SelectDirectoryExport.Label = Select a directory to export
21

  
0 22

  
tags/0.5.23/modelio3.8.x/src/main/java/org/modelio/module/attacktreedesigner/api/AttackTreeStereotypes.java
1
package org.modelio.module.attacktreedesigner.api;
2

  
3
import com.modeliosoft.modelio.javadesigner.annotations.objid;
4

  
5
/**
6
 * @author ebrosse
7
 */
8
@objid ("aa25de17-6718-4ec6-9d23-ae1ce1473250")
9
public interface AttackTreeStereotypes {
10
    @objid ("8b0ed670-d6fe-4425-9cf9-d081d93fee4d")
11
    public static final String ATTACK_TREE_DIAGRAM = "AttackTreeDiagram";
12

  
13
    @objid ("9ed47491-0e71-4898-b628-a07583d88201")
14
    public static final String ROOT = "Root";
15

  
16
    @objid ("13509460-cf81-4611-9e0a-20cc54a11b9e")
17
    public static final String AND = "AND";
18

  
19
    @objid ("6d01b8a6-7e7d-4dd7-9f2e-3ed1609bff3c")
20
    public static final String OR = "OR";
21

  
22
    @objid ("54ff413b-d4e0-4417-ab93-32952ef79a85")
23
    public static final String ATTACK = "Attack";
24

  
25
    @objid ("5be35f6d-1348-41cd-8e2f-5c48719c1b91")
26
    public static final String CONNECTION = "Connection";
27

  
28
    @objid ("4bf4c6bb-0e17-4afd-8f70-d74fec27ef40")
29
    public static final String SUBTREE = "SubTree";
30

  
31
    @objid ("25390562-acd5-4c73-8fac-42a2f97fa1ad")
32
    public static final String NODE = "Node";
33

  
34
    @objid ("61d17d69-3dec-4f33-878d-e8f37655ff63")
35
    public static final String OPERATOR = "Operator";
36

  
37
    @objid ("d23a5afb-bfda-498f-9d0d-9b57b2e29985")
38
    public static final String TREE_REFERENCE = "TreeReference";
39

  
40
    @objid ("1220a502-fe6e-4e3c-9a61-a5c600a26614")
41
    public static final String TREE_REFERENCE_ATTRIBUTE = "TreeReferenceAttribute";
42

  
43
}
0 44

  
tags/0.5.23/modelio3.8.x/src/main/java/org/modelio/module/attacktreedesigner/api/AttackTreeNoteTypes.java
1
package org.modelio.module.attacktreedesigner.api;
2

  
3
import com.modeliosoft.modelio.javadesigner.annotations.objid;
4

  
5
@objid ("00dca667-ba09-4a9f-bcdc-18b01c32f1b0")
6
public interface AttackTreeNoteTypes {
7
    @objid ("7b285bac-df22-4439-b4bb-8b03c4b55fad")
8
    public static final String COUNTER_MEASURE = "Counter-Measure";
9

  
10
}
0 11

  
tags/0.5.23/modelio3.8.x/src/main/java/org/modelio/module/attacktreedesigner/api/IAttackTreeDesignerPeerModule.java
1
package org.modelio.module.attacktreedesigner.api;
2

  
3
import com.modeliosoft.modelio.javadesigner.annotations.objid;
4
import org.modelio.api.module.IPeerModule;
5
import org.modelio.metamodel.diagrams.ClassDiagram;
6
import org.modelio.metamodel.uml.infrastructure.Dependency;
7
import org.modelio.metamodel.uml.infrastructure.ModelElement;
8
import org.modelio.metamodel.uml.infrastructure.Note;
9
import org.modelio.metamodel.uml.statik.Class;
10
import org.modelio.metamodel.uml.statik.Package;
11
import org.modelio.vcore.smkernel.mapi.MObject;
12

  
13
@objid ("bbd2491a-c005-46f1-80e2-5370d1fd7230")
14
public interface IAttackTreeDesignerPeerModule extends IPeerModule {
15
    @objid ("6e21714d-90ef-4676-87cb-baa9888b56f7")
16
    public static final String MODULE_NAME = "AttackTreeDesigner";
17

  
18
    @objid ("ba84000d-1a23-4ce5-a11b-f7de39ce2bb4")
19
    void exportModel(ModelElement selectedElement, String targetDirectoryPath);
20

  
21
    @objid ("f7819d05-47d0-4973-a336-bc6e5b583ee7")
22
    void importModel(Package targetPackage, String sourceElementPath);
23

  
24
    @objid ("1761e79e-34b9-456f-862f-03588326df15")
25
    ModelElement createNewTree(ModelElement owner);
26

  
27
    @objid ("36ea40f8-8a64-4cdf-a260-083f9290887c")
28
    Class createANDChild(Class owner, ClassDiagram diagram);
29

  
30
    @objid ("4103d4f7-2e21-4644-af65-f51c8cb29063")
31
    Class createORChild(Class owner, ClassDiagram diagram);
32

  
33
    @objid ("2cae7f7f-573e-4439-8700-a976ef8c5d28")
34
    Class createAttack(ClassDiagram diagram);
35

  
36
    @objid ("ed051488-9b4c-4c1a-9f41-129a7c15435d")
37
    Class createReference(ClassDiagram diagram);
38

  
39
    @objid ("1b659a6f-7bcd-435d-8594-3ff66bd9a8ec")
40
    Note createCounterMeasure(Class attack, ClassDiagram diagram);
41

  
42
    @objid ("bf82fcf8-66a5-4e5d-bdc5-9398466918f7")
43
    void updateTag(Class attack, String tagType, String TagValue);
44

  
45
    @objid ("05bcb59d-86eb-4c2a-8ef7-75838d41cab4")
46
    Dependency createConnection(Class source, Class target, ClassDiagram diagram);
47

  
48
    @objid ("22f26825-e5a9-408e-bb98-744de3eba2ab")
49
    String getElementFullPath(MObject element);
50

  
51
    @objid ("d29d7190-885c-4cb1-a3b5-1841fcb9e1d1")
52
    void updateReference(Class reference, String referencedTreeFullPath);
53

  
54
}
0 55

  
tags/0.5.23/modelio3.8.x/src/main/java/org/modelio/module/attacktreedesigner/api/AttackTreeTagTypes.java
1
package org.modelio.module.attacktreedesigner.api;
2

  
3
import com.modeliosoft.modelio.javadesigner.annotations.objid;
4

  
5
@objid ("af31a1b2-cb3c-4759-8344-72297d509be4")
6
public interface AttackTreeTagTypes {
7
    @objid ("10ad6f6e-8c6b-45ef-9b13-dbf6d2d6ed5e")
8
    public static final String SEVERITY = "Severity";
9

  
10
    @objid ("ee10cda6-1aab-4cf2-9969-5147294bcdb2")
11
    public static final String PROBABILITY = "Probability";
12

  
13
    @objid ("b8e82735-64ce-40be-9243-3fae2d12fbf9")
14
    public static final String RISK_LEVEL = "Risk level";
15

  
16
    @objid ("c946fca0-fe9b-4fd5-8b85-27ca7db97752")
17
    public static final String SECURITY_RELATED = "Security related";
18

  
19
    @objid ("a3147554-875b-4e63-9418-8d50bc7e1d2a")
20
    public static final String SAFETY_RELATED = "Safety related";
21

  
22
    @objid ("e35270e4-86ba-48d1-a637-6ceed3e0d30b")
23
    public static final String OUT_OF_SCOPE = "Out of scope";
24

  
25
    @objid ("4280546a-6b03-40cb-924f-68c035a1cbae")
26
    public static final String CUSTOM_TAG = "Custom tag";
27

  
28
    @objid ("b0582ef9-cde5-4c02-bb51-72e3717bf89a")
29
    public static final String COUNTERED_ATTACK = "Countered attack";
30

  
31
}
0 32

  
tags/0.5.23/modelio3.8.x/src/main/java/org/modelio/module/attacktreedesigner/api/AttackTreeDesignerParameters.java
1
package org.modelio.module.attacktreedesigner.api;
2

  
3
import com.modeliosoft.modelio.javadesigner.annotations.objid;
4

  
5
@objid ("162fda67-c85b-41a6-9670-18e6d4042a61")
6
public interface AttackTreeDesignerParameters {
7
}
0 8

  
tags/0.5.23/modelio3.8.x/src/main/java/org/modelio/module/attacktreedesigner/command/explorer/ExportCommand.java
1
package org.modelio.module.attacktreedesigner.command.explorer;
2

  
3
import java.io.File;
4
import java.util.List;
5
import com.modeliosoft.modelio.javadesigner.annotations.objid;
6
import org.modelio.api.module.IModule;
7
import org.modelio.api.module.command.DefaultModuleCommandHandler;
8
import org.modelio.metamodel.uml.statik.Class;
9
import org.modelio.metamodel.uml.statik.Package;
10
import org.modelio.module.attacktreedesigner.api.AttackTreeStereotypes;
11
import org.modelio.module.attacktreedesigner.api.IAttackTreeDesignerPeerModule;
12
import org.modelio.module.attacktreedesigner.conversion.ModelToJaxbConvertor;
13
import org.modelio.module.attacktreedesigner.i18n.Messages;
14
import org.modelio.module.attacktreedesigner.utils.FileSystemManager;
15
import org.modelio.vcore.smkernel.mapi.MObject;
16

  
17
@objid ("286570d9-dd5d-4974-9067-813c6d3c8ff7")
18
public class ExportCommand extends DefaultModuleCommandHandler {
19
    @objid ("b18adffa-2cab-4db4-b632-4e0991478fb5")
20
    @Override
21
    public void actionPerformed(List<MObject> selectedElements, IModule module) {
22
        String directoryPath = FileSystemManager.getDialogDirectoryPath(Messages.getString("Ui.Dialog.SelectDirectoryExport.Label"));
23
        if(directoryPath == null)
24
            return;
25
        
26
        MObject selectedElement = selectedElements.get(0);
27
        
28
        // selectedElement is a Tree
29
        if(selectedElement instanceof Class) {
30
            Class modelTree = (Class) selectedElement;
31
            exportTree(directoryPath, modelTree);        
32
        } 
33
        // selected element is a package
34
        else if (selectedElement instanceof Package) {
35
            Package pkg = (Package) selectedElement;
36
            exportPackageTrees(directoryPath, pkg);
37
        }
38
    }
39

  
40
    @objid ("3870445b-8622-4a21-ad68-04f114f76a79")
41
    @Override
42
    public boolean accept(final List<MObject> selectedElements, final IModule module) {
43
        if ((selectedElements != null) && (selectedElements.size() == 1)){
44
            MObject selectedElement = selectedElements.get(0);
45
            return (
46
                            ((selectedElement instanceof Class) 
47
                                    && ((Class)selectedElement).isStereotyped(IAttackTreeDesignerPeerModule.MODULE_NAME, AttackTreeStereotypes.ROOT)) 
48
                            || selectedElement instanceof Package
49
                    );
50
        }
51
        return false;
52
    }
53

  
54
    @objid ("3305ebb0-7e96-4806-8e8a-8bd47f90bdc7")
55
    public static void exportPackageTrees(String directoryPath, Package pkg) {
56
        for(MObject element : pkg.getCompositionChildren()) {
57
            if(element instanceof Class) {
58
                Class node = (Class) element;
59
                if(node.isStereotyped(IAttackTreeDesignerPeerModule.MODULE_NAME, AttackTreeStereotypes.ROOT)) {
60
                    exportTree(directoryPath + FileSystemManager.PATH_SEPARATOR + pkg.getName(), node);
61
                }
62
            } else if (element instanceof Package) {
63
                Package childPackage = (Package) element;
64
                exportPackageTrees(directoryPath + FileSystemManager.PATH_SEPARATOR + pkg.getName(), childPackage);
65
            }
66
        }
67
    }
68

  
69
    @objid ("1f6c3069-cbbf-4875-8bc7-beac1a409a26")
70
    public static void exportTree(String directoryPath, Class modelTree) {
71
        ModelToJaxbConvertor modelToJaxbConvertor = new ModelToJaxbConvertor(modelTree);
72
        File file = FileSystemManager.createFile(directoryPath, modelToJaxbConvertor.getModelTree().getName() + FileSystemManager.XML_FILE_EXTENSION);
73
        FileSystemManager.marshallJaxbContentInFile(file, modelToJaxbConvertor.convertModelToJaxb());
74
    }
75

  
76
}
0 77

  
tags/0.5.23/modelio3.8.x/src/main/java/org/modelio/module/attacktreedesigner/command/explorer/MaskSubTreeCommand.java
1
package org.modelio.module.attacktreedesigner.command.explorer;
2

  
3
import java.util.List;
4
import com.modeliosoft.modelio.javadesigner.annotations.objid;
5
import org.modelio.api.modelio.diagram.IDiagramHandle;
6
import org.modelio.api.modelio.diagram.IDiagramService;
7
import org.modelio.api.modelio.model.IModelingSession;
8
import org.modelio.api.modelio.model.ITransaction;
9
import org.modelio.api.module.IModule;
10
import org.modelio.api.module.command.DefaultModuleCommandHandler;
11
import org.modelio.api.module.context.IModuleContext;
12
import org.modelio.metamodel.diagrams.AbstractDiagram;
13
import org.modelio.metamodel.uml.infrastructure.Dependency;
14
import org.modelio.metamodel.uml.infrastructure.Element;
15
import org.modelio.metamodel.uml.infrastructure.ModelTree;
16
import org.modelio.metamodel.uml.statik.Class;
17
import org.modelio.module.attacktreedesigner.api.AttackTreeStereotypes;
18
import org.modelio.module.attacktreedesigner.api.IAttackTreeDesignerPeerModule;
19
import org.modelio.module.attacktreedesigner.i18n.Messages;
20
import org.modelio.module.attacktreedesigner.impl.AttackTreeDesignerModule;
21
import org.modelio.module.attacktreedesigner.utils.elementmanager.representation.ElementRepresentationManager;
22
import org.modelio.vcore.smkernel.mapi.MObject;
23

  
24
@objid ("6528192d-24c6-477e-b7c8-3fabb14aacf6")
25
public class MaskSubTreeCommand extends DefaultModuleCommandHandler {
26
    @objid ("093217f9-c7fa-456d-8c32-aff51cf34765")
27
    @Override
28
    public void actionPerformed(final List<MObject> selectedElements, final IModule module) {
29
        IModuleContext moduleContext = AttackTreeDesignerModule.getInstance().getModuleContext();
30
        IModelingSession session = moduleContext.getModelingSession();
31
        MObject selectedElement = selectedElements.get(0);  
32
        
33
        try( ITransaction transaction = session.createTransaction(Messages.getString ("Info.Session.UpdateModel"))){
34
        
35
            ((Class) selectedElement).addStereotype(IAttackTreeDesignerPeerModule.MODULE_NAME, AttackTreeStereotypes.SUBTREE);
36
            
37
            // Mask children of newly modified attack to subtree
38
            IDiagramService diagramService = moduleContext.getModelioServices().getDiagramService();
39
        
40
            
41
            List<AbstractDiagram> associatedDiagrams = ((Element) selectedElement).getDiagramElement(AbstractDiagram.class);
42
            for(AbstractDiagram diagram: associatedDiagrams) {
43
        
44
                try(  IDiagramHandle diagramHandle = diagramService.getDiagramHandle(diagram);){
45
        
46
                    ElementRepresentationManager.maskChildren(moduleContext, diagramService, selectedElement, diagramHandle);
47
        
48
                    diagramHandle.save();
49
                    diagramHandle.close();
50
                }
51
            }
52
        
53
            transaction.commit ();
54
        }
55
    }
56

  
57
    @objid ("7168cd67-7184-4d1c-8e77-58d362ef1137")
58
    @Override
59
    public boolean accept(final List<MObject> selectedElements, final IModule module) {
60
        if ((selectedElements != null) && (selectedElements.size() == 1)){
61
            MObject selectedElement = selectedElements.get(0);
62
            if((selectedElement instanceof Class)
63
                    && ((Class) selectedElement).isStereotyped(IAttackTreeDesignerPeerModule.MODULE_NAME, AttackTreeStereotypes.ATTACK)
64
                    && !((Class) selectedElement).isStereotyped(IAttackTreeDesignerPeerModule.MODULE_NAME, AttackTreeStereotypes.SUBTREE)
65
                    && selectedElement.getStatus().isModifiable()
66
                    && (((ModelTree) selectedElement)).getDependsOnDependency().size()>0) {
67
                for(Dependency dependency:(((ModelTree) selectedElement)).getDependsOnDependency()) {
68
                    if(dependency.isStereotyped(IAttackTreeDesignerPeerModule.MODULE_NAME, AttackTreeStereotypes.CONNECTION)) {
69
                        return true;
70
                    }
71
                }
72
            }
73
            return ((selectedElement != null) 
74
                    && (selectedElement instanceof Class)
75
                    && ((Class) selectedElement).isStereotyped(IAttackTreeDesignerPeerModule.MODULE_NAME, AttackTreeStereotypes.ATTACK)
76
                    && !((Class) selectedElement).isStereotyped(IAttackTreeDesignerPeerModule.MODULE_NAME, AttackTreeStereotypes.SUBTREE)
77
                    && selectedElement.getStatus().isModifiable()
78
                    && (((ModelTree) selectedElement)).getDependsOnDependency().size()>0);
79
        
80
        }
81
        return false;
82
    }
83

  
84
}
0 85

  
tags/0.5.23/modelio3.8.x/src/main/java/org/modelio/module/attacktreedesigner/command/explorer/AutoLayoutCommand.java
1
package org.modelio.module.attacktreedesigner.command.explorer;
2

  
3
import java.util.List;
4
import com.modeliosoft.modelio.javadesigner.annotations.objid;
5
import org.modelio.api.modelio.diagram.IDiagramHandle;
6
import org.modelio.api.modelio.diagram.IDiagramService;
7
import org.modelio.api.modelio.model.IModelingSession;
8
import org.modelio.api.modelio.model.ITransaction;
9
import org.modelio.api.module.IModule;
10
import org.modelio.api.module.command.DefaultModuleCommandHandler;
11
import org.modelio.api.module.context.IModuleContext;
12
import org.modelio.metamodel.diagrams.ClassDiagram;
13
import org.modelio.module.attacktreedesigner.api.AttackTreeStereotypes;
14
import org.modelio.module.attacktreedesigner.api.IAttackTreeDesignerPeerModule;
15
import org.modelio.module.attacktreedesigner.i18n.Messages;
16
import org.modelio.module.attacktreedesigner.impl.AttackTreeDesignerModule;
17
import org.modelio.module.attacktreedesigner.utils.elementmanager.representation.AutoLayoutManager;
18
import org.modelio.vcore.smkernel.mapi.MObject;
19

  
20
@objid ("2b416d6a-09f7-4f10-a756-f1bd7f901d69")
21
public class AutoLayoutCommand extends DefaultModuleCommandHandler {
22
    @objid ("9af6b559-1381-47af-a5a4-76899a689b2c")
23
    @Override
24
    public void actionPerformed(List<MObject> selectedElements, IModule module) {
25
        IModuleContext moduleContext = AttackTreeDesignerModule.getInstance().getModuleContext();
26
        IModelingSession session = moduleContext.getModelingSession();
27
        
28
        ClassDiagram selectedDiagram = (ClassDiagram) selectedElements.get(0);
29
        
30
        MObject rootElement = selectedDiagram.getCompositionOwner();
31
        
32
        
33
        IDiagramService diagramService = moduleContext.getModelioServices().getDiagramService();
34
        
35
        try( ITransaction transaction = session.createTransaction(Messages.getString ("Info.Session.UpdateModel"))){
36
        
37
        
38
        
39
            try(  IDiagramHandle diagramHandle = diagramService.getDiagramHandle(selectedDiagram);){
40
        
41
                AutoLayoutManager.autolayoutTree(rootElement, diagramHandle);
42
        
43
                
44
                diagramHandle.save();
45
                diagramHandle.close();
46
            }
47
        
48
            transaction.commit ();
49
        }
50
    }
51

  
52
    @objid ("deeca976-dc65-45b7-8107-98d420f3b196")
53
    @Override
54
    public boolean accept(final List<MObject> selectedElements, final IModule module) {
55
        if ((selectedElements != null) && (selectedElements.size() == 1)){
56
            MObject selectedElement = selectedElements.get(0);
57
            return ((selectedElement != null) 
58
                    && (selectedElement instanceof ClassDiagram)
59
                    && ((ClassDiagram) selectedElement).isStereotyped(IAttackTreeDesignerPeerModule.MODULE_NAME, AttackTreeStereotypes.ATTACK_TREE_DIAGRAM)
60
                    && selectedElement.getStatus().isModifiable());
61
        }
62
        return false;
63
    }
64

  
65
}
0 66

  
tags/0.5.23/modelio3.8.x/src/main/java/org/modelio/module/attacktreedesigner/command/explorer/ImportPackageCommand.java
1
package org.modelio.module.attacktreedesigner.command.explorer;
2

  
3
import java.io.File;
4
import java.util.List;
5
import com.modeliosoft.modelio.javadesigner.annotations.objid;
6
import org.modelio.api.modelio.model.IModelingSession;
7
import org.modelio.api.modelio.model.ITransaction;
8
import org.modelio.api.modelio.model.IUmlModel;
9
import org.modelio.api.module.IModule;
10
import org.modelio.api.module.command.DefaultModuleCommandHandler;
11
import org.modelio.metamodel.uml.statik.Package;
12
import org.modelio.module.attacktreedesigner.conversion.JaxbToModelConvertor;
13
import org.modelio.module.attacktreedesigner.conversion.schema.AttackTreeType;
14
import org.modelio.module.attacktreedesigner.i18n.Messages;
15
import org.modelio.module.attacktreedesigner.impl.AttackTreeDesignerModule;
16
import org.modelio.module.attacktreedesigner.utils.FileSystemManager;
17
import org.modelio.vcore.smkernel.mapi.MObject;
18

  
19
@objid ("7dec2c56-ca0f-427c-a31c-4a43ebd1bc8c")
20
public class ImportPackageCommand extends DefaultModuleCommandHandler {
21
    @objid ("90ebe09b-0be3-45fb-be7d-092f56a0eeb2")
22
    @Override
23
    public void actionPerformed(final List<MObject> selectedElements, final IModule module) {
24
        Package destinationPackage = (Package) selectedElements.get(0);
25
        
26
        String directoryPath = FileSystemManager.getDialogDirectoryPath(Messages.getString("Ui.Dialog.SelectDirectoryImport.Label"));
27
        if(directoryPath == null)
28
            return;
29
        
30
        importDirectory(module, directoryPath, destinationPackage);
31
    }
32

  
33
    @objid ("55818d2f-f714-4233-b8cd-fe6af41c74cc")
34
    @Override
35
    public boolean accept(final List<MObject> selectedElements, final IModule module) {
36
        if ((selectedElements != null) && (selectedElements.size() == 1)){
37
            return selectedElements.get(0) instanceof Package ;
38
        }
39
        return false;
40
    }
41

  
42
    @objid ("3e9faabc-f3eb-4da1-8c7f-4803c9029707")
43
    private static void walkDirectoryAndImportTree(File directory, IModule module, Package destinationPackage) {
44
        for(File file: directory.listFiles()){
45
            if(file.isDirectory()) {
46
        
47
                Package newPackage = destinationPackage;
48
        
49
                IModelingSession modellingSession = AttackTreeDesignerModule.getInstance().getModuleContext().getModelingSession ();
50
                IUmlModel model = modellingSession.getModel();                
51
        
52
                try( ITransaction transaction = modellingSession.createTransaction(Messages.getString ("Info.Session.Create", ""))){
53
        
54
                    newPackage = model.createPackage(file.getName(), destinationPackage);
55
        
56
                    transaction.commit ();
57
                }
58
        
59
        
60
                walkDirectoryAndImportTree(file, module, newPackage);
61
        
62
            } else if (file.isFile() && file.getName().endsWith(FileSystemManager.XML_FILE_EXTENSION)) {
63
                AttackTreeType jaxbTree = FileSystemManager.unmarshallFileToJaxb(file);
64
                JaxbToModelConvertor modelToJaxbConvertor = new JaxbToModelConvertor(jaxbTree);
65
        
66
                modelToJaxbConvertor.createTreeModel(module, destinationPackage);
67
            }
68
        }
69
    }
70

  
71
    @objid ("882dd116-0588-4e48-8c21-dc4dbcf52945")
72
    public static void importDirectory(final IModule module, String directoryPath, Package destinationPackage) {
73
        File directory = new File (directoryPath);
74
        
75
        
76
        IModelingSession modellingSession = AttackTreeDesignerModule.getInstance().getModuleContext().getModelingSession ();
77
        IUmlModel model = modellingSession.getModel();                
78
        
79
        try( ITransaction transaction = modellingSession.createTransaction(Messages.getString ("Info.Session.Create", ""))){
80
        
81
            Package newPackage = model.createPackage(directory.getName(), destinationPackage);
82
        
83
            walkDirectoryAndImportTree(directory, module, newPackage);
84
        
85
            JaxbToModelConvertor.updatePostponedReferences();
86
            transaction.commit ();
87
        }
88
    }
89

  
90
}
0 91

  
tags/0.5.23/modelio3.8.x/src/main/java/org/modelio/module/attacktreedesigner/command/explorer/UnmaskSubTreeCommand.java
1
package org.modelio.module.attacktreedesigner.command.explorer;
2

  
3
import java.util.List;
4
import com.modeliosoft.modelio.javadesigner.annotations.objid;
5
import org.eclipse.draw2d.geometry.Rectangle;
6
import org.modelio.api.modelio.diagram.IDiagramGraphic;
7
import org.modelio.api.modelio.diagram.IDiagramHandle;
8
import org.modelio.api.modelio.diagram.IDiagramNode;
9
import org.modelio.api.modelio.diagram.IDiagramService;
10
import org.modelio.api.modelio.model.IModelingSession;
11
import org.modelio.api.modelio.model.ITransaction;
12
import org.modelio.api.module.IModule;
13
import org.modelio.api.module.command.DefaultModuleCommandHandler;
14
import org.modelio.api.module.context.IModuleContext;
15
import org.modelio.metamodel.diagrams.AbstractDiagram;
16
import org.modelio.metamodel.uml.infrastructure.Dependency;
17
import org.modelio.metamodel.uml.infrastructure.Element;
18
import org.modelio.metamodel.uml.infrastructure.ModelElement;
19
import org.modelio.metamodel.uml.infrastructure.ModelTree;
20
import org.modelio.metamodel.uml.statik.Class;
21
import org.modelio.module.attacktreedesigner.api.AttackTreeStereotypes;
22
import org.modelio.module.attacktreedesigner.api.IAttackTreeDesignerPeerModule;
23
import org.modelio.module.attacktreedesigner.i18n.Messages;
24
import org.modelio.module.attacktreedesigner.impl.AttackTreeDesignerModule;
25
import org.modelio.module.attacktreedesigner.utils.elementmanager.representation.AutoLayoutManager;
26
import org.modelio.module.attacktreedesigner.utils.elementmanager.representation.ElementRepresentationManager;
27
import org.modelio.vcore.smkernel.mapi.MObject;
28

  
29
@objid ("fc2698b1-fc2d-4a0c-99d8-c38b18503d7e")
30
public class UnmaskSubTreeCommand extends DefaultModuleCommandHandler {
31
    @objid ("bf6048fb-b21c-4bb3-b690-0ef3fec6e9fe")
32
    @Override
33
    public void actionPerformed(final List<MObject> selectedElements, final IModule module) {
34
        IModuleContext moduleContext = AttackTreeDesignerModule.getInstance().getModuleContext();
35
        IModelingSession session = moduleContext.getModelingSession();
36
        MObject selectedElement = selectedElements.get(0);  
37
        
38
        try( ITransaction transaction = session.createTransaction(Messages.getString ("Info.Session.UpdateModel"))){
39
        
40
            // Remove SubTree stereotype from "selectedElement" 
41
            ((Class) selectedElement).removeStereotypes(IAttackTreeDesignerPeerModule.MODULE_NAME, AttackTreeStereotypes.SUBTREE);
42
        
43
        
44
            /*
45
             * Unmask Children
46
             */
47
            IDiagramService diagramService = moduleContext.getModelioServices().getDiagramService();            
48
        
49
            List<AbstractDiagram> diagrams = ((Element) selectedElement).getDiagramElement(AbstractDiagram.class);
50
            for(AbstractDiagram diagram: diagrams) {
51
                try(  IDiagramHandle diagramHandle = diagramService.getDiagramHandle(diagram);){
52
        
53
        
54
                    MObject root = diagram.getCompositionOwner();
55
        
56
                    List<IDiagramGraphic> diagramGraphics = diagramHandle.getDiagramGraphics(selectedElement);
57
                    IDiagramGraphic diagramGraphic = diagramGraphics.get(0);
58
        
59
        
60
                    Rectangle elementBounds = ((IDiagramNode) diagramGraphic).getBounds();
61
        
62
        
63
                    List<Dependency> elementDependencies = ((ModelTree) selectedElement).getDependsOnDependency();
64
                    for(Dependency elementDependency:elementDependencies) {
65
                        if(elementDependency.isStereotyped(IAttackTreeDesignerPeerModule.MODULE_NAME, AttackTreeStereotypes.CONNECTION)) {
66
        
67
                            Class elementChild = (Class) elementDependency.getDependsOn();
68
                            
69
                            ElementRepresentationManager.unmaskChildren(moduleContext, diagramService, diagramHandle , elementChild, elementBounds.x, elementBounds.y + AutoLayoutManager.VERTICAL_AUTOSPACING);
70
        
71
        
72
                            /*
73
                             * setOwner of Operator element child of Selected element to update representation
74
                             */
75
                            MObject packageOwner = diagram.getOrigin().getCompositionOwner();
76
                            elementChild.setOwner((ModelTree) packageOwner);
77
        
78
        
79
                            /*
80
                             *  Unmask Operator element child of Selected element
81
                             */
82
                            List<IDiagramGraphic> graph = diagramHandle.unmask(elementChild, elementBounds.x, elementBounds.y + AutoLayoutManager.VERTICAL_AUTOSPACING);
83
        
84
        
85
                            /*
86
                             * Update Operator element child's style
87
                             */
88
                            if((graph != null) &&  (graph.size() > 0) && (graph.get(0) instanceof IDiagramNode)) {
89
                                IDiagramNode graphNode = (IDiagramNode)graph.get(0);
90
                                ElementRepresentationManager.updateNodeStyle(graphNode);
91
                            }
92
        
93
        
94
                            /*
95
                             *  unmask dependencies related to displaced operator element
96
                             */
97
                            List<Dependency> elementDependsOnDependencies = ((ModelElement) elementChild).getDependsOnDependency();
98
                            for(Dependency dependency: elementDependsOnDependencies) {
99
                                if(dependency.isStereotyped(IAttackTreeDesignerPeerModule.MODULE_NAME, AttackTreeStereotypes.CONNECTION)) {
100
                                    diagramHandle.unmask(dependency, 0, 0);
101
                                }
102
                            }
103
        //                            List<Dependency> elementImpactedDependency = ((ModelElement) elementChild).getImpactedDependency();
104
        //                            for(Dependency dependency: elementImpactedDependency) {
105
        //                                if(dependency.isStereotyped(IAttackTreeDesignerPeerModule.MODULE_NAME, AttackTreeStereotypes.CONNECTION)) {
106
        //                                    diagramHandle.unmask(dependency, 0, 0);
107
        //                                }
108
        //                            }
109
                            diagramHandle.unmask(elementDependency, 0, 0);
110
        
111
                            /*
112
                             * update owner of displaced operator element Child of selected element
113
                             */
114
                            elementChild.setOwner((ModelTree) selectedElement);
115
                        }
116
                    }
117
        
118
        
119
                    /*
120
                     * Autolayout Tree
121
                     */
122
                    AutoLayoutManager.autolayoutTree(root, diagramHandle);
123
        
124
        
125
        
126
                    diagramHandle.save();
127
                    diagramHandle.close();
128
                }
129
            }
130
        
131
        
132
            transaction.commit ();
133
        }
134
    }
135

  
136
    @objid ("7d0beca4-ff4e-4484-9a27-c3d6aec6beca")
137
    @Override
138
    public boolean accept(final List<MObject> selectedElements, final IModule module) {
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff