redcar 0.3.2dev → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (485) hide show
  1. data/CHANGES +49 -2
  2. data/README.md +2 -7
  3. data/ROADMAP.md +8 -9
  4. data/Rakefile +29 -44
  5. data/bin/redcar +11 -2
  6. data/lib/openssl/History.txt +75 -0
  7. data/lib/openssl/License.txt +30 -0
  8. data/lib/openssl/Manifest.txt +99 -0
  9. data/lib/openssl/README.txt +24 -0
  10. data/lib/openssl/Rakefile +71 -0
  11. data/lib/openssl/build.properties.SAMPLE +7 -0
  12. data/lib/openssl/build.xml +57 -0
  13. data/lib/openssl/lib/jopenssl/version.rb +5 -0
  14. data/lib/openssl/lib/openssl.rb +24 -0
  15. data/lib/openssl/lib/openssl/bn.rb +33 -0
  16. data/lib/openssl/lib/openssl/buffering.rb +239 -0
  17. data/lib/openssl/lib/openssl/cipher.rb +56 -0
  18. data/lib/openssl/lib/openssl/digest.rb +46 -0
  19. data/lib/openssl/lib/openssl/dummy.rb +34 -0
  20. data/lib/openssl/lib/openssl/dummyssl.rb +13 -0
  21. data/lib/openssl/lib/openssl/ssl.rb +135 -0
  22. data/lib/openssl/lib/openssl/x509.rb +154 -0
  23. data/lib/openssl/mocha/COPYING +3 -0
  24. data/lib/openssl/mocha/MIT-LICENSE +7 -0
  25. data/lib/openssl/mocha/README +35 -0
  26. data/lib/openssl/mocha/RELEASE +171 -0
  27. data/lib/openssl/mocha/Rakefile +147 -0
  28. data/lib/openssl/mocha/TODO +48 -0
  29. data/lib/openssl/mocha/examples/misc.rb +36 -0
  30. data/lib/openssl/mocha/examples/mocha.rb +26 -0
  31. data/lib/openssl/mocha/examples/stubba.rb +65 -0
  32. data/lib/openssl/mocha/init.rb +3 -0
  33. data/lib/openssl/mocha/lib/mocha.rb +19 -0
  34. data/lib/openssl/mocha/lib/mocha/any_instance_method.rb +35 -0
  35. data/lib/openssl/mocha/lib/mocha/auto_verify.rb +111 -0
  36. data/lib/openssl/mocha/lib/mocha/central.rb +35 -0
  37. data/lib/openssl/mocha/lib/mocha/class_method.rb +62 -0
  38. data/lib/openssl/mocha/lib/mocha/deprecation.rb +22 -0
  39. data/lib/openssl/mocha/lib/mocha/exception_raiser.rb +17 -0
  40. data/lib/openssl/mocha/lib/mocha/expectation.rb +382 -0
  41. data/lib/openssl/mocha/lib/mocha/expectation_error.rb +6 -0
  42. data/lib/openssl/mocha/lib/mocha/expectation_list.rb +45 -0
  43. data/lib/openssl/mocha/lib/mocha/infinite_range.rb +25 -0
  44. data/lib/openssl/mocha/lib/mocha/inspect.rb +39 -0
  45. data/lib/openssl/mocha/lib/mocha/instance_method.rb +8 -0
  46. data/lib/openssl/mocha/lib/mocha/is_a.rb +9 -0
  47. data/lib/openssl/mocha/lib/mocha/metaclass.rb +7 -0
  48. data/lib/openssl/mocha/lib/mocha/missing_expectation.rb +27 -0
  49. data/lib/openssl/mocha/lib/mocha/mock.rb +200 -0
  50. data/lib/openssl/mocha/lib/mocha/multiple_yields.rb +20 -0
  51. data/lib/openssl/mocha/lib/mocha/no_yields.rb +11 -0
  52. data/lib/openssl/mocha/lib/mocha/object.rb +110 -0
  53. data/lib/openssl/mocha/lib/mocha/parameter_matchers.rb +9 -0
  54. data/lib/openssl/mocha/lib/mocha/parameter_matchers/all_of.rb +39 -0
  55. data/lib/openssl/mocha/lib/mocha/parameter_matchers/any_of.rb +44 -0
  56. data/lib/openssl/mocha/lib/mocha/parameter_matchers/anything.rb +30 -0
  57. data/lib/openssl/mocha/lib/mocha/parameter_matchers/has_entry.rb +39 -0
  58. data/lib/openssl/mocha/lib/mocha/parameter_matchers/has_key.rb +39 -0
  59. data/lib/openssl/mocha/lib/mocha/parameter_matchers/has_value.rb +39 -0
  60. data/lib/openssl/mocha/lib/mocha/parameter_matchers/includes.rb +37 -0
  61. data/lib/openssl/mocha/lib/mocha/parameter_matchers/instance_of.rb +39 -0
  62. data/lib/openssl/mocha/lib/mocha/parameter_matchers/kind_of.rb +39 -0
  63. data/lib/openssl/mocha/lib/mocha/pretty_parameters.rb +28 -0
  64. data/lib/openssl/mocha/lib/mocha/return_values.rb +31 -0
  65. data/lib/openssl/mocha/lib/mocha/setup_and_teardown.rb +23 -0
  66. data/lib/openssl/mocha/lib/mocha/single_return_value.rb +24 -0
  67. data/lib/openssl/mocha/lib/mocha/single_yield.rb +18 -0
  68. data/lib/openssl/mocha/lib/mocha/standalone.rb +32 -0
  69. data/lib/openssl/mocha/lib/mocha/stub.rb +18 -0
  70. data/lib/openssl/mocha/lib/mocha/test_case_adapter.rb +49 -0
  71. data/lib/openssl/mocha/lib/mocha/yield_parameters.rb +31 -0
  72. data/lib/openssl/mocha/lib/mocha_standalone.rb +2 -0
  73. data/lib/openssl/mocha/lib/stubba.rb +2 -0
  74. data/lib/openssl/mocha/templates/html_with_google_analytics.rb +742 -0
  75. data/lib/openssl/mocha/test/acceptance/expected_invocation_count_acceptance_test.rb +187 -0
  76. data/lib/openssl/mocha/test/acceptance/mocha_acceptance_test.rb +98 -0
  77. data/lib/openssl/mocha/test/acceptance/mocked_methods_dispatch_acceptance_test.rb +71 -0
  78. data/lib/openssl/mocha/test/acceptance/parameter_matcher_acceptance_test.rb +63 -0
  79. data/lib/openssl/mocha/test/acceptance/standalone_acceptance_test.rb +131 -0
  80. data/lib/openssl/mocha/test/acceptance/stubba_acceptance_test.rb +102 -0
  81. data/lib/openssl/mocha/test/active_record_test_case.rb +36 -0
  82. data/lib/openssl/mocha/test/deprecation_disabler.rb +15 -0
  83. data/lib/openssl/mocha/test/execution_point.rb +34 -0
  84. data/lib/openssl/mocha/test/integration/mocha_test_result_integration_test.rb +105 -0
  85. data/lib/openssl/mocha/test/integration/stubba_integration_test.rb +89 -0
  86. data/lib/openssl/mocha/test/integration/stubba_test_result_integration_test.rb +85 -0
  87. data/lib/openssl/mocha/test/method_definer.rb +18 -0
  88. data/lib/openssl/mocha/test/test_helper.rb +12 -0
  89. data/lib/openssl/mocha/test/test_runner.rb +31 -0
  90. data/lib/openssl/mocha/test/unit/any_instance_method_test.rb +124 -0
  91. data/lib/openssl/mocha/test/unit/array_inspect_test.rb +16 -0
  92. data/lib/openssl/mocha/test/unit/auto_verify_test.rb +122 -0
  93. data/lib/openssl/mocha/test/unit/central_test.rb +124 -0
  94. data/lib/openssl/mocha/test/unit/class_method_test.rb +196 -0
  95. data/lib/openssl/mocha/test/unit/date_time_inspect_test.rb +21 -0
  96. data/lib/openssl/mocha/test/unit/expectation_list_test.rb +69 -0
  97. data/lib/openssl/mocha/test/unit/expectation_raiser_test.rb +28 -0
  98. data/lib/openssl/mocha/test/unit/expectation_test.rb +399 -0
  99. data/lib/openssl/mocha/test/unit/hash_inspect_test.rb +16 -0
  100. data/lib/openssl/mocha/test/unit/infinite_range_test.rb +53 -0
  101. data/lib/openssl/mocha/test/unit/metaclass_test.rb +22 -0
  102. data/lib/openssl/mocha/test/unit/missing_expectation_test.rb +45 -0
  103. data/lib/openssl/mocha/test/unit/mock_test.rb +316 -0
  104. data/lib/openssl/mocha/test/unit/multiple_yields_test.rb +18 -0
  105. data/lib/openssl/mocha/test/unit/no_yield_test.rb +18 -0
  106. data/lib/openssl/mocha/test/unit/object_inspect_test.rb +35 -0
  107. data/lib/openssl/mocha/test/unit/object_test.rb +165 -0
  108. data/lib/openssl/mocha/test/unit/parameter_matchers/all_of_test.rb +26 -0
  109. data/lib/openssl/mocha/test/unit/parameter_matchers/any_of_test.rb +26 -0
  110. data/lib/openssl/mocha/test/unit/parameter_matchers/anything_test.rb +21 -0
  111. data/lib/openssl/mocha/test/unit/parameter_matchers/has_entry_test.rb +25 -0
  112. data/lib/openssl/mocha/test/unit/parameter_matchers/has_key_test.rb +25 -0
  113. data/lib/openssl/mocha/test/unit/parameter_matchers/has_value_test.rb +25 -0
  114. data/lib/openssl/mocha/test/unit/parameter_matchers/includes_test.rb +25 -0
  115. data/lib/openssl/mocha/test/unit/parameter_matchers/instance_of_test.rb +25 -0
  116. data/lib/openssl/mocha/test/unit/parameter_matchers/kind_of_test.rb +25 -0
  117. data/lib/openssl/mocha/test/unit/parameter_matchers/stub_matcher.rb +22 -0
  118. data/lib/openssl/mocha/test/unit/pretty_parameters_test.rb +32 -0
  119. data/lib/openssl/mocha/test/unit/return_values_test.rb +63 -0
  120. data/lib/openssl/mocha/test/unit/setup_and_teardown_test.rb +76 -0
  121. data/lib/openssl/mocha/test/unit/single_return_value_test.rb +33 -0
  122. data/lib/openssl/mocha/test/unit/single_yield_test.rb +18 -0
  123. data/lib/openssl/mocha/test/unit/string_inspect_test.rb +11 -0
  124. data/lib/openssl/mocha/test/unit/stub_test.rb +24 -0
  125. data/lib/openssl/mocha/test/unit/yield_parameters_test.rb +93 -0
  126. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/FOLDERS +53 -0
  127. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/LICENSE +340 -0
  128. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/README +117 -0
  129. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/bin/coderay +77 -0
  130. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/bin/coderay_stylesheet +4 -0
  131. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay.rb +319 -0
  132. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/duo.rb +29 -0
  133. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/encoder.rb +173 -0
  134. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/encoders/_map.rb +8 -0
  135. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/encoders/count.rb +21 -0
  136. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/encoders/debug.rb +46 -0
  137. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/encoders/div.rb +20 -0
  138. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/encoders/html.rb +260 -0
  139. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/encoders/html/classes.rb +77 -0
  140. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/encoders/html/css.rb +65 -0
  141. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/encoders/html/numerization.rb +122 -0
  142. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/encoders/html/output.rb +195 -0
  143. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/encoders/null.rb +26 -0
  144. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/encoders/page.rb +21 -0
  145. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/encoders/span.rb +20 -0
  146. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/encoders/statistic.rb +81 -0
  147. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/encoders/text.rb +33 -0
  148. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/encoders/tokens.rb +44 -0
  149. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/encoders/xml.rb +71 -0
  150. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/encoders/yaml.rb +22 -0
  151. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/helpers/file_type.rb +182 -0
  152. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/helpers/gzip_simple.rb +122 -0
  153. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/helpers/plugin.rb +326 -0
  154. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/helpers/word_list.rb +119 -0
  155. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/scanner.rb +238 -0
  156. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/scanners/_map.rb +15 -0
  157. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/scanners/c.rb +163 -0
  158. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/scanners/debug.rb +60 -0
  159. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/scanners/delphi.rb +149 -0
  160. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/scanners/html.rb +177 -0
  161. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/scanners/nitro_xhtml.rb +133 -0
  162. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/scanners/plaintext.rb +16 -0
  163. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/scanners/rhtml.rb +73 -0
  164. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/scanners/ruby.rb +367 -0
  165. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/scanners/ruby/patterns.rb +230 -0
  166. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/scanners/xml.rb +18 -0
  167. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/style.rb +20 -0
  168. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/styles/_map.rb +7 -0
  169. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/styles/cycnus.rb +125 -0
  170. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/styles/murphy.rb +119 -0
  171. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/tokens.rb +368 -0
  172. data/lib/openssl/mocha/vendor/meta_project-0.4.15/CHANGES +295 -0
  173. data/lib/openssl/mocha/vendor/meta_project-0.4.15/MIT-LICENSE +21 -0
  174. data/lib/openssl/mocha/vendor/meta_project-0.4.15/README +129 -0
  175. data/lib/openssl/mocha/vendor/meta_project-0.4.15/Rakefile +152 -0
  176. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project.rb +19 -0
  177. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/core_ext/open_uri.rb +22 -0
  178. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/core_ext/pathname.rb +36 -0
  179. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/core_ext/string.rb +5 -0
  180. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/http/multipart.rb +32 -0
  181. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/patois.rb +1 -0
  182. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/patois/parser.rb +99 -0
  183. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/project.rb +4 -0
  184. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/project/base.rb +9 -0
  185. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/project/codehaus.rb +1 -0
  186. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/project/codehaus/codehaus_project_svn.rb +31 -0
  187. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/project/trac.rb +1 -0
  188. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/project/trac/trac_project.rb +54 -0
  189. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/project/xforge.rb +5 -0
  190. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/project/xforge/ruby_forge.rb +47 -0
  191. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/project/xforge/session.rb +177 -0
  192. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/project/xforge/source_forge.rb +50 -0
  193. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/project/xforge/xfile.rb +45 -0
  194. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/project/xforge/xforge_base.rb +85 -0
  195. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/project_analyzer.rb +36 -0
  196. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/release/freshmeat.rb +267 -0
  197. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/release/raa.rb +572 -0
  198. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/scm_web.rb +2 -0
  199. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/scm_web/browser.rb +112 -0
  200. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/scm_web/pathname.rb +89 -0
  201. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/tracker.rb +6 -0
  202. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/tracker/base.rb +24 -0
  203. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/tracker/digit_issues.rb +34 -0
  204. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/tracker/issue.rb +57 -0
  205. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/tracker/jira.rb +2 -0
  206. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/tracker/jira/jira_issues.rb +35 -0
  207. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/tracker/jira/jira_tracker.rb +149 -0
  208. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/tracker/trac.rb +1 -0
  209. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/tracker/trac/trac_tracker.rb +33 -0
  210. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/tracker/xforge.rb +3 -0
  211. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/tracker/xforge/ruby_forge_tracker.rb +17 -0
  212. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/tracker/xforge/source_forge_tracker.rb +17 -0
  213. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/tracker/xforge/xforge_tracker.rb +191 -0
  214. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/version_parser.rb +52 -0
  215. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/rake/contrib/xforge.rb +3 -0
  216. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/rake/contrib/xforge/base.rb +64 -0
  217. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/rake/contrib/xforge/news_publisher.rb +97 -0
  218. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/rake/contrib/xforge/release.rb +134 -0
  219. data/lib/openssl/nbproject/genfiles.properties +5 -0
  220. data/lib/openssl/nbproject/jdk.xml +157 -0
  221. data/lib/openssl/nbproject/nbjdk.properties +1 -0
  222. data/lib/openssl/nbproject/nbjdk.xml +16 -0
  223. data/lib/openssl/nbproject/project.xml +117 -0
  224. data/lib/openssl/src/java/JopensslService.java +41 -0
  225. data/lib/openssl/src/java/org/jruby/ext/openssl/ASN1.java +930 -0
  226. data/lib/openssl/src/java/org/jruby/ext/openssl/Attribute.java +132 -0
  227. data/lib/openssl/src/java/org/jruby/ext/openssl/BN.java +769 -0
  228. data/lib/openssl/src/java/org/jruby/ext/openssl/BouncyCastlePEMHandler.java +69 -0
  229. data/lib/openssl/src/java/org/jruby/ext/openssl/Callable.java +10 -0
  230. data/lib/openssl/src/java/org/jruby/ext/openssl/Cipher.java +661 -0
  231. data/lib/openssl/src/java/org/jruby/ext/openssl/CipherStrings.java +1827 -0
  232. data/lib/openssl/src/java/org/jruby/ext/openssl/Config.java +49 -0
  233. data/lib/openssl/src/java/org/jruby/ext/openssl/DefaultPEMHandler.java +44 -0
  234. data/lib/openssl/src/java/org/jruby/ext/openssl/Digest.java +207 -0
  235. data/lib/openssl/src/java/org/jruby/ext/openssl/HMAC.java +183 -0
  236. data/lib/openssl/src/java/org/jruby/ext/openssl/NetscapeSPKI.java +212 -0
  237. data/lib/openssl/src/java/org/jruby/ext/openssl/OpenSSLImpl.java +341 -0
  238. data/lib/openssl/src/java/org/jruby/ext/openssl/OpenSSLReal.java +113 -0
  239. data/lib/openssl/src/java/org/jruby/ext/openssl/PEMHandler.java +40 -0
  240. data/lib/openssl/src/java/org/jruby/ext/openssl/PKCS10CertificationRequestExt.java +159 -0
  241. data/lib/openssl/src/java/org/jruby/ext/openssl/PKCS7.java +642 -0
  242. data/lib/openssl/src/java/org/jruby/ext/openssl/PKey.java +154 -0
  243. data/lib/openssl/src/java/org/jruby/ext/openssl/PKeyDH.java +401 -0
  244. data/lib/openssl/src/java/org/jruby/ext/openssl/PKeyDSA.java +419 -0
  245. data/lib/openssl/src/java/org/jruby/ext/openssl/PKeyRSA.java +762 -0
  246. data/lib/openssl/src/java/org/jruby/ext/openssl/Random.java +103 -0
  247. data/lib/openssl/src/java/org/jruby/ext/openssl/Request.java +336 -0
  248. data/lib/openssl/src/java/org/jruby/ext/openssl/SSL.java +71 -0
  249. data/lib/openssl/src/java/org/jruby/ext/openssl/SSLContext.java +358 -0
  250. data/lib/openssl/src/java/org/jruby/ext/openssl/SSLSocket.java +561 -0
  251. data/lib/openssl/src/java/org/jruby/ext/openssl/SimpleSecretKey.java +53 -0
  252. data/lib/openssl/src/java/org/jruby/ext/openssl/Utils.java +60 -0
  253. data/lib/openssl/src/java/org/jruby/ext/openssl/X509.java +108 -0
  254. data/lib/openssl/src/java/org/jruby/ext/openssl/X509CRL.java +446 -0
  255. data/lib/openssl/src/java/org/jruby/ext/openssl/X509Cert.java +520 -0
  256. data/lib/openssl/src/java/org/jruby/ext/openssl/X509Extensions.java +751 -0
  257. data/lib/openssl/src/java/org/jruby/ext/openssl/X509Name.java +405 -0
  258. data/lib/openssl/src/java/org/jruby/ext/openssl/X509Revoked.java +111 -0
  259. data/lib/openssl/src/java/org/jruby/ext/openssl/X509Store.java +282 -0
  260. data/lib/openssl/src/java/org/jruby/ext/openssl/X509StoreCtx.java +206 -0
  261. data/lib/openssl/src/java/org/jruby/ext/openssl/impl/ASN1Registry.java +5135 -0
  262. data/lib/openssl/src/java/org/jruby/ext/openssl/impl/Attribute.java +79 -0
  263. data/lib/openssl/src/java/org/jruby/ext/openssl/impl/BIO.java +345 -0
  264. data/lib/openssl/src/java/org/jruby/ext/openssl/impl/BIOFilter.java +38 -0
  265. data/lib/openssl/src/java/org/jruby/ext/openssl/impl/Base64BIOFilter.java +84 -0
  266. data/lib/openssl/src/java/org/jruby/ext/openssl/impl/CipherBIOFilter.java +157 -0
  267. data/lib/openssl/src/java/org/jruby/ext/openssl/impl/Digest.java +126 -0
  268. data/lib/openssl/src/java/org/jruby/ext/openssl/impl/EVP.java +136 -0
  269. data/lib/openssl/src/java/org/jruby/ext/openssl/impl/EncContent.java +178 -0
  270. data/lib/openssl/src/java/org/jruby/ext/openssl/impl/Encrypt.java +77 -0
  271. data/lib/openssl/src/java/org/jruby/ext/openssl/impl/Envelope.java +169 -0
  272. data/lib/openssl/src/java/org/jruby/ext/openssl/impl/IssuerAndSerial.java +35 -0
  273. data/lib/openssl/src/java/org/jruby/ext/openssl/impl/MemBIO.java +117 -0
  274. data/lib/openssl/src/java/org/jruby/ext/openssl/impl/MessageDigestBIOFilter.java +76 -0
  275. data/lib/openssl/src/java/org/jruby/ext/openssl/impl/Mime.java +245 -0
  276. data/lib/openssl/src/java/org/jruby/ext/openssl/impl/MimeHeader.java +103 -0
  277. data/lib/openssl/src/java/org/jruby/ext/openssl/impl/MimeParam.java +69 -0
  278. data/lib/openssl/src/java/org/jruby/ext/openssl/impl/NotVerifiedPKCS7Exception.java +38 -0
  279. data/lib/openssl/src/java/org/jruby/ext/openssl/impl/NullSinkBIO.java +52 -0
  280. data/lib/openssl/src/java/org/jruby/ext/openssl/impl/PKCS7.java +1276 -0
  281. data/lib/openssl/src/java/org/jruby/ext/openssl/impl/PKCS7Data.java +168 -0
  282. data/lib/openssl/src/java/org/jruby/ext/openssl/impl/PKCS7DataData.java +88 -0
  283. data/lib/openssl/src/java/org/jruby/ext/openssl/impl/PKCS7DataDigest.java +64 -0
  284. data/lib/openssl/src/java/org/jruby/ext/openssl/impl/PKCS7DataEncrypted.java +61 -0
  285. data/lib/openssl/src/java/org/jruby/ext/openssl/impl/PKCS7DataEnveloped.java +85 -0
  286. data/lib/openssl/src/java/org/jruby/ext/openssl/impl/PKCS7DataSigned.java +127 -0
  287. data/lib/openssl/src/java/org/jruby/ext/openssl/impl/PKCS7DataSignedAndEnveloped.java +91 -0
  288. data/lib/openssl/src/java/org/jruby/ext/openssl/impl/PKCS7Exception.java +68 -0
  289. data/lib/openssl/src/java/org/jruby/ext/openssl/impl/RecipInfo.java +244 -0
  290. data/lib/openssl/src/java/org/jruby/ext/openssl/impl/SMIME.java +281 -0
  291. data/lib/openssl/src/java/org/jruby/ext/openssl/impl/SignEnvelope.java +202 -0
  292. data/lib/openssl/src/java/org/jruby/ext/openssl/impl/Signed.java +345 -0
  293. data/lib/openssl/src/java/org/jruby/ext/openssl/impl/SignerInfoWithPkey.java +365 -0
  294. data/lib/openssl/src/java/org/jruby/ext/openssl/impl/TypeDiscriminating.java +34 -0
  295. data/lib/openssl/src/java/org/jruby/ext/openssl/impl/utils/Base64.java +1809 -0
  296. data/lib/openssl/src/java/org/jruby/ext/openssl/util/Base64Coder.java +103 -0
  297. data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/CRL.java +59 -0
  298. data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/Certificate.java +57 -0
  299. data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/CertificateFile.java +46 -0
  300. data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/CertificateHashDir.java +46 -0
  301. data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/Function0.java +43 -0
  302. data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/Function1.java +43 -0
  303. data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/Function2.java +43 -0
  304. data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/Function3.java +43 -0
  305. data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/Function4.java +43 -0
  306. data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/Function5.java +43 -0
  307. data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/Lookup.java +560 -0
  308. data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/LookupMethod.java +84 -0
  309. data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/Name.java +85 -0
  310. data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/PEMInputOutput.java +1210 -0
  311. data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/PKey.java +41 -0
  312. data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/PolicyTree.java +36 -0
  313. data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/Purpose.java +475 -0
  314. data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/Store.java +377 -0
  315. data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/StoreContext.java +1356 -0
  316. data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/Trust.java +279 -0
  317. data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/VerifyParameter.java +324 -0
  318. data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/X509Aux.java +43 -0
  319. data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/X509AuxCertificate.java +170 -0
  320. data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/X509Error.java +70 -0
  321. data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/X509Object.java +88 -0
  322. data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/X509Utils.java +541 -0
  323. data/lib/openssl/test/cert_with_ec_pk.cer +27 -0
  324. data/lib/openssl/test/fixture/ca_path/72fa7371.0 +19 -0
  325. data/lib/openssl/test/fixture/ca_path/verisign.pem +19 -0
  326. data/lib/openssl/test/fixture/cacert.pem +23 -0
  327. data/lib/openssl/test/fixture/cert_localhost.pem +19 -0
  328. data/lib/openssl/test/fixture/common.pem +48 -0
  329. data/lib/openssl/test/fixture/localhost_keypair.pem +18 -0
  330. data/lib/openssl/test/fixture/max.pem +29 -0
  331. data/lib/openssl/test/fixture/purpose/b70a5bc1.0 +24 -0
  332. data/lib/openssl/test/fixture/purpose/ca/PASSWD_OF_CA_KEY_IS_1234 +0 -0
  333. data/lib/openssl/test/fixture/purpose/ca/ca_config.rb +37 -0
  334. data/lib/openssl/test/fixture/purpose/ca/cacert.pem +24 -0
  335. data/lib/openssl/test/fixture/purpose/ca/newcerts/2_cert.pem +19 -0
  336. data/lib/openssl/test/fixture/purpose/ca/newcerts/3_cert.pem +19 -0
  337. data/lib/openssl/test/fixture/purpose/ca/private/cakeypair.pem +30 -0
  338. data/lib/openssl/test/fixture/purpose/ca/serial +1 -0
  339. data/lib/openssl/test/fixture/purpose/cacert.pem +24 -0
  340. data/lib/openssl/test/fixture/purpose/scripts/gen_cert.rb +127 -0
  341. data/lib/openssl/test/fixture/purpose/scripts/gen_csr.rb +50 -0
  342. data/lib/openssl/test/fixture/purpose/scripts/init_ca.rb +66 -0
  343. data/lib/openssl/test/fixture/purpose/sslclient.pem +19 -0
  344. data/lib/openssl/test/fixture/purpose/sslclient/csr.pem +10 -0
  345. data/lib/openssl/test/fixture/purpose/sslclient/keypair.pem +15 -0
  346. data/lib/openssl/test/fixture/purpose/sslclient/sslclient.pem +19 -0
  347. data/lib/openssl/test/fixture/purpose/sslserver.pem +19 -0
  348. data/lib/openssl/test/fixture/purpose/sslserver/csr.pem +10 -0
  349. data/lib/openssl/test/fixture/purpose/sslserver/keypair.pem +15 -0
  350. data/lib/openssl/test/fixture/purpose/sslserver/sslserver.pem +19 -0
  351. data/lib/openssl/test/fixture/verisign.pem +19 -0
  352. data/lib/openssl/test/fixture/verisign_c3.pem +14 -0
  353. data/lib/openssl/test/openssl/ssl_server.rb +99 -0
  354. data/lib/openssl/test/openssl/test_asn1.rb +199 -0
  355. data/lib/openssl/test/openssl/test_cipher.rb +196 -0
  356. data/lib/openssl/test/openssl/test_digest.rb +88 -0
  357. data/lib/openssl/test/openssl/test_hmac.rb +44 -0
  358. data/lib/openssl/test/openssl/test_ns_spki.rb +69 -0
  359. data/lib/openssl/test/openssl/test_pair.rb +149 -0
  360. data/lib/openssl/test/openssl/test_pkcs7.rb +160 -0
  361. data/lib/openssl/test/openssl/test_pkey_rsa.rb +49 -0
  362. data/lib/openssl/test/openssl/test_ssl.rb +413 -0
  363. data/lib/openssl/test/openssl/test_x509cert.rb +236 -0
  364. data/lib/openssl/test/openssl/test_x509crl.rb +234 -0
  365. data/lib/openssl/test/openssl/test_x509ext.rb +95 -0
  366. data/lib/openssl/test/openssl/test_x509name.rb +281 -0
  367. data/lib/openssl/test/openssl/test_x509req.rb +178 -0
  368. data/lib/openssl/test/openssl/test_x509store.rb +245 -0
  369. data/lib/openssl/test/openssl/utils.rb +135 -0
  370. data/lib/openssl/test/pkcs7_mime_enveloped.message +19 -0
  371. data/lib/openssl/test/pkcs7_mime_signed.message +30 -0
  372. data/lib/openssl/test/pkcs7_multipart_signed.message +45 -0
  373. data/lib/openssl/test/ref/compile.rb +8 -0
  374. data/lib/openssl/test/ref/pkcs1 +0 -0
  375. data/lib/openssl/test/ref/pkcs1.c +21 -0
  376. data/lib/openssl/test/test_cipher.rb +95 -0
  377. data/lib/openssl/test/test_integration.rb +139 -0
  378. data/lib/openssl/test/test_java.rb +98 -0
  379. data/lib/openssl/test/test_java_attribute.rb +25 -0
  380. data/lib/openssl/test/test_java_bio.rb +42 -0
  381. data/lib/openssl/test/test_java_mime.rb +173 -0
  382. data/lib/openssl/test/test_java_pkcs7.rb +769 -0
  383. data/lib/openssl/test/test_java_smime.rb +177 -0
  384. data/lib/openssl/test/test_openssl.rb +34 -0
  385. data/lib/openssl/test/test_openssl_x509.rb +34 -0
  386. data/lib/openssl/test/test_parse_certificate.rb +20 -0
  387. data/lib/openssl/test/test_pkey.rb +46 -0
  388. data/lib/openssl/test/test_x509store.rb +155 -0
  389. data/lib/openssl/test/ut_eof.rb +128 -0
  390. data/lib/redcar.rb +134 -8
  391. data/lib/redcar/installer.rb +46 -11
  392. data/lib/redcar/runner.rb +2 -1
  393. data/lib/redcar/usage.rb +12 -5
  394. data/lib/redcar_quick_start.rb +37 -0
  395. data/plugins/application/features/support/env.rb +9 -1
  396. data/plugins/application/icons/redcar_icon_beta.png +0 -0
  397. data/plugins/application/lib/application.rb +113 -43
  398. data/plugins/application/lib/application/clipboard.rb +28 -4
  399. data/plugins/application/lib/application/command.rb +4 -12
  400. data/plugins/application/lib/application/command/executor.rb +2 -2
  401. data/plugins/application/lib/application/keymap.rb +39 -0
  402. data/plugins/application/lib/application/keymap/builder.rb +19 -0
  403. data/plugins/application/lib/application/speedbar.rb +33 -24
  404. data/plugins/application/lib/application/tab.rb +15 -0
  405. data/plugins/application/lib/application/window.rb +28 -5
  406. data/plugins/application/spec/application/clipboard_spec.rb +20 -1
  407. data/plugins/application/spec/application/command/executor_spec.rb +7 -2
  408. data/plugins/application/spec/application/command_spec.rb +0 -5
  409. data/plugins/application/spec/application/keymap/builder_spec.rb +17 -0
  410. data/plugins/application/spec/application/menu_spec.rb +30 -0
  411. data/plugins/application/spec/application/speedbar_spec.rb +30 -6
  412. data/plugins/application/spec/application/window_spec.rb +2 -2
  413. data/plugins/application/spec/spec_helper.rb +1 -1
  414. data/plugins/application_swt/lib/application_swt.rb +3 -0
  415. data/plugins/application_swt/lib/application_swt/dialogs/filter_list_dialog_controller.rb +10 -1
  416. data/plugins/application_swt/lib/application_swt/html_tab.rb +1 -0
  417. data/plugins/application_swt/lib/application_swt/menu.rb +4 -3
  418. data/plugins/application_swt/lib/application_swt/menu/binding_translator.rb +12 -4
  419. data/plugins/application_swt/lib/application_swt/speedbar.rb +105 -19
  420. data/plugins/application_swt/lib/application_swt/swt_wrapper.rb +2 -0
  421. data/plugins/application_swt/lib/application_swt/window.rb +55 -23
  422. data/plugins/application_swt/spec/spec_helper.rb +0 -1
  423. data/plugins/auto_completer/lib/auto_completer.rb +57 -3
  424. data/plugins/auto_indenter/lib/auto_indenter.rb +1 -1
  425. data/plugins/core/lib/core.rb +5 -3
  426. data/plugins/core/lib/core/interface.rb +73 -0
  427. data/plugins/core/lib/core/model.rb +2 -0
  428. data/plugins/core/lib/core/observable.rb +12 -1
  429. data/plugins/core/lib/core/observable_struct.rb +34 -0
  430. data/plugins/core/lib/core/plugin/storage.rb +16 -3
  431. data/plugins/core/lib/core/reentry_helpers.rb +13 -0
  432. data/plugins/core/spec/core/observable_spec.rb +13 -0
  433. data/plugins/core/spec/core/storage_spec.rb +18 -0
  434. data/plugins/core/spec/spec_helper.rb +1 -0
  435. data/plugins/edit_view/features/cut_and_paste.feature +4 -2
  436. data/plugins/edit_view/features/soft_tabs.feature +243 -0
  437. data/plugins/edit_view/features/step_definitions/editing_steps.rb +91 -2
  438. data/plugins/edit_view/features/step_definitions/tab_steps.rb +1 -1
  439. data/plugins/edit_view/features/tabs.feature +146 -0
  440. data/plugins/edit_view/lib/edit_view.rb +197 -8
  441. data/plugins/edit_view/lib/edit_view/actions/arrow_keys.rb +121 -0
  442. data/plugins/edit_view/lib/edit_view/actions/deletion.rb +30 -0
  443. data/plugins/edit_view/lib/edit_view/actions/tab.rb +66 -0
  444. data/plugins/edit_view/lib/edit_view/command.rb +0 -2
  445. data/plugins/edit_view/lib/edit_view/document.rb +62 -27
  446. data/plugins/edit_view/lib/edit_view/document/command.rb +11 -0
  447. data/plugins/edit_view/lib/edit_view/edit_tab.rb +2 -1
  448. data/plugins/edit_view/lib/edit_view/info_speedbar.rb +69 -0
  449. data/plugins/edit_view/lib/edit_view/tab_settings.rb +40 -0
  450. data/plugins/edit_view/spec/edit_view/document_spec.rb +26 -0
  451. data/plugins/edit_view/spec/spec_helper.rb +0 -1
  452. data/plugins/edit_view_swt/lib/edit_view_swt.rb +57 -69
  453. data/plugins/edit_view_swt/lib/edit_view_swt/document.rb +24 -3
  454. data/plugins/edit_view_swt/lib/edit_view_swt/edit_tab.rb +23 -6
  455. data/plugins/edit_view_swt/spec/spec_helper.rb +0 -1
  456. data/plugins/edit_view_swt/vendor/java-mateview.rb +19 -2
  457. data/plugins/encryption/encryption.rb +38 -0
  458. data/plugins/encryption/ezcrypto.rb +652 -0
  459. data/plugins/encryption/jarmor-1.1.jar +0 -0
  460. data/plugins/encryption/plugin.rb +9 -0
  461. data/plugins/execute_current_tab/lib/execute_current_tab.rb +56 -0
  462. data/plugins/execute_current_tab/plugin.rb +8 -0
  463. data/plugins/html_view/lib/html_view.rb +16 -11
  464. data/plugins/plugin_manager_ui/lib/plugin_manager_ui.rb +2 -1
  465. data/plugins/plugin_manager_ui/views/index.html.erb +22 -4
  466. data/plugins/project/lib/project.rb +140 -26
  467. data/plugins/project/lib/project/drb_service.rb +75 -0
  468. data/plugins/project/lib/project/file_mirror.rb +5 -5
  469. data/plugins/project/lib/project/find_file_dialog.rb +123 -32
  470. data/plugins/project/spec/project/file_mirror_spec.rb +10 -1
  471. data/plugins/project/spec/spec_helper.rb +0 -1
  472. data/plugins/redcar/plugin.rb +1 -1
  473. data/plugins/redcar/redcar.rb +204 -109
  474. data/plugins/redcar/spec/redcar/redcar_spec.rb +70 -0
  475. data/plugins/redcar/spec/spec_helper.rb +4 -0
  476. data/plugins/repl/lib/repl.rb +14 -7
  477. data/plugins/repl/lib/repl/internal_mirror.rb +43 -22
  478. data/plugins/repl/spec/repl/internal_mirror_spec.rb +34 -7
  479. data/plugins/repl/spec/spec_helper.rb +0 -1
  480. data/plugins/tree/spec/spec_helper.rb +0 -1
  481. data/plugins/tree_view_swt/lib/tree_view_swt.rb +1 -1
  482. data/textmate/Bundles/RedcarRepl.tmbundle/Syntaxes/InternalRuby.plist +2 -18
  483. data/textmate/Bundles/asciidoc.tmbundle/Syntaxes/AsciiDoc.tmLanguage +428 -0
  484. metadata +790 -371
  485. data/lib/redcar/boot.rb +0 -108
@@ -0,0 +1,345 @@
1
+ /***** BEGIN LICENSE BLOCK *****
2
+ * Version: CPL 1.0/GPL 2.0/LGPL 2.1
3
+ *
4
+ * The contents of this file are subject to the Common Public
5
+ * License Version 1.0 (the "License"); you may not use this file
6
+ * except in compliance with the License. You may obtain a copy of
7
+ * the License at http://www.eclipse.org/legal/cpl-v10.html
8
+ *
9
+ * Software distributed under the License is distributed on an "AS
10
+ * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
11
+ * implied. See the License for the specific language governing
12
+ * rights and limitations under the License.
13
+ *
14
+ * Copyright (C) 2008 Ola Bini <ola.bini@gmail.com>
15
+ *
16
+ * Alternatively, the contents of this file may be used under the terms of
17
+ * either of the GNU General Public License Version 2 or later (the "GPL"),
18
+ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
19
+ * in which case the provisions of the GPL or the LGPL are applicable instead
20
+ * of those above. If you wish to allow use of your version of this file only
21
+ * under the terms of either the GPL or the LGPL, and not to allow others to
22
+ * use your version of this file under the terms of the CPL, indicate your
23
+ * decision by deleting the provisions above and replace them with the notice
24
+ * and other provisions required by the GPL or the LGPL. If you do not delete
25
+ * the provisions above, a recipient may use your version of this file under
26
+ * the terms of any one of the CPL, the GPL or the LGPL.
27
+ ***** END LICENSE BLOCK *****/
28
+ package org.jruby.ext.openssl.impl;
29
+
30
+ import java.io.ByteArrayInputStream;
31
+ import java.security.cert.CertificateParsingException;
32
+ import java.security.cert.X509CRL;
33
+ import java.util.ArrayList;
34
+ import java.util.Collection;
35
+ import java.util.Enumeration;
36
+ import java.util.HashSet;
37
+ import java.util.List;
38
+ import java.util.Set;
39
+ import org.bouncycastle.asn1.ASN1Encodable;
40
+ import org.bouncycastle.asn1.ASN1EncodableVector;
41
+ import org.bouncycastle.asn1.ASN1InputStream;
42
+ import org.bouncycastle.asn1.ASN1Sequence;
43
+ import org.bouncycastle.asn1.ASN1Set;
44
+ import org.bouncycastle.asn1.DEREncodable;
45
+ import org.bouncycastle.asn1.DERInteger;
46
+ import org.bouncycastle.asn1.DERObjectIdentifier;
47
+ import org.bouncycastle.asn1.DERSequence;
48
+ import org.bouncycastle.asn1.DERSet;
49
+ import org.bouncycastle.asn1.DERTaggedObject;
50
+ import org.bouncycastle.asn1.pkcs.SignerInfo;
51
+ import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
52
+ import org.bouncycastle.asn1.x509.X509CertificateStructure;
53
+ import org.bouncycastle.jce.provider.X509CertificateObject;
54
+ import org.jruby.ext.openssl.x509store.X509AuxCertificate;
55
+
56
+ /** PKCS7_SIGNED
57
+ *
58
+ * @author <a href="mailto:ola.bini@gmail.com">Ola Bini</a>
59
+ */
60
+ public class Signed {
61
+ /**
62
+ * Describe version here.
63
+ */
64
+ private int version;
65
+
66
+ /**
67
+ * Describe crl here.
68
+ */
69
+ private Collection<X509CRL> crl = new ArrayList<X509CRL>();
70
+
71
+ /**
72
+ * Describe cert here.
73
+ */
74
+ private Collection<X509AuxCertificate> cert = new ArrayList<X509AuxCertificate>();
75
+
76
+ /**
77
+ * Describe mdAlgs here.
78
+ */
79
+ private Set<AlgorithmIdentifier> mdAlgs = new HashSet<AlgorithmIdentifier>();
80
+
81
+ /**
82
+ * Describe signerInfo here.
83
+ */
84
+ private Collection<SignerInfoWithPkey> signerInfo = new ArrayList<SignerInfoWithPkey>();
85
+
86
+ PKCS7 contents;
87
+
88
+ /**
89
+ * Get the <code>Version</code> value.
90
+ *
91
+ * @return an <code>int</code> value
92
+ */
93
+ public final int getVersion() {
94
+ return version;
95
+ }
96
+
97
+ /**
98
+ * Set the <code>Version</code> value.
99
+ *
100
+ * @param newVersion The new Version value.
101
+ */
102
+ public final void setVersion(final int newVersion) {
103
+ this.version = newVersion;
104
+ }
105
+
106
+ /**
107
+ * Get the <code>SignerInfo</code> value.
108
+ *
109
+ * @return a <code>Collection<SignerInfoWithPkey></code> value
110
+ */
111
+ public final Collection<SignerInfoWithPkey> getSignerInfo() {
112
+ return signerInfo;
113
+ }
114
+
115
+ /**
116
+ * Set the <code>SignerInfo</code> value.
117
+ *
118
+ * @param newSignerInfo The new SignerInfo value.
119
+ */
120
+ public final void setSignerInfo(final Collection<SignerInfoWithPkey> newSignerInfo) {
121
+ this.signerInfo = newSignerInfo;
122
+ }
123
+
124
+ /**
125
+ * Get the <code>MdAlgs</code> value.
126
+ *
127
+ * @return a <code>Set<AlgorithmIdentifier></code> value
128
+ */
129
+ public final Set<AlgorithmIdentifier> getMdAlgs() {
130
+ return mdAlgs;
131
+ }
132
+
133
+ /**
134
+ * Set the <code>MdAlgs</code> value.
135
+ *
136
+ * @param newMdAlgs The new MdAlgs value.
137
+ */
138
+ public final void setMdAlgs(final Set<AlgorithmIdentifier> newMdAlgs) {
139
+ this.mdAlgs = newMdAlgs;
140
+ }
141
+
142
+ /**
143
+ * Get the <code>Contents</code> value.
144
+ *
145
+ * @return a <code>PKCS7</code> value
146
+ */
147
+ public final PKCS7 getContents() {
148
+ return contents;
149
+ }
150
+
151
+ /**
152
+ * Set the <code>Contents</code> value.
153
+ *
154
+ * @param newContents The new Contents value.
155
+ */
156
+ public final void setContents(final PKCS7 newContents) {
157
+ this.contents = newContents;
158
+ }
159
+
160
+ /**
161
+ * Get the <code>Cert</code> value.
162
+ *
163
+ * @return a <code>Collection<X509AuxCertificate></code> value
164
+ */
165
+ public final Collection<X509AuxCertificate> getCert() {
166
+ return cert;
167
+ }
168
+
169
+ /**
170
+ * Set the <code>Cert</code> value.
171
+ *
172
+ * @param newCert The new Cert value.
173
+ */
174
+ public final void setCert(final Collection<X509AuxCertificate> newCert) {
175
+ this.cert = newCert;
176
+ }
177
+
178
+ /**
179
+ * Get the <code>Crl</code> value.
180
+ *
181
+ * @return a <code>Set<X509CRL></code> value
182
+ */
183
+ public final Collection<X509CRL> getCrl() {
184
+ return crl;
185
+ }
186
+
187
+ /**
188
+ * Set the <code>Crl</code> value.
189
+ *
190
+ * @param newCrl The new Crl value.
191
+ */
192
+ public final void setCrl(final Collection<X509CRL> newCrl) {
193
+ this.crl = newCrl;
194
+ }
195
+
196
+ @Override
197
+ public String toString() {
198
+ return "#<Signed version=" + version + " mdAlgs="+mdAlgs+" content="+contents+" cert="+cert+" crls="+crl+" signerInfos="+signerInfo+">";
199
+ }
200
+
201
+ public ASN1Encodable asASN1() {
202
+ ASN1EncodableVector vector = new ASN1EncodableVector();
203
+ vector.add(new DERInteger(version));
204
+ vector.add(digestAlgorithmsToASN1Set());
205
+ vector.add(contents.asASN1());
206
+ if(cert != null && cert.size() > 0) {
207
+ vector.add(new DERTaggedObject(0, certificatesToASN1Set()));
208
+ }
209
+ if(crl != null && crl.size() > 0) {
210
+ vector.add(new DERTaggedObject(1, crlsToASN1Set()));
211
+ }
212
+ vector.add(signerInfosToASN1Set());
213
+ return new DERSequence(vector);
214
+ }
215
+
216
+ private ASN1Set digestAlgorithmsToASN1Set() {
217
+ ASN1EncodableVector vector = new ASN1EncodableVector();
218
+ for(AlgorithmIdentifier ai : mdAlgs) {
219
+ vector.add(ai.toASN1Object());
220
+ }
221
+ return new DERSet(vector);
222
+ }
223
+
224
+ // This imlementation is stupid and wasteful. Ouch.
225
+ private ASN1Set certificatesToASN1Set() {
226
+ try {
227
+ ASN1EncodableVector vector = new ASN1EncodableVector();
228
+ for(X509AuxCertificate c : cert) {
229
+ vector.add(new ASN1InputStream(new ByteArrayInputStream(c.getEncoded())).readObject());
230
+ }
231
+ return new DERSet(vector);
232
+ } catch(Exception e) {
233
+ return null;
234
+ }
235
+ }
236
+
237
+ private ASN1Set crlsToASN1Set() {
238
+ throw new RuntimeException("TODO: implement CRL part");
239
+ }
240
+
241
+ private ASN1Set signerInfosToASN1Set() {
242
+ ASN1EncodableVector vector = new ASN1EncodableVector();
243
+ for(SignerInfoWithPkey si : signerInfo) {
244
+ vector.add(si.toASN1Object());
245
+ }
246
+ return new DERSet(vector);
247
+ }
248
+
249
+ /**
250
+ * SignedData ::= SEQUENCE {
251
+ * version Version,
252
+ * digestAlgorithms DigestAlgorithmIdentifiers,
253
+ * contentInfo ContentInfo,
254
+ * certificates [0] IMPLICIT ExtendedCertificatesAndCertificates OPTIONAL,
255
+ * crls [1] IMPLICIT CertificateRevocationLists OPTIONAL,
256
+ * signerInfos SignerInfos }
257
+ *
258
+ * Version ::= INTEGER
259
+ *
260
+ * DigestAlgorithmIdentifiers ::= SET OF DigestAlgorithmIdentifier
261
+ *
262
+ * SignerInfos ::= SET OF SignerInfo
263
+ */
264
+ public static Signed fromASN1(DEREncodable content) {
265
+ ASN1Sequence sequence = (ASN1Sequence)content;
266
+ DERInteger version = (DERInteger)sequence.getObjectAt(0);
267
+ ASN1Set digestAlgos = (ASN1Set)sequence.getObjectAt(1);
268
+ DEREncodable contentInfo = sequence.getObjectAt(2);
269
+
270
+ DEREncodable certificates = null;
271
+ DEREncodable crls = null;
272
+
273
+ int index = 3;
274
+ DEREncodable tmp = sequence.getObjectAt(index);
275
+ if((tmp instanceof DERTaggedObject) && ((DERTaggedObject)tmp).getTagNo() == 0) {
276
+ certificates = ((DERTaggedObject)tmp).getObject();
277
+ index++;
278
+ }
279
+
280
+ tmp = sequence.getObjectAt(index);
281
+ if((tmp instanceof DERTaggedObject) && ((DERTaggedObject)tmp).getTagNo() == 1) {
282
+ crls = ((DERTaggedObject)tmp).getObject();
283
+ index++;
284
+ }
285
+
286
+ ASN1Set signerInfos = (ASN1Set)sequence.getObjectAt(index);
287
+
288
+ Signed signed = new Signed();
289
+ signed.setVersion(version.getValue().intValue());
290
+ signed.setMdAlgs(algorithmIdentifiersFromASN1Set(digestAlgos));
291
+ signed.setContents(PKCS7.fromASN1(contentInfo));
292
+ if(certificates != null) {
293
+ signed.setCert(certificatesFromASN1Set(certificates));
294
+ }
295
+ if(crls != null) {
296
+ throw new RuntimeException("TODO: implement CRL part");
297
+ }
298
+ signed.setSignerInfo(signerInfosFromASN1Set(signerInfos));
299
+
300
+ return signed;
301
+ }
302
+
303
+ private static Collection<X509AuxCertificate> certificatesFromASN1Set(DEREncodable content) {
304
+ Collection<X509AuxCertificate> result = new ArrayList<X509AuxCertificate>();
305
+ if(content instanceof DERSet) {
306
+ for(Enumeration<?> enm = ((DERSet)content).getObjects(); enm.hasMoreElements(); ) {
307
+ DEREncodable current = (DEREncodable)enm.nextElement();
308
+ X509CertificateStructure struct = X509CertificateStructure.getInstance(current);
309
+ try {
310
+ result.add(new X509AuxCertificate(new X509CertificateObject(struct)));
311
+ } catch(CertificateParsingException ex) {
312
+ throw new PKCS7Exception(PKCS7.F_B64_READ_PKCS7, PKCS7.R_CERTIFICATE_VERIFY_ERROR, "exception: " + ex);
313
+ }
314
+ }
315
+ } else {
316
+ X509CertificateStructure struct = X509CertificateStructure.getInstance(content);
317
+ try {
318
+ result.add(new X509AuxCertificate(new X509CertificateObject(struct)));
319
+ } catch(CertificateParsingException ex) {
320
+ throw new PKCS7Exception(PKCS7.F_B64_READ_PKCS7, PKCS7.R_CERTIFICATE_VERIFY_ERROR, "exception: " + ex);
321
+ }
322
+ }
323
+
324
+
325
+ return result;
326
+ }
327
+
328
+ private static Set<AlgorithmIdentifier> algorithmIdentifiersFromASN1Set(DEREncodable content) {
329
+ ASN1Set set = (ASN1Set)content;
330
+ Set<AlgorithmIdentifier> result = new HashSet<AlgorithmIdentifier>();
331
+ for(Enumeration<?> e = set.getObjects(); e.hasMoreElements();) {
332
+ result.add(AlgorithmIdentifier.getInstance(e.nextElement()));
333
+ }
334
+ return result;
335
+ }
336
+
337
+ private static Collection<SignerInfoWithPkey> signerInfosFromASN1Set(DEREncodable content) {
338
+ ASN1Set set = (ASN1Set)content;
339
+ Collection<SignerInfoWithPkey> result = new ArrayList<SignerInfoWithPkey>();
340
+ for(Enumeration<?> e = set.getObjects(); e.hasMoreElements();) {
341
+ result.add(SignerInfoWithPkey.getInstance(e.nextElement()));
342
+ }
343
+ return result;
344
+ }
345
+ }// Signed
@@ -0,0 +1,365 @@
1
+ /***** BEGIN LICENSE BLOCK *****
2
+ * Version: CPL 1.0/GPL 2.0/LGPL 2.1
3
+ *
4
+ * The contents of this file are subject to the Common Public
5
+ * License Version 1.0 (the "License"); you may not use this file
6
+ * except in compliance with the License. You may obtain a copy of
7
+ * the License at http://www.eclipse.org/legal/cpl-v10.html
8
+ *
9
+ * Software distributed under the License is distributed on an "AS
10
+ * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
11
+ * implied. See the License for the specific language governing
12
+ * rights and limitations under the License.
13
+ *
14
+ * Copyright (C) 2008 Ola Bini <ola.bini@gmail.com>
15
+ *
16
+ * Alternatively, the contents of this file may be used under the terms of
17
+ * either of the GNU General Public License Version 2 or later (the "GPL"),
18
+ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
19
+ * in which case the provisions of the GPL or the LGPL are applicable instead
20
+ * of those above. If you wish to allow use of your version of this file only
21
+ * under the terms of either the GPL or the LGPL, and not to allow others to
22
+ * use your version of this file under the terms of the CPL, indicate your
23
+ * decision by deleting the provisions above and replace them with the notice
24
+ * and other provisions required by the GPL or the LGPL. If you do not delete
25
+ * the provisions above, a recipient may use your version of this file under
26
+ * the terms of any one of the CPL, the GPL or the LGPL.
27
+ ***** END LICENSE BLOCK *****/
28
+ package org.jruby.ext.openssl.impl;
29
+
30
+ import java.io.ByteArrayInputStream;
31
+ import java.io.IOException;
32
+ import java.math.BigInteger;
33
+ import java.security.MessageDigest;
34
+ import java.security.PrivateKey;
35
+ import java.security.interfaces.DSAPrivateKey;
36
+ import java.security.interfaces.ECPrivateKey;
37
+ import java.security.interfaces.RSAPrivateKey;
38
+ import java.util.Enumeration;
39
+ import org.bouncycastle.asn1.ASN1Encodable;
40
+ import org.bouncycastle.asn1.ASN1EncodableVector;
41
+ import org.bouncycastle.asn1.ASN1InputStream;
42
+ import org.bouncycastle.asn1.ASN1OctetString;
43
+ import org.bouncycastle.asn1.ASN1Sequence;
44
+ import org.bouncycastle.asn1.ASN1Set;
45
+ import org.bouncycastle.asn1.ASN1TaggedObject;
46
+ import org.bouncycastle.asn1.DEREncodable;
47
+ import org.bouncycastle.asn1.DERInteger;
48
+ import org.bouncycastle.asn1.DERObject;
49
+ import org.bouncycastle.asn1.DERObjectIdentifier;
50
+ import org.bouncycastle.asn1.DEROctetString;
51
+ import org.bouncycastle.asn1.DERSequence;
52
+ import org.bouncycastle.asn1.DERSet;
53
+ import org.bouncycastle.asn1.DERTaggedObject;
54
+ import org.bouncycastle.asn1.pkcs.Attribute;
55
+ import org.bouncycastle.asn1.pkcs.IssuerAndSerialNumber;
56
+ import org.bouncycastle.asn1.pkcs.SignerInfo;
57
+ import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
58
+ import org.bouncycastle.asn1.x509.X509Name;
59
+ import org.jruby.ext.openssl.x509store.X509AuxCertificate;
60
+
61
+ /**
62
+ *
63
+ * @author <a href="mailto:ola.bini@gmail.com">Ola Bini</a>
64
+ */
65
+ public class SignerInfoWithPkey extends ASN1Encodable {
66
+ private DERInteger version;
67
+ private IssuerAndSerialNumber issuerAndSerialNumber;
68
+ private AlgorithmIdentifier digAlgorithm;
69
+ private ASN1Set authenticatedAttributes;
70
+ private AlgorithmIdentifier digEncryptionAlgorithm;
71
+ private ASN1OctetString encryptedDigest;
72
+ private ASN1Set unauthenticatedAttributes;
73
+
74
+ public static SignerInfoWithPkey getInstance(Object o) {
75
+ if(o instanceof SignerInfo) {
76
+ return (SignerInfoWithPkey)o;
77
+ } else if (o instanceof ASN1Sequence) {
78
+ return new SignerInfoWithPkey((ASN1Sequence)o);
79
+ }
80
+
81
+ throw new IllegalArgumentException("unknown object in factory: " + o.getClass().getName());
82
+ }
83
+
84
+ public SignerInfoWithPkey dup() {
85
+ SignerInfoWithPkey copy = new SignerInfoWithPkey(version,
86
+ issuerAndSerialNumber,
87
+ digAlgorithm,
88
+ authenticatedAttributes,
89
+ digEncryptionAlgorithm,
90
+ encryptedDigest,
91
+ unauthenticatedAttributes);
92
+ copy.pkey = pkey;
93
+ return copy;
94
+ }
95
+
96
+ SignerInfoWithPkey() {
97
+ }
98
+
99
+ public SignerInfoWithPkey(DERInteger version,
100
+ IssuerAndSerialNumber issuerAndSerialNumber,
101
+ AlgorithmIdentifier digAlgorithm,
102
+ ASN1Set authenticatedAttributes,
103
+ AlgorithmIdentifier digEncryptionAlgorithm,
104
+ ASN1OctetString encryptedDigest,
105
+ ASN1Set unauthenticatedAttributes) {
106
+ this.version = version;
107
+ this.issuerAndSerialNumber = issuerAndSerialNumber;
108
+ this.digAlgorithm = digAlgorithm;
109
+ this.authenticatedAttributes = authenticatedAttributes;
110
+ this.digEncryptionAlgorithm = digEncryptionAlgorithm;
111
+ this.encryptedDigest = encryptedDigest;
112
+ this.unauthenticatedAttributes = unauthenticatedAttributes;
113
+ }
114
+
115
+ public SignerInfoWithPkey(ASN1Sequence seq) {
116
+ Enumeration e = seq.getObjects();
117
+
118
+ version = (DERInteger)e.nextElement();
119
+ issuerAndSerialNumber = IssuerAndSerialNumber.getInstance(e.nextElement());
120
+ digAlgorithm = AlgorithmIdentifier.getInstance(e.nextElement());
121
+
122
+ Object obj = e.nextElement();
123
+
124
+ if(obj instanceof ASN1TaggedObject) {
125
+ authenticatedAttributes = ASN1Set.getInstance((ASN1TaggedObject)obj, false);
126
+
127
+ digEncryptionAlgorithm = AlgorithmIdentifier.getInstance(e.nextElement());
128
+ }
129
+ else {
130
+ authenticatedAttributes = null;
131
+ digEncryptionAlgorithm = AlgorithmIdentifier.getInstance(obj);
132
+ }
133
+
134
+ encryptedDigest = DEROctetString.getInstance(e.nextElement());
135
+
136
+ if(e.hasMoreElements()) {
137
+ unauthenticatedAttributes = ASN1Set.getInstance((ASN1TaggedObject)e.nextElement(), false);
138
+ }
139
+ else {
140
+ unauthenticatedAttributes = null;
141
+ }
142
+ }
143
+
144
+ public DERInteger getVersion() {
145
+ return version;
146
+ }
147
+
148
+ public IssuerAndSerialNumber getIssuerAndSerialNumber() {
149
+ return issuerAndSerialNumber;
150
+ }
151
+
152
+ public ASN1Set getAuthenticatedAttributes() {
153
+ return authenticatedAttributes;
154
+ }
155
+
156
+ public AlgorithmIdentifier getDigestAlgorithm() {
157
+ return digAlgorithm;
158
+ }
159
+
160
+ public ASN1OctetString getEncryptedDigest() {
161
+ return encryptedDigest;
162
+ }
163
+
164
+ public AlgorithmIdentifier getDigestEncryptionAlgorithm() {
165
+ return digEncryptionAlgorithm;
166
+ }
167
+
168
+ public ASN1Set getUnauthenticatedAttributes() {
169
+ return unauthenticatedAttributes;
170
+ }
171
+
172
+ /* c: PKCS7_SIGNER_INFO_set
173
+ *
174
+ */
175
+ public void set(X509AuxCertificate x509, PrivateKey pkey, MessageDigest dgst) {
176
+ boolean dsa =
177
+ (pkey instanceof DSAPrivateKey) ||
178
+ (pkey instanceof ECPrivateKey);
179
+
180
+ version = new DERInteger(1);
181
+
182
+ try {
183
+ X509Name issuer = X509Name.getInstance(new ASN1InputStream(new ByteArrayInputStream(x509.getIssuerX500Principal().getEncoded())).readObject());
184
+ BigInteger serial = x509.getSerialNumber();
185
+ issuerAndSerialNumber = new IssuerAndSerialNumber(issuer, serial);
186
+ } catch(IOException e) {
187
+ throw new PKCS7Exception(-1, -1);
188
+ }
189
+
190
+ this.pkey = pkey;
191
+
192
+ if(dsa) {
193
+ digAlgorithm = new AlgorithmIdentifier(ASN1Registry.nid2obj(ASN1Registry.NID_sha1));
194
+ } else {
195
+ digAlgorithm = new AlgorithmIdentifier(ASN1Registry.nid2obj(EVP.type(dgst)));
196
+ }
197
+
198
+ if(pkey instanceof RSAPrivateKey) {
199
+ digEncryptionAlgorithm = new AlgorithmIdentifier(ASN1Registry.nid2obj(ASN1Registry.NID_rsaEncryption));
200
+ } else if(pkey instanceof DSAPrivateKey) {
201
+ digEncryptionAlgorithm = new AlgorithmIdentifier(ASN1Registry.nid2obj(ASN1Registry.NID_dsa));
202
+ } else if(pkey instanceof ECPrivateKey) {
203
+ digEncryptionAlgorithm = new AlgorithmIdentifier(ASN1Registry.nid2obj(ASN1Registry.NID_ecdsa_with_SHA1));
204
+ }
205
+ }
206
+
207
+ /**
208
+ * Produce an object suitable for an ASN1OutputStream.
209
+ * <pre>
210
+ * SignerInfo ::= SEQUENCE {
211
+ * version Version,
212
+ * issuerAndSerialNumber IssuerAndSerialNumber,
213
+ * digestAlgorithm DigestAlgorithmIdentifier,
214
+ * authenticatedAttributes [0] IMPLICIT Attributes OPTIONAL,
215
+ * digestEncryptionAlgorithm DigestEncryptionAlgorithmIdentifier,
216
+ * encryptedDigest EncryptedDigest,
217
+ * unauthenticatedAttributes [1] IMPLICIT Attributes OPTIONAL
218
+ * }
219
+ *
220
+ * EncryptedDigest ::= OCTET STRING
221
+ *
222
+ * DigestAlgorithmIdentifier ::= AlgorithmIdentifier
223
+ *
224
+ * DigestEncryptionAlgorithmIdentifier ::= AlgorithmIdentifier
225
+ * </pre>
226
+ */
227
+ public DERObject toASN1Object() {
228
+ ASN1EncodableVector v = new ASN1EncodableVector();
229
+
230
+ v.add(version);
231
+ v.add(issuerAndSerialNumber);
232
+ v.add(digAlgorithm);
233
+
234
+ if (authenticatedAttributes != null) {
235
+ v.add(new DERTaggedObject(false, 0, authenticatedAttributes));
236
+ }
237
+
238
+ v.add(digEncryptionAlgorithm);
239
+ v.add(encryptedDigest);
240
+
241
+ if (unauthenticatedAttributes != null) {
242
+ v.add(new DERTaggedObject(false, 1, unauthenticatedAttributes));
243
+ }
244
+
245
+ return new DERSequence(v);
246
+ }
247
+
248
+ /**
249
+ * Describe pkey here.
250
+ */
251
+ private PrivateKey pkey;
252
+
253
+ /**
254
+ * Get the <code>Pkey</code> value.
255
+ *
256
+ * @return a <code>PrivateKey</code> value
257
+ */
258
+ public final PrivateKey getPkey() {
259
+ return pkey;
260
+ }
261
+
262
+ /**
263
+ * Set the <code>Pkey</code> value.
264
+ *
265
+ * @param newPkey The new Pkey value.
266
+ */
267
+ public final void setPkey(final PrivateKey newPkey) {
268
+ this.pkey = newPkey;
269
+ }
270
+
271
+ public void setAuthenticatedAttributes(ASN1Set authAttr) {
272
+ this.authenticatedAttributes = authAttr;
273
+ }
274
+
275
+ public void setUnauthenticatedAttributes(ASN1Set unauthAttr) {
276
+ this.unauthenticatedAttributes = unauthAttr;
277
+ }
278
+
279
+ public void setEncryptedDigest(ASN1OctetString encryptedDigest) {
280
+ this.encryptedDigest = encryptedDigest;
281
+ }
282
+
283
+ /** c: PKCS7_get_signed_attribute
284
+ *
285
+ */
286
+ public DEREncodable getSignedAttribute(int nid) {
287
+ return getAttribute(this.authenticatedAttributes, nid);
288
+ }
289
+
290
+ /** c: PKCS7_get_attribute
291
+ *
292
+ */
293
+ public DEREncodable getAttribute(int nid) {
294
+ return getAttribute(this.unauthenticatedAttributes, nid);
295
+ }
296
+
297
+ /** c: static get_attribute
298
+ *
299
+ */
300
+ public static DEREncodable getAttribute(ASN1Set sk, int nid) {
301
+ Attribute xa = null;
302
+ DERObjectIdentifier o = ASN1Registry.nid2obj(nid);
303
+
304
+ if(null == o || null == sk) {
305
+ return null;
306
+ }
307
+
308
+ for(Enumeration e = sk.getObjects(); e.hasMoreElements();) {
309
+ Object val = e.nextElement();
310
+ if(val instanceof Attribute) {
311
+ xa = (Attribute)val;
312
+ } else {
313
+ xa = Attribute.getInstance(val);
314
+ }
315
+
316
+ if(o.equals(xa.getAttrType())) {
317
+ if(xa.getAttrValues().size() > 0) {
318
+ return xa.getAttrValues().getObjectAt(0);
319
+ } else {
320
+ return null;
321
+ }
322
+ }
323
+ }
324
+ return null;
325
+ }
326
+
327
+ /** c: PKCS7_add_signed_attribute
328
+ *
329
+ */
330
+ public void addSignedAttribute(int atrType, DEREncodable value) {
331
+ this.authenticatedAttributes = addAttribute(this.authenticatedAttributes, atrType, value);
332
+ }
333
+
334
+ /** c: PKCS7_add_attribute
335
+ *
336
+ */
337
+ public void addAttribute(int atrType, DEREncodable value) {
338
+ this.unauthenticatedAttributes = addAttribute(this.unauthenticatedAttributes, atrType, value);
339
+ }
340
+
341
+ /** c: static add_attribute
342
+ *
343
+ */
344
+ private ASN1Set addAttribute(ASN1Set base, int atrType, DEREncodable value) {
345
+ ASN1EncodableVector vector = new ASN1EncodableVector();
346
+ if(base == null) {
347
+ base = new DERSet();
348
+ }
349
+ Attribute attr = null;
350
+ for(Enumeration e = base.getObjects(); e.hasMoreElements();) {
351
+ Object val = e.nextElement();
352
+ if(val instanceof Attribute) {
353
+ attr = (Attribute)val;
354
+ } else {
355
+ attr = Attribute.getInstance(val);
356
+ }
357
+ if(ASN1Registry.obj2nid(attr.getAttrType()) != atrType) {
358
+ vector.add(attr);
359
+ }
360
+ }
361
+ attr = new Attribute(ASN1Registry.nid2obj(atrType), new DERSet(value));
362
+ vector.add(attr);
363
+ return new DERSet(vector);
364
+ }
365
+ }// SignerInfoWithPkey