redcar 0.3.2dev → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +49 -2
- data/README.md +2 -7
- data/ROADMAP.md +8 -9
- data/Rakefile +29 -44
- data/bin/redcar +11 -2
- data/lib/openssl/History.txt +75 -0
- data/lib/openssl/License.txt +30 -0
- data/lib/openssl/Manifest.txt +99 -0
- data/lib/openssl/README.txt +24 -0
- data/lib/openssl/Rakefile +71 -0
- data/lib/openssl/build.properties.SAMPLE +7 -0
- data/lib/openssl/build.xml +57 -0
- data/lib/openssl/lib/jopenssl/version.rb +5 -0
- data/lib/openssl/lib/openssl.rb +24 -0
- data/lib/openssl/lib/openssl/bn.rb +33 -0
- data/lib/openssl/lib/openssl/buffering.rb +239 -0
- data/lib/openssl/lib/openssl/cipher.rb +56 -0
- data/lib/openssl/lib/openssl/digest.rb +46 -0
- data/lib/openssl/lib/openssl/dummy.rb +34 -0
- data/lib/openssl/lib/openssl/dummyssl.rb +13 -0
- data/lib/openssl/lib/openssl/ssl.rb +135 -0
- data/lib/openssl/lib/openssl/x509.rb +154 -0
- data/lib/openssl/mocha/COPYING +3 -0
- data/lib/openssl/mocha/MIT-LICENSE +7 -0
- data/lib/openssl/mocha/README +35 -0
- data/lib/openssl/mocha/RELEASE +171 -0
- data/lib/openssl/mocha/Rakefile +147 -0
- data/lib/openssl/mocha/TODO +48 -0
- data/lib/openssl/mocha/examples/misc.rb +36 -0
- data/lib/openssl/mocha/examples/mocha.rb +26 -0
- data/lib/openssl/mocha/examples/stubba.rb +65 -0
- data/lib/openssl/mocha/init.rb +3 -0
- data/lib/openssl/mocha/lib/mocha.rb +19 -0
- data/lib/openssl/mocha/lib/mocha/any_instance_method.rb +35 -0
- data/lib/openssl/mocha/lib/mocha/auto_verify.rb +111 -0
- data/lib/openssl/mocha/lib/mocha/central.rb +35 -0
- data/lib/openssl/mocha/lib/mocha/class_method.rb +62 -0
- data/lib/openssl/mocha/lib/mocha/deprecation.rb +22 -0
- data/lib/openssl/mocha/lib/mocha/exception_raiser.rb +17 -0
- data/lib/openssl/mocha/lib/mocha/expectation.rb +382 -0
- data/lib/openssl/mocha/lib/mocha/expectation_error.rb +6 -0
- data/lib/openssl/mocha/lib/mocha/expectation_list.rb +45 -0
- data/lib/openssl/mocha/lib/mocha/infinite_range.rb +25 -0
- data/lib/openssl/mocha/lib/mocha/inspect.rb +39 -0
- data/lib/openssl/mocha/lib/mocha/instance_method.rb +8 -0
- data/lib/openssl/mocha/lib/mocha/is_a.rb +9 -0
- data/lib/openssl/mocha/lib/mocha/metaclass.rb +7 -0
- data/lib/openssl/mocha/lib/mocha/missing_expectation.rb +27 -0
- data/lib/openssl/mocha/lib/mocha/mock.rb +200 -0
- data/lib/openssl/mocha/lib/mocha/multiple_yields.rb +20 -0
- data/lib/openssl/mocha/lib/mocha/no_yields.rb +11 -0
- data/lib/openssl/mocha/lib/mocha/object.rb +110 -0
- data/lib/openssl/mocha/lib/mocha/parameter_matchers.rb +9 -0
- data/lib/openssl/mocha/lib/mocha/parameter_matchers/all_of.rb +39 -0
- data/lib/openssl/mocha/lib/mocha/parameter_matchers/any_of.rb +44 -0
- data/lib/openssl/mocha/lib/mocha/parameter_matchers/anything.rb +30 -0
- data/lib/openssl/mocha/lib/mocha/parameter_matchers/has_entry.rb +39 -0
- data/lib/openssl/mocha/lib/mocha/parameter_matchers/has_key.rb +39 -0
- data/lib/openssl/mocha/lib/mocha/parameter_matchers/has_value.rb +39 -0
- data/lib/openssl/mocha/lib/mocha/parameter_matchers/includes.rb +37 -0
- data/lib/openssl/mocha/lib/mocha/parameter_matchers/instance_of.rb +39 -0
- data/lib/openssl/mocha/lib/mocha/parameter_matchers/kind_of.rb +39 -0
- data/lib/openssl/mocha/lib/mocha/pretty_parameters.rb +28 -0
- data/lib/openssl/mocha/lib/mocha/return_values.rb +31 -0
- data/lib/openssl/mocha/lib/mocha/setup_and_teardown.rb +23 -0
- data/lib/openssl/mocha/lib/mocha/single_return_value.rb +24 -0
- data/lib/openssl/mocha/lib/mocha/single_yield.rb +18 -0
- data/lib/openssl/mocha/lib/mocha/standalone.rb +32 -0
- data/lib/openssl/mocha/lib/mocha/stub.rb +18 -0
- data/lib/openssl/mocha/lib/mocha/test_case_adapter.rb +49 -0
- data/lib/openssl/mocha/lib/mocha/yield_parameters.rb +31 -0
- data/lib/openssl/mocha/lib/mocha_standalone.rb +2 -0
- data/lib/openssl/mocha/lib/stubba.rb +2 -0
- data/lib/openssl/mocha/templates/html_with_google_analytics.rb +742 -0
- data/lib/openssl/mocha/test/acceptance/expected_invocation_count_acceptance_test.rb +187 -0
- data/lib/openssl/mocha/test/acceptance/mocha_acceptance_test.rb +98 -0
- data/lib/openssl/mocha/test/acceptance/mocked_methods_dispatch_acceptance_test.rb +71 -0
- data/lib/openssl/mocha/test/acceptance/parameter_matcher_acceptance_test.rb +63 -0
- data/lib/openssl/mocha/test/acceptance/standalone_acceptance_test.rb +131 -0
- data/lib/openssl/mocha/test/acceptance/stubba_acceptance_test.rb +102 -0
- data/lib/openssl/mocha/test/active_record_test_case.rb +36 -0
- data/lib/openssl/mocha/test/deprecation_disabler.rb +15 -0
- data/lib/openssl/mocha/test/execution_point.rb +34 -0
- data/lib/openssl/mocha/test/integration/mocha_test_result_integration_test.rb +105 -0
- data/lib/openssl/mocha/test/integration/stubba_integration_test.rb +89 -0
- data/lib/openssl/mocha/test/integration/stubba_test_result_integration_test.rb +85 -0
- data/lib/openssl/mocha/test/method_definer.rb +18 -0
- data/lib/openssl/mocha/test/test_helper.rb +12 -0
- data/lib/openssl/mocha/test/test_runner.rb +31 -0
- data/lib/openssl/mocha/test/unit/any_instance_method_test.rb +124 -0
- data/lib/openssl/mocha/test/unit/array_inspect_test.rb +16 -0
- data/lib/openssl/mocha/test/unit/auto_verify_test.rb +122 -0
- data/lib/openssl/mocha/test/unit/central_test.rb +124 -0
- data/lib/openssl/mocha/test/unit/class_method_test.rb +196 -0
- data/lib/openssl/mocha/test/unit/date_time_inspect_test.rb +21 -0
- data/lib/openssl/mocha/test/unit/expectation_list_test.rb +69 -0
- data/lib/openssl/mocha/test/unit/expectation_raiser_test.rb +28 -0
- data/lib/openssl/mocha/test/unit/expectation_test.rb +399 -0
- data/lib/openssl/mocha/test/unit/hash_inspect_test.rb +16 -0
- data/lib/openssl/mocha/test/unit/infinite_range_test.rb +53 -0
- data/lib/openssl/mocha/test/unit/metaclass_test.rb +22 -0
- data/lib/openssl/mocha/test/unit/missing_expectation_test.rb +45 -0
- data/lib/openssl/mocha/test/unit/mock_test.rb +316 -0
- data/lib/openssl/mocha/test/unit/multiple_yields_test.rb +18 -0
- data/lib/openssl/mocha/test/unit/no_yield_test.rb +18 -0
- data/lib/openssl/mocha/test/unit/object_inspect_test.rb +35 -0
- data/lib/openssl/mocha/test/unit/object_test.rb +165 -0
- data/lib/openssl/mocha/test/unit/parameter_matchers/all_of_test.rb +26 -0
- data/lib/openssl/mocha/test/unit/parameter_matchers/any_of_test.rb +26 -0
- data/lib/openssl/mocha/test/unit/parameter_matchers/anything_test.rb +21 -0
- data/lib/openssl/mocha/test/unit/parameter_matchers/has_entry_test.rb +25 -0
- data/lib/openssl/mocha/test/unit/parameter_matchers/has_key_test.rb +25 -0
- data/lib/openssl/mocha/test/unit/parameter_matchers/has_value_test.rb +25 -0
- data/lib/openssl/mocha/test/unit/parameter_matchers/includes_test.rb +25 -0
- data/lib/openssl/mocha/test/unit/parameter_matchers/instance_of_test.rb +25 -0
- data/lib/openssl/mocha/test/unit/parameter_matchers/kind_of_test.rb +25 -0
- data/lib/openssl/mocha/test/unit/parameter_matchers/stub_matcher.rb +22 -0
- data/lib/openssl/mocha/test/unit/pretty_parameters_test.rb +32 -0
- data/lib/openssl/mocha/test/unit/return_values_test.rb +63 -0
- data/lib/openssl/mocha/test/unit/setup_and_teardown_test.rb +76 -0
- data/lib/openssl/mocha/test/unit/single_return_value_test.rb +33 -0
- data/lib/openssl/mocha/test/unit/single_yield_test.rb +18 -0
- data/lib/openssl/mocha/test/unit/string_inspect_test.rb +11 -0
- data/lib/openssl/mocha/test/unit/stub_test.rb +24 -0
- data/lib/openssl/mocha/test/unit/yield_parameters_test.rb +93 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/FOLDERS +53 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/LICENSE +340 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/README +117 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/bin/coderay +77 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/bin/coderay_stylesheet +4 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay.rb +319 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/duo.rb +29 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/encoder.rb +173 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/encoders/_map.rb +8 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/encoders/count.rb +21 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/encoders/debug.rb +46 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/encoders/div.rb +20 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/encoders/html.rb +260 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/encoders/html/classes.rb +77 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/encoders/html/css.rb +65 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/encoders/html/numerization.rb +122 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/encoders/html/output.rb +195 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/encoders/null.rb +26 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/encoders/page.rb +21 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/encoders/span.rb +20 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/encoders/statistic.rb +81 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/encoders/text.rb +33 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/encoders/tokens.rb +44 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/encoders/xml.rb +71 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/encoders/yaml.rb +22 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/helpers/file_type.rb +182 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/helpers/gzip_simple.rb +122 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/helpers/plugin.rb +326 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/helpers/word_list.rb +119 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/scanner.rb +238 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/scanners/_map.rb +15 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/scanners/c.rb +163 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/scanners/debug.rb +60 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/scanners/delphi.rb +149 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/scanners/html.rb +177 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/scanners/nitro_xhtml.rb +133 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/scanners/plaintext.rb +16 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/scanners/rhtml.rb +73 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/scanners/ruby.rb +367 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/scanners/ruby/patterns.rb +230 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/scanners/xml.rb +18 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/style.rb +20 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/styles/_map.rb +7 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/styles/cycnus.rb +125 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/styles/murphy.rb +119 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/tokens.rb +368 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/CHANGES +295 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/MIT-LICENSE +21 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/README +129 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/Rakefile +152 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project.rb +19 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/core_ext/open_uri.rb +22 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/core_ext/pathname.rb +36 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/core_ext/string.rb +5 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/http/multipart.rb +32 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/patois.rb +1 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/patois/parser.rb +99 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/project.rb +4 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/project/base.rb +9 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/project/codehaus.rb +1 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/project/codehaus/codehaus_project_svn.rb +31 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/project/trac.rb +1 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/project/trac/trac_project.rb +54 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/project/xforge.rb +5 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/project/xforge/ruby_forge.rb +47 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/project/xforge/session.rb +177 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/project/xforge/source_forge.rb +50 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/project/xforge/xfile.rb +45 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/project/xforge/xforge_base.rb +85 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/project_analyzer.rb +36 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/release/freshmeat.rb +267 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/release/raa.rb +572 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/scm_web.rb +2 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/scm_web/browser.rb +112 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/scm_web/pathname.rb +89 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/tracker.rb +6 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/tracker/base.rb +24 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/tracker/digit_issues.rb +34 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/tracker/issue.rb +57 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/tracker/jira.rb +2 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/tracker/jira/jira_issues.rb +35 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/tracker/jira/jira_tracker.rb +149 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/tracker/trac.rb +1 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/tracker/trac/trac_tracker.rb +33 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/tracker/xforge.rb +3 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/tracker/xforge/ruby_forge_tracker.rb +17 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/tracker/xforge/source_forge_tracker.rb +17 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/tracker/xforge/xforge_tracker.rb +191 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/version_parser.rb +52 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/rake/contrib/xforge.rb +3 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/rake/contrib/xforge/base.rb +64 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/rake/contrib/xforge/news_publisher.rb +97 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/rake/contrib/xforge/release.rb +134 -0
- data/lib/openssl/nbproject/genfiles.properties +5 -0
- data/lib/openssl/nbproject/jdk.xml +157 -0
- data/lib/openssl/nbproject/nbjdk.properties +1 -0
- data/lib/openssl/nbproject/nbjdk.xml +16 -0
- data/lib/openssl/nbproject/project.xml +117 -0
- data/lib/openssl/src/java/JopensslService.java +41 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/ASN1.java +930 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/Attribute.java +132 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/BN.java +769 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/BouncyCastlePEMHandler.java +69 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/Callable.java +10 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/Cipher.java +661 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/CipherStrings.java +1827 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/Config.java +49 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/DefaultPEMHandler.java +44 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/Digest.java +207 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/HMAC.java +183 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/NetscapeSPKI.java +212 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/OpenSSLImpl.java +341 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/OpenSSLReal.java +113 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/PEMHandler.java +40 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/PKCS10CertificationRequestExt.java +159 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/PKCS7.java +642 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/PKey.java +154 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/PKeyDH.java +401 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/PKeyDSA.java +419 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/PKeyRSA.java +762 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/Random.java +103 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/Request.java +336 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/SSL.java +71 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/SSLContext.java +358 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/SSLSocket.java +561 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/SimpleSecretKey.java +53 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/Utils.java +60 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/X509.java +108 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/X509CRL.java +446 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/X509Cert.java +520 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/X509Extensions.java +751 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/X509Name.java +405 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/X509Revoked.java +111 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/X509Store.java +282 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/X509StoreCtx.java +206 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/impl/ASN1Registry.java +5135 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/impl/Attribute.java +79 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/impl/BIO.java +345 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/impl/BIOFilter.java +38 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/impl/Base64BIOFilter.java +84 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/impl/CipherBIOFilter.java +157 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/impl/Digest.java +126 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/impl/EVP.java +136 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/impl/EncContent.java +178 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/impl/Encrypt.java +77 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/impl/Envelope.java +169 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/impl/IssuerAndSerial.java +35 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/impl/MemBIO.java +117 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/impl/MessageDigestBIOFilter.java +76 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/impl/Mime.java +245 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/impl/MimeHeader.java +103 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/impl/MimeParam.java +69 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/impl/NotVerifiedPKCS7Exception.java +38 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/impl/NullSinkBIO.java +52 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/impl/PKCS7.java +1276 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/impl/PKCS7Data.java +168 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/impl/PKCS7DataData.java +88 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/impl/PKCS7DataDigest.java +64 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/impl/PKCS7DataEncrypted.java +61 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/impl/PKCS7DataEnveloped.java +85 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/impl/PKCS7DataSigned.java +127 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/impl/PKCS7DataSignedAndEnveloped.java +91 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/impl/PKCS7Exception.java +68 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/impl/RecipInfo.java +244 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/impl/SMIME.java +281 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/impl/SignEnvelope.java +202 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/impl/Signed.java +345 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/impl/SignerInfoWithPkey.java +365 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/impl/TypeDiscriminating.java +34 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/impl/utils/Base64.java +1809 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/util/Base64Coder.java +103 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/CRL.java +59 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/Certificate.java +57 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/CertificateFile.java +46 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/CertificateHashDir.java +46 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/Function0.java +43 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/Function1.java +43 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/Function2.java +43 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/Function3.java +43 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/Function4.java +43 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/Function5.java +43 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/Lookup.java +560 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/LookupMethod.java +84 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/Name.java +85 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/PEMInputOutput.java +1210 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/PKey.java +41 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/PolicyTree.java +36 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/Purpose.java +475 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/Store.java +377 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/StoreContext.java +1356 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/Trust.java +279 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/VerifyParameter.java +324 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/X509Aux.java +43 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/X509AuxCertificate.java +170 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/X509Error.java +70 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/X509Object.java +88 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/X509Utils.java +541 -0
- data/lib/openssl/test/cert_with_ec_pk.cer +27 -0
- data/lib/openssl/test/fixture/ca_path/72fa7371.0 +19 -0
- data/lib/openssl/test/fixture/ca_path/verisign.pem +19 -0
- data/lib/openssl/test/fixture/cacert.pem +23 -0
- data/lib/openssl/test/fixture/cert_localhost.pem +19 -0
- data/lib/openssl/test/fixture/common.pem +48 -0
- data/lib/openssl/test/fixture/localhost_keypair.pem +18 -0
- data/lib/openssl/test/fixture/max.pem +29 -0
- data/lib/openssl/test/fixture/purpose/b70a5bc1.0 +24 -0
- data/lib/openssl/test/fixture/purpose/ca/PASSWD_OF_CA_KEY_IS_1234 +0 -0
- data/lib/openssl/test/fixture/purpose/ca/ca_config.rb +37 -0
- data/lib/openssl/test/fixture/purpose/ca/cacert.pem +24 -0
- data/lib/openssl/test/fixture/purpose/ca/newcerts/2_cert.pem +19 -0
- data/lib/openssl/test/fixture/purpose/ca/newcerts/3_cert.pem +19 -0
- data/lib/openssl/test/fixture/purpose/ca/private/cakeypair.pem +30 -0
- data/lib/openssl/test/fixture/purpose/ca/serial +1 -0
- data/lib/openssl/test/fixture/purpose/cacert.pem +24 -0
- data/lib/openssl/test/fixture/purpose/scripts/gen_cert.rb +127 -0
- data/lib/openssl/test/fixture/purpose/scripts/gen_csr.rb +50 -0
- data/lib/openssl/test/fixture/purpose/scripts/init_ca.rb +66 -0
- data/lib/openssl/test/fixture/purpose/sslclient.pem +19 -0
- data/lib/openssl/test/fixture/purpose/sslclient/csr.pem +10 -0
- data/lib/openssl/test/fixture/purpose/sslclient/keypair.pem +15 -0
- data/lib/openssl/test/fixture/purpose/sslclient/sslclient.pem +19 -0
- data/lib/openssl/test/fixture/purpose/sslserver.pem +19 -0
- data/lib/openssl/test/fixture/purpose/sslserver/csr.pem +10 -0
- data/lib/openssl/test/fixture/purpose/sslserver/keypair.pem +15 -0
- data/lib/openssl/test/fixture/purpose/sslserver/sslserver.pem +19 -0
- data/lib/openssl/test/fixture/verisign.pem +19 -0
- data/lib/openssl/test/fixture/verisign_c3.pem +14 -0
- data/lib/openssl/test/openssl/ssl_server.rb +99 -0
- data/lib/openssl/test/openssl/test_asn1.rb +199 -0
- data/lib/openssl/test/openssl/test_cipher.rb +196 -0
- data/lib/openssl/test/openssl/test_digest.rb +88 -0
- data/lib/openssl/test/openssl/test_hmac.rb +44 -0
- data/lib/openssl/test/openssl/test_ns_spki.rb +69 -0
- data/lib/openssl/test/openssl/test_pair.rb +149 -0
- data/lib/openssl/test/openssl/test_pkcs7.rb +160 -0
- data/lib/openssl/test/openssl/test_pkey_rsa.rb +49 -0
- data/lib/openssl/test/openssl/test_ssl.rb +413 -0
- data/lib/openssl/test/openssl/test_x509cert.rb +236 -0
- data/lib/openssl/test/openssl/test_x509crl.rb +234 -0
- data/lib/openssl/test/openssl/test_x509ext.rb +95 -0
- data/lib/openssl/test/openssl/test_x509name.rb +281 -0
- data/lib/openssl/test/openssl/test_x509req.rb +178 -0
- data/lib/openssl/test/openssl/test_x509store.rb +245 -0
- data/lib/openssl/test/openssl/utils.rb +135 -0
- data/lib/openssl/test/pkcs7_mime_enveloped.message +19 -0
- data/lib/openssl/test/pkcs7_mime_signed.message +30 -0
- data/lib/openssl/test/pkcs7_multipart_signed.message +45 -0
- data/lib/openssl/test/ref/compile.rb +8 -0
- data/lib/openssl/test/ref/pkcs1 +0 -0
- data/lib/openssl/test/ref/pkcs1.c +21 -0
- data/lib/openssl/test/test_cipher.rb +95 -0
- data/lib/openssl/test/test_integration.rb +139 -0
- data/lib/openssl/test/test_java.rb +98 -0
- data/lib/openssl/test/test_java_attribute.rb +25 -0
- data/lib/openssl/test/test_java_bio.rb +42 -0
- data/lib/openssl/test/test_java_mime.rb +173 -0
- data/lib/openssl/test/test_java_pkcs7.rb +769 -0
- data/lib/openssl/test/test_java_smime.rb +177 -0
- data/lib/openssl/test/test_openssl.rb +34 -0
- data/lib/openssl/test/test_openssl_x509.rb +34 -0
- data/lib/openssl/test/test_parse_certificate.rb +20 -0
- data/lib/openssl/test/test_pkey.rb +46 -0
- data/lib/openssl/test/test_x509store.rb +155 -0
- data/lib/openssl/test/ut_eof.rb +128 -0
- data/lib/redcar.rb +134 -8
- data/lib/redcar/installer.rb +46 -11
- data/lib/redcar/runner.rb +2 -1
- data/lib/redcar/usage.rb +12 -5
- data/lib/redcar_quick_start.rb +37 -0
- data/plugins/application/features/support/env.rb +9 -1
- data/plugins/application/icons/redcar_icon_beta.png +0 -0
- data/plugins/application/lib/application.rb +113 -43
- data/plugins/application/lib/application/clipboard.rb +28 -4
- data/plugins/application/lib/application/command.rb +4 -12
- data/plugins/application/lib/application/command/executor.rb +2 -2
- data/plugins/application/lib/application/keymap.rb +39 -0
- data/plugins/application/lib/application/keymap/builder.rb +19 -0
- data/plugins/application/lib/application/speedbar.rb +33 -24
- data/plugins/application/lib/application/tab.rb +15 -0
- data/plugins/application/lib/application/window.rb +28 -5
- data/plugins/application/spec/application/clipboard_spec.rb +20 -1
- data/plugins/application/spec/application/command/executor_spec.rb +7 -2
- data/plugins/application/spec/application/command_spec.rb +0 -5
- data/plugins/application/spec/application/keymap/builder_spec.rb +17 -0
- data/plugins/application/spec/application/menu_spec.rb +30 -0
- data/plugins/application/spec/application/speedbar_spec.rb +30 -6
- data/plugins/application/spec/application/window_spec.rb +2 -2
- data/plugins/application/spec/spec_helper.rb +1 -1
- data/plugins/application_swt/lib/application_swt.rb +3 -0
- data/plugins/application_swt/lib/application_swt/dialogs/filter_list_dialog_controller.rb +10 -1
- data/plugins/application_swt/lib/application_swt/html_tab.rb +1 -0
- data/plugins/application_swt/lib/application_swt/menu.rb +4 -3
- data/plugins/application_swt/lib/application_swt/menu/binding_translator.rb +12 -4
- data/plugins/application_swt/lib/application_swt/speedbar.rb +105 -19
- data/plugins/application_swt/lib/application_swt/swt_wrapper.rb +2 -0
- data/plugins/application_swt/lib/application_swt/window.rb +55 -23
- data/plugins/application_swt/spec/spec_helper.rb +0 -1
- data/plugins/auto_completer/lib/auto_completer.rb +57 -3
- data/plugins/auto_indenter/lib/auto_indenter.rb +1 -1
- data/plugins/core/lib/core.rb +5 -3
- data/plugins/core/lib/core/interface.rb +73 -0
- data/plugins/core/lib/core/model.rb +2 -0
- data/plugins/core/lib/core/observable.rb +12 -1
- data/plugins/core/lib/core/observable_struct.rb +34 -0
- data/plugins/core/lib/core/plugin/storage.rb +16 -3
- data/plugins/core/lib/core/reentry_helpers.rb +13 -0
- data/plugins/core/spec/core/observable_spec.rb +13 -0
- data/plugins/core/spec/core/storage_spec.rb +18 -0
- data/plugins/core/spec/spec_helper.rb +1 -0
- data/plugins/edit_view/features/cut_and_paste.feature +4 -2
- data/plugins/edit_view/features/soft_tabs.feature +243 -0
- data/plugins/edit_view/features/step_definitions/editing_steps.rb +91 -2
- data/plugins/edit_view/features/step_definitions/tab_steps.rb +1 -1
- data/plugins/edit_view/features/tabs.feature +146 -0
- data/plugins/edit_view/lib/edit_view.rb +197 -8
- data/plugins/edit_view/lib/edit_view/actions/arrow_keys.rb +121 -0
- data/plugins/edit_view/lib/edit_view/actions/deletion.rb +30 -0
- data/plugins/edit_view/lib/edit_view/actions/tab.rb +66 -0
- data/plugins/edit_view/lib/edit_view/command.rb +0 -2
- data/plugins/edit_view/lib/edit_view/document.rb +62 -27
- data/plugins/edit_view/lib/edit_view/document/command.rb +11 -0
- data/plugins/edit_view/lib/edit_view/edit_tab.rb +2 -1
- data/plugins/edit_view/lib/edit_view/info_speedbar.rb +69 -0
- data/plugins/edit_view/lib/edit_view/tab_settings.rb +40 -0
- data/plugins/edit_view/spec/edit_view/document_spec.rb +26 -0
- data/plugins/edit_view/spec/spec_helper.rb +0 -1
- data/plugins/edit_view_swt/lib/edit_view_swt.rb +57 -69
- data/plugins/edit_view_swt/lib/edit_view_swt/document.rb +24 -3
- data/plugins/edit_view_swt/lib/edit_view_swt/edit_tab.rb +23 -6
- data/plugins/edit_view_swt/spec/spec_helper.rb +0 -1
- data/plugins/edit_view_swt/vendor/java-mateview.rb +19 -2
- data/plugins/encryption/encryption.rb +38 -0
- data/plugins/encryption/ezcrypto.rb +652 -0
- data/plugins/encryption/jarmor-1.1.jar +0 -0
- data/plugins/encryption/plugin.rb +9 -0
- data/plugins/execute_current_tab/lib/execute_current_tab.rb +56 -0
- data/plugins/execute_current_tab/plugin.rb +8 -0
- data/plugins/html_view/lib/html_view.rb +16 -11
- data/plugins/plugin_manager_ui/lib/plugin_manager_ui.rb +2 -1
- data/plugins/plugin_manager_ui/views/index.html.erb +22 -4
- data/plugins/project/lib/project.rb +140 -26
- data/plugins/project/lib/project/drb_service.rb +75 -0
- data/plugins/project/lib/project/file_mirror.rb +5 -5
- data/plugins/project/lib/project/find_file_dialog.rb +123 -32
- data/plugins/project/spec/project/file_mirror_spec.rb +10 -1
- data/plugins/project/spec/spec_helper.rb +0 -1
- data/plugins/redcar/plugin.rb +1 -1
- data/plugins/redcar/redcar.rb +204 -109
- data/plugins/redcar/spec/redcar/redcar_spec.rb +70 -0
- data/plugins/redcar/spec/spec_helper.rb +4 -0
- data/plugins/repl/lib/repl.rb +14 -7
- data/plugins/repl/lib/repl/internal_mirror.rb +43 -22
- data/plugins/repl/spec/repl/internal_mirror_spec.rb +34 -7
- data/plugins/repl/spec/spec_helper.rb +0 -1
- data/plugins/tree/spec/spec_helper.rb +0 -1
- data/plugins/tree_view_swt/lib/tree_view_swt.rb +1 -1
- data/textmate/Bundles/RedcarRepl.tmbundle/Syntaxes/InternalRuby.plist +2 -18
- data/textmate/Bundles/asciidoc.tmbundle/Syntaxes/AsciiDoc.tmLanguage +428 -0
- metadata +790 -371
- data/lib/redcar/boot.rb +0 -108
@@ -0,0 +1,358 @@
|
|
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) 2006 Ola Bini <ola@ologix.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;
|
29
|
+
|
30
|
+
|
31
|
+
|
32
|
+
import java.security.cert.CertificateException;
|
33
|
+
import java.util.ArrayList;
|
34
|
+
import java.util.Arrays;
|
35
|
+
import java.util.HashMap;
|
36
|
+
import java.util.Iterator;
|
37
|
+
import java.util.List;
|
38
|
+
import java.util.Map;
|
39
|
+
import javax.net.ssl.SSLEngine;
|
40
|
+
import org.jruby.Ruby;
|
41
|
+
import org.jruby.RubyArray;
|
42
|
+
import org.jruby.RubyClass;
|
43
|
+
import org.jruby.RubyModule;
|
44
|
+
import org.jruby.RubyNumeric;
|
45
|
+
import org.jruby.RubyObject;
|
46
|
+
import org.jruby.anno.JRubyMethod;
|
47
|
+
import org.jruby.common.IRubyWarnings.ID;
|
48
|
+
import org.jruby.ext.openssl.x509store.Store;
|
49
|
+
import org.jruby.ext.openssl.x509store.StoreContext;
|
50
|
+
import org.jruby.ext.openssl.x509store.X509AuxCertificate;
|
51
|
+
import org.jruby.runtime.Block;
|
52
|
+
import org.jruby.runtime.ObjectAllocator;
|
53
|
+
import org.jruby.runtime.builtin.IRubyObject;
|
54
|
+
|
55
|
+
/**
|
56
|
+
* @author <a href="mailto:ola.bini@ki.se">Ola Bini</a>
|
57
|
+
*/
|
58
|
+
public class SSLContext extends RubyObject {
|
59
|
+
private final static String[] ctx_attrs = {
|
60
|
+
"cert", "key", "client_ca", "ca_file", "ca_path",
|
61
|
+
"timeout", "verify_mode", "verify_depth",
|
62
|
+
"verify_callback", "options", "cert_store", "extra_chain_cert",
|
63
|
+
"client_cert_cb", "tmp_dh_callback", "session_id_context"};
|
64
|
+
|
65
|
+
private static ObjectAllocator SSLCONTEXT_ALLOCATOR = new ObjectAllocator() {
|
66
|
+
public IRubyObject allocate(Ruby runtime, RubyClass klass) {
|
67
|
+
return new SSLContext(runtime, klass);
|
68
|
+
}
|
69
|
+
};
|
70
|
+
|
71
|
+
public static void createSSLContext(Ruby runtime, RubyModule mSSL) {
|
72
|
+
RubyClass cSSLContext = mSSL.defineClassUnder("SSLContext",runtime.getObject(),SSLCONTEXT_ALLOCATOR);
|
73
|
+
for(int i=0;i<ctx_attrs.length;i++) {
|
74
|
+
cSSLContext.attr_accessor(runtime.getCurrentContext(),new IRubyObject[]{runtime.newSymbol(ctx_attrs[i])});
|
75
|
+
}
|
76
|
+
|
77
|
+
cSSLContext.defineAnnotatedMethods(SSLContext.class);
|
78
|
+
}
|
79
|
+
|
80
|
+
public SSLContext(Ruby runtime, RubyClass type) {
|
81
|
+
super(runtime,type);
|
82
|
+
}
|
83
|
+
|
84
|
+
private IRubyObject ciphers;
|
85
|
+
private PKey t_key = null;
|
86
|
+
private X509Cert t_cert = null;
|
87
|
+
|
88
|
+
private java.security.cert.X509Certificate peer_cert;
|
89
|
+
|
90
|
+
public void setPeer(java.security.cert.X509Certificate p) {
|
91
|
+
this.peer_cert = p;
|
92
|
+
}
|
93
|
+
|
94
|
+
public java.security.cert.X509Certificate getPeer() {
|
95
|
+
return this.peer_cert;
|
96
|
+
}
|
97
|
+
|
98
|
+
private void initFromCallback(IRubyObject cb) {
|
99
|
+
IRubyObject out = cb.callMethod(getRuntime().getCurrentContext(),"call",this);
|
100
|
+
t_cert = (X509Cert)(((RubyArray)out).getList().get(0));
|
101
|
+
t_key = (PKey)(((RubyArray)out).getList().get(1));
|
102
|
+
}
|
103
|
+
|
104
|
+
public PKey getCallbackKey() {
|
105
|
+
IRubyObject cb = callMethod(getRuntime().getCurrentContext(),"client_cert_cb");
|
106
|
+
if(t_key == null && !cb.isNil()) {
|
107
|
+
initFromCallback(cb);
|
108
|
+
}
|
109
|
+
return t_key;
|
110
|
+
}
|
111
|
+
|
112
|
+
public X509Cert getCallbackCert() {
|
113
|
+
IRubyObject cb = callMethod(getRuntime().getCurrentContext(),"client_cert_cb");
|
114
|
+
if(t_cert == null && !cb.isNil()) {
|
115
|
+
initFromCallback(cb);
|
116
|
+
}
|
117
|
+
return t_cert;
|
118
|
+
}
|
119
|
+
|
120
|
+
@JRubyMethod(rest=true)
|
121
|
+
public IRubyObject initialize(IRubyObject[] args) {
|
122
|
+
ciphers = getRuntime().getNil();
|
123
|
+
return this;
|
124
|
+
}
|
125
|
+
|
126
|
+
@JRubyMethod
|
127
|
+
public IRubyObject ciphers() {
|
128
|
+
System.err.println("fetching ciphers");
|
129
|
+
return this.ciphers;
|
130
|
+
}
|
131
|
+
|
132
|
+
@JRubyMethod(name="ciphers=")
|
133
|
+
public IRubyObject set_ciphers(IRubyObject val) {
|
134
|
+
this.ciphers = val;
|
135
|
+
return val;
|
136
|
+
}
|
137
|
+
|
138
|
+
String[] getCipherSuites(SSLEngine engine) {
|
139
|
+
List<CipherStrings.Def> ciphs = null;
|
140
|
+
if(this.ciphers.isNil()) {
|
141
|
+
ciphs = CipherStrings.getMatchingCiphers(CipherStrings.SSL_DEFAULT_CIPHER_LIST, engine.getSupportedCipherSuites());
|
142
|
+
} else if(this.ciphers instanceof RubyArray) {
|
143
|
+
StringBuilder builder = new StringBuilder();
|
144
|
+
String sep = "";
|
145
|
+
for(Iterator iter = ((RubyArray)this.ciphers).getList().iterator();iter.hasNext();) {
|
146
|
+
builder.append(sep).append(iter.next().toString());
|
147
|
+
sep = ":";
|
148
|
+
}
|
149
|
+
ciphs = CipherStrings.getMatchingCiphers(builder.toString(), engine.getSupportedCipherSuites());
|
150
|
+
} else {
|
151
|
+
ciphs = CipherStrings.getMatchingCiphers(this.ciphers.toString(), engine.getSupportedCipherSuites());
|
152
|
+
}
|
153
|
+
String[] result = new String[ciphs.size()];
|
154
|
+
for(int i=0;i<result.length;i++) {
|
155
|
+
result[i] = ciphs.get(i).cipherSuite;
|
156
|
+
}
|
157
|
+
return result;
|
158
|
+
}
|
159
|
+
|
160
|
+
KM getKM() {
|
161
|
+
return new KM(this);
|
162
|
+
}
|
163
|
+
|
164
|
+
TM getTM() {
|
165
|
+
return new TM(this);
|
166
|
+
}
|
167
|
+
|
168
|
+
private static class KM extends javax.net.ssl.X509ExtendedKeyManager {
|
169
|
+
private SSLContext ctt;
|
170
|
+
public KM(SSLContext ctt) {
|
171
|
+
super();
|
172
|
+
this.ctt = ctt;
|
173
|
+
}
|
174
|
+
|
175
|
+
public String chooseEngineClientAlias(String[] keyType, java.security.Principal[] issuers, javax.net.ssl.SSLEngine engine) {
|
176
|
+
PKey k = null;
|
177
|
+
if(!ctt.callMethod(ctt.getRuntime().getCurrentContext(),"key").isNil()) {
|
178
|
+
k = (PKey)ctt.callMethod(ctt.getRuntime().getCurrentContext(),"key");
|
179
|
+
} else {
|
180
|
+
k = ctt.getCallbackKey();
|
181
|
+
}
|
182
|
+
if(k == null) {
|
183
|
+
return null;
|
184
|
+
}
|
185
|
+
for(int i=0;i<keyType.length;i++) {
|
186
|
+
if(keyType[i].equalsIgnoreCase(k.getAlgorithm())) {
|
187
|
+
return keyType[i];
|
188
|
+
}
|
189
|
+
}
|
190
|
+
return null;
|
191
|
+
}
|
192
|
+
|
193
|
+
public String chooseEngineServerAlias(String keyType, java.security.Principal[] issuers, javax.net.ssl.SSLEngine engine) {
|
194
|
+
PKey k = null;
|
195
|
+
if(!ctt.callMethod(ctt.getRuntime().getCurrentContext(),"key").isNil()) {
|
196
|
+
k = (PKey)ctt.callMethod(ctt.getRuntime().getCurrentContext(),"key");
|
197
|
+
} else {
|
198
|
+
k = ctt.getCallbackKey();
|
199
|
+
}
|
200
|
+
if(k == null) {
|
201
|
+
return null;
|
202
|
+
}
|
203
|
+
if(keyType.equalsIgnoreCase(k.getAlgorithm())) {
|
204
|
+
return keyType;
|
205
|
+
}
|
206
|
+
return null;
|
207
|
+
}
|
208
|
+
public String chooseClientAlias(String[] keyType, java.security.Principal[] issuers, java.net.Socket socket) {
|
209
|
+
return null;
|
210
|
+
}
|
211
|
+
public String chooseServerAlias(String keyType, java.security.Principal[] issuers, java.net.Socket socket) {
|
212
|
+
return null;
|
213
|
+
}
|
214
|
+
public java.security.cert.X509Certificate[] getCertificateChain(String alias) {
|
215
|
+
X509Cert c = null;
|
216
|
+
if(!ctt.callMethod(ctt.getRuntime().getCurrentContext(),"cert").isNil()) {
|
217
|
+
c = (X509Cert)ctt.callMethod(ctt.getRuntime().getCurrentContext(),"cert");
|
218
|
+
} else {
|
219
|
+
c = ctt.getCallbackCert();
|
220
|
+
}
|
221
|
+
if(c == null) {
|
222
|
+
return null;
|
223
|
+
}
|
224
|
+
return new java.security.cert.X509Certificate[]{c.getAuxCert()};
|
225
|
+
}
|
226
|
+
public String[] getClientAliases(String keyType, java.security.Principal[] issuers) {
|
227
|
+
return null;
|
228
|
+
}
|
229
|
+
public java.security.PrivateKey getPrivateKey(String alias) {
|
230
|
+
PKey k = null;
|
231
|
+
if(!ctt.callMethod(ctt.getRuntime().getCurrentContext(),"key").isNil()) {
|
232
|
+
k = (PKey)ctt.callMethod(ctt.getRuntime().getCurrentContext(),"key");
|
233
|
+
} else {
|
234
|
+
k = ctt.getCallbackKey();
|
235
|
+
}
|
236
|
+
if(k == null) {
|
237
|
+
return null;
|
238
|
+
}
|
239
|
+
return k.getPrivateKey();
|
240
|
+
}
|
241
|
+
public String[] getServerAliases(String keyType, java.security.Principal[] issuers) {
|
242
|
+
return null;
|
243
|
+
}
|
244
|
+
}
|
245
|
+
|
246
|
+
private static class TM implements javax.net.ssl.X509TrustManager {
|
247
|
+
private SSLContext ctt;
|
248
|
+
public TM(SSLContext ctt) {
|
249
|
+
this.ctt = ctt;
|
250
|
+
}
|
251
|
+
|
252
|
+
public void checkClientTrusted(java.security.cert.X509Certificate[] chain, String authType) throws CertificateException {
|
253
|
+
if(ctt.callMethod(ctt.getRuntime().getCurrentContext(),"verify_mode").isNil()) {
|
254
|
+
if(chain != null && chain.length > 0) {
|
255
|
+
ctt.setPeer(chain[0]);
|
256
|
+
}
|
257
|
+
return;
|
258
|
+
}
|
259
|
+
|
260
|
+
int verify_mode = RubyNumeric.fix2int(ctt.callMethod(ctt.getRuntime().getCurrentContext(),"verify_mode"));
|
261
|
+
if(chain != null && chain.length > 0) {
|
262
|
+
ctt.setPeer(chain[0]);
|
263
|
+
if((verify_mode & 0x1) != 0) { // verify_peer
|
264
|
+
X509AuxCertificate x = StoreContext.ensureAux(chain[0]);
|
265
|
+
StoreContext ctx = new StoreContext();
|
266
|
+
IRubyObject str = ctt.callMethod(ctt.getRuntime().getCurrentContext(),"cert_store");
|
267
|
+
Store store = null;
|
268
|
+
if(!str.isNil()) {
|
269
|
+
store = ((X509Store)str).getStore();
|
270
|
+
}
|
271
|
+
if(ctx.init(store,x,StoreContext.ensureAux(chain)) == 0) {
|
272
|
+
throw new CertificateException("couldn't initialize store");
|
273
|
+
}
|
274
|
+
|
275
|
+
ctx.setDefault("ssl_client");
|
276
|
+
|
277
|
+
IRubyObject val = ctt.callMethod(ctt.getRuntime().getCurrentContext(),"ca_file");
|
278
|
+
String ca_file = val.isNil() ? null : val.convertToString().toString();
|
279
|
+
val = ctt.callMethod(ctt.getRuntime().getCurrentContext(),"ca_path");
|
280
|
+
String ca_path = val.isNil() ? null : val.convertToString().toString();
|
281
|
+
|
282
|
+
if(ca_file != null || ca_path != null) {
|
283
|
+
if(ctx.loadVerifyLocations(ca_file, ca_path) == 0) {
|
284
|
+
ctt.getRuntime().getWarnings().warn(ID.MISCELLANEOUS, "can't set verify locations");
|
285
|
+
}
|
286
|
+
}
|
287
|
+
|
288
|
+
try {
|
289
|
+
if(ctx.verifyCertificate() == 0) {
|
290
|
+
throw new CertificateException("certificate verify failed");
|
291
|
+
}
|
292
|
+
} catch(Exception e) {
|
293
|
+
throw new CertificateException("certificate verify failed");
|
294
|
+
}
|
295
|
+
}
|
296
|
+
} else {
|
297
|
+
if((verify_mode & 0x2) != 0) { // fail if no peer cer
|
298
|
+
throw new CertificateException("no peer certificate");
|
299
|
+
}
|
300
|
+
}
|
301
|
+
}
|
302
|
+
|
303
|
+
public void checkServerTrusted(java.security.cert.X509Certificate[] chain, String authType) throws CertificateException {
|
304
|
+
if(ctt.callMethod(ctt.getRuntime().getCurrentContext(),"verify_mode").isNil()) {
|
305
|
+
if(chain != null && chain.length > 0) {
|
306
|
+
ctt.setPeer(chain[0]);
|
307
|
+
}
|
308
|
+
return;
|
309
|
+
}
|
310
|
+
|
311
|
+
int verify_mode = RubyNumeric.fix2int(ctt.callMethod(ctt.getRuntime().getCurrentContext(),"verify_mode"));
|
312
|
+
if(chain != null && chain.length > 0) {
|
313
|
+
ctt.setPeer(chain[0]);
|
314
|
+
if((verify_mode & 0x1) != 0) { // verify_peer
|
315
|
+
X509AuxCertificate x = StoreContext.ensureAux(chain[0]);
|
316
|
+
StoreContext ctx = new StoreContext();
|
317
|
+
IRubyObject str = ctt.callMethod(ctt.getRuntime().getCurrentContext(),"cert_store");
|
318
|
+
Store store = null;
|
319
|
+
if(!str.isNil()) {
|
320
|
+
store = ((X509Store)str).getStore();
|
321
|
+
}
|
322
|
+
if(ctx.init(store,x,StoreContext.ensureAux(chain)) == 0) {
|
323
|
+
throw new CertificateException("couldn't initialize store");
|
324
|
+
}
|
325
|
+
|
326
|
+
ctx.setDefault("ssl_server");
|
327
|
+
|
328
|
+
IRubyObject val = ctt.callMethod(ctt.getRuntime().getCurrentContext(),"ca_file");
|
329
|
+
String ca_file = val.isNil() ? null : val.convertToString().toString();
|
330
|
+
val = ctt.callMethod(ctt.getRuntime().getCurrentContext(),"ca_path");
|
331
|
+
String ca_path = val.isNil() ? null : val.convertToString().toString();
|
332
|
+
|
333
|
+
if(ca_file != null || ca_path != null) {
|
334
|
+
if(ctx.loadVerifyLocations(ca_file, ca_path) == 0) {
|
335
|
+
ctt.getRuntime().getWarnings().warn(ID.MISCELLANEOUS, "can't set verify locations");
|
336
|
+
}
|
337
|
+
}
|
338
|
+
|
339
|
+
try {
|
340
|
+
if(ctx.verifyCertificate() == 0) {
|
341
|
+
throw new CertificateException("certificate verify failed");
|
342
|
+
}
|
343
|
+
} catch(Exception e) {
|
344
|
+
throw new CertificateException("certificate verify failed");
|
345
|
+
}
|
346
|
+
}
|
347
|
+
} else {
|
348
|
+
if((verify_mode & 0x2) != 0) { // fail if no peer cer
|
349
|
+
throw new CertificateException("no peer certificate");
|
350
|
+
}
|
351
|
+
}
|
352
|
+
}
|
353
|
+
|
354
|
+
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
|
355
|
+
return new java.security.cert.X509Certificate[0];
|
356
|
+
}
|
357
|
+
}
|
358
|
+
}// SSLContext
|
@@ -0,0 +1,561 @@
|
|
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) 2006, 2007 Ola Bini <ola@ologix.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;
|
29
|
+
|
30
|
+
import java.io.IOException;
|
31
|
+
import java.nio.ByteBuffer;
|
32
|
+
import java.nio.channels.SelectionKey;
|
33
|
+
import java.nio.channels.Selector;
|
34
|
+
import java.nio.channels.SocketChannel;
|
35
|
+
import java.security.KeyManagementException;
|
36
|
+
import java.security.NoSuchAlgorithmException;
|
37
|
+
import java.security.cert.Certificate;
|
38
|
+
import java.security.cert.CertificateEncodingException;
|
39
|
+
import java.util.Iterator;
|
40
|
+
|
41
|
+
import java.util.logging.Level;
|
42
|
+
import java.util.logging.Logger;
|
43
|
+
import javax.net.ssl.SSLContext;
|
44
|
+
import javax.net.ssl.SSLEngine;
|
45
|
+
import javax.net.ssl.SSLEngineResult;
|
46
|
+
import javax.net.ssl.SSLException;
|
47
|
+
import javax.net.ssl.SSLHandshakeException;
|
48
|
+
import javax.net.ssl.SSLPeerUnverifiedException;
|
49
|
+
import javax.net.ssl.SSLSession;
|
50
|
+
|
51
|
+
import org.jruby.Ruby;
|
52
|
+
import org.jruby.RubyArray;
|
53
|
+
import org.jruby.RubyClass;
|
54
|
+
import org.jruby.RubyIO;
|
55
|
+
import org.jruby.RubyModule;
|
56
|
+
import org.jruby.RubyNumeric;
|
57
|
+
import org.jruby.RubyObject;
|
58
|
+
import org.jruby.RubyObjectAdapter;
|
59
|
+
import org.jruby.RubyString;
|
60
|
+
import org.jruby.anno.JRubyMethod;
|
61
|
+
import org.jruby.javasupport.JavaEmbedUtils;
|
62
|
+
import org.jruby.runtime.Arity;
|
63
|
+
import org.jruby.runtime.Block;
|
64
|
+
import org.jruby.runtime.ObjectAllocator;
|
65
|
+
import org.jruby.runtime.ThreadContext;
|
66
|
+
import org.jruby.runtime.builtin.IRubyObject;
|
67
|
+
|
68
|
+
/**
|
69
|
+
* @author <a href="mailto:ola.bini@ki.se">Ola Bini</a>
|
70
|
+
*/
|
71
|
+
public class SSLSocket extends RubyObject {
|
72
|
+
private static ObjectAllocator SSLSOCKET_ALLOCATOR = new ObjectAllocator() {
|
73
|
+
public IRubyObject allocate(Ruby runtime, RubyClass klass) {
|
74
|
+
return new SSLSocket(runtime, klass);
|
75
|
+
}
|
76
|
+
};
|
77
|
+
|
78
|
+
private static RubyObjectAdapter api = JavaEmbedUtils.newObjectAdapter();
|
79
|
+
|
80
|
+
public static void createSSLSocket(Ruby runtime, RubyModule mSSL) {
|
81
|
+
RubyClass cSSLSocket = mSSL.defineClassUnder("SSLSocket",runtime.getObject(),SSLSOCKET_ALLOCATOR);
|
82
|
+
|
83
|
+
cSSLSocket.attr_accessor(runtime.getCurrentContext(), new IRubyObject[]{runtime.newSymbol("io")});
|
84
|
+
cSSLSocket.attr_accessor(runtime.getCurrentContext(), new IRubyObject[]{runtime.newSymbol("context")});
|
85
|
+
cSSLSocket.attr_accessor(runtime.getCurrentContext(), new IRubyObject[]{runtime.newSymbol("sync_close")});
|
86
|
+
cSSLSocket.defineAlias("to_io","io");
|
87
|
+
|
88
|
+
cSSLSocket.defineAnnotatedMethods(SSLSocket.class);
|
89
|
+
}
|
90
|
+
|
91
|
+
public SSLSocket(Ruby runtime, RubyClass type) {
|
92
|
+
super(runtime,type);
|
93
|
+
}
|
94
|
+
|
95
|
+
private SSLEngine engine;
|
96
|
+
private SocketChannel c = null;
|
97
|
+
|
98
|
+
private ByteBuffer peerAppData;
|
99
|
+
private ByteBuffer peerNetData;
|
100
|
+
private ByteBuffer netData;
|
101
|
+
private ByteBuffer dummy;
|
102
|
+
|
103
|
+
private boolean initialHandshake = false;
|
104
|
+
|
105
|
+
private SSLEngineResult.HandshakeStatus hsStatus;
|
106
|
+
private SSLEngineResult.Status status = null;
|
107
|
+
|
108
|
+
private Selector rsel;
|
109
|
+
private Selector wsel;
|
110
|
+
private Selector asel;
|
111
|
+
|
112
|
+
@JRubyMethod(name="initialize", rest=true, frame=true)
|
113
|
+
public IRubyObject _initialize(IRubyObject[] args, Block unused) {
|
114
|
+
IRubyObject io, ctx;
|
115
|
+
if (Arity.checkArgumentCount(getRuntime(),args,1,2) == 1) {
|
116
|
+
RubyClass sslContext = ((RubyModule) (getRuntime().getModule("OpenSSL").getConstant("SSL"))).getClass("SSLContext");
|
117
|
+
ctx = api.callMethod(sslContext,"new");
|
118
|
+
} else {
|
119
|
+
ctx = args[1];
|
120
|
+
}
|
121
|
+
io = args[0];
|
122
|
+
api.callMethod(this,"io=",io);
|
123
|
+
// This is a bit of a hack: SSLSocket should share code with RubyBasicSocket, which always sets sync to true.
|
124
|
+
// Instead we set it here for now.
|
125
|
+
api.callMethod(io,"sync=",getRuntime().getTrue());
|
126
|
+
c = (SocketChannel)(((RubyIO)io).getChannel());
|
127
|
+
api.callMethod(this,"context=",ctx);
|
128
|
+
api.callMethod(this,"sync_close=",getRuntime().getFalse());
|
129
|
+
return api.callSuper(this, args);
|
130
|
+
}
|
131
|
+
|
132
|
+
private void ossl_ssl_setup() throws NoSuchAlgorithmException, KeyManagementException, IOException {
|
133
|
+
if(null == engine) {
|
134
|
+
ThreadContext tc = getRuntime().getCurrentContext();
|
135
|
+
SSLContext ctx = SSLContext.getInstance("SSL");
|
136
|
+
IRubyObject store = callMethod(tc,"context").callMethod(tc,"cert_store");
|
137
|
+
callMethod(tc,"context").callMethod(tc,"verify_mode");
|
138
|
+
|
139
|
+
ctx.init(new javax.net.ssl.KeyManager[]{((org.jruby.ext.openssl.SSLContext)callMethod(tc,"context")).getKM()},new javax.net.ssl.TrustManager[]{((org.jruby.ext.openssl.SSLContext)callMethod(tc,"context")).getTM()},null);
|
140
|
+
|
141
|
+
String peerHost = ((SocketChannel)c).socket().getInetAddress().getHostName();
|
142
|
+
int peerPort = ((SocketChannel)c).socket().getPort();
|
143
|
+
engine = ctx.createSSLEngine(peerHost,peerPort);
|
144
|
+
engine.setEnabledCipherSuites(((org.jruby.ext.openssl.SSLContext)callMethod(tc,"context")).getCipherSuites(engine));
|
145
|
+
SSLSession session = engine.getSession();
|
146
|
+
peerNetData = ByteBuffer.allocate(session.getPacketBufferSize());
|
147
|
+
peerAppData = ByteBuffer.allocate(session.getApplicationBufferSize());
|
148
|
+
netData = ByteBuffer.allocate(session.getPacketBufferSize());
|
149
|
+
peerNetData.limit(0);
|
150
|
+
peerAppData.limit(0);
|
151
|
+
netData.limit(0);
|
152
|
+
dummy = ByteBuffer.allocate(0);
|
153
|
+
rsel = Selector.open();
|
154
|
+
wsel = Selector.open();
|
155
|
+
asel = Selector.open();
|
156
|
+
c.register(rsel,SelectionKey.OP_READ);
|
157
|
+
c.register(wsel,SelectionKey.OP_WRITE);
|
158
|
+
c.register(asel,SelectionKey.OP_READ | SelectionKey.OP_WRITE);
|
159
|
+
}
|
160
|
+
}
|
161
|
+
|
162
|
+
@JRubyMethod
|
163
|
+
public IRubyObject connect(ThreadContext context) {
|
164
|
+
Ruby runtime = context.getRuntime();
|
165
|
+
|
166
|
+
try {
|
167
|
+
ossl_ssl_setup();
|
168
|
+
engine.setUseClientMode(true);
|
169
|
+
engine.beginHandshake();
|
170
|
+
hsStatus = engine.getHandshakeStatus();
|
171
|
+
initialHandshake = true;
|
172
|
+
doHandshake();
|
173
|
+
} catch(SSLHandshakeException e) {
|
174
|
+
Throwable v = e;
|
175
|
+
while(v.getCause() != null && (v instanceof SSLHandshakeException)) {
|
176
|
+
v = v.getCause();
|
177
|
+
}
|
178
|
+
throw SSL.newSSLError(runtime, v);
|
179
|
+
} catch (NoSuchAlgorithmException ex) {
|
180
|
+
throw SSL.newSSLError(runtime, ex);
|
181
|
+
} catch (KeyManagementException ex) {
|
182
|
+
throw SSL.newSSLError(runtime, ex);
|
183
|
+
} catch (IOException ex) {
|
184
|
+
throw SSL.newSSLError(runtime, ex);
|
185
|
+
|
186
|
+
}
|
187
|
+
return this;
|
188
|
+
}
|
189
|
+
|
190
|
+
@JRubyMethod
|
191
|
+
public IRubyObject accept(ThreadContext context) {
|
192
|
+
Ruby runtime = context.getRuntime();
|
193
|
+
|
194
|
+
try {
|
195
|
+
int vfy = 0;
|
196
|
+
ossl_ssl_setup();
|
197
|
+
engine.setUseClientMode(false);
|
198
|
+
IRubyObject ccc = callMethod(context,"context");
|
199
|
+
if(!ccc.isNil() && !ccc.callMethod(context,"verify_mode").isNil()) {
|
200
|
+
vfy = RubyNumeric.fix2int(ccc.callMethod(context,"verify_mode"));
|
201
|
+
if(vfy == 0) { //VERIFY_NONE
|
202
|
+
engine.setNeedClientAuth(false);
|
203
|
+
engine.setWantClientAuth(false);
|
204
|
+
}
|
205
|
+
if((vfy & 1) != 0) { //VERIFY_PEER
|
206
|
+
engine.setWantClientAuth(true);
|
207
|
+
}
|
208
|
+
if((vfy & 2) != 0) { //VERIFY_FAIL_IF_NO_PEER_CERT
|
209
|
+
engine.setNeedClientAuth(true);
|
210
|
+
}
|
211
|
+
}
|
212
|
+
engine.beginHandshake();
|
213
|
+
hsStatus = engine.getHandshakeStatus();
|
214
|
+
initialHandshake = true;
|
215
|
+
doHandshake();
|
216
|
+
} catch(SSLHandshakeException e) {
|
217
|
+
throw SSL.newSSLError(runtime, e);
|
218
|
+
} catch (NoSuchAlgorithmException ex) {
|
219
|
+
throw SSL.newSSLError(runtime, ex);
|
220
|
+
} catch (KeyManagementException ex) {
|
221
|
+
throw SSL.newSSLError(runtime, ex);
|
222
|
+
} catch (IOException ex) {
|
223
|
+
throw SSL.newSSLError(runtime, ex);
|
224
|
+
}
|
225
|
+
|
226
|
+
return this;
|
227
|
+
}
|
228
|
+
|
229
|
+
private void waitSelect(Selector sel) {
|
230
|
+
try {
|
231
|
+
sel.select();
|
232
|
+
} catch(Exception e) {
|
233
|
+
return;
|
234
|
+
}
|
235
|
+
Iterator it = sel.selectedKeys().iterator();
|
236
|
+
while(it.hasNext()) {
|
237
|
+
it.next();
|
238
|
+
it.remove();
|
239
|
+
}
|
240
|
+
}
|
241
|
+
|
242
|
+
private void doHandshake() throws IOException {
|
243
|
+
while (true) {
|
244
|
+
SSLEngineResult res;
|
245
|
+
waitSelect(asel);
|
246
|
+
if(hsStatus == SSLEngineResult.HandshakeStatus.FINISHED) {
|
247
|
+
if (initialHandshake) {
|
248
|
+
finishInitialHandshake();
|
249
|
+
}
|
250
|
+
return;
|
251
|
+
} else if(hsStatus == SSLEngineResult.HandshakeStatus.NEED_TASK) {
|
252
|
+
doTasks();
|
253
|
+
} else if(hsStatus == SSLEngineResult.HandshakeStatus.NEED_UNWRAP) {
|
254
|
+
if(readAndUnwrap() == -1 && hsStatus != SSLEngineResult.HandshakeStatus.FINISHED) {
|
255
|
+
throw new SSLHandshakeException("Socket closed");
|
256
|
+
}
|
257
|
+
} else if(hsStatus == SSLEngineResult.HandshakeStatus.NEED_WRAP) {
|
258
|
+
if (netData.hasRemaining()) {
|
259
|
+
while(flushData());
|
260
|
+
}
|
261
|
+
netData.clear();
|
262
|
+
res = engine.wrap(dummy, netData);
|
263
|
+
hsStatus = res.getHandshakeStatus();
|
264
|
+
netData.flip();
|
265
|
+
flushData();
|
266
|
+
} else {
|
267
|
+
assert false : "doHandshake() should never reach the NOT_HANDSHAKING state";
|
268
|
+
return;
|
269
|
+
}
|
270
|
+
}
|
271
|
+
}
|
272
|
+
|
273
|
+
private void doTasks() {
|
274
|
+
Runnable task;
|
275
|
+
while ((task = engine.getDelegatedTask()) != null) {
|
276
|
+
task.run();
|
277
|
+
}
|
278
|
+
hsStatus = engine.getHandshakeStatus();
|
279
|
+
}
|
280
|
+
|
281
|
+
private boolean flushData() throws IOException {
|
282
|
+
try {
|
283
|
+
writeToChannel(c, netData);
|
284
|
+
} catch (IOException ioe) {
|
285
|
+
netData.position(netData.limit());
|
286
|
+
throw ioe;
|
287
|
+
}
|
288
|
+
if (netData.hasRemaining()) {
|
289
|
+
return false;
|
290
|
+
} else {
|
291
|
+
return true;
|
292
|
+
}
|
293
|
+
}
|
294
|
+
|
295
|
+
private int writeToChannel(SocketChannel channel, ByteBuffer buffer) throws IOException {
|
296
|
+
int totalWritten = 0;
|
297
|
+
while (buffer.hasRemaining()) {
|
298
|
+
totalWritten += channel.write(buffer);
|
299
|
+
}
|
300
|
+
return totalWritten;
|
301
|
+
}
|
302
|
+
|
303
|
+
private void finishInitialHandshake() {
|
304
|
+
initialHandshake = false;
|
305
|
+
}
|
306
|
+
|
307
|
+
public int write(ByteBuffer src) throws SSLException, IOException {
|
308
|
+
if(initialHandshake) {
|
309
|
+
return 0;
|
310
|
+
}
|
311
|
+
if(netData.hasRemaining()) {
|
312
|
+
return 0;
|
313
|
+
}
|
314
|
+
netData.clear();
|
315
|
+
SSLEngineResult res = engine.wrap(src, netData);
|
316
|
+
netData.flip();
|
317
|
+
flushData();
|
318
|
+
return res.bytesConsumed();
|
319
|
+
}
|
320
|
+
|
321
|
+
public int read(ByteBuffer dst) throws IOException {
|
322
|
+
if(initialHandshake) {
|
323
|
+
return 0;
|
324
|
+
}
|
325
|
+
if (engine.isInboundDone()) {
|
326
|
+
return -1;
|
327
|
+
}
|
328
|
+
if (!peerAppData.hasRemaining()) {
|
329
|
+
int appBytesProduced = readAndUnwrap();
|
330
|
+
if (appBytesProduced == -1 || appBytesProduced == 0) {
|
331
|
+
return appBytesProduced;
|
332
|
+
}
|
333
|
+
}
|
334
|
+
int limit = Math.min(peerAppData.remaining(), dst.remaining());
|
335
|
+
for (int i = 0; i < limit; i++) {
|
336
|
+
dst.put(peerAppData.get());
|
337
|
+
}
|
338
|
+
return limit;
|
339
|
+
}
|
340
|
+
|
341
|
+
private int readAndUnwrap() throws IOException {
|
342
|
+
int bytesRead = c.read(peerNetData);
|
343
|
+
|
344
|
+
if(bytesRead == -1) {
|
345
|
+
// engine.closeInbound();
|
346
|
+
if ((peerNetData.position() == 0) || (status == SSLEngineResult.Status.BUFFER_UNDERFLOW)) {
|
347
|
+
return -1;
|
348
|
+
}
|
349
|
+
}
|
350
|
+
peerAppData.clear();
|
351
|
+
peerNetData.flip();
|
352
|
+
SSLEngineResult res;
|
353
|
+
do {
|
354
|
+
res = engine.unwrap(peerNetData, peerAppData);
|
355
|
+
} while (res.getStatus() == SSLEngineResult.Status.OK &&
|
356
|
+
res.getHandshakeStatus() == SSLEngineResult.HandshakeStatus.NEED_UNWRAP &&
|
357
|
+
res.bytesProduced() == 0);
|
358
|
+
if(res.getHandshakeStatus() == SSLEngineResult.HandshakeStatus.FINISHED) {
|
359
|
+
finishInitialHandshake();
|
360
|
+
}
|
361
|
+
if(peerAppData.position() == 0 &&
|
362
|
+
res.getStatus() == SSLEngineResult.Status.OK &&
|
363
|
+
peerNetData.hasRemaining()) {
|
364
|
+
res = engine.unwrap(peerNetData, peerAppData);
|
365
|
+
}
|
366
|
+
status = res.getStatus();
|
367
|
+
hsStatus = res.getHandshakeStatus();
|
368
|
+
|
369
|
+
if(status == SSLEngineResult.Status.CLOSED) {
|
370
|
+
doShutdown();
|
371
|
+
return -1;
|
372
|
+
}
|
373
|
+
peerNetData.compact();
|
374
|
+
peerAppData.flip();
|
375
|
+
if(!initialHandshake && (hsStatus == SSLEngineResult.HandshakeStatus.NEED_TASK ||
|
376
|
+
hsStatus == SSLEngineResult.HandshakeStatus.NEED_WRAP ||
|
377
|
+
hsStatus == SSLEngineResult.HandshakeStatus.FINISHED)) {
|
378
|
+
doHandshake();
|
379
|
+
}
|
380
|
+
return peerAppData.remaining();
|
381
|
+
}
|
382
|
+
|
383
|
+
private void doShutdown() throws IOException {
|
384
|
+
if (engine.isOutboundDone()) {
|
385
|
+
return;
|
386
|
+
}
|
387
|
+
netData.clear();
|
388
|
+
try {
|
389
|
+
engine.wrap(dummy, netData);
|
390
|
+
} catch(Exception e1) {
|
391
|
+
return;
|
392
|
+
}
|
393
|
+
netData.flip();
|
394
|
+
flushData();
|
395
|
+
|
396
|
+
rsel.close();
|
397
|
+
wsel.close();
|
398
|
+
asel.close();
|
399
|
+
}
|
400
|
+
|
401
|
+
@JRubyMethod(rest = true, required = 1, optional = 1)
|
402
|
+
public IRubyObject sysread(ThreadContext context, IRubyObject[] args) {
|
403
|
+
Ruby runtime = context.getRuntime();
|
404
|
+
int len = RubyNumeric.fix2int(args[0]);
|
405
|
+
IRubyObject str = getRuntime().getNil();
|
406
|
+
|
407
|
+
if (args.length == 2) {
|
408
|
+
str = args[1];
|
409
|
+
}
|
410
|
+
if (str.isNil()) {
|
411
|
+
str = getRuntime().newString("");
|
412
|
+
}
|
413
|
+
if(len == 0) {
|
414
|
+
return str;
|
415
|
+
}
|
416
|
+
if (len < 0) {
|
417
|
+
throw runtime.newArgumentError("negative string size (or size too big)");
|
418
|
+
}
|
419
|
+
|
420
|
+
// So we need to make sure to only block when there is no data left to process
|
421
|
+
if(engine == null || !(peerAppData.hasRemaining() || peerNetData.position() > 0)) {
|
422
|
+
waitSelect(rsel);
|
423
|
+
}
|
424
|
+
|
425
|
+
ByteBuffer dst = ByteBuffer.allocate(len);
|
426
|
+
try {
|
427
|
+
int rr = -1;
|
428
|
+
if(engine == null) {
|
429
|
+
rr = c.read(dst);
|
430
|
+
} else {
|
431
|
+
rr = read(dst);
|
432
|
+
}
|
433
|
+
byte[] out = null;
|
434
|
+
boolean eof = false;
|
435
|
+
if(rr == -1) {
|
436
|
+
eof = true;
|
437
|
+
} else {
|
438
|
+
byte[] bss = new byte[rr];
|
439
|
+
dst.position(dst.position()-rr);
|
440
|
+
dst.get(bss);
|
441
|
+
out = bss;
|
442
|
+
}
|
443
|
+
if(eof){
|
444
|
+
throw getRuntime().newEOFError();
|
445
|
+
}
|
446
|
+
|
447
|
+
str.callMethod(getRuntime().getCurrentContext(),"<<",RubyString.newString(getRuntime(), out));
|
448
|
+
return str;
|
449
|
+
} catch (IOException ioe) {
|
450
|
+
throw runtime.newIOErrorFromException(ioe);
|
451
|
+
}
|
452
|
+
}
|
453
|
+
|
454
|
+
@JRubyMethod
|
455
|
+
public IRubyObject syswrite(ThreadContext context, IRubyObject arg) {
|
456
|
+
Ruby runtime = context.getRuntime();
|
457
|
+
waitSelect(wsel);
|
458
|
+
byte[] bls = arg.convertToString().getBytes();
|
459
|
+
ByteBuffer b1 = ByteBuffer.wrap(bls);
|
460
|
+
try {
|
461
|
+
int written;
|
462
|
+
if(engine == null) {
|
463
|
+
written = writeToChannel(c, b1);
|
464
|
+
} else {
|
465
|
+
written = write(b1);
|
466
|
+
}
|
467
|
+
((RubyIO)api.callMethod(this,"io")).flush();
|
468
|
+
|
469
|
+
return getRuntime().newFixnum(written);
|
470
|
+
} catch (IOException ioe) {
|
471
|
+
throw runtime.newIOErrorFromException(ioe);
|
472
|
+
}
|
473
|
+
}
|
474
|
+
|
475
|
+
private void close() {
|
476
|
+
if (engine == null) throw getRuntime().newEOFError();
|
477
|
+
engine.closeOutbound();
|
478
|
+
if (netData.hasRemaining()) {
|
479
|
+
return;
|
480
|
+
} else {
|
481
|
+
try {
|
482
|
+
doShutdown();
|
483
|
+
} catch (IOException ex) {
|
484
|
+
// ignore?
|
485
|
+
}
|
486
|
+
}
|
487
|
+
}
|
488
|
+
|
489
|
+
@JRubyMethod
|
490
|
+
public IRubyObject sysclose() {
|
491
|
+
close();
|
492
|
+
ThreadContext tc = getRuntime().getCurrentContext();
|
493
|
+
if(callMethod(tc,"sync_close").isTrue()) {
|
494
|
+
callMethod(tc,"io").callMethod(tc,"close");
|
495
|
+
}
|
496
|
+
return getRuntime().getNil();
|
497
|
+
}
|
498
|
+
|
499
|
+
@JRubyMethod
|
500
|
+
public IRubyObject cert() {
|
501
|
+
try {
|
502
|
+
Certificate[] cert = engine.getSession().getLocalCertificates();
|
503
|
+
if (cert.length > 0) {
|
504
|
+
return X509Cert.wrap(getRuntime(), cert[0]);
|
505
|
+
}
|
506
|
+
} catch (CertificateEncodingException ex) {
|
507
|
+
throw X509Cert.newCertificateError(getRuntime(), ex);
|
508
|
+
}
|
509
|
+
return getRuntime().getNil();
|
510
|
+
}
|
511
|
+
|
512
|
+
@JRubyMethod
|
513
|
+
public IRubyObject peer_cert() {
|
514
|
+
try {
|
515
|
+
Certificate[] cert = engine.getSession().getPeerCertificates();
|
516
|
+
if (cert.length > 0) {
|
517
|
+
return X509Cert.wrap(getRuntime(), cert[0]);
|
518
|
+
}
|
519
|
+
} catch (CertificateEncodingException ex) {
|
520
|
+
throw X509Cert.newCertificateError(getRuntime(), ex);
|
521
|
+
} catch (SSLPeerUnverifiedException ex) {
|
522
|
+
Logger.getLogger(SSLSocket.class.getName()).log(Level.SEVERE, null, ex);
|
523
|
+
}
|
524
|
+
return getRuntime().getNil();
|
525
|
+
}
|
526
|
+
|
527
|
+
@JRubyMethod
|
528
|
+
public IRubyObject peer_cert_chain() {
|
529
|
+
try {
|
530
|
+
javax.security.cert.Certificate[] certs = engine.getSession().getPeerCertificateChain();
|
531
|
+
|
532
|
+
RubyArray arr = getRuntime().newArray(certs.length);
|
533
|
+
for(int i = 0 ; i < certs.length; i++ ) {
|
534
|
+
arr.add(X509Cert.wrap(getRuntime(), certs[i]));
|
535
|
+
}
|
536
|
+
return arr;
|
537
|
+
} catch (javax.security.cert.CertificateEncodingException e) {
|
538
|
+
throw X509Cert.newCertificateError(getRuntime(), e);
|
539
|
+
} catch (SSLPeerUnverifiedException ex) {
|
540
|
+
Logger.getLogger(SSLSocket.class.getName()).log(Level.SEVERE, null, ex);
|
541
|
+
}
|
542
|
+
return getRuntime().getNil();
|
543
|
+
}
|
544
|
+
|
545
|
+
@JRubyMethod
|
546
|
+
public IRubyObject cipher() {
|
547
|
+
return getRuntime().newString(engine.getSession().getCipherSuite());
|
548
|
+
}
|
549
|
+
|
550
|
+
@JRubyMethod
|
551
|
+
public IRubyObject state() {
|
552
|
+
System.err.println("WARNING: unimplemented method called: SSLSocket#state");
|
553
|
+
return getRuntime().getNil();
|
554
|
+
}
|
555
|
+
|
556
|
+
@JRubyMethod
|
557
|
+
public IRubyObject pending() {
|
558
|
+
System.err.println("WARNING: unimplemented method called: SSLSocket#pending");
|
559
|
+
return getRuntime().getNil();
|
560
|
+
}
|
561
|
+
}// SSLSocket
|