Browse Source

sVote source code publication

master
Swisspost 5 months ago
commit
460d0e0780
100 changed files with 6118 additions and 0 deletions
  1. 103
    0
      LICENSE.md
  2. 11
    0
      README.md
  3. BIN
      dependencies/bsh-core-2.0b6.jar
  4. BIN
      dependencies/cryptography-4.2.1.jar
  5. BIN
      dependencies/iaikPkcs11Wrapper-1.4.jar
  6. BIN
      dependencies/jakarta-oro-2.0.6-local.jar
  7. BIN
      dependencies/log4j-1.3alpha-7-local.jar
  8. BIN
      dependencies/ov-keystore-1.3.0-tests.jar
  9. BIN
      dependencies/ov-keystore-1.3.0.jar
  10. BIN
      dependencies/scytl-gmp-6.1.1-amd64-Linux-gpp-shared.nar
  11. BIN
      dependencies/scytl-gmp-6.1.1-amd64-Windows-gpp-shared.nar
  12. BIN
      dependencies/scytl-math-1.0.1.jar
  13. BIN
      dependencies/scytl-math-native-1.0.1-amd64-Linux-gpp-jni.nar
  14. BIN
      dependencies/scytl-math-native-1.0.1-amd64-Windows-gpp-jni.nar
  15. BIN
      dependencies/shares-1.0.2.jar
  16. BIN
      documentation/Scytl sVote Audit with Control Components.pdf
  17. BIN
      documentation/Scytl sVote Protocol Specifications.pdf
  18. BIN
      documentation/Scytl_sVote_Software_Architecture.pdf
  19. 12
    0
      source-code/Copyright.txt
  20. 5
    0
      source-code/maven-generic-conf/.gitignore
  21. 15
    0
      source-code/maven-generic-conf/README.md
  22. 2
    0
      source-code/maven-generic-conf/THIRD-PARTY.txt
  23. 166
    0
      source-code/maven-generic-conf/etc/eclipse/scytl_checkstyle.xml
  24. 33
    0
      source-code/maven-generic-conf/etc/eclipse/scytl_codetemplates.xml
  25. 251
    0
      source-code/maven-generic-conf/etc/eclipse/scytl_javaformat-1.1.xml
  26. 4
    0
      source-code/maven-generic-conf/extlibs/barcode4j/INSTALL.txt
  27. BIN
      source-code/maven-generic-conf/extlibs/barcode4j/barcode4j.jar
  28. 11
    0
      source-code/maven-generic-conf/extlibs/ec2-plugin/.gitignore
  29. 2
    0
      source-code/maven-generic-conf/extlibs/ec2-plugin/TODO.txt
  30. 75
    0
      source-code/maven-generic-conf/extlibs/ec2-plugin/pom.xml
  31. 118
    0
      source-code/maven-generic-conf/extlibs/ec2-plugin/src/main/java/hudson/plugins/ec2/AmazonEC2Cloud.java
  32. 459
    0
      source-code/maven-generic-conf/extlibs/ec2-plugin/src/main/java/hudson/plugins/ec2/EC2Cloud.java
  33. 126
    0
      source-code/maven-generic-conf/extlibs/ec2-plugin/src/main/java/hudson/plugins/ec2/EC2Computer.java
  34. 73
    0
      source-code/maven-generic-conf/extlibs/ec2-plugin/src/main/java/hudson/plugins/ec2/EC2ComputerLauncher.java
  35. 152
    0
      source-code/maven-generic-conf/extlibs/ec2-plugin/src/main/java/hudson/plugins/ec2/EC2PrivateKey.java
  36. 77
    0
      source-code/maven-generic-conf/extlibs/ec2-plugin/src/main/java/hudson/plugins/ec2/EC2RetentionStrategy.java
  37. 382
    0
      source-code/maven-generic-conf/extlibs/ec2-plugin/src/main/java/hudson/plugins/ec2/EC2Slave.java
  38. 82
    0
      source-code/maven-generic-conf/extlibs/ec2-plugin/src/main/java/hudson/plugins/ec2/EC2Tag.java
  39. 180
    0
      source-code/maven-generic-conf/extlibs/ec2-plugin/src/main/java/hudson/plugins/ec2/Eucalyptus.java
  40. 23
    0
      source-code/maven-generic-conf/extlibs/ec2-plugin/src/main/java/hudson/plugins/ec2/InstanceState.java
  41. 56
    0
      source-code/maven-generic-conf/extlibs/ec2-plugin/src/main/java/hudson/plugins/ec2/InstanceTypeConverter.java
  42. 212
    0
      source-code/maven-generic-conf/extlibs/ec2-plugin/src/main/java/hudson/plugins/ec2/OpenNebula.java
  43. 40
    0
      source-code/maven-generic-conf/extlibs/ec2-plugin/src/main/java/hudson/plugins/ec2/PluginImpl.java
  44. 442
    0
      source-code/maven-generic-conf/extlibs/ec2-plugin/src/main/java/hudson/plugins/ec2/SlaveTemplate.java
  45. 27
    0
      source-code/maven-generic-conf/extlibs/ec2-plugin/src/main/java/hudson/plugins/ec2/ebs/ZPoolExpandNotice.java
  46. 66
    0
      source-code/maven-generic-conf/extlibs/ec2-plugin/src/main/java/hudson/plugins/ec2/ebs/ZPoolMonitor.java
  47. 9
    0
      source-code/maven-generic-conf/extlibs/ec2-plugin/src/main/java/hudson/plugins/ec2/ebs/package-info.java
  48. 555
    0
      source-code/maven-generic-conf/extlibs/ec2-plugin/src/main/java/hudson/plugins/ec2/one/OneEC2Cloud.java
  49. 139
    0
      source-code/maven-generic-conf/extlibs/ec2-plugin/src/main/java/hudson/plugins/ec2/one/OneEC2Computer.java
  50. 458
    0
      source-code/maven-generic-conf/extlibs/ec2-plugin/src/main/java/hudson/plugins/ec2/one/OneEC2Slave.java
  51. 82
    0
      source-code/maven-generic-conf/extlibs/ec2-plugin/src/main/java/hudson/plugins/ec2/one/OneEC2Tag.java
  52. 54
    0
      source-code/maven-generic-conf/extlibs/ec2-plugin/src/main/java/hudson/plugins/ec2/one/OneInstanceType.java
  53. 665
    0
      source-code/maven-generic-conf/extlibs/ec2-plugin/src/main/java/hudson/plugins/ec2/one/OneSlaveTemplate.java
  54. 232
    0
      source-code/maven-generic-conf/extlibs/ec2-plugin/src/main/java/hudson/plugins/ec2/ssh/EC2UnixLauncher.java
  55. 50
    0
      source-code/maven-generic-conf/extlibs/ec2-plugin/src/main/java/hudson/plugins/ec2/ssh/HostKeyVerifierImpl.java
  56. 23
    0
      source-code/maven-generic-conf/extlibs/ec2-plugin/src/main/resources/hudson/plugins/ec2/AmazonEC2Cloud/config-entries.jelly
  57. 6
    0
      source-code/maven-generic-conf/extlibs/ec2-plugin/src/main/resources/hudson/plugins/ec2/AmazonEC2Cloud/help-region.html
  58. 26
    0
      source-code/maven-generic-conf/extlibs/ec2-plugin/src/main/resources/hudson/plugins/ec2/EC2Cloud/computerSet.jelly
  59. 1
    0
      source-code/maven-generic-conf/extlibs/ec2-plugin/src/main/resources/hudson/plugins/ec2/EC2Cloud/computerSet.properties
  60. 9
    0
      source-code/maven-generic-conf/extlibs/ec2-plugin/src/main/resources/hudson/plugins/ec2/EC2Cloud/config.jelly
  61. 6
    0
      source-code/maven-generic-conf/extlibs/ec2-plugin/src/main/resources/hudson/plugins/ec2/EC2Cloud/help-accessId.html
  62. 10
    0
      source-code/maven-generic-conf/extlibs/ec2-plugin/src/main/resources/hudson/plugins/ec2/EC2Cloud/help-ec2EndpointUrl.html
  63. 15
    0
      source-code/maven-generic-conf/extlibs/ec2-plugin/src/main/resources/hudson/plugins/ec2/EC2Cloud/help-instanceCapStr.html
  64. 1
    0
      source-code/maven-generic-conf/extlibs/ec2-plugin/src/main/resources/hudson/plugins/ec2/EC2Cloud/help-jvmopts.html
  65. 12
    0
      source-code/maven-generic-conf/extlibs/ec2-plugin/src/main/resources/hudson/plugins/ec2/EC2Cloud/help-privateKey.html
  66. 7
    0
      source-code/maven-generic-conf/extlibs/ec2-plugin/src/main/resources/hudson/plugins/ec2/EC2Cloud/help-remoteAdmin.html
  67. 5
    0
      source-code/maven-generic-conf/extlibs/ec2-plugin/src/main/resources/hudson/plugins/ec2/EC2Cloud/help-rootCommandPrefix.html
  68. 10
    0
      source-code/maven-generic-conf/extlibs/ec2-plugin/src/main/resources/hudson/plugins/ec2/EC2Cloud/help-s3EndpointUrl.html
  69. 7
    0
      source-code/maven-generic-conf/extlibs/ec2-plugin/src/main/resources/hudson/plugins/ec2/EC2Cloud/help-userData.html
  70. 104
    0
      source-code/maven-generic-conf/extlibs/ec2-plugin/src/main/resources/hudson/plugins/ec2/EC2Computer/configure.jelly
  71. 6
    0
      source-code/maven-generic-conf/extlibs/ec2-plugin/src/main/resources/hudson/plugins/ec2/EC2Computer/help-idleTerminationMinutes.html
  72. 6
    0
      source-code/maven-generic-conf/extlibs/ec2-plugin/src/main/resources/hudson/plugins/ec2/EC2Computer/help-usePrivateDnsName.html
  73. 4
    0
      source-code/maven-generic-conf/extlibs/ec2-plugin/src/main/resources/hudson/plugins/ec2/EC2Slave/help-initScript.html
  74. 3
    0
      source-code/maven-generic-conf/extlibs/ec2-plugin/src/main/resources/hudson/plugins/ec2/EC2Slave/help-numExecutors.html
  75. 7
    0
      source-code/maven-generic-conf/extlibs/ec2-plugin/src/main/resources/hudson/plugins/ec2/EC2Slave/help-remoteAdmin.html
  76. 5
    0
      source-code/maven-generic-conf/extlibs/ec2-plugin/src/main/resources/hudson/plugins/ec2/EC2Slave/help-rootCommandPrefix.html
  77. 5
    0
      source-code/maven-generic-conf/extlibs/ec2-plugin/src/main/resources/hudson/plugins/ec2/EC2Slave/help-securityGroups.html
  78. 6
    0
      source-code/maven-generic-conf/extlibs/ec2-plugin/src/main/resources/hudson/plugins/ec2/EC2Slave/help-stopOnTerminate.html
  79. 4
    0
      source-code/maven-generic-conf/extlibs/ec2-plugin/src/main/resources/hudson/plugins/ec2/EC2Slave/help-subnetId.html
  80. 3
    0
      source-code/maven-generic-conf/extlibs/ec2-plugin/src/main/resources/hudson/plugins/ec2/EC2Slave/help-type.html
  81. 9
    0
      source-code/maven-generic-conf/extlibs/ec2-plugin/src/main/resources/hudson/plugins/ec2/EC2Slave/help-zone.html
  82. 41
    0
      source-code/maven-generic-conf/extlibs/ec2-plugin/src/main/resources/hudson/plugins/ec2/EC2Tag/config.jelly
  83. 21
    0
      source-code/maven-generic-conf/extlibs/ec2-plugin/src/main/resources/hudson/plugins/ec2/Eucalyptus/config-entries.jelly
  84. 4
    0
      source-code/maven-generic-conf/extlibs/ec2-plugin/src/main/resources/hudson/plugins/ec2/Eucalyptus/help-url.html
  85. 3
    0
      source-code/maven-generic-conf/extlibs/ec2-plugin/src/main/resources/hudson/plugins/ec2/Messages.properties
  86. 17
    0
      source-code/maven-generic-conf/extlibs/ec2-plugin/src/main/resources/hudson/plugins/ec2/OpenNebula/config-entries.jelly
  87. 4
    0
      source-code/maven-generic-conf/extlibs/ec2-plugin/src/main/resources/hudson/plugins/ec2/OpenNebula/help-url.html
  88. 124
    0
      source-code/maven-generic-conf/extlibs/ec2-plugin/src/main/resources/hudson/plugins/ec2/SlaveTemplate/config.jelly
  89. 6
    0
      source-code/maven-generic-conf/extlibs/ec2-plugin/src/main/resources/hudson/plugins/ec2/SlaveTemplate/help-idleTerminationMinutes.html
  90. 6
    0
      source-code/maven-generic-conf/extlibs/ec2-plugin/src/main/resources/hudson/plugins/ec2/SlaveTemplate/help-usePrivateDnsName.html
  91. 40
    0
      source-code/maven-generic-conf/extlibs/ec2-plugin/src/main/resources/hudson/plugins/ec2/ebs/ZPoolExpandNotice/index.jelly
  92. 33
    0
      source-code/maven-generic-conf/extlibs/ec2-plugin/src/main/resources/hudson/plugins/ec2/ebs/ZPoolExpandNotice/message.jelly
  93. 3
    0
      source-code/maven-generic-conf/extlibs/ec2-plugin/src/main/resources/hudson/plugins/ec2/one/Messages.properties
  94. 26
    0
      source-code/maven-generic-conf/extlibs/ec2-plugin/src/main/resources/hudson/plugins/ec2/one/OneEC2Cloud/computerSet.jelly
  95. 1
    0
      source-code/maven-generic-conf/extlibs/ec2-plugin/src/main/resources/hudson/plugins/ec2/one/OneEC2Cloud/computerSet.properties
  96. 9
    0
      source-code/maven-generic-conf/extlibs/ec2-plugin/src/main/resources/hudson/plugins/ec2/one/OneEC2Cloud/config.jelly
  97. 6
    0
      source-code/maven-generic-conf/extlibs/ec2-plugin/src/main/resources/hudson/plugins/ec2/one/OneEC2Cloud/help-accessId.html
  98. 10
    0
      source-code/maven-generic-conf/extlibs/ec2-plugin/src/main/resources/hudson/plugins/ec2/one/OneEC2Cloud/help-ec2EndpointUrl.html
  99. 15
    0
      source-code/maven-generic-conf/extlibs/ec2-plugin/src/main/resources/hudson/plugins/ec2/one/OneEC2Cloud/help-instanceCapStr.html
  100. 0
    0
      source-code/maven-generic-conf/extlibs/ec2-plugin/src/main/resources/hudson/plugins/ec2/one/OneEC2Cloud/help-jvmopts.html

+ 103
- 0
LICENSE.md View File

@@ -0,0 +1,103 @@
1
+**Electronic Voting Solution Source Code Access Agreement**
2
+
3
+1.	Summary
4
+
5
+The aim of publishing the source code is to establish and build confidence in the public domain, while obtaining feedback from professional experts and the opportunity to make improvements. Constructive contributions and findings on the source code are always welcome.
6
+At this stage, we would like to highlight the key points in the terms of use:
7
+* The OEV (Federal Chancellery Ordinance on Electronic Voting) allows the source code to be examined, modified, compiled and executed for ideational purposes. Publication is organized and regulated in line with this idea.
8
+* The published code, including the source code, is the intellectual property of the companies Scytl and Post CH Ltd. The code in question is proprietary and not subject to a free and open source software (FOSS) licence.
9
+* Distributing or publishing the access tools, granting access to third parties and sharing the source code are not permitted.
10
+* Post CH Ltd must be consulted before any findings may be published. 
11
+* All feedback regarding vulnerabilities found in the electronic voting solution source code is welcome. All feedback must be reported on the GitLab.com platform as an issue and set to “confidential”. Swiss Post will incorporate the reported vulnerabilities into the development of the system.
12
+
13
+2.	INTRODUCTION
14
+
15
+This Electronic Voting (EV) Solution Source Code Access Agreement (“the Agreement”) governs the access to the EV Solution Source Code (“the EV Solution Source Code” or “the Source Code”), consisting of (a) the source code of the EV Solution cryptographic protocols and/or its security measures and any other components of the EV Solution as well as (b) the documentation on the system and its operation, as made accessible by its Owners in this Source Code Access Program (“the Program”). The Program includes release 2.1 of the Source Code. The documents and software components made public under www.swisspost.ch/evoting are not part of the Program.
16
+Scytl Secure Electronic Voting, S.A. (Scytl) and Post CH Ltd (Swiss Post) are the Owners of the EV Solution and the Source Code.
17
+The Owners own and retain all rights, titles and interests in and to their respective parts of the EV Solution Source Code, including all copyright, patents, trade secret rights, trademarks, and other intellectual property rights therein. 
18
+The Owners grant access to the EV Solution Source Code in the Program to the extent required by the (Swiss) Federal Chancellery Ordinance on Electronic Voting (“the Ordinance”) . No part of this Agreement shall be construed as to provide surpassing rights or to permit its use for other purposes. 
19
+The Program takes place because the system has the property of complete verifiability and the system and its operation have been successfully tested according to the Ordinance. The Program aims to give interested persons sufficient time to analyse the Source Code and submit their results to the authorities and to the system providers prior to the canton’s application for general approval. 
20
+The Owners welcome independent security researchers (Researchers) to evaluate and report any vulnerabilities that may be found in the EV Solution Source Code.
21
+
22
+3.	AGREEMENT TO THE EV SOLUTION SOURCE CODE ACCESS AGREEMENT
23
+
24
+By signing up to gain access to the EV Solution Source Code, you agree to be bound by the Agreement for the duration of the access to the EV Solution Source Code and thereafter. 
25
+
26
+4.	ORGANIZATION OF THE PROGRAM
27
+
28
+The Program begins on 07.02.2019 and ends at the termination of the productive use of the release 2.1. 
29
+Swiss Post provides a repository dedicated to the Program on the GitLab platform (https://www.gitlab.com/swisspost). Researchers will receive access to the repository with their GitLab.com account. The GitLab account is free of charge. Access to the repository is limited for the duration of the Program. Accesses to the repository will be logged. 
30
+Participants who have found or believe they have found a vulnerability are obliged to submit a report in the GitLab platform as an issue set explicitly to confidential (see para. 7 FAIR USE RESTRICTIONS). The publication of any vulnerability or other test findings has to comply with the Disclosure Policy (see para. 8 REPORTING PROCEDURE), which fully replaces the Responsible Disclosure Policy of GitLab under the Program.
31
+The Owners will make their best efforts to give timely feedback on a submitted finding. 
32
+
33
+5.	REGISTRATION POLICY
34
+
35
+Registration is mandatory to access the EV Solution Source Code. 
36
+You can register via http://www.swisspost.ch/evoting-sourcecode (website operated by Swiss Post). If participating as a team, all members need to register separately. 
37
+Registration will allow you to access the GitLab repository dedicated to the Program and use the EV Solution Source Code within the scope of the Regulatory License (see para. 6 REGULATORY LICENSE). The means of access are personal and may not be shared with anyone.
38
+Registration for the Program is open to all natural persons willing to comply with the Agreement, with the exception of natural persons who do not act under their own responsibility, but as employees, civil servants, officers or any other subordinate capacity. Registration is therefore not open to organizations, associations, institutions, administrations, governments, government agencies, foreign states, or any other entity that is not a natural person.
39
+The registration data will only be used by Swiss Post to ensure the proper operation of the Program and compliance with this Agreement. 
40
+
41
+6.	REGULATORY LICENSE
42
+
43
+The EV Solution Source Code may be examined, modified, compiled and executed for ideational purposes and Researchers may write and publish studies thereon (“the Purpose”); any other use of the EV Solution Source Code is forbidden, unless a legally valid license is granted by the Owners. 
44
+Unauthorized reproduction, distribution, transformation, public communication of the EV Solution outside the Purpose is illegal, and may result in civil or criminal liability. 
45
+
46
+7.	FAIR USE RESTRICTIONS
47
+
48
+The EV Solution Source Code can be accessed for the Purpose under the following fair use rules:
49
+* Researchers cannot use the EV Solution Source Code for any kind of commercial purposes, including but not limited to, the creation of a product, derivative works of the EV Solution and/or the provision of services.
50
+* It is forbidden to remove or alter any notices regarding intellectual property rights such as copyright, patents, trademarks or other proprietary rights. 
51
+* Researchers shall follow the Reporting Procedure to communicate any vulnerabilities, bugs, errors or other issues (“the Vulnerabilities”) found in the EV Solution Source Code and comply with the Responsible Disclosure rules.
52
+* Researchers shall conduct tests following the deployment, configuration, trust assumptions and infrastructure specifications also published by the Owners. 
53
+* Researchers shall comply with the applicable law and shall not breach any agreements in order to find Vulnerabilities.
54
+* Researchers shall not exploit any found Vulnerability on any real elections or votes, or perform any action that is intended to negatively affect the reputation of any of the Owners, any election or vote, electoral authority and any election technology providers and partners.
55
+* Researchers shall avoid any attempt to modify or destroy data
56
+.
57
+
58
+8.	REPORTING PROCEDURE
59
+
60
+Any Vulnerability found in the EV Solution Source Code must be reported in the communication channels provided by the Owners. When communicating via the GitLab platform, Researchers are obliged to submit a report as an issue set explicitly to confidential, and thus make it visible only to team members.
61
+
62
+Researchers shall provide sufficient information to reproduce the Vulnerability so that the Owners can act as quickly as possible. Usually, a vulnerability description is sufficient, but for more complex vulnerabilities, more detailed information may be needed.
63
+
64
+The Researcher e-mail address must not be managed or accessible by more than one person and the information received in the Researcher e-mail account must not be shared with or forwarded to any other e-mail account.
65
+
66
+The Owners will acknowledge reception of the report, and will decide, at their sole discretion, (i) whether the Vulnerability needs correction and (ii) whether to apply any correction reported by the Researcher. 
67
+The Researcher accepts to provide support to the Owners to verify the potential Vulnerability, and the Owners will update the researcher on any corrections applied.
68
+
69
+9.	RESPONSIBLE DISCLOSURE
70
+
71
+The Program follows a “responsible disclosure” policy. The following rules apply cumulatively:
72
+a)	No Vulnerability shall be published without the Researcher having followed previously the Reporting Procedure set out in Clause 8 above;
73
+b)	No Vulnerability shall be published without the Researcher having at least received the acknowledgment from the Owners on the reported Vulnerability.
74
+c)	No Vulnerability shall be published within a period of forty five (45) days since the last communication exchanged with the Owners with regards to such potential Vulnerability, unless the Owners have agreed to a shorter period or defined a longer period.
75
+
76
+10.	CODE OF CONDUCT
77
+
78
+The GitLab Community Code of Conduct (https://about.gitlab.com/community/contribute/code-of-conduct/) applies with respect to the Agreement.
79
+
80
+11.	DISCLAIMER
81
+
82
+The EV Solution Source Code is provided “as is”. 
83
+The Owners hereby disclaim any support, representation or warranty of any kind whatsoever, including any implied warranty of fitness for a particular purpose (including the compilation or execution of the source code) or non-infringement.
84
+
85
+12.	LIABILITY DISCLAIMER
86
+
87
+In no event will the Owners be liable for any damages whatsoever including – but not restricted to – lost revenue or profits or other direct, indirect, special, incidental, cover, or consequential damages arising out of the access to or inability to access the Electronic Voting Solution Source Code, even if advised of the possibility of such damages, except to the extent provided by law (where applicable). 
88
+
89
+13.	TERMINATION
90
+
91
+The Agreement and Source Code Access expires at the termination of the productive use of the release to which the Program is dedicated. 
92
+The right to access the EV Solution shall terminate immediately and automatically without notice if the Researcher fails to comply with the terms and conditions under this Agreement. The Researcher shall destroy any copies of the EV Solution Source Code upon termination. 
93
+The expiry or termination of the Agreement shall not affect the validity of the obligations of the Researcher entered into under the Agreement (including but not limited to the Fair Use Restrictions, the Reporting Procedure and the Responsible Disclosure).
94
+
95
+14.	ENTIRE AGREEMENT
96
+
97
+This Agreement constitutes the entire agreement between the Owners and the Researcher enabling access to the EV Solution Source Code.
98
+Researchers will be allowed to access the EV Solution Source Code only if they accept the Agreement by registering for the Program as defined above.
99
+
100
+15.	APPLICABLE LAW AND JURISDICTION
101
+
102
+This Agreement is governed by and construed in accordance with the laws of Switzerland. 
103
+Any dispute arising out of or relating to the Agreement shall be submitted and finally resolved by the courts of Berne, Switzerland.

+ 11
- 0
README.md View File

@@ -0,0 +1,11 @@
1
+The aim of publishing the source code is to establish and build confidence in the public domain, while obtaining feedback from professional experts and the opportunity to make improvements. Constructive contributions and findings on the source code are always welcome.
2
+At this stage, we would like to highlight the key points in the terms of use:
3
+
4
+*  The OEV (Federal Chancellery Ordinance on Electronic Voting) allows the source code to be examined, modified, compiled and executed for ideational purposes. Publication is organized and regulated in line with this idea.
5
+*  The published code, including the source code, is the intellectual property of the companies Scytl and Post CH Ltd. The code in question is proprietary and not subject to a free and open source software (FOSS) licence.
6
+*  Distributing or publishing the access tools, granting access to third parties and sharing the source code are not permitted.
7
+*  Post CH Ltd must be consulted before any findings may be published. 
8
+*  All feedback regarding vulnerabilities found in the electronic voting solution source code is welcome. All feedback must be reported on the GitLab.com platform as an issue and set to “confidential”. Swiss Post will incorporate the reported vulnerabilities into the development of the system.
9
+
10
+
11
+Please refer to the [Wiki](https://gitlab.com/swisspost/evoting-solution-int/wikis/home) for complementary infomration as well as a presentation of the published Source Code

BIN
dependencies/bsh-core-2.0b6.jar View File


BIN
dependencies/cryptography-4.2.1.jar View File


BIN
dependencies/iaikPkcs11Wrapper-1.4.jar View File


BIN
dependencies/jakarta-oro-2.0.6-local.jar View File


BIN
dependencies/log4j-1.3alpha-7-local.jar View File


BIN
dependencies/ov-keystore-1.3.0-tests.jar View File


BIN
dependencies/ov-keystore-1.3.0.jar View File


BIN
dependencies/scytl-gmp-6.1.1-amd64-Linux-gpp-shared.nar View File


BIN
dependencies/scytl-gmp-6.1.1-amd64-Windows-gpp-shared.nar View File


BIN
dependencies/scytl-math-1.0.1.jar View File


BIN
dependencies/scytl-math-native-1.0.1-amd64-Linux-gpp-jni.nar View File


BIN
dependencies/scytl-math-native-1.0.1-amd64-Windows-gpp-jni.nar View File


BIN
dependencies/shares-1.0.2.jar View File


BIN
documentation/Scytl sVote Audit with Control Components.pdf View File


BIN
documentation/Scytl sVote Protocol Specifications.pdf View File


BIN
documentation/Scytl_sVote_Software_Architecture.pdf View File


+ 12
- 0
source-code/Copyright.txt View File

@@ -0,0 +1,12 @@
1
+SCYTL SECURE ELECTRONIC VOTING SA (SCYTL) owns and shall retain all rights, title and interests in and to sVote, except for those open source libraries and dependencies which are listed in the 'THIRD-PARTY.txt' file which is part of the source code package.
2
+
3
+Except otherwise defined in this copyright notice, SCYTL shall be the sole and only authorized to use and exploit (commercially or non-commercially) sVote, including any and all exploitation rights whether existing or in the future, throughout the world for all the duration of the intellectual property rights, for any purpose and without any limit or restriction.
4
+
5
+The use of sVote is only permitted to authorized licensees subject to the terms and conditions of a duly executed and legally binding software license agreement.
6
+
7
+Please contact SCYTL for further information on our software license agreements at licensing@scytl.com.
8
+
9
+POST CH Ltd (Swiss Post) is the authorized licensee of the sVote, as embedded in the EV Solution, on exclusive basis for the territory of Switzerland including the right to:
10
+
11
+(i) Use, license deploy, install and implement the EV Solution and
12
+(ii) Sub-license the EV Solution to the Swiss Cantons (without further right to sublicensing).

+ 5
- 0
source-code/maven-generic-conf/.gitignore View File

@@ -0,0 +1,5 @@
1
+target
2
+bin
3
+/.classpath
4
+/.project
5
+/.settings

+ 15
- 0
source-code/maven-generic-conf/README.md View File

@@ -0,0 +1,15 @@
1
+# maven-generic-conf
2
+
3
+Scytl Super POM is the parent project for all Scytl projects.
4
+
5
+It is the central point where global configuration is defined.
6
+
7
+In maven the dependency is defined as:
8
+
9
+```xml
10
+    <parent>
11
+        <groupId>com.scytl</groupId>
12
+        <artifactId>maven-generic-conf</artifactId>
13
+        <version>1.5.4</version>
14
+    </parent>
15
+```

+ 2
- 0
source-code/maven-generic-conf/THIRD-PARTY.txt View File

@@ -0,0 +1,2 @@
1
+
2
+The project has no dependencies.

+ 166
- 0
source-code/maven-generic-conf/etc/eclipse/scytl_checkstyle.xml View File

@@ -0,0 +1,166 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<!--
3
+	This configuration file was written by the eclipse-cs plugin configuration editor
4
+-->
5
+<!--
6
+Checkstyle-Configuration: ScytlCheckStyle
7
+Description:
8
+
9
+-->
10
+<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.2//EN" "http://www.puppycrawl.com/dtds/configuration_1_2.dtd">
11
+<module name="Checker">
12
+    <property name="severity" value="warning"/>
13
+    <module name="TreeWalker">
14
+        <module name="JavadocMethod">
15
+            <property name="severity" value="ignore"/>
16
+            <property name="allowMissingParamTags" value="true"/>
17
+            <property name="allowMissingThrowsTags" value="true"/>
18
+            <property name="allowMissingReturnTag" value="true"/>
19
+        </module>
20
+        <module name="JavadocType">
21
+            <property name="severity" value="ignore"/>
22
+        </module>
23
+        <module name="JavadocVariable">
24
+            <property name="severity" value="ignore"/>
25
+        </module>
26
+        <module name="JavadocStyle">
27
+            <property name="severity" value="ignore"/>
28
+        </module>
29
+        <module name="ConstantName">
30
+            <property name="format" value="^[A-Z][A-Z0-9]*(__?[A-Z0-9]+)*$"/>
31
+        </module>
32
+        <module name="LocalFinalVariableName"/>
33
+        <module name="LocalVariableName"/>
34
+        <module name="MemberName">
35
+            <property name="format" value="^_[a-z][a-zA-Z0-9]*$"/>
36
+        </module>
37
+        <module name="MethodName"/>
38
+        <module name="PackageName"/>
39
+        <module name="ParameterName"/>
40
+        <module name="StaticVariableName">
41
+            <property name="severity" value="ignore"/>
42
+        </module>
43
+        <module name="TypeName"/>
44
+        <module name="AvoidStarImport"/>
45
+        <module name="IllegalImport"/>
46
+        <module name="RedundantImport"/>
47
+        <module name="UnusedImports"/>
48
+        <module name="FileLength"/>
49
+        <module name="LineLength">
50
+            <property name="severity" value="ignore"/>
51
+        </module>
52
+        <module name="MethodLength"/>
53
+        <module name="ParameterNumber">
54
+            <property name="severity" value="ignore"/>
55
+        </module>
56
+        <module name="EmptyForIteratorPad"/>
57
+        <module name="MethodParamPad"/>
58
+        <module name="NoWhitespaceAfter">
59
+            <property name="tokens" value="BNOT,DEC,DOT,INC,LNOT,UNARY_MINUS,UNARY_PLUS"/>
60
+        </module>
61
+        <module name="NoWhitespaceBefore"/>
62
+        <module name="OperatorWrap"/>
63
+        <module name="ParenPad"/>
64
+        <module name="TypecastParenPad">
65
+            <property name="tokens" value="RPAREN,TYPECAST"/>
66
+        </module>
67
+        <module name="TabCharacter"/>
68
+        <module name="WhitespaceAfter"/>
69
+        <module name="WhitespaceAround">
70
+            <property name="tokens" value="ASSIGN,BAND,BAND_ASSIGN,BOR,BOR_ASSIGN,BSR,BSR_ASSIGN,BXOR,BXOR_ASSIGN,COLON,DIV,DIV_ASSIGN,EQUAL,GE,GT,LAND,LCURLY,LE,LITERAL_ASSERT,LITERAL_CATCH,LITERAL_DO,LITERAL_ELSE,LITERAL_FINALLY,LITERAL_FOR,LITERAL_IF,LITERAL_RETURN,LITERAL_SYNCHRONIZED,LITERAL_TRY,LITERAL_WHILE,LOR,LT,MINUS,MINUS_ASSIGN,MOD,MOD_ASSIGN,NOT_EQUAL,PLUS,PLUS_ASSIGN,QUESTION,RCURLY,SL,SLIST,SL_ASSIGN,SR,SR_ASSIGN,STAR,STAR_ASSIGN,LITERAL_ASSERT,TYPE_EXTENSION_AND"/>
71
+        </module>
72
+        <module name="ModifierOrder"/>
73
+        <module name="RedundantModifier"/>
74
+        <module name="AvoidNestedBlocks"/>
75
+        <module name="EmptyBlock"/>
76
+        <module name="LeftCurly"/>
77
+        <module name="NeedBraces"/>
78
+        <module name="RightCurly"/>
79
+        <module name="AvoidInlineConditionals">
80
+            <property name="severity" value="ignore"/>
81
+        </module>
82
+        <module name="DoubleCheckedLocking"/>
83
+        <module name="EmptyStatement"/>
84
+        <module name="EqualsHashCode"/>
85
+        <module name="HiddenField"/>
86
+        <module name="IllegalInstantiation"/>
87
+        <module name="InnerAssignment"/>
88
+        <module name="MagicNumber">
89
+            <property name="ignoreNumbers" value="-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10"/>
90
+        </module>
91
+        <module name="MissingSwitchDefault"/>
92
+        <module name="RedundantThrows">
93
+            <property name="severity" value="ignore"/>
94
+        </module>
95
+        <module name="SimplifyBooleanExpression"/>
96
+        <module name="SimplifyBooleanReturn"/>
97
+        <module name="DesignForExtension">
98
+            <property name="severity" value="ignore"/>
99
+        </module>
100
+        <module name="FinalClass"/>
101
+        <module name="HideUtilityClassConstructor"/>
102
+        <module name="InterfaceIsType">
103
+            <property name="severity" value="ignore"/>
104
+        </module>
105
+        <module name="VisibilityModifier">
106
+            <metadata name="com.atlassw.tools.eclipse.checkstyle.comment" value="Scytl convention"/>
107
+            <property name="protectedAllowed" value="true"/>
108
+        </module>
109
+        <module name="ArrayTypeStyle"/>
110
+        <module name="FinalParameters"/>
111
+        <module name="GenericIllegalRegexp">
112
+            <property name="severity" value="ignore"/>
113
+            <property name="format" value="\s+$"/>
114
+            <property name="message" value="Line has trailing spaces."/>
115
+        </module>
116
+        <module name="TodoComment"/>
117
+        <module name="UpperEll"/>
118
+        <module name="StaticVariableName">
119
+            <metadata name="com.atlassw.tools.eclipse.checkstyle.comment" value="Scytl convention"/>
120
+            <property name="format" value="^_[a-z][a-zA-Z0-9]*$"/>
121
+        </module>
122
+        <module name="AnonInnerLength">
123
+            <property name="max" value="50"/>
124
+        </module>
125
+        <module name="ExecutableStatementCount">
126
+            <property name="tokens" value="INSTANCE_INIT,STATIC_INIT,METHOD_DEF,CTOR_DEF"/>
127
+        </module>
128
+        <module name="EmptyForInitializerPad">
129
+            <property name="severity" value="ignore"/>
130
+        </module>
131
+        <module name="CovariantEquals"/>
132
+        <module name="DefaultComesLast"/>
133
+        <module name="IllegalCatch"/>
134
+        <module name="IllegalThrows"/>
135
+        <module name="JUnitTestCase"/>
136
+        <module name="ModifiedControlVariable"/>
137
+        <module name="MultipleStringLiterals"/>
138
+        <module name="MultipleVariableDeclarations"/>
139
+        <module name="NestedTryDepth"/>
140
+        <module name="NestedIfDepth">
141
+            <property name="max" value="2"/>
142
+        </module>
143
+        <module name="PackageDeclaration"/>
144
+        <module name="SuperFinalize"/>
145
+        <module name="SuperClone"/>
146
+        <module name="StringLiteralEquality"/>
147
+        <module name="ReturnCount">
148
+            <property name="max" value="3"/>
149
+        </module>
150
+        <module name="ClassFanOutComplexity"/>
151
+        <module name="CyclomaticComplexity"/>
152
+        <module name="NPathComplexity"/>
153
+        <module name="ClassDataAbstractionCoupling">
154
+            <property name="max" value="15"/>
155
+        </module>
156
+        <module name="BooleanExpressionComplexity"/>
157
+        <module name="JavaNCSS">
158
+            <property name="methodMaximum" value="150"/>
159
+        </module>
160
+    </module>
161
+    <module name="PackageHtml">
162
+        <property name="severity" value="ignore"/>
163
+    </module>
164
+    <module name="NewlineAtEndOfFile"/>
165
+    <module name="Translation"/>
166
+</module>

+ 33
- 0
source-code/maven-generic-conf/etc/eclipse/scytl_codetemplates.xml View File

@@ -0,0 +1,33 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<templates><template id="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name="gettercomment" description="Comment for getter method" context="gettercomment_context" enabled="true" deleted="false" autoinsert="true">/**
3
+ * @return Returns the ${bare_field_name}.
4
+ */</template><template id="org.eclipse.jdt.ui.text.codetemplates.settercomment" name="settercomment" description="Comment for setter method" context="settercomment_context" enabled="true" deleted="false" autoinsert="true">/**
5
+ * @param ${param} The ${bare_field_name} to set.
6
+ */</template><template id="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name="constructorcomment" description="Comment for created constructors" context="constructorcomment_context" enabled="true" deleted="false" autoinsert="true">/**
7
+ * ${tags}
8
+ */</template><template id="org.eclipse.jdt.ui.text.codetemplates.filecomment" name="filecomment" description="Comment for created Java files" context="filecomment_context" enabled="true" deleted="false" autoinsert="false">/**
9
+ * $$Id$$
10
+ * @author &lt;a href="mailto:developer@scytl.com"&gt;developer name&lt;/a&gt;
11
+ * @date    ${date} ${time}
12
+ *
13
+ * Copyright (C) ${year} Scytl Secure Electronic Voting SA
14
+ *
15
+ * All rights reserved.
16
+ *
17
+ */</template><template id="org.eclipse.jdt.ui.text.codetemplates.typecomment" name="typecomment" description="Comment for created types" context="typecomment_context" enabled="true" deleted="false" autoinsert="true">/**
18
+ *
19
+ * ${tags}
20
+ */</template><template id="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name="fieldcomment" description="Comment for fields" context="fieldcomment_context" enabled="true" deleted="false" autoinsert="true">/**
21
+ * 
22
+ */</template><template id="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name="methodcomment" description="Comment for non-overriding methods" context="methodcomment_context" enabled="true" deleted="false" autoinsert="true">/**
23
+ * ${tags}
24
+ */</template><template id="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name="overridecomment" description="Comment for overriding methods" context="overridecomment_context" enabled="true" deleted="false" autoinsert="false">/**
25
+ * ${see_to_overridden}
26
+ */</template><template id="org.eclipse.jdt.ui.text.codetemplates.newtype" name="newtype" description="Newly created files" context="newtype_context" enabled="true" deleted="false" autoinsert="true">${filecomment}
27
+${package_declaration}
28
+
29
+${typecomment}
30
+${type_declaration}</template><template id="org.eclipse.jdt.ui.text.codetemplates.catchblock" name="catchblock" description="Code in new catch blocks" context="catchblock_context" enabled="true" deleted="false" autoinsert="true">// ${todo} Auto-generated catch block
31
+${exception_var}.printStackTrace();</template><template id="org.eclipse.jdt.ui.text.codetemplates.methodbody" name="methodbody" description="Code in created method stubs" context="methodbody_context" enabled="true" deleted="false" autoinsert="true">// ${todo} Auto-generated method stub
32
+${body_statement}</template><template id="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name="constructorbody" description="Code in created constructor stubs" context="constructorbody_context" enabled="true" deleted="false" autoinsert="true">${body_statement}
33
+// ${todo} Auto-generated constructor stub</template><template id="org.eclipse.jdt.ui.text.codetemplates.getterbody" name="getterbody" description="Code in created getters" context="getterbody_context" enabled="true" deleted="false" autoinsert="true">return ${field};</template><template id="org.eclipse.jdt.ui.text.codetemplates.setterbody" name="setterbody" description="Code in created setters" context="setterbody_context" enabled="true" deleted="false" autoinsert="true">${field} = ${param};</template></templates>

+ 251
- 0
source-code/maven-generic-conf/etc/eclipse/scytl_javaformat-1.1.xml View File

@@ -0,0 +1,251 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<profiles version="10">
3
+<profile name="Scytl Profile" version="10">
4
+<setting id="org.eclipse.jdt.core.formatter.align_type_members_on_columns" value="false"/>
5
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression" value="20"/>
6
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant" value="16"/>
7
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call" value="20"/>
8
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation" value="20"/>
9
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression" value="16"/>
10
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_assignment" value="20"/>
11
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_binary_expression" value="20"/>
12
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_compact_if" value="16"/>
13
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_conditional_expression" value="80"/>
14
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_enum_constants" value="0"/>
15
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer" value="16"/>
16
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_multiple_fields" value="16"/>
17
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration" value="16"/>
18
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration" value="16"/>
19
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation" value="20"/>
20
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration" value="16"/>
21
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration" value="16"/>
22
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration" value="16"/>
23
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration" value="32"/>
24
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration" value="32"/>
25
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_imports" value="1"/>
26
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_package" value="1"/>
27
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_field" value="1"/>
28
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration" value="0"/>
29
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_imports" value="1"/>
30
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_member_type" value="1"/>
31
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_method" value="1"/>
32
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk" value="1"/>
33
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_package" value="0"/>
34
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations" value="1"/>
35
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration" value="end_of_line"/>
36
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration" value="end_of_line"/>
37
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_array_initializer" value="end_of_line"/>
38
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block" value="end_of_line"/>
39
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block_in_case" value="end_of_line"/>
40
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration" value="end_of_line"/>
41
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_constant" value="end_of_line"/>
42
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration" value="end_of_line"/>
43
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_method_declaration" value="end_of_line"/>
44
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_switch" value="end_of_line"/>
45
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_type_declaration" value="end_of_line"/>
46
+<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines" value="true"/>
47
+<setting id="org.eclipse.jdt.core.formatter.comment.format_comments" value="true"/>
48
+<setting id="org.eclipse.jdt.core.formatter.comment.format_header" value="false"/>
49
+<setting id="org.eclipse.jdt.core.formatter.comment.format_html" value="true"/>
50
+<setting id="org.eclipse.jdt.core.formatter.comment.format_source_code" value="false"/>
51
+<setting id="org.eclipse.jdt.core.formatter.comment.indent_parameter_description" value="true"/>
52
+<setting id="org.eclipse.jdt.core.formatter.comment.indent_root_tags" value="true"/>
53
+<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags" value="insert"/>
54
+<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter" value="insert"/>
55
+<setting id="org.eclipse.jdt.core.formatter.comment.line_length" value="80"/>
56
+<setting id="org.eclipse.jdt.core.formatter.compact_else_if" value="true"/>
57
+<setting id="org.eclipse.jdt.core.formatter.continuation_indentation" value="2"/>
58
+<setting id="org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer" value="2"/>
59
+<setting id="org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line" value="false"/>
60
+<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header" value="true"/>
61
+<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header" value="true"/>
62
+<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header" value="true"/>
63
+<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header" value="true"/>
64
+<setting id="org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases" value="true"/>
65
+<setting id="org.eclipse.jdt.core.formatter.indent_empty_lines" value="false"/>
66
+<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_block" value="true"/>
67
+<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_body" value="true"/>
68
+<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases" value="true"/>
69
+<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch" value="false"/>
70
+<setting id="org.eclipse.jdt.core.formatter.indentation.size" value="4"/>
71
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation" value="insert"/>
72
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer" value="do not insert"/>
73
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing" value="insert"/>
74
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement" value="do not insert"/>
75
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer" value="do not insert"/>
76
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement" value="do not insert"/>
77
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement" value="do not insert"/>
78
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement" value="do not insert"/>
79
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration" value="insert"/>
80
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration" value="insert"/>
81
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block" value="insert"/>
82
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant" value="insert"/>
83
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration" value="insert"/>
84
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body" value="insert"/>
85
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration" value="insert"/>
86
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter" value="insert"/>
87
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator" value="insert"/>
88
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation" value="do not insert"/>
89
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration" value="do not insert"/>
90
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_binary_operator" value="insert"/>
91
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments" value="insert"/>
92
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters" value="insert"/>
93
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block" value="insert"/>
94
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast" value="insert"/>
95
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert" value="insert"/>
96
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case" value="insert"/>
97
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional" value="insert"/>
98
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for" value="insert"/>
99
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement" value="insert"/>
100
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression" value="insert"/>
101
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation" value="insert"/>
102
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer" value="insert"/>
103
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters" value="insert"/>
104
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws" value="insert"/>
105
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments" value="insert"/>
106
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations" value="insert"/>
107
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments" value="insert"/>
108
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments" value="insert"/>
109
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits" value="insert"/>
110
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters" value="insert"/>
111
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws" value="insert"/>
112
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments" value="insert"/>
113
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations" value="insert"/>
114
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations" value="insert"/>
115
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference" value="insert"/>
116
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces" value="insert"/>
117
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments" value="insert"/>
118
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters" value="insert"/>
119
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_ellipsis" value="insert"/>
120
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
121
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments" value="do not insert"/>
122
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters" value="do not insert"/>
123
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer" value="do not insert"/>
124
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression" value="do not insert"/>
125
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference" value="do not insert"/>
126
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation" value="do not insert"/>
127
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast" value="do not insert"/>
128
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch" value="do not insert"/>
129
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration" value="do not insert"/>
130
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant" value="do not insert"/>
131
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for" value="do not insert"/>
132
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if" value="do not insert"/>
133
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration" value="do not insert"/>
134
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation" value="do not insert"/>
135
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression" value="do not insert"/>
136
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch" value="do not insert"/>
137
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized" value="do not insert"/>
138
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while" value="do not insert"/>
139
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator" value="do not insert"/>
140
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator" value="do not insert"/>
141
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional" value="insert"/>
142
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard" value="do not insert"/>
143
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for" value="insert"/>
144
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_unary_operator" value="do not insert"/>
145
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter" value="insert"/>
146
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator" value="insert"/>
147
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration" value="insert"/>
148
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_binary_operator" value="insert"/>
149
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
150
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments" value="do not insert"/>
151
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters" value="do not insert"/>
152
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer" value="insert"/>
153
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression" value="do not insert"/>
154
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference" value="do not insert"/>
155
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation" value="do not insert"/>
156
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast" value="do not insert"/>
157
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch" value="do not insert"/>
158
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration" value="do not insert"/>
159
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant" value="do not insert"/>
160
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for" value="do not insert"/>
161
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if" value="do not insert"/>
162
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration" value="do not insert"/>
163
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation" value="do not insert"/>
164
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression" value="do not insert"/>
165
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch" value="do not insert"/>
166
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized" value="do not insert"/>
167
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while" value="do not insert"/>
168
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert" value="insert"/>
169
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case" value="do not insert"/>
170
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional" value="insert"/>
171
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default" value="do not insert"/>
172
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for" value="insert"/>
173
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement" value="do not insert"/>
174
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression" value="do not insert"/>
175
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation" value="do not insert"/>
176
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer" value="do not insert"/>
177
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters" value="do not insert"/>
178
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws" value="do not insert"/>
179
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments" value="do not insert"/>
180
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations" value="do not insert"/>
181
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments" value="do not insert"/>
182
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments" value="do not insert"/>
183
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits" value="do not insert"/>
184
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters" value="do not insert"/>
185
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws" value="do not insert"/>
186
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments" value="do not insert"/>
187
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations" value="do not insert"/>
188
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations" value="do not insert"/>
189
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference" value="do not insert"/>
190
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces" value="do not insert"/>
191
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments" value="do not insert"/>
192
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters" value="do not insert"/>
193
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_ellipsis" value="do not insert"/>
194
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
195
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments" value="do not insert"/>
196
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters" value="do not insert"/>
197
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration" value="insert"/>
198
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration" value="insert"/>
199
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer" value="insert"/>
200
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block" value="insert"/>
201
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration" value="insert"/>
202
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant" value="insert"/>
203
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration" value="insert"/>
204
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration" value="insert"/>
205
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch" value="insert"/>
206
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration" value="insert"/>
207
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression" value="do not insert"/>
208
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference" value="do not insert"/>
209
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference" value="do not insert"/>
210
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation" value="do not insert"/>
211
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration" value="do not insert"/>
212
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch" value="insert"/>
213
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration" value="do not insert"/>
214
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant" value="do not insert"/>
215
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for" value="insert"/>
216
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if" value="insert"/>
217
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration" value="do not insert"/>
218
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation" value="do not insert"/>
219
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression" value="do not insert"/>
220
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch" value="insert"/>
221
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized" value="insert"/>
222
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while" value="insert"/>
223
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return" value="insert"/>
224
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator" value="do not insert"/>
225
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator" value="do not insert"/>
226
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional" value="insert"/>
227
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard" value="do not insert"/>
228
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon" value="do not insert"/>
229
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for" value="do not insert"/>
230
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_unary_operator" value="do not insert"/>
231
+<setting id="org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference" value="do not insert"/>
232
+<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer" value="do not insert"/>
233
+<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression" value="do not insert"/>
234
+<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration" value="do not insert"/>
235
+<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration" value="do not insert"/>
236
+<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant" value="do not insert"/>
237
+<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration" value="do not insert"/>
238
+<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation" value="do not insert"/>
239
+<setting id="org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line" value="false"/>
240
+<setting id="org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line" value="false"/>
241
+<setting id="org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line" value="false"/>
242
+<setting id="org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line" value="false"/>
243
+<setting id="org.eclipse.jdt.core.formatter.lineSplit" value="75"/>
244
+<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body" value="0"/>
245
+<setting id="org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve" value="1"/>
246
+<setting id="org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line" value="true"/>
247
+<setting id="org.eclipse.jdt.core.formatter.tabulation.char" value="space"/>
248
+<setting id="org.eclipse.jdt.core.formatter.tabulation.size" value="4"/>
249
+<setting id="org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations" value="false"/>
250
+</profile>
251
+</profiles>

+ 4
- 0
source-code/maven-generic-conf/extlibs/barcode4j/INSTALL.txt View File

@@ -0,0 +1,4 @@
1
+To install the file do the following:
2
+
3
+  alias mvndeploy "mvn deploy:deploy-file -Durl=scpexe://pnyx@nightly01/opt/jakarta-tomcat-5.0.28/webapps/maven-repos"
4
+  mvndeploy -DgroupId=com.scytl.extlibs -DartifactId=barcode4j -Dversion=2.0alpha2 -Dpackaging=jar -Dfile=barcode4j.jar

BIN
source-code/maven-generic-conf/extlibs/barcode4j/barcode4j.jar View File


+ 11
- 0
source-code/maven-generic-conf/extlibs/ec2-plugin/.gitignore View File

@@ -0,0 +1,11 @@
1
+*.iml
2
+*.ipr
3
+*.iws
4
+target
5
+
6
+.classpath
7
+.project
8
+.settings
9
+
10
+/bin
11
+/work

+ 2
- 0
source-code/maven-generic-conf/extlibs/ec2-plugin/TODO.txt View File

@@ -0,0 +1,2 @@
1
+- the uptime should be displayed there
2
+- cloud configuration page should be moved elsewhere, like how we configure slaves

+ 75
- 0
source-code/maven-generic-conf/extlibs/ec2-plugin/pom.xml View File

@@ -0,0 +1,75 @@
1
+<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/maven-v4_0_0.xsd">
2
+  <modelVersion>4.0.0</modelVersion>
3
+
4
+  <parent>
5
+    <groupId>org.jenkins-ci.plugins</groupId>
6
+    <artifactId>plugin</artifactId>
7
+      <version>1.424</version>
8
+  </parent>
9
+  
10
+  <artifactId>ec2</artifactId>
11
+  <version>1.18-SNAPSHOT</version>
12
+  <packaging>hpi</packaging>
13
+  <name>Amazon EC2 plugin</name>
14
+  <url>http://wiki.jenkins-ci.org/display/JENKINS/Amazon+EC2+Plugin</url>
15
+
16
+  <scm>
17
+    <connection>scm:git:git://github.com/jenkinsci/ec2-plugin.git</connection>
18
+    <developerConnection>scm:git:git@github.com:jenkinsci/ec2-plugin.git</developerConnection>
19
+  </scm>
20
+
21
+  <dependencies>
22
+    <dependency>
23
+      <!-- we only use this to handle key fingerprint. should be able to replace this with trilead -->
24
+      <groupId>bouncycastle</groupId>
25
+      <artifactId>bcprov-jdk15</artifactId>
26
+      <version>140</version>
27
+    </dependency>
28
+    <dependency>
29
+      <groupId>com.amazonaws</groupId>
30
+      <artifactId>aws-java-sdk</artifactId>
31
+      <version>1.3.7</version>
32
+      <exclusions>
33
+        <exclusion>
34
+          <groupId>commons-codec</groupId>
35
+          <artifactId>commons-codec</artifactId>
36
+        </exclusion>
37
+      </exclusions>
38
+    </dependency>
39
+  </dependencies>
40
+
41
+  <developers>
42
+	<!-- current maintainer -->
43
+    <developer>
44
+      <id>francisu</id>
45
+      <name>Francis Upton IV</name>
46
+      <email>francis@oaklandsoftware.com</email>
47
+    </developer>
48
+	<!-- kohsuke did the original implementation -->
49
+    <developer>
50
+      <id>kohsuke</id>
51
+      <name>Kohsuke Kawaguchi</name>
52
+      <email>kkawaguchi@cloudbees.com</email>
53
+    </developer>
54
+  </developers>
55
+
56
+
57
+    <repositories>
58
+        <repository>
59
+            <id>repo.jenkins-ci.org</id>
60
+            <url>http://repo.jenkins-ci.org/public/</url>
61
+        </repository>
62
+    </repositories>
63
+
64
+    <pluginRepositories>
65
+        <pluginRepository>
66
+            <id>repo.jenkins-ci.org</id>
67
+            <url>http://repo.jenkins-ci.org/public/</url>
68
+        </pluginRepository>
69
+    </pluginRepositories>
70
+</project>  
71
+  
72
+
73
+
74
+
75
+

+ 118
- 0
source-code/maven-generic-conf/extlibs/ec2-plugin/src/main/java/hudson/plugins/ec2/AmazonEC2Cloud.java View File

@@ -0,0 +1,118 @@
1
+package hudson.plugins.ec2;
2
+
3
+import hudson.Extension;
4
+import hudson.util.FormValidation;
5
+import hudson.util.ListBoxModel;
6
+
7
+import java.io.IOException;
8
+import java.net.MalformedURLException;
9
+import java.net.URL;
10
+import java.util.List;
11
+import java.util.Locale;
12
+
13
+import javax.servlet.ServletException;
14
+
15
+import org.apache.commons.lang.StringUtils;
16
+import org.kohsuke.stapler.DataBoundConstructor;
17
+import org.kohsuke.stapler.QueryParameter;
18
+import org.kohsuke.stapler.StaplerResponse;
19
+
20
+import com.amazonaws.services.ec2.AmazonEC2;
21
+import com.amazonaws.services.ec2.model.DescribeRegionsResult;
22
+import com.amazonaws.services.ec2.model.Region;
23
+
24
+/**
25
+ * The original implementation of {@link EC2Cloud}.
26
+ *
27
+ * @author Kohsuke Kawaguchi
28
+ */
29
+public class AmazonEC2Cloud extends EC2Cloud {
30
+    /**
31
+     * Represents the region. Can be null for backward compatibility reasons.
32
+     */
33
+    private String region;
34
+
35
+    // Used when running unit tests
36
+    public static boolean testMode;
37
+    
38
+    
39
+    @DataBoundConstructor
40
+    public AmazonEC2Cloud(String accessId, String secretKey, String region, String privateKey, String instanceCapStr, List<SlaveTemplate> templates) {
41
+        super("ec2-"+region, accessId, secretKey, privateKey, instanceCapStr, templates);
42
+        this.region = region;
43
+    }
44
+
45
+    public String getRegion() {
46
+        if (region == null)
47
+            region = DEFAULT_EC2_HOST; // Backward compatibility
48
+        // Handles pre 1.14 region names that used the old AwsRegion enum, note we don't change
49
+        // the region here to keep the meta-data compatible in the case of a downgrade (is that right?)
50
+        if (region.indexOf('_') > 0)
51
+        	return region.replace('_', '-').toLowerCase(Locale.ENGLISH);
52
+        return region;
53
+    }
54
+
55
+    public static URL getEc2EndpointUrl(String region) {
56
+        try {
57
+			return new URL("https://" + region + "." + EC2_URL_HOST + "/");
58
+		} catch (MalformedURLException e) {
59
+			throw new Error(e); // Impossible
60
+		}
61
+    }
62
+    
63
+    @Override
64
+    public URL getEc2EndpointUrl() {
65
+    	return getEc2EndpointUrl(getRegion());
66
+    }
67
+
68
+    @Override
69
+    public URL getS3EndpointUrl() {
70
+        try {
71
+			return new URL("https://"+getRegion()+".s3.amazonaws.com/");
72
+		} catch (MalformedURLException e) {
73
+			throw new Error(e); // Impossible
74
+		}
75
+    }
76
+
77
+    @Extension
78
+    public static class DescriptorImpl extends EC2Cloud.DescriptorImpl {
79
+        @Override
80
+		public String getDisplayName() {
81
+            return "Amazon EC2";
82
+        }
83
+
84
+		public ListBoxModel doFillRegionItems(@QueryParameter String accessId,
85
+				@QueryParameter String secretKey) throws IOException,
86
+				ServletException {
87
+			ListBoxModel model = new ListBoxModel();
88
+			if (testMode) {
89
+				model.add(DEFAULT_EC2_HOST);
90
+				return model;
91
+			}
92
+				
93
+			if (!StringUtils.isEmpty(accessId) && !StringUtils.isEmpty(secretKey)) {
94
+				AmazonEC2 client = connect(accessId, secretKey, new URL(
95
+						"http://ec2.amazonaws.com"));
96
+				DescribeRegionsResult regions = client.describeRegions();
97
+				List<Region> regionList = regions.getRegions();
98
+				for (Region r : regionList) {
99
+					model.add(r.getRegionName(), r.getRegionName());
100
+				}
101
+			}
102
+			return model;
103
+		}
104
+
105
+        public FormValidation doTestConnection(
106
+                @QueryParameter String region,
107
+                 @QueryParameter String accessId,
108
+                 @QueryParameter String secretKey,
109
+                 @QueryParameter String privateKey) throws IOException, ServletException {
110
+            return super.doTestConnection(getEc2EndpointUrl(region),accessId,secretKey,privateKey);
111
+        }
112
+
113
+        public FormValidation doGenerateKey(
114
+                StaplerResponse rsp, @QueryParameter String region, @QueryParameter String accessId, @QueryParameter String secretKey) throws IOException, ServletException {
115
+            return super.doGenerateKey(rsp,getEc2EndpointUrl(region),accessId,secretKey);
116
+        }
117
+    }
118
+}

+ 459
- 0
source-code/maven-generic-conf/extlibs/ec2-plugin/src/main/java/hudson/plugins/ec2/EC2Cloud.java View File

@@ -0,0 +1,459 @@
1
+package hudson.plugins.ec2;
2
+
3
+import hudson.model.Computer;
4
+import hudson.model.Descriptor;
5
+import hudson.model.Hudson;
6
+import hudson.model.Label;
7
+import hudson.model.Node;
8
+import hudson.slaves.Cloud;
9
+import hudson.slaves.NodeProvisioner.PlannedNode;
10
+import hudson.util.FormValidation;
11
+import hudson.util.Secret;
12
+import hudson.util.StreamTaskListener;
13
+
14
+import java.io.BufferedReader;
15
+import java.io.IOException;
16
+import java.io.StringReader;
17
+import java.io.StringWriter;
18
+import java.net.MalformedURLException;
19
+import java.net.URL;
20
+import java.util.ArrayList;
21
+import java.util.Collection;
22
+import java.util.Collections;
23
+import java.util.Date;
24
+import java.util.List;
25
+import java.util.concurrent.Callable;
26
+import java.util.logging.Level;
27
+import java.util.logging.Logger;
28
+
29
+import javax.servlet.ServletException;
30
+
31
+import org.kohsuke.stapler.QueryParameter;
32
+import org.kohsuke.stapler.StaplerRequest;
33
+import org.kohsuke.stapler.StaplerResponse;
34
+
35
+import com.amazonaws.AmazonClientException;
36
+import com.amazonaws.auth.AWSCredentials;
37
+import com.amazonaws.auth.BasicAWSCredentials;
38
+import com.amazonaws.services.ec2.AmazonEC2;
39
+import com.amazonaws.services.ec2.AmazonEC2Client;
40
+import com.amazonaws.services.ec2.model.CreateKeyPairRequest;
41
+import com.amazonaws.services.ec2.model.Instance;
42
+import com.amazonaws.services.ec2.model.InstanceStateName;
43
+import com.amazonaws.services.ec2.model.InstanceType;
44
+import com.amazonaws.services.ec2.model.KeyPair;
45
+import com.amazonaws.services.ec2.model.KeyPairInfo;
46
+import com.amazonaws.services.ec2.model.Reservation;
47
+import com.amazonaws.services.s3.AmazonS3;
48
+import com.amazonaws.services.s3.AmazonS3Client;
49
+import com.amazonaws.services.s3.model.GeneratePresignedUrlRequest;
50
+
51
+
52
+/**
53
+ * Hudson's view of EC2. 
54
+ *
55
+ * @author Kohsuke Kawaguchi
56
+ */
57
+public abstract class EC2Cloud extends Cloud {
58
+
59
+	public static final String DEFAULT_EC2_HOST = "us-east-1";
60
+	public static final String EC2_URL_HOST = "ec2.amazonaws.com";
61
+	
62
+    private final String accessId;
63
+    private final Secret secretKey;
64
+    private final EC2PrivateKey privateKey;
65
+
66
+    /**
67
+     * Upper bound on how many instances we may provision.
68
+     */
69
+    public final int instanceCap;
70
+    private final List<SlaveTemplate> templates;
71
+    private transient KeyPair usableKeyPair;
72
+
73
+    private transient AmazonEC2 connection;
74
+    
75
+	private static AWSCredentials awsCredentials;
76
+    
77
+    protected EC2Cloud(String id, String accessId, String secretKey, String privateKey, String instanceCapStr, List<SlaveTemplate> templates) {
78
+        super(id);
79
+        this.accessId = accessId.trim();
80
+        this.secretKey = Secret.fromString(secretKey.trim());
81
+        this.privateKey = new EC2PrivateKey(privateKey);
82
+
83
+        if(templates==null) {
84
+            this.templates=Collections.emptyList();
85
+        } else {
86
+            this.templates=templates;
87
+        }
88
+
89
+        if(instanceCapStr.equals("")) {
90
+            this.instanceCap = Integer.MAX_VALUE;
91
+        } else {
92
+            this.instanceCap = Integer.parseInt(instanceCapStr);
93
+        }
94
+
95
+        readResolve(); // set parents
96
+    }
97
+
98
+    public abstract URL getEc2EndpointUrl() throws IOException;
99
+    public abstract URL getS3EndpointUrl() throws IOException;
100
+
101
+    protected Object readResolve() {
102
+        for (SlaveTemplate t : templates)
103
+            t.parent = this;
104
+        return this;
105
+    }
106
+
107
+    public String getAccessId() {
108
+        return accessId;
109
+    }
110
+
111
+    public String getSecretKey() {
112
+        return secretKey.getEncryptedValue();
113
+    }
114
+
115
+    public EC2PrivateKey getPrivateKey() {
116
+        return privateKey;
117
+    }
118
+
119
+    public String getInstanceCapStr() {
120
+        if(instanceCap==Integer.MAX_VALUE)
121
+            return "";
122
+        else
123
+            return String.valueOf(instanceCap);
124
+    }
125
+
126
+    public List<SlaveTemplate> getTemplates() {
127
+        return Collections.unmodifiableList(templates);
128
+    }
129
+
130
+    public SlaveTemplate getTemplate(String ami) {
131
+        for (SlaveTemplate t : templates)
132
+            if(t.ami.equals(ami))
133
+                return t;
134
+        return null;
135
+    }
136
+
137
+    /**
138
+     * Gets {@link SlaveTemplate} that has the matching {@link Label}.
139
+     */
140
+    public SlaveTemplate getTemplate(Label label) {
141
+        for (SlaveTemplate t : templates)
142
+        	if(label == null || label.matches(t.getLabelSet()))
143
+                return t;
144
+        return null;
145
+    }
146
+
147
+    /**
148
+     * Gets the {@link KeyPairInfo} used for the launch.
149
+     */
150
+    public synchronized KeyPair getKeyPair() throws AmazonClientException, IOException {
151
+        if(usableKeyPair==null)
152
+            usableKeyPair = privateKey.find(connect());
153
+        return usableKeyPair;
154
+    }
155
+
156
+    /**
157
+     * Counts the number of instances in EC2 currently running that are using the specifed image.
158
+     *
159
+     * @param ami If AMI is left null, then all instances are counted.
160
+     * <p>
161
+     * This includes those instances that may be started outside Hudson.
162
+     */
163
+    public int countCurrentEC2Slaves(String ami) throws AmazonClientException {
164
+        int n=0;
165
+        for (Reservation r : connect().describeInstances().getReservations()) {
166
+            for (Instance i : r.getInstances()) {
167
+                if (ami == null || ami.equals(i.getImageId())) {
168
+                    InstanceStateName stateName = InstanceStateName.fromValue(i.getState().getName());
169
+                    if (stateName == InstanceStateName.Pending || stateName == InstanceStateName.Running)
170
+                        n++;
171
+                }
172
+            }
173
+        }
174
+        return n;
175
+    }
176
+
177
+    /**
178
+     * Debug command to attach to a running instance.
179
+     */
180
+    public void doAttach(StaplerRequest req, StaplerResponse rsp, @QueryParameter String id) throws ServletException, IOException, AmazonClientException {
181
+        checkPermission(PROVISION);
182
+        SlaveTemplate t = getTemplates().get(0);
183
+
184
+        StringWriter sw = new StringWriter();
185
+        StreamTaskListener listener = new StreamTaskListener(sw);
186
+        EC2Slave node = t.attach(id,listener);
187
+        Hudson.getInstance().addNode(node);
188
+
189
+        rsp.sendRedirect2(req.getContextPath()+"/computer/"+node.getNodeName());
190
+    }
191
+
192
+    public void doProvision(StaplerRequest req, StaplerResponse rsp, @QueryParameter String ami) throws ServletException, IOException {
193
+        checkPermission(PROVISION);
194
+        if(ami==null) {
195
+            sendError("The 'ami' query parameter is missing",req,rsp);
196
+            return;
197
+        }
198
+        SlaveTemplate t = getTemplate(ami);
199
+        if(t==null) {
200
+            sendError("No such AMI: "+ami,req,rsp);
201
+            return;
202
+        }
203
+
204
+        StringWriter sw = new StringWriter();
205
+        StreamTaskListener listener = new StreamTaskListener(sw);
206
+        try {
207
+            EC2Slave node = t.provision(listener);
208
+            Hudson.getInstance().addNode(node);
209
+
210
+            rsp.sendRedirect2(req.getContextPath()+"/computer/"+node.getNodeName());
211
+        } catch (AmazonClientException e) {
212
+            e.printStackTrace(listener.error(e.getMessage()));
213
+            sendError(sw.toString(),req,rsp);
214
+        }
215
+    }
216
+
217
+    @Override
218
+	public Collection<PlannedNode> provision(Label label, int excessWorkload) {
219
+        try {
220
+
221
+
222
+        	final SlaveTemplate t = getTemplate(label);
223
+
224
+            List<PlannedNode> r = new ArrayList<PlannedNode>();
225
+            for( ; excessWorkload>0; excessWorkload-- ) {
226
+                if(countCurrentEC2Slaves(null)>=instanceCap) {
227
+                    LOGGER.log(Level.INFO, "Instance cap reached, not provisioning.");
228
+                    break;      // maxed out
229
+                }
230
+
231
+                int amiCap = t.getInstanceCap();
232
+                if (amiCap < countCurrentEC2Slaves(t.ami)) {
233
+                    LOGGER.log(Level.INFO, "AMI Instance cap reached, not provisioning.");
234
+                    break;      // maxed out
235
+                }
236
+
237
+
238
+                r.add(new PlannedNode(t.getDisplayName(),
239
+                        Computer.threadPoolForRemoting.submit(new Callable<Node>() {
240
+                            public Node call() throws Exception {
241
+                                // TODO: record the output somewhere
242
+                                EC2Slave s = t.provision(new StreamTaskListener(System.out));
243
+                                Hudson.getInstance().addNode(s);
244
+                                // EC2 instances may have a long init script. If we declare
245
+                                // the provisioning complete by returning without the connect
246
+                                // operation, NodeProvisioner may decide that it still wants
247
+                                // one more instance, because it sees that (1) all the slaves
248
+                                // are offline (because it's still being launched) and
249
+                                // (2) there's no capacity provisioned yet.
250
+                                //
251
+                                // deferring the completion of provisioning until the launch
252
+                                // goes successful prevents this problem.
253
+                                s.toComputer().connect(false).get();
254
+                                return s;
255
+                            }
256
+                        })
257
+                        ,t.getNumExecutors()));
258
+            }
259
+            return r;
260
+        } catch (AmazonClientException e) {
261
+            LOGGER.log(Level.WARNING,"Failed to count the # of live instances on EC2",e);
262
+            return Collections.emptyList();
263
+        }
264
+    }
265
+
266
+    @Override
267
+	public boolean canProvision(Label label) {
268
+        return getTemplate(label)!=null;
269
+    }
270
+
271
+    /**
272
+     * Gets the first {@link EC2Cloud} instance configured in the current Hudson, or null if no such thing exists.
273
+     */
274
+    public static EC2Cloud get() {
275
+        return Hudson.getInstance().clouds.get(EC2Cloud.class);
276
+    }
277
+
278
+    /**
279
+     * Connects to EC2 and returns {@link AmazonEC2}, which can then be used to communicate with EC2.
280
+     */
281
+    public synchronized AmazonEC2 connect() throws AmazonClientException {
282
+        try {
283
+            if (connection == null) {
284
+                connection = connect(accessId, secretKey, getEc2EndpointUrl());
285
+            }
286
+            return connection;
287
+        } catch (IOException e) {
288
+            throw new AmazonClientException("Failed to retrieve the endpoint",e);
289
+        }
290
+    }
291
+
292
+    /***
293
+     * Connect to an EC2 instance.
294
+     * @return {@link AmazonEC2} client
295
+     */
296
+    public static AmazonEC2 connect(String accessId, String secretKey, URL endpoint) {
297
+        return connect(accessId, Secret.fromString(secretKey), endpoint);
298
+    }
299
+
300
+    /***
301
+     * Connect to an EC2 instance.
302
+     * @return {@link AmazonEC2} client
303
+     */
304
+    public static AmazonEC2 connect(String accessId, Secret secretKey, URL endpoint) {
305
+    	awsCredentials = new BasicAWSCredentials(accessId, Secret.toString(secretKey));
306
+        AmazonEC2 client = new AmazonEC2Client(awsCredentials);
307
+        client.setEndpoint(endpoint.toString());
308
+        return client;
309
+    }
310
+
311
+    /***
312
+     * Convert a configured hostname like 'us-east-1' to a FQDN or ip address
313
+     */
314
+    public static String convertHostName(String ec2HostName) {
315
+        if (ec2HostName == null || ec2HostName.length()==0)
316
+            ec2HostName = DEFAULT_EC2_HOST;
317
+        if (!ec2HostName.contains("."))
318
+            ec2HostName = ec2HostName + "." + EC2_URL_HOST;
319
+	return ec2HostName;
320
+    }
321
+
322
+    /***
323
+     * Convert a user entered string into a port number
324
+     * "" -> -1 to indicate default based on SSL setting
325
+     */
326
+    public static Integer convertPort(String ec2Port) {
327
+        if (ec2Port == null || ec2Port.length() == 0)
328
+            return -1;
329
+        else
330
+            return Integer.parseInt(ec2Port);
331
+    }
332
+
333
+    /**
334
+     * Computes the presigned URL for the given S3 resource.
335
+     *
336
+     * @param path
337
+     *      String like "/bucketName/folder/folder/abc.txt" that represents the resource to request.
338
+     */
339
+    public URL buildPresignedURL(String path) throws IOException, AmazonClientException {
340
+        long expires = System.currentTimeMillis()+60*60*1000;
341
+        GeneratePresignedUrlRequest request = new GeneratePresignedUrlRequest(path, Secret.toString(secretKey));
342
+        request.setExpiration(new Date(expires));
343
+        AmazonS3 s3 = new AmazonS3Client(awsCredentials);
344
+        return s3.generatePresignedUrl(request);
345
+    }
346
+
347
+    /* Parse a url or return a sensible error */
348
+    public static URL checkEndPoint(String url) throws FormValidation {
349
+        try {
350
+            return new URL(url);
351
+        } catch (MalformedURLException ex) {
352
+            throw FormValidation.error("Endpoint URL is not a valid URL");
353
+        }
354
+    }
355
+
356
+
357
+    public static abstract class DescriptorImpl extends Descriptor<Cloud> {
358
+        public InstanceType[] getInstanceTypes() {
359
+            return InstanceType.values();
360
+        }
361
+
362
+        public FormValidation doCheckAccessId(@QueryParameter String value) throws IOException, ServletException {
363
+            return FormValidation.validateBase64(value,false,false,Messages.EC2Cloud_InvalidAccessId());
364
+        }
365
+
366
+        public FormValidation doCheckSecretKey(@QueryParameter String value) throws IOException, ServletException {
367
+            return FormValidation.validateBase64(value,false,false,Messages.EC2Cloud_InvalidSecretKey());
368
+        }
369
+
370
+        public FormValidation doCheckPrivateKey(@QueryParameter String value) throws IOException, ServletException {
371
+            boolean hasStart=false,hasEnd=false;
372
+            BufferedReader br = new BufferedReader(new StringReader(value));
373
+            String line;
374
+            while ((line = br.readLine()) != null) {
375
+                if (line.equals("-----BEGIN RSA PRIVATE KEY-----"))
376
+                    hasStart=true;
377
+                if (line.equals("-----END RSA PRIVATE KEY-----"))
378
+                    hasEnd=true;
379
+            }
380
+            if(!hasStart)
381
+                return FormValidation.error("This doesn't look like a private key at all");
382
+            if(!hasEnd)
383
+                return FormValidation.error("The private key is missing the trailing 'END RSA PRIVATE KEY' marker. Copy&paste error?");
384
+            return FormValidation.ok();
385
+        }
386
+
387
+        protected FormValidation doTestConnection( URL ec2endpoint,
388
+                                     String accessId, String secretKey, String privateKey) throws IOException, ServletException {
389
+            try {
390
+                AmazonEC2 ec2 = connect(accessId, secretKey, ec2endpoint);
391
+                ec2.describeInstances();
392
+
393
+                if(accessId==null)
394
+                    return FormValidation.error("Access ID is not specified");
395
+                if(secretKey==null)
396
+                    return FormValidation.error("Secret key is not specified");
397
+                if(privateKey==null)
398
+                    return FormValidation.error("Private key is not specified. Click 'Generate Key' to generate one.");
399
+
400
+                if(privateKey.trim().length()>0) {
401
+                    // check if this key exists
402
+                    EC2PrivateKey pk = new EC2PrivateKey(privateKey);
403
+                    if(pk.find(ec2)==null)
404
+                        return FormValidation.error("The EC2 key pair private key isn't registered to this EC2 region (fingerprint is "+pk.getFingerprint()+")");
405
+                }
406
+
407
+                return FormValidation.ok(Messages.EC2Cloud_Success());
408
+            } catch (AmazonClientException e) {
409
+                LOGGER.log(Level.WARNING, "Failed to check EC2 credential",e);
410
+                return FormValidation.error(e.getMessage());
411
+            }
412
+        }
413
+
414
+        public FormValidation doGenerateKey(StaplerResponse rsp, URL ec2EndpointUrl, String accessId, String secretKey
415
+        ) throws IOException, ServletException {
416
+            try {
417
+                AmazonEC2 ec2 = connect(accessId, secretKey, ec2EndpointUrl);
418
+                List<KeyPairInfo> existingKeys = ec2.describeKeyPairs().getKeyPairs();
419
+
420
+                int n = 0;
421
+                while(true) {
422
+                    boolean found = false;
423
+                    for (KeyPairInfo k : existingKeys) {
424
+                        if(k.getKeyName().equals("hudson-"+n))
425
+                            found=true;
426
+                    }
427
+                    if(!found)
428
+                        break;
429
+                    n++;
430
+                }
431
+
432
+                CreateKeyPairRequest request = new CreateKeyPairRequest("hudson-" + n);
433
+                KeyPair key = ec2.createKeyPair(request).getKeyPair();
434
+
435
+
436
+                rsp.addHeader("script","findPreviousFormItem(button,'privateKey').value='"+key.getKeyMaterial().replace("\n","\\n")+"'");
437
+
438
+                return FormValidation.ok(Messages.EC2Cloud_Success());
439
+            } catch (AmazonClientException e) {
440
+                LOGGER.log(Level.WARNING, "Failed to check EC2 credential",e);
441
+                return FormValidation.error(e.getMessage());
442
+            }
443
+        }
444
+    }
445
+
446
+    private static final Logger LOGGER = Logger.getLogger(EC2Cloud.class.getName());
447
+
448
+    private static boolean isSSL(URL endpoint) {
449
+        return endpoint.getProtocol().equals("https");
450
+    }
451
+
452
+    private static int portFromURL(URL endpoint) {
453
+        int ec2Port = endpoint.getPort();
454
+        if (ec2Port == -1) {
455
+            ec2Port = endpoint.getDefaultPort();
456
+        }
457
+        return ec2Port;
458
+    }
459
+}

+ 126
- 0
source-code/maven-generic-conf/extlibs/ec2-plugin/src/main/java/hudson/plugins/ec2/EC2Computer.java View File

@@ -0,0 +1,126 @@
1
+package hudson.plugins.ec2;
2
+
3
+import hudson.Util;
4
+import hudson.slaves.SlaveComputer;
5
+import java.io.IOException;
6
+import java.util.Collections;
7
+
8
+import org.kohsuke.stapler.HttpRedirect;
9
+import org.kohsuke.stapler.HttpResponse;
10
+import com.amazonaws.AmazonClientException;
11
+import com.amazonaws.services.ec2.AmazonEC2;
12
+import com.amazonaws.services.ec2.model.DescribeInstancesRequest;
13
+import com.amazonaws.services.ec2.model.GetConsoleOutputRequest;
14
+import com.amazonaws.services.ec2.model.Instance;
15
+
16
+/**
17
+ * @author Kohsuke Kawaguchi
18
+ */
19
+public class EC2Computer extends SlaveComputer {
20
+    /**
21
+     * Cached description of this EC2 instance. Lazily fetched.
22
+     */
23
+    private volatile Instance ec2InstanceDescription;
24
+
25
+    public EC2Computer(EC2Slave slave) {
26
+        super(slave);
27
+    }
28
+
29
+    @Override
30
+    public EC2Slave getNode() {
31
+        return (EC2Slave)super.getNode();
32
+    }
33
+
34
+    public String getInstanceId() {
35
+        return getName();
36
+    }
37
+
38
+    /**
39
+     * Gets the EC2 console output.
40
+     */
41
+    public String getConsoleOutput() throws AmazonClientException {
42
+        AmazonEC2 ec2 = EC2Cloud.get().connect();
43
+        GetConsoleOutputRequest request = new GetConsoleOutputRequest(getInstanceId());
44
+        return ec2.getConsoleOutput(request).getOutput();
45
+    }
46
+
47
+    /**
48
+     * Obtains the instance state description in EC2.
49
+     *
50
+     * <p>
51
+     * This method returns a cached state, so it's not suitable to check {@link Instance#getState()}
52
+     * and {@link Instance#getStateCode()} from the returned instance (but all the other fields are valid as it won't change.)
53
+     *
54
+     * The cache can be flushed using {@link #updateInstanceDescription()}
55
+     */
56
+    public Instance describeInstance() throws AmazonClientException {
57
+        if(ec2InstanceDescription==null)
58
+            ec2InstanceDescription = _describeInstance();
59
+        return ec2InstanceDescription;
60
+    }
61
+
62
+    /**
63
+     * This will flush any cached description held by {@link #describeInstance()}.
64
+     */
65
+    public Instance updateInstanceDescription() throws AmazonClientException {
66
+        return ec2InstanceDescription = _describeInstance();
67
+    }
68
+
69
+    /**
70
+     * Gets the current state of the instance.
71
+     *
72
+     * <p>
73
+     * Unlike {@link #describeInstance()}, this method always return the current status by calling EC2.
74
+     */
75
+    public InstanceState getState() throws AmazonClientException {
76
+        ec2InstanceDescription=_describeInstance();
77
+        return InstanceState.find(ec2InstanceDescription.getState().getName());
78
+    }
79
+
80
+    /**
81
+     * Number of milli-secs since the instance was started.
82
+     */
83
+    public long getUptime() throws AmazonClientException {
84
+        return System.currentTimeMillis()-describeInstance().getLaunchTime().getTime();
85
+    }
86
+
87
+    /**
88
+     * Returns uptime in the human readable form.
89
+     */
90
+    public String getUptimeString() throws AmazonClientException {
91
+        return Util.getTimeSpanString(getUptime());
92
+    }
93
+
94
+    private Instance _describeInstance() throws AmazonClientException {
95
+    	DescribeInstancesRequest request = new DescribeInstancesRequest();
96
+    	request.setInstanceIds(Collections.<String>singletonList(getNode().getInstanceId()));
97
+        return EC2Cloud.get().connect().describeInstances(request).getReservations().get(0).getInstances().get(0);
98
+    }
99
+
100
+    /**
101
+     * When the slave is deleted, terminate the instance.
102
+     */
103
+    @Override
104
+    public HttpResponse doDoDelete() throws IOException {
105
+        checkPermission(DELETE);
106
+        if (getNode() != null)
107
+        	getNode().terminate();
108
+        return new HttpRedirect("..");
109
+    }
110
+
111
+    /** What username to use to run root-like commands
112
+     *
113
+     */
114
+    public String getRemoteAdmin() {
115
+        return getNode().getRemoteAdmin();
116
+    }
117
+
118
+    public int getSshPort() {
119
+         return getNode().getSshPort();
120
+     }
121
+
122
+    public String getRootCommandPrefix() {
123
+        return getNode().getRootCommandPrefix();
124
+    }
125
+    
126
+}

+ 73
- 0
source-code/maven-generic-conf/extlibs/ec2-plugin/src/main/java/hudson/plugins/ec2/EC2ComputerLauncher.java View File

@@ -0,0 +1,73 @@
1
+package hudson.plugins.ec2;
2
+
3
+import hudson.model.TaskListener;
4
+import hudson.slaves.ComputerLauncher;
5
+import hudson.slaves.SlaveComputer;
6
+
7
+import java.io.IOException;
8
+import java.io.PrintStream;
9
+import java.util.ArrayList;
10
+import java.util.List;
11
+
12
+import com.amazonaws.AmazonClientException;
13
+import com.amazonaws.services.ec2.AmazonEC2;
14
+import com.amazonaws.services.ec2.model.Instance;
15
+import com.amazonaws.services.ec2.model.StartInstancesRequest;
16
+import com.amazonaws.services.ec2.model.StartInstancesResult;
17
+
18
+/**
19
+ * {@link ComputerLauncher} for EC2 that waits for the instance to really come up before proceeding to
20
+ * the real user-specified {@link ComputerLauncher}.
21
+ *
22
+ * @author Kohsuke Kawaguchi
23
+ */
24
+public abstract class EC2ComputerLauncher extends ComputerLauncher {
25
+    @Override
26
+    public void launch(SlaveComputer _computer, TaskListener listener) {
27
+        try {
28
+            EC2Computer computer = (EC2Computer)_computer;
29
+            PrintStream logger = listener.getLogger();
30
+
31
+            OUTER:
32
+            while(true) {
33
+                switch (computer.getState()) {
34
+                    case PENDING:
35
+                    case STOPPING:
36
+                        Thread.sleep(5000); // check every 5 secs
37
+                        continue OUTER;
38
+                    case RUNNING:
39
+                        break OUTER;
40
+                    case STOPPED:
41
+                    	AmazonEC2 ec2 = EC2Cloud.get().connect();
42
+                        List<String> instances = new ArrayList<String>();
43
+                        instances.add(computer.getInstanceId());
44
+
45
+                        StartInstancesRequest siRequest = new StartInstancesRequest(instances);
46
+                        StartInstancesResult siResult = ec2.startInstances(siRequest);
47
+                        logger.println("Starting existing instance: "+computer.getInstanceId()+ " result:"+siResult);
48
+                        continue OUTER;
49
+                    case SHUTTING_DOWN:
50
+                    case TERMINATED:
51
+                        // abort
52
+                        logger.println("The instance "+computer.getInstanceId()+" appears to be shut down. Aborting launch.");
53
+                        return;
54
+                }
55
+            }
56
+
57
+            launch(computer, logger, computer.describeInstance());
58
+        } catch (AmazonClientException e) {
59
+            e.printStackTrace(listener.error(e.getMessage()));
60
+        } catch (IOException e) {
61
+            e.printStackTrace(listener.error(e.getMessage()));
62
+        } catch (InterruptedException e) {
63
+            e.printStackTrace(listener.error(e.getMessage()));
64
+        }
65
+
66
+    }
67
+
68
+    /**
69
+     * Stage 2 of the launch. Called after the EC2 instance comes up.
70
+     */
71
+    protected abstract void launch(EC2Computer computer, PrintStream logger, Instance inst)
72
+            throws AmazonClientException, IOException, InterruptedException;
73
+}

+ 152
- 0
source-code/maven-generic-conf/extlibs/ec2-plugin/src/main/java/hudson/plugins/ec2/EC2PrivateKey.java View File

@@ -0,0 +1,152 @@
1
+package hudson.plugins.ec2;
2
+
3
+import hudson.util.Secret;
4
+
5
+import java.io.BufferedReader;
6
+import java.io.ByteArrayInputStream;
7
+import java.io.IOException;
8
+import java.io.Reader;
9
+import java.io.StringReader;
10
+import java.security.DigestInputStream;
11
+import java.security.KeyPair;
12
+import java.security.MessageDigest;
13
+import java.security.NoSuchAlgorithmException;
14
+import java.security.PrivateKey;
15
+import java.security.Security;
16
+
17
+import org.apache.commons.codec.binary.Hex;
18
+import org.bouncycastle.openssl.PEMReader;
19
+import org.bouncycastle.openssl.PasswordFinder;
20
+
21
+import com.amazonaws.AmazonClientException;
22
+import com.amazonaws.services.ec2.AmazonEC2;
23
+import com.amazonaws.services.ec2.model.KeyPairInfo;
24
+
25
+/**
26
+ * RSA private key (the one that you generate with ec2-add-keypair.) Starts with
27
+ * "----- BEGIN RSA PRIVATE KEY------\n".
28
+ * 
29
+ * @author Kohsuke Kawaguchi
30
+ */
31
+public final class EC2PrivateKey {
32
+    private final Secret privateKey;
33
+
34
+    public EC2PrivateKey(final String privateKey) {
35
+        this.privateKey = Secret.fromString(privateKey.trim());
36
+    }
37
+
38
+    /**
39
+     * Obtains the fingerprint of the key in the "ab:cd:ef:...:12" format.
40
+     */
41
+    /**
42
+     * Obtains the fingerprint of the key in the "ab:cd:ef:...:12" format.
43
+     */
44
+    public String getFingerprint() throws IOException {
45
+        Security
46
+            .addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
47
+        Reader r =
48
+            new BufferedReader(new StringReader(privateKey.toString()));
49
+        PEMReader pem = new PEMReader(r, new PasswordFinder() {
50
+            public char[] getPassword() {
51
+                throw PRIVATE_KEY_WITH_PASSWORD;
52
+            }
53
+        });
54
+
55
+        try {
56
+            KeyPair pair = (KeyPair) pem.readObject();
57
+            if (pair == null) {
58
+                return null;
59
+            }
60
+            PrivateKey key = pair.getPrivate();
61
+            return digest(key);
62
+        } catch (RuntimeException e) {
63
+            if (e == PRIVATE_KEY_WITH_PASSWORD) {
64
+                throw new IOException(
65
+                    "This private key is password protected, which isn't supported yet");
66
+            }
67
+            throw e;
68
+        }
69
+    }
70
+
71
+    /**
72
+     * Is this file really a private key?
73
+     */
74
+    public boolean isPrivateKey() throws IOException {
75
+        BufferedReader br =
76
+            new BufferedReader(new StringReader(privateKey.toString()));
77
+        String line;
78
+        while ((line = br.readLine()) != null) {
79
+            if (line.equals("-----BEGIN RSA PRIVATE KEY-----")) {
80
+                return true;
81
+            }
82
+        }
83
+        return false;
84
+    }
85
+
86
+    /**
87
+     * Finds the {@link KeyPairInfo} that corresponds to this key in EC2.
88
+     */
89
+    public com.amazonaws.services.ec2.model.KeyPair find(
90
+            final AmazonEC2 ec2) throws IOException, AmazonClientException {
91
+        String fp = getFingerprint();
92
+        for (KeyPairInfo kp : ec2.describeKeyPairs().getKeyPairs()) {
93
+            if (kp.getKeyFingerprint().equalsIgnoreCase(fp)) {
94
+                com.amazonaws.services.ec2.model.KeyPair keyPair =
95
+                    new com.amazonaws.services.ec2.model.KeyPair();
96
+                keyPair.setKeyName(kp.getKeyName());
97
+                keyPair.setKeyFingerprint(fp);
98
+                keyPair.setKeyMaterial(Secret.toString(privateKey));
99
+                return keyPair;
100
+            }
101
+        }
102
+        return null;
103
+    }
104
+
105
+    @Override
106
+    public int hashCode() {
107
+        return privateKey.hashCode();
108
+    }
109
+
110
+    @Override
111
+    public boolean equals(final Object that) {
112
+        return that instanceof EC2PrivateKey
113
+            && privateKey.equals(((EC2PrivateKey) that).privateKey);
114
+    }
115
+
116
+    @Override
117
+    public String toString() {
118
+        return privateKey.toString();
119
+    }
120
+
121
+    /* package */static String digest(final PrivateKey k)
122
+            throws IOException {
123
+        try {
124
+            MessageDigest md5 = MessageDigest.getInstance("SHA1");
125
+
126
+            DigestInputStream in =
127
+                new DigestInputStream(new ByteArrayInputStream(
128
+                    k.getEncoded()), md5);
129
+            try {
130
+                while (in.read(new byte[128]) > 0) {
131
+                    ; // simply discard the input
132
+                }
133
+            } finally {
134
+                in.close();
135
+            }
136
+            StringBuilder buf = new StringBuilder();
137
+            char[] hex = Hex.encodeHex(md5.digest());
138
+            for (int i = 0; i < hex.length; i += 2) {
139
+                if (buf.length() > 0) {
140
+                    buf.append(':');
141
+                }
142
+                buf.append(hex, i, 2);
143
+            }
144
+            return buf.toString();
145
+        } catch (NoSuchAlgorithmException e) {
146
+            throw new AssertionError(e);
147
+        }
148
+    }
149
+
150
+    private static final RuntimeException PRIVATE_KEY_WITH_PASSWORD =
151
+        new RuntimeException();
152
+}

+ 77
- 0
source-code/maven-generic-conf/extlibs/ec2-plugin/src/main/java/hudson/plugins/ec2/EC2RetentionStrategy.java View File

@@ -0,0 +1,77 @@
1
+package hudson.plugins.ec2;
2
+
3
+import hudson.model.Descriptor;
4
+import hudson.slaves.RetentionStrategy;
5
+import hudson.util.TimeUnit2;
6
+
7
+import java.util.logging.Logger;
8
+
9
+import org.kohsuke.stapler.DataBoundConstructor;
10
+
11
+/**
12
+ * {@link RetentionStrategy} for EC2.
13
+ *
14
+ * @author Kohsuke Kawaguchi
15
+ */
16
+public class EC2RetentionStrategy extends RetentionStrategy<EC2Computer> {
17
+    /** Number of minutes of idleness before an instance should be terminated.
18
+	    A value of zero indicates that the instance should never be automatically terminated */
19
+    public final int idleTerminationMinutes;
20
+
21
+
22
+    @DataBoundConstructor
23
+    public EC2RetentionStrategy(String idleTerminationMinutes) {
24
+        if (idleTerminationMinutes == null || idleTerminationMinutes.trim() == "") {
25
+            this.idleTerminationMinutes = 0;
26
+        } else {
27
+            int value = 30;
28
+            try {
29
+                value = Integer.parseInt(idleTerminationMinutes);
30
+            } catch (NumberFormatException nfe) {
31
+                LOGGER.info("Malformed default idleTermination value: " + idleTerminationMinutes); 
32
+            }
33
+
34
+            this.idleTerminationMinutes = value;
35
+        }
36
+    }
37
+
38
+    @Override
39
+	public synchronized long check(EC2Computer c) {
40
+
41
+        /* If we've been told never to terminate, then we're done. */
42
+        if  (idleTerminationMinutes == 0) return 1;
43
+        final long idleMilliseconds1 = System.currentTimeMillis() - c.getIdleStartMilliseconds();
44
+        System.out.println(c.getName() + " idle: " + idleMilliseconds1);
45
+        
46
+        if (c.isIdle() && c.isOnline() && !disabled) {
47
+            // TODO: really think about the right strategy here
48
+            final long idleMilliseconds = System.currentTimeMillis() - c.getIdleStartMilliseconds();
49
+            if (idleMilliseconds > TimeUnit2.MINUTES.toMillis(idleTerminationMinutes)) {
50
+                LOGGER.info("Idle timeout: "+c.getName());
51
+                c.getNode().idleTimeout();
52
+            }
53
+        }
54
+        return 1;
55
+    }
56
+
57
+    /**
58
+     * Try to connect to it ASAP.
59
+     */
60
+    @Override
61
+    public void start(EC2Computer c) {
62
+        c.connect(false);
63
+    }
64
+
65
+    // no registration since this retention strategy is used only for EC2 nodes that we provision automatically.
66
+    // @Extension
67
+    public static class DescriptorImpl extends Descriptor<RetentionStrategy<?>> {
68
+        @Override
69
+		public String getDisplayName() {
70
+            return "EC2";
71
+        }
72
+    }
73
+
74
+    private static final Logger LOGGER = Logger.getLogger(EC2RetentionStrategy.class.getName());
75
+
76
+    public static boolean disabled = Boolean.getBoolean(EC2RetentionStrategy.class.getName()+".disabled");
77
+}

+ 382
- 0
source-code/maven-generic-conf/extlibs/ec2-plugin/src/main/java/hudson/plugins/ec2/EC2Slave.java View File

@@ -0,0 +1,382 @@
1
+package hudson.plugins.ec2;
2
+
3
+import hudson.Extension;
4
+import hudson.Util;
5
+import hudson.model.Computer;
6
+import hudson.model.Descriptor.FormException;
7
+import hudson.model.Hudson;
8
+import hudson.model.Slave;
9
+import hudson.model.Node;
10
+import hudson.plugins.ec2.ssh.EC2UnixLauncher;
11
+import hudson.slaves.NodeProperty;
12
+import hudson.util.ListBoxModel;
13
+
14
+import java.io.IOException;
15
+import java.util.Collections;
16
+import java.util.List;
17
+import java.util.LinkedList;
18
+import java.util.HashSet;
19
+import java.util.logging.Level;
20
+import java.util.logging.Logger;
21
+
22
+import javax.servlet.ServletException;
23
+
24
+import org.apache.commons.lang.StringUtils;
25
+import org.kohsuke.stapler.DataBoundConstructor;
26
+import org.kohsuke.stapler.QueryParameter;
27
+import org.kohsuke.stapler.StaplerRequest;
28
+
29
+import com.amazonaws.AmazonClientException;
30
+import com.amazonaws.services.ec2.AmazonEC2;
31
+import com.amazonaws.services.ec2.model.*;
32
+
33
+import net.sf.json.JSONObject;
34
+
35
+/**
36
+ * Slave running on EC2.
37
+ * 
38
+ * @author Kohsuke Kawaguchi
39
+ */
40
+public final class EC2Slave extends Slave {
41
+    /**
42
+     * Comes from {@link SlaveTemplate#initScript}.
43
+     */
44
+    public final String initScript;
45
+    public final String remoteAdmin; // e.g. 'ubuntu'
46
+    public final String rootCommandPrefix; // e.g. 'sudo'
47
+    public final String jvmopts; //e.g. -Xmx1g
48
+    public final boolean stopOnTerminate;
49
+    public final String idleTerminationMinutes;
50
+    public final boolean usePrivateDnsName;
51
+    public List<EC2Tag> tags;
52
+
53
+    // Temporary stuff that is obtained live from EC2
54
+    public String publicDNS;
55
+    public String privateDNS;
56
+
57
+    /* The last instance data to be fetched for the slave */
58
+    private Instance lastFetchInstance = null;
59
+
60
+    /* The time at which we fetched the last instance data */
61
+    private long lastFetchTime = 0;
62
+
63
+    /* The time (in milliseconds) after which we will always re-fetch externally changeable EC2 data when we are asked for it */
64
+    private static final long MIN_FETCH_TIME = 20 * 1000;
65
+
66
+
67
+    /**
68
+     * For data read from old Hudson, this is 0, so we use that to indicate 22.
69
+     */
70
+    private final int sshPort;
71
+
72
+    public static final String TEST_ZONE = "testZone";
73
+    
74
+    public EC2Slave(String instanceId, String description, String remoteFS, int sshPort, int numExecutors, String labelString, String initScript, String remoteAdmin, String rootCommandPrefix, String jvmopts, boolean stopOnTerminate, String idleTerminationMinutes, String publicDNS, String privateDNS, List<EC2Tag> tags) throws FormException, IOException {
75
+        this(instanceId, description, remoteFS, sshPort, numExecutors, Mode.NORMAL, labelString, initScript, Collections.<NodeProperty<?>>emptyList(), remoteAdmin, rootCommandPrefix, jvmopts, stopOnTerminate, idleTerminationMinutes, publicDNS, privateDNS, tags, false);
76
+    }
77
+
78
+    public EC2Slave(String instanceId, String description, String remoteFS, int sshPort, int numExecutors, String labelString, String initScript, String remoteAdmin, String rootCommandPrefix, String jvmopts, boolean stopOnTerminate, String idleTerminationMinutes, String publicDNS, String privateDNS, List<EC2Tag> tags, boolean usePrivateDnsName) throws FormException, IOException {
79
+        this(instanceId, description, remoteFS, sshPort, numExecutors, Mode.NORMAL, labelString, initScript, Collections.<NodeProperty<?>>emptyList(), remoteAdmin, rootCommandPrefix, jvmopts, stopOnTerminate, idleTerminationMinutes, publicDNS, privateDNS, tags, usePrivateDnsName);
80
+    }
81
+
82
+
83
+    @DataBoundConstructor
84
+    public EC2Slave(String instanceId, String description, String remoteFS, int sshPort, int numExecutors, Mode mode, String labelString, String initScript, List<? extends NodeProperty<?>> nodeProperties, String remoteAdmin, String rootCommandPrefix, String jvmopts, boolean stopOnTerminate, String idleTerminationMinutes, String publicDNS, String privateDNS, List<EC2Tag> tags, boolean usePrivateDnsName) throws FormException, IOException {
85
+
86
+        super(instanceId, description, remoteFS, numExecutors, mode, labelString, new EC2UnixLauncher(), new EC2RetentionStrategy(idleTerminationMinutes), nodeProperties);
87
+
88
+        this.initScript  = initScript;
89
+        this.remoteAdmin = remoteAdmin;
90
+        this.rootCommandPrefix = rootCommandPrefix;
91
+        this.jvmopts = jvmopts;
92
+        this.sshPort = sshPort;
93
+        this.stopOnTerminate = stopOnTerminate;
94
+        this.idleTerminationMinutes = idleTerminationMinutes;
95
+        this.publicDNS = publicDNS;
96
+        this.privateDNS = privateDNS;
97
+        this.tags = tags;
98
+        this.usePrivateDnsName = usePrivateDnsName;
99
+    }
100
+
101
+    /**
102
+     * Constructor for debugging.
103
+     */
104
+    public EC2Slave(String instanceId) throws FormException, IOException {
105
+        this(instanceId,"debug", "/tmp/hudson", 22, 1, Mode.NORMAL, "debug", "", Collections.<NodeProperty<?>>emptyList(), null, null, null, false, null, "Fake public", "Fake private", null, false);
106
+    }
107
+
108
+    /**
109
+     * See http://aws.amazon.com/ec2/instance-types/
110
+     */
111
+    /*package*/ static int toNumExecutors(InstanceType it) {
112
+        switch (it) {
113
+        case T1Micro:       return 1;
114
+        case M1Small:       return 1;
115
+        case M1Medium:      return 2;
116
+        case M1Large:       return 4;
117
+        case C1Medium:      return 5;
118
+        case M2Xlarge:      return 6;
119
+        case M1Xlarge:      return 8;
120
+        case M22xlarge:     return 13;
121
+        case C1Xlarge:      return 20;
122
+        case M24xlarge:     return 26;
123
+        case Cc14xlarge:    return 33;
124
+        case Cg14xlarge:    return 33;
125
+        default:            throw new AssertionError();
126
+        }
127
+    }
128
+
129
+    /**
130
+     * EC2 instance ID.
131
+     */
132
+    public String getInstanceId() {
133
+        return getNodeName();
134
+    }
135
+
136
+    @Override
137
+    public Computer createComputer() {
138
+        return new EC2Computer(this);
139
+    }
140
+
141
+    public static Instance getInstance(String instanceId) {
142
+        DescribeInstancesRequest request = new DescribeInstancesRequest();
143
+    	request.setInstanceIds(Collections.<String>singletonList(instanceId));
144
+        EC2Cloud cloudInstance = EC2Cloud.get();
145
+        if (cloudInstance == null)
146
+        	return null;
147
+        AmazonEC2 ec2 = cloudInstance.connect();
148
+    	List<Reservation> reservations = ec2.describeInstances(request).getReservations();
149
+        Instance i = null;
150
+    	if (reservations.size() > 0) {
151
+    		List<Instance> instances = reservations.get(0).getInstances();
152
+    		if (instances.size() > 0)
153
+    			i = instances.get(0);
154
+    	}
155
+    	return i;
156
+    }
157
+    
158
+    /**
159
+     * Terminates the instance in EC2.
160
+     */
161
+    public void terminate() {
162
+        try {
163
+            if (!isAlive(true)) {
164
+                /* The node has been killed externally, so we've nothing to do here */
165
+                LOGGER.info("EC2 instance already terminated: "+getInstanceId());
166
+            } else {
167
+                AmazonEC2 ec2 = EC2Cloud.get().connect();
168
+                TerminateInstancesRequest request = new TerminateInstancesRequest(Collections.singletonList(getInstanceId()));
169
+                ec2.terminateInstances(request);
170
+                LOGGER.info("Terminated EC2 instance (terminated): "+getInstanceId());
171
+            }
172
+            Hudson.getInstance().removeNode(this);
173
+        } catch (AmazonClientException e) {
174
+            LOGGER.log(Level.WARNING,"Failed to terminate EC2 instance: "+getInstanceId(),e);
175
+        } catch (IOException e) {
176
+            LOGGER.log(Level.WARNING,"Failed to terminate EC2 instance: "+getInstanceId(),e);
177
+        }
178
+    }
179
+
180
+	void idleTimeout() {
181
+		LOGGER.info("EC2 instance idle time expired: "+getInstanceId());
182
+		if (!stopOnTerminate) {
183
+			terminate();
184
+			return;
185
+		}
186
+
187
+		try {
188
+			AmazonEC2 ec2 = EC2Cloud.get().connect();
189
+			StopInstancesRequest request = new StopInstancesRequest(
190
+					Collections.singletonList(getInstanceId()));
191
+			ec2.stopInstances(request);
192
+			toComputer().disconnect(null);
193
+		} catch (AmazonClientException e) {
194
+	        Instance i = getInstance(getNodeName());
195
+			LOGGER.log(Level.WARNING, "Failed to terminate EC2 instance: "+getInstanceId() + " info: "+((i != null)?i:"") , e);
196
+		}
197
+		LOGGER.info("EC2 instance stopped: " + getInstanceId());
198
+	}
199
+
200
+    String getRemoteAdmin() {
201
+        if (remoteAdmin == null || remoteAdmin.length() == 0)
202
+            return "root";
203
+        return remoteAdmin;
204
+    }
205
+
206
+    String getRootCommandPrefix() {
207
+        if (rootCommandPrefix == null || rootCommandPrefix.length() == 0)
208
+            return "";
209
+        return rootCommandPrefix + " ";
210
+    }
211
+
212
+    String getJvmopts() {
213
+        return Util.fixNull(jvmopts);
214
+    }
215
+
216
+    public int getSshPort() {
217
+        return sshPort!=0 ? sshPort : 22;
218
+    }
219
+
220
+    public boolean getStopOnTerminate() {
221
+        return stopOnTerminate;
222
+    }
223
+
224
+    private boolean isAlive(boolean force) {
225
+        fetchLiveInstanceData(force);
226
+        if (lastFetchInstance == null) return false;
227
+        if (lastFetchInstance.getState().getName().equals(InstanceStateName.Terminated.toString())) return false;
228
+        return true;
229
+    }
230
+
231
+    /* Much of the EC2 data is beyond our direct control, therefore we need to refresh it from time to
232
+       time to ensure we reflect the reality of the instances. */
233
+    private void fetchLiveInstanceData( boolean force ) throws AmazonClientException {
234
+		/* If we've grabbed the data recently, don't bother getting it again unless we are forced */
235
+        long now = System.currentTimeMillis();
236
+        if ((lastFetchTime > 0) && (now - lastFetchTime < MIN_FETCH_TIME) && !force) {
237
+            return;
238
+        }
239
+
240
+        Instance i = getInstance(getNodeName());
241
+
242
+        lastFetchTime = now;
243
+        lastFetchInstance = i;
244
+        if (i == null)
245
+        	return;
246
+
247
+        publicDNS = i.getPublicDnsName();
248
+        privateDNS = i.getPrivateIpAddress();
249
+        tags = new LinkedList<EC2Tag>();
250
+
251
+        for (Tag t : i.getTags()) {
252
+            tags.add(new EC2Tag(t.getKey(), t.getValue()));
253
+        }
254
+    }
255
+
256
+
257
+	/* Clears all existing tag data so that we can force the instance into a known state */
258
+    private void clearLiveInstancedata() throws AmazonClientException {
259
+        Instance inst = getInstance(getNodeName());
260
+
261
+        /* Now that we have our instance, we can clear the tags on it */
262
+        if (!tags.isEmpty()) {
263
+            HashSet<Tag> inst_tags = new HashSet<Tag>();
264
+
265
+            for(EC2Tag t : tags) {
266
+                inst_tags.add(new Tag(t.getName(), t.getValue()));
267
+            }
268
+
269
+            DeleteTagsRequest tag_request = new DeleteTagsRequest();
270
+            tag_request.withResources(inst.getInstanceId()).setTags(inst_tags);
271
+            EC2Cloud.get().connect().deleteTags(tag_request);
272
+        }
273
+    }
274
+
275
+
276
+    /* Sets tags on an instance.  This will not clear existing tag data, so call clearLiveInstancedata if needed */
277
+    private void pushLiveInstancedata() throws AmazonClientException {
278
+        Instance inst = getInstance(getNodeName());
279
+
280
+        /* Now that we have our instance, we can set tags on it */
281
+        if (tags != null && !tags.isEmpty()) {
282
+            HashSet<Tag> inst_tags = new HashSet<Tag>();
283
+
284
+            for(EC2Tag t : tags) {
285
+                inst_tags.add(new Tag(t.getName(), t.getValue()));
286
+            }            
287
+
288
+            CreateTagsRequest tag_request = new CreateTagsRequest();
289
+            tag_request.withResources(inst.getInstanceId()).setTags(inst_tags);
290
+            EC2Cloud.get().connect().createTags(tag_request);
291
+        }
292
+    }
293
+
294
+    public String getPublicDNS() {
295
+        fetchLiveInstanceData(false);
296
+        return publicDNS;
297
+    }
298
+
299
+    public String getPrivateDNS() {
300
+        fetchLiveInstanceData(false);
301
+        return privateDNS;
302
+    }
303
+
304
+    public List<EC2Tag> getTags() {
305
+        fetchLiveInstanceData(false);
306
+        return Collections.unmodifiableList(tags);
307
+    }
308
+
309
+    @Override
310
+	public Node reconfigure(final StaplerRequest req, JSONObject form) throws FormException {
311
+        if (form == null) {
312
+            return null;
313
+        }
314
+
315
+        if (!isAlive(true)) {
316
+            LOGGER.info("EC2 instance terminated externally: " + getInstanceId());
317
+            try {
318
+                Hudson.getInstance().removeNode(this);
319
+            } catch (IOException ioe) {
320
+                LOGGER.log(Level.WARNING, "Attempt to reconfigure EC2 instance which has been externally terminated: " + getInstanceId(), ioe);
321
+            }
322
+
323
+            return null;
324
+        }
325
+
326
+        Node result = super.reconfigure(req, form);
327
+
328
+        /* Get rid of the old tags, as represented by ourselves. */
329
+        clearLiveInstancedata();
330
+
331
+        /* Set the new tags, as represented by our successor */
332
+        ((EC2Slave) result).pushLiveInstancedata();
333
+
334
+        return result;
335
+    }
336
+
337
+
338
+    public boolean getUsePrivateDnsName() {
339
+        return usePrivateDnsName;
340
+    }
341
+    
342
+    public static ListBoxModel fillZoneItems(String accessId, String secretKey, String region) throws IOException, ServletException {
343
+		ListBoxModel model = new ListBoxModel();
344
+		if (AmazonEC2Cloud.testMode) {
345
+			model.add(TEST_ZONE);
346
+			return model;
347
+		}
348
+			
349
+		if (!StringUtils.isEmpty(accessId) && !StringUtils.isEmpty(secretKey) && !StringUtils.isEmpty(region)) {
350
+			AmazonEC2 client = EC2Cloud.connect(accessId, secretKey, AmazonEC2Cloud.getEc2EndpointUrl(region));
351
+			DescribeAvailabilityZonesResult zones = client.describeAvailabilityZones();
352
+			List<AvailabilityZone> zoneList = zones.getAvailabilityZones();
353
+			model.add("<not specified>", "");
354
+			for (AvailabilityZone z : zoneList) {
355
+				model.add(z.getZoneName(), z.getZoneName());
356
+			}
357
+		}
358
+		return model;
359
+	}
360
+    
361
+    
362
+    @Extension
363
+    public static final class DescriptorImpl extends SlaveDescriptor {
364
+        @Override
365
+		public String getDisplayName() {
366
+            return "Amazon EC2";
367
+        }
368
+
369
+        @Override
370
+        public boolean isInstantiable() {
371
+            return false;
372
+        }
373
+
374
+        public ListBoxModel doFillZoneItems(@QueryParameter String accessId,
375
+        		@QueryParameter String secretKey, @QueryParameter String region) throws IOException,
376
+    			ServletException {
377
+        	return fillZoneItems(accessId, secretKey, region);
378
+    	}
379
+    }
380
+
381
+    private static final Logger LOGGER = Logger.getLogger(EC2Slave.class.getName());
382
+}

+ 82
- 0
source-code/maven-generic-conf/extlibs/ec2-plugin/src/main/java/hudson/plugins/ec2/EC2Tag.java View File

@@ -0,0 +1,82 @@
1
+package hudson.plugins.ec2;
2
+
3
+import hudson.model.Descriptor;
4
+import hudson.model.AbstractDescribableImpl;
5
+import hudson.Extension;
6
+import org.kohsuke.stapler.DataBoundConstructor;
7
+
8
+import java.util.List;
9
+import java.util.LinkedList;
10
+
11
+import com.amazonaws.services.ec2.model.Tag;
12
+
13
+
14
+public class EC2Tag extends AbstractDescribableImpl<EC2Tag>
15
+{
16
+   private String name;
17
+   private String value;
18
+
19
+   @DataBoundConstructor
20
+   public EC2Tag(String name, String value) {
21
+      this.name = name;
22
+      this.value = value;
23
+   }
24
+
25
+
26
+   /* Constructor from Amazon Tag */
27
+   public EC2Tag(Tag t) {
28
+       name = t.getKey();
29
+       value = t.getValue();
30
+   }
31
+
32
+
33
+   public String getName() {
34
+      return name;
35
+   }
36
+
37
+
38
+   public String getValue() {
39
+      return value;
40
+   }
41
+
42
+
43
+   @Override
44
+   public String toString() {
45
+      return "EC2Tag: " + name + "->" + value;
46
+   }
47
+
48
+
49
+   @Override
50
+   public boolean equals(Object o) {
51
+      if (o == null) return false;
52
+      if (!(o instanceof EC2Tag)) return false;
53
+
54
+      EC2Tag other = (EC2Tag) o;
55
+      if ((name == null && other.name != null) || !name.equals( other.name)) return false;
56
+      if ((value == null && other.value != null) || !value.equals( other.value)) return false;
57
+
58
+      return true;
59
+   }
60
+
61
+
62
+   @Extension
63
+   public static class DescriptorImpl extends Descriptor<EC2Tag> {
64
+      @Override
65
+	  public String getDisplayName() { return ""; }
66
+   }
67
+
68
+
69
+   /* Helper method to convert lists of Amazon tags into internal format */ 
70
+   public static List<EC2Tag> fromAmazonTags(List<Tag> amazon_tags) {
71
+       if (null == amazon_tags) {
72
+           return null;
73
+       }
74
+
75
+       LinkedList<EC2Tag> result = new LinkedList<EC2Tag>();
76
+       for (Tag t : amazon_tags) {
77
+           result.add(new EC2Tag(t));
78
+       }
79
+
80
+       return result;
81
+   }
82
+}

+ 180
- 0
source-code/maven-generic-conf/extlibs/ec2-plugin/src/main/java/hudson/plugins/ec2/Eucalyptus.java View File

@@ -0,0 +1,180 @@
1
+package hudson.plugins.ec2;
2
+
3
+import hudson.Extension;
4
+import hudson.util.FormValidation;
5
+import hudson.util.IOException2;
6
+
7
+import java.io.IOException;
8
+import java.net.MalformedURLException;
9
+import java.net.URL;
10
+import java.security.GeneralSecurityException;
11
+import java.security.KeyManagementException;
12
+import java.security.NoSuchAlgorithmException;
13
+import java.security.cert.X509Certificate;
14
+import java.util.List;
15
+
16
+import javax.net.ssl.HostnameVerifier;
17
+import javax.net.ssl.HttpsURLConnection;
18
+import javax.net.ssl.SSLContext;
19
+import javax.net.ssl.SSLSession;
20
+import javax.net.ssl.TrustManager;
21
+import javax.net.ssl.X509TrustManager;
22
+import javax.servlet.ServletException;
23
+
24
+import org.dom4j.Document;
25
+import org.dom4j.DocumentException;
26
+import org.dom4j.Element;
27
+import org.dom4j.io.SAXReader;
28
+import org.kohsuke.stapler.DataBoundConstructor;
29
+import org.kohsuke.stapler.QueryParameter;
30
+import org.kohsuke.stapler.StaplerResponse;
31
+
32
+/**
33
+ * Eucalyptus.
34
+ *
35
+ * @author Kohsuke Kawaguchi
36
+ */
37
+public class Eucalyptus extends EC2Cloud {
38
+    private transient Metadata metadata;
39
+
40
+    public final URL url;
41
+
42
+    @DataBoundConstructor
43
+    public Eucalyptus(URL url, String accessId, String secretKey, String privateKey, String instanceCapStr, List<SlaveTemplate> templates) throws IOException {
44
+        super("eucalyptus", accessId, secretKey, privateKey, instanceCapStr, templates);
45
+        this.url = url;
46
+    }
47
+
48
+    private Metadata getMetadata() throws IOException {
49
+        if (metadata==null)
50
+            metadata = new Metadata(url);
51
+        return metadata;
52
+    }
53
+
54
+    @Override
55
+    public URL getEc2EndpointUrl() throws IOException {
56
+        return getMetadata().ec2endpoint;
57
+    }
58
+
59
+    @Override
60
+    public URL getS3EndpointUrl() throws IOException {
61
+        return getMetadata().s3endpoint;
62
+    }
63
+
64
+    @Extension
65
+    public static class DescriptorImpl extends EC2Cloud.DescriptorImpl {
66
+        @Override
67
+		public String getDisplayName() {
68
+            return "Eucalyptus";
69
+        }
70
+
71
+        @Override
72
+		public FormValidation doTestConnection(
73
+                @QueryParameter URL url,
74
+                @QueryParameter String accessId,
75
+                @QueryParameter String secretKey,
76
+                @QueryParameter String privateKey) throws IOException, ServletException {
77
+            return super.doTestConnection(new Metadata(url).ec2endpoint,accessId,secretKey,privateKey);
78
+        }
79
+
80
+        @Override
81
+		public FormValidation doGenerateKey(
82
+                StaplerResponse rsp, @QueryParameter URL url, @QueryParameter String accessId, @QueryParameter String secretKey) throws IOException, ServletException {
83
+            return super.doGenerateKey(rsp, new Metadata(url).ec2endpoint, accessId,secretKey);
84
+        }
85
+    }
86
+
87
+    /**
88
+     * Eucalyptus service endpoint metadata.
89
+     */
90
+    static class Metadata {
91
+        final URL ec2endpoint,s3endpoint;
92
+
93
+        Metadata(URL eucalyptus) throws IOException {
94
+            if (!eucalyptus.getProtocol().equals("https"))
95
+                throw new IOException("Expecting an HTTPS URL but got "+eucalyptus);
96
+            URL metadataUrl = new URL(eucalyptus, "/register");
97
+            try {
98
+                HttpsURLConnection con = (HttpsURLConnection)metadataUrl.openConnection();
99
+                makeIgnoreCertificate(con);
100
+                Document metadata = new SAXReader().read(con.getInputStream());
101
+                /*
102
+                       Metadata, as of Eucalyptus 1.5.2, looks like this:
103
+
104
+                       <Signature>
105
+                         <SignedInfo>
106
+                           <SignatureMethod>http://www.w3.org/2001/04/xmldsig-more#hmac-sha256</SignatureMethod>
107
+                         </SignedInfo>
108
+                         <SignatureValue>62595777525d7dbba4b5f361b3e9041d3d37e92611684557e67e85a9222a3ffb  </SignatureValue>
109
+                         <Object>
110
+                          <CloudSchema>
111
+                         <Services type="array">
112
+                           <Service>
113
+                             <Name>ec2</Name>
114
+                             <EndpointUrl>http://eucalyptus.hudson-slaves.sfbay.sun.com:8773/services/Eucalyptus</EndpointUrl>
115
+                             <Resources type="array">
116
+                               ...
117
+                             </Resources>
118
+                           </Service>
119
+                           <Service>
120
+                             <Name>s3</Name>
121
+                             <EndpointUrl>http://eucalyptus.hudson-slaves.sfbay.sun.com:8773/services/Walrus</EndpointUrl>
122
+                             <Resources type="array">
123
+                               ...
124
+                             </Resources>
125
+                           </Service>
126
+                         </Services>
127
+                         <id>a002c56e-b994-4ed8-956b-b30eda9b6153</id>  <CloudType>eucalyptus</CloudType>
128
+                         <CloudVersion>1.5.2</CloudVersion>
129
+                         <SchemaVersion>1.0</SchemaVersion>
130
+                         <Description>Public cloud in the new cluster</Description>
131
+                       </CloudSchema>
132
+
133
+                    */
134
+
135
+                this.ec2endpoint = readURLFromMetadata(metadata, "ec2");
136
+                this.s3endpoint = readURLFromMetadata(metadata, "s3");
137
+            } catch (DocumentException e) {
138
+                throw new IOException2("Failed to parse Eucalyptus metadata at "+metadataUrl,e);
139
+            } catch (IOException e) {
140
+                throw new IOException2("Failed to parse Eucalyptus metadata at "+metadataUrl,e);
141
+            } catch (GeneralSecurityException e) {
142
+                throw new IOException2("Failed to parse Eucalyptus metadata at "+metadataUrl,e);
143
+            }
144
+        }
145
+