]> source.dussan.org Git - sonarqube.git/commitdiff
rollback SONAR-1920
authorsimonbrandhof <simon.brandhof@gmail.com>
Wed, 3 Nov 2010 15:03:05 +0000 (15:03 +0000)
committersimonbrandhof <simon.brandhof@gmail.com>
Wed, 3 Nov 2010 15:03:05 +0000 (15:03 +0000)
17 files changed:
sonar-server/src/main/webapp/WEB-INF/gems/gems/jruby-openssl-0.5.1/History.txt [new file with mode: 0644]
sonar-server/src/main/webapp/WEB-INF/gems/gems/jruby-openssl-0.5.1/License.txt [new file with mode: 0644]
sonar-server/src/main/webapp/WEB-INF/gems/gems/jruby-openssl-0.5.1/README.txt [new file with mode: 0644]
sonar-server/src/main/webapp/WEB-INF/gems/gems/jruby-openssl-0.5.1/lib/bcmail-jdk14-139.jar [new file with mode: 0644]
sonar-server/src/main/webapp/WEB-INF/gems/gems/jruby-openssl-0.5.1/lib/bcprov-jdk14-139.jar [new file with mode: 0644]
sonar-server/src/main/webapp/WEB-INF/gems/gems/jruby-openssl-0.5.1/lib/jopenssl.jar [new file with mode: 0644]
sonar-server/src/main/webapp/WEB-INF/gems/gems/jruby-openssl-0.5.1/lib/jopenssl/version.rb [new file with mode: 0644]
sonar-server/src/main/webapp/WEB-INF/gems/gems/jruby-openssl-0.5.1/lib/openssl.rb [new file with mode: 0644]
sonar-server/src/main/webapp/WEB-INF/gems/gems/jruby-openssl-0.5.1/lib/openssl/bn.rb [new file with mode: 0644]
sonar-server/src/main/webapp/WEB-INF/gems/gems/jruby-openssl-0.5.1/lib/openssl/buffering.rb [new file with mode: 0644]
sonar-server/src/main/webapp/WEB-INF/gems/gems/jruby-openssl-0.5.1/lib/openssl/cipher.rb [new file with mode: 0644]
sonar-server/src/main/webapp/WEB-INF/gems/gems/jruby-openssl-0.5.1/lib/openssl/digest.rb [new file with mode: 0644]
sonar-server/src/main/webapp/WEB-INF/gems/gems/jruby-openssl-0.5.1/lib/openssl/dummy.rb [new file with mode: 0644]
sonar-server/src/main/webapp/WEB-INF/gems/gems/jruby-openssl-0.5.1/lib/openssl/dummyssl.rb [new file with mode: 0644]
sonar-server/src/main/webapp/WEB-INF/gems/gems/jruby-openssl-0.5.1/lib/openssl/ssl.rb [new file with mode: 0644]
sonar-server/src/main/webapp/WEB-INF/gems/gems/jruby-openssl-0.5.1/lib/openssl/x509.rb [new file with mode: 0644]
sonar-server/src/main/webapp/WEB-INF/gems/specifications/jruby-openssl-0.5.1.gemspec [new file with mode: 0644]

diff --git a/sonar-server/src/main/webapp/WEB-INF/gems/gems/jruby-openssl-0.5.1/History.txt b/sonar-server/src/main/webapp/WEB-INF/gems/gems/jruby-openssl-0.5.1/History.txt
new file mode 100644 (file)
index 0000000..4608db0
--- /dev/null
@@ -0,0 +1,39 @@
+== 0.5.1
+
+* Multiple fixes by Brice Figureau to get net/ssh working. Requires JRuby 1.3.1 to be 100%
+* Fix by Frederic Jean for a character-decoding issue for some certificates
+
+== 0.5
+
+* Fixed JRUBY-3614: Unsupported HMAC algorithm (HMACSHA-256)
+* Fixed JRUBY-3570: ActiveMerchant's AuthorizeNet Gateway throws OpenSSL Cert Validation Error, when there should be no error
+* Fixed JRUBY-3557 Class cast exception in PKeyRSA.java
+* Fixed JRUBY-3468 X.509 certificates: subjectKeyIdentifier corrupted
+* Fixed JRUBY-3285 Unsupported HMAC algorithm (HMACSHA1) error when generating digest
+* Misc code cleanup
+
+== 0.2
+
+- Enable remaining tests; fix a nil string issue in SSLSocket.sysread (JRUBY-1888)
+- Fix socket buffering issue by setting socket IO sync = true
+- Fix bad file descriptor issue caused by unnecessary close (JRUBY-2152)
+- Fix AES key length (JRUBY-2187)
+- Fix cipher initialization (JRUBY-1100)
+- Now, only compatible with JRuby 1.1
+
+== 0.1.1
+
+- Fixed blocker issue preventing HTTPS/SSL from working (JRUBY-1222)
+
+== 0.1
+
+- PLEASE NOTE: This release is not compatible with JRuby releases earlier than
+  1.0.3 or 1.1b2. If you must use JRuby 1.0.2 or earlier, please install the
+  0.6 release.
+- Release coincides with JRuby 1.0.3 and JRuby 1.1b2 releases
+- Simultaneous support for JRuby trunk and 1.0 branch
+- Start of support for OpenSSL::BN
+
+== 0.0.5 and prior
+
+- Initial versions with maintenance updates
diff --git a/sonar-server/src/main/webapp/WEB-INF/gems/gems/jruby-openssl-0.5.1/License.txt b/sonar-server/src/main/webapp/WEB-INF/gems/gems/jruby-openssl-0.5.1/License.txt
new file mode 100644 (file)
index 0000000..e013639
--- /dev/null
@@ -0,0 +1,30 @@
+JRuby-OpenSSL is distributed under the same license as JRuby (http://www.jruby.org/).
+
+Version: CPL 1.0/GPL 2.0/LGPL 2.1
+
+The contents of this file are subject to the Common Public
+License Version 1.0 (the "License"); you may not use this file
+except in compliance with the License. You may obtain a copy of
+the License at http://www.eclipse.org/legal/cpl-v10.html
+
+Software distributed under the License is distributed on an "AS
+IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+implied. See the License for the specific language governing
+rights and limitations under the License.
+
+Copyright (C) 2007 Ola Bini <ola.bini@gmail.com>
+
+Alternatively, the contents of this file may be used under the terms of
+either of the GNU General Public License Version 2 or later (the "GPL"),
+or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+in which case the provisions of the GPL or the LGPL are applicable instead
+of those above. If you wish to allow use of your version of this file only
+under the terms of either the GPL or the LGPL, and not to allow others to
+use your version of this file under the terms of the CPL, indicate your
+decision by deleting the provisions above and replace them with the notice
+and other provisions required by the GPL or the LGPL. If you do not delete
+the provisions above, a recipient may use your version of this file under
+the terms of any one of the CPL, the GPL or the LGPL.
+
+JRuby-OpenSSL includes software by the Legion of the Bouncy Castle
+(http://bouncycastle.org/license.html).
diff --git a/sonar-server/src/main/webapp/WEB-INF/gems/gems/jruby-openssl-0.5.1/README.txt b/sonar-server/src/main/webapp/WEB-INF/gems/gems/jruby-openssl-0.5.1/README.txt
new file mode 100644 (file)
index 0000000..cc3b589
--- /dev/null
@@ -0,0 +1,24 @@
+= JRuby-OpenSSL
+
+* http://jruby-extras.rubyforge.org/jruby-openssl
+
+== DESCRIPTION:
+
+JRuby-OpenSSL is an add-on gem for JRuby that emulates the Ruby OpenSSL native library.
+
+JRuby offers *just enough* compatibility for most Ruby applications that use OpenSSL. 
+
+Libraries that appear to work fine:
+
+    Rails, Net::HTTPS
+
+Notable libraries that do *not* yet work include:
+
+    Net::SSH, Net::SFTP, etc.
+
+Please report bugs and incompatibilities (preferably with testcases) to either the JRuby 
+mailing list [1] or the JRuby bug tracker [2].
+
+[1]: http://xircles.codehaus.org/projects/jruby/lists
+
+[2]: http://jira.codehaus.org/browse/JRUBY
\ No newline at end of file
diff --git a/sonar-server/src/main/webapp/WEB-INF/gems/gems/jruby-openssl-0.5.1/lib/bcmail-jdk14-139.jar b/sonar-server/src/main/webapp/WEB-INF/gems/gems/jruby-openssl-0.5.1/lib/bcmail-jdk14-139.jar
new file mode 100644 (file)
index 0000000..40b994d
Binary files /dev/null and b/sonar-server/src/main/webapp/WEB-INF/gems/gems/jruby-openssl-0.5.1/lib/bcmail-jdk14-139.jar differ
diff --git a/sonar-server/src/main/webapp/WEB-INF/gems/gems/jruby-openssl-0.5.1/lib/bcprov-jdk14-139.jar b/sonar-server/src/main/webapp/WEB-INF/gems/gems/jruby-openssl-0.5.1/lib/bcprov-jdk14-139.jar
new file mode 100644 (file)
index 0000000..986049b
Binary files /dev/null and b/sonar-server/src/main/webapp/WEB-INF/gems/gems/jruby-openssl-0.5.1/lib/bcprov-jdk14-139.jar differ
diff --git a/sonar-server/src/main/webapp/WEB-INF/gems/gems/jruby-openssl-0.5.1/lib/jopenssl.jar b/sonar-server/src/main/webapp/WEB-INF/gems/gems/jruby-openssl-0.5.1/lib/jopenssl.jar
new file mode 100644 (file)
index 0000000..e028495
Binary files /dev/null and b/sonar-server/src/main/webapp/WEB-INF/gems/gems/jruby-openssl-0.5.1/lib/jopenssl.jar differ
diff --git a/sonar-server/src/main/webapp/WEB-INF/gems/gems/jruby-openssl-0.5.1/lib/jopenssl/version.rb b/sonar-server/src/main/webapp/WEB-INF/gems/gems/jruby-openssl-0.5.1/lib/jopenssl/version.rb
new file mode 100644 (file)
index 0000000..69d7f51
--- /dev/null
@@ -0,0 +1,5 @@
+module Jopenssl
+  module Version
+    VERSION = "0.5.1"
+  end
+end
diff --git a/sonar-server/src/main/webapp/WEB-INF/gems/gems/jruby-openssl-0.5.1/lib/openssl.rb b/sonar-server/src/main/webapp/WEB-INF/gems/gems/jruby-openssl-0.5.1/lib/openssl.rb
new file mode 100644 (file)
index 0000000..555411d
--- /dev/null
@@ -0,0 +1,24 @@
+=begin
+= $RCSfile: openssl.rb,v $ -- Loader for all OpenSSL C-space and Ruby-space definitions
+
+= Info
+  'OpenSSL for Ruby 2' project
+  Copyright (C) 2002  Michal Rokos <m.rokos@sh.cvut.cz>
+  All rights reserved.
+
+= Licence
+  This program is licenced under the same licence as Ruby.
+  (See the file 'LICENCE'.)
+
+= Version
+  $Id: openssl.rb,v 1.1 2003/07/23 16:11:29 gotoyuzo Exp $
+=end
+
+require 'jopenssl'
+
+require 'openssl/bn'
+require 'openssl/cipher'
+require 'openssl/digest'
+require 'openssl/ssl'
+require 'openssl/x509'
+
diff --git a/sonar-server/src/main/webapp/WEB-INF/gems/gems/jruby-openssl-0.5.1/lib/openssl/bn.rb b/sonar-server/src/main/webapp/WEB-INF/gems/gems/jruby-openssl-0.5.1/lib/openssl/bn.rb
new file mode 100644 (file)
index 0000000..4a1595c
--- /dev/null
@@ -0,0 +1,35 @@
+=begin
+= $RCSfile: bn.rb,v $ -- Ruby-space definitions that completes C-space funcs for BN
+
+= Info
+  'OpenSSL for Ruby 2' project
+  Copyright (C) 2002  Michal Rokos <m.rokos@sh.cvut.cz>
+  All rights reserved.
+
+= Licence
+  This program is licenced under the same licence as Ruby.
+  (See the file 'LICENCE'.)
+
+= Version
+  $Id: bn.rb,v 1.1 2003/07/23 16:11:30 gotoyuzo Exp $
+=end
+
+##
+# Should we care what if somebody require this file directly?
+#require 'openssl'
+
+module OpenSSL
+  class BN
+    include Comparable
+  end # BN
+end # OpenSSL
+
+##
+# Add double dispatch to Integer
+#
+class Integer
+  def to_bn
+    OpenSSL::BN::new(self)
+  end
+end # Integer
+
diff --git a/sonar-server/src/main/webapp/WEB-INF/gems/gems/jruby-openssl-0.5.1/lib/openssl/buffering.rb b/sonar-server/src/main/webapp/WEB-INF/gems/gems/jruby-openssl-0.5.1/lib/openssl/buffering.rb
new file mode 100644 (file)
index 0000000..9eeb19d
--- /dev/null
@@ -0,0 +1,239 @@
+=begin
+= $RCSfile: buffering.rb,v $ -- Buffering mix-in module.
+
+= Info
+  'OpenSSL for Ruby 2' project
+  Copyright (C) 2001 GOTOU YUUZOU <gotoyuzo@notwork.org>
+  All rights reserved.
+
+= Licence
+  This program is licenced under the same licence as Ruby.
+  (See the file 'LICENCE'.)
+
+= Version
+  $Id: buffering.rb,v 1.5.2.4 2005/09/04 22:03:24 gotoyuzo Exp $
+=end
+
+module Buffering
+  include Enumerable
+  attr_accessor :sync
+  BLOCK_SIZE = 1024*16
+
+  def initialize(*args)
+    @eof = false
+    @rbuffer = ""
+    @sync = @io.sync
+  end
+
+  #
+  # for reading.
+  #
+  private
+
+  def fill_rbuff
+    begin
+      @rbuffer << self.sysread(BLOCK_SIZE)
+    rescue Errno::EAGAIN
+      retry
+    rescue EOFError
+      @eof = true
+    end
+  end
+
+  def consume_rbuff(size=nil)
+    if @rbuffer.empty?
+      nil
+    else
+      size = @rbuffer.size unless size
+      ret = @rbuffer[0, size]
+      @rbuffer[0, size] = ""
+      ret
+    end
+  end
+
+  public
+
+  def read(size=nil, buf=nil)
+    if size == 0
+      if buf
+        buf.clear
+      else
+        buf = ""
+      end
+      return @eof ? nil : buf
+    end
+    until @eof
+      break if size && size <= @rbuffer.size
+      fill_rbuff
+    end
+    ret = consume_rbuff(size) || ""
+    if buf
+      buf.replace(ret)
+      ret = buf
+    end
+    (size && ret.empty?) ? nil : ret
+  end
+
+  def readpartial(maxlen, buf=nil)
+    if maxlen == 0
+      if buf
+        buf.clear
+      else
+        buf = ""
+      end
+      return @eof ? nil : buf
+    end
+    if @rbuffer.empty?
+      begin
+        return sysread(maxlen, buf)
+      rescue Errno::EAGAIN
+        retry
+      end
+    end
+    ret = consume_rbuff(maxlen)
+    if buf
+      buf.replace(ret)
+      ret = buf
+    end
+    raise EOFError if ret.empty?
+    ret
+  end
+
+  def gets(eol=$/)
+    idx = @rbuffer.index(eol)
+    until @eof
+      break if idx
+      fill_rbuff
+      idx = @rbuffer.index(eol)
+    end
+    if eol.is_a?(Regexp)
+      size = idx ? idx+$&.size : nil
+    else
+      size = idx ? idx+eol.size : nil
+    end
+    consume_rbuff(size)
+  end
+
+  def each(eol=$/)
+    while line = self.gets(eol)
+      yield line
+    end
+  end
+  alias each_line each
+
+  def readlines(eol=$/)
+    ary = []
+    while line = self.gets(eol)
+      ary << line
+    end
+    ary
+  end
+
+  def readline(eol=$/)
+    raise EOFError if eof?
+    gets(eol)
+  end
+
+  def getc
+    c = read(1)
+    c ? c[0] : nil
+  end
+
+  def each_byte
+    while c = getc
+      yield(c)
+    end
+  end
+
+  def readchar
+    raise EOFError if eof?
+    getc
+  end
+
+  def ungetc(c)
+    @rbuffer[0,0] = c.chr
+  end
+
+  def eof?
+    fill_rbuff if !@eof && @rbuffer.empty?
+    @eof && @rbuffer.empty?
+  end
+  alias eof eof?
+
+  #
+  # for writing.
+  #
+  private
+
+  def do_write(s)
+    @wbuffer = "" unless defined? @wbuffer
+    @wbuffer << s
+    @sync ||= false
+    if @sync or @wbuffer.size > BLOCK_SIZE or idx = @wbuffer.rindex($/)
+      remain = idx ? idx + $/.size : @wbuffer.length
+      nwritten = 0
+      while remain > 0
+        str = @wbuffer[nwritten,remain]
+        begin
+          nwrote = syswrite(str)
+        rescue Errno::EAGAIN
+          retry
+        end
+        remain -= nwrote
+        nwritten += nwrote
+      end
+      @wbuffer[0,nwritten] = ""
+    end
+  end
+
+  public
+
+  def write(s)
+    do_write(s)
+    s.length
+  end
+
+  def << (s)
+    do_write(s)
+    self
+  end
+
+  def puts(*args)
+    s = ""
+    if args.empty?
+      s << "\n"
+    end
+    args.each{|arg|
+      s << arg.to_s
+      if $/ && /\n\z/ !~ s
+        s << "\n"
+      end
+    }
+    do_write(s)
+    nil
+  end
+
+  def print(*args)
+    s = ""
+    args.each{ |arg| s << arg.to_s }
+    do_write(s)
+    nil
+  end
+
+  def printf(s, *args)
+    do_write(s % args)
+    nil
+  end
+
+  def flush
+    osync = @sync
+    @sync = true
+    do_write ""
+    @sync = osync
+  end
+
+  def close
+    flush rescue nil
+    sysclose
+  end
+end
diff --git a/sonar-server/src/main/webapp/WEB-INF/gems/gems/jruby-openssl-0.5.1/lib/openssl/cipher.rb b/sonar-server/src/main/webapp/WEB-INF/gems/gems/jruby-openssl-0.5.1/lib/openssl/cipher.rb
new file mode 100644 (file)
index 0000000..7825e5e
--- /dev/null
@@ -0,0 +1,58 @@
+=begin
+= $RCSfile: cipher.rb,v $ -- Ruby-space predefined Cipher subclasses
+
+= Info
+  'OpenSSL for Ruby 2' project
+  Copyright (C) 2002  Michal Rokos <m.rokos@sh.cvut.cz>
+  All rights reserved.
+
+= Licence
+  This program is licenced under the same licence as Ruby.
+  (See the file 'LICENCE'.)
+
+= Version
+  $Id: cipher.rb,v 1.1.2.2 2006/06/20 11:18:15 gotoyuzo Exp $
+=end
+
+##
+# Should we care what if somebody require this file directly?
+#require 'openssl'
+
+module OpenSSL
+  module Cipher
+    %w(AES CAST5 BF DES IDEA RC2 RC4 RC5).each{|name|
+      klass = Class.new(Cipher){
+        define_method(:initialize){|*args|
+          cipher_name = args.inject(name){|n, arg| "#{n}-#{arg}" }
+          super(cipher_name)
+        }
+      }
+      const_set(name, klass)
+    }
+
+    %w(128 192 256).each{|keylen|
+      klass = Class.new(Cipher){
+        define_method(:initialize){|mode|
+          mode ||= "CBC"
+          cipher_name = "AES-#{keylen}-#{mode}"
+          super(cipher_name)
+        }
+      }
+      const_set("AES#{keylen}", klass)
+    }
+
+    class Cipher
+      def random_key
+        str = OpenSSL::Random.random_bytes(self.key_len)
+        self.key = str
+        return str
+      end
+
+      def random_iv
+        str = OpenSSL::Random.random_bytes(self.iv_len)
+        self.iv = str
+        return str
+      end
+    end
+  end # Cipher
+end # OpenSSL
diff --git a/sonar-server/src/main/webapp/WEB-INF/gems/gems/jruby-openssl-0.5.1/lib/openssl/digest.rb b/sonar-server/src/main/webapp/WEB-INF/gems/gems/jruby-openssl-0.5.1/lib/openssl/digest.rb
new file mode 100644 (file)
index 0000000..ac7dd3c
--- /dev/null
@@ -0,0 +1,48 @@
+=begin
+= $RCSfile: digest.rb,v $ -- Ruby-space predefined Digest subclasses
+
+= Info
+  'OpenSSL for Ruby 2' project
+  Copyright (C) 2002  Michal Rokos <m.rokos@sh.cvut.cz>
+  All rights reserved.
+
+= Licence
+  This program is licenced under the same licence as Ruby.
+  (See the file 'LICENCE'.)
+
+= Version
+  $Id: digest.rb,v 1.1.2.2 2006/06/20 11:18:15 gotoyuzo Exp $
+=end
+
+##
+# Should we care what if somebody require this file directly?
+#require 'openssl'
+
+module OpenSSL
+  module Digest
+
+    alg = %w(DSS DSS1 MD2 MD4 MD5 MDC2 RIPEMD160 SHA SHA1)
+    if OPENSSL_VERSION_NUMBER > 0x00908000
+      alg += %w(SHA224 SHA256 SHA384 SHA512)
+    end
+    alg.each{|name|
+      klass = Class.new(Digest){
+        define_method(:initialize){|*data|
+          if data.length > 1
+            raise ArgumentError,
+              "wrong number of arguments (#{data.length} for 1)"
+          end
+          super(name, data.first)
+        }
+      }
+      singleton = (class <<klass; self; end)
+      singleton.class_eval{
+        define_method(:digest){|data| Digest.digest(name, data) }
+        define_method(:hexdigest){|data| Digest.hexdigest(name, data) }
+      }
+      const_set(name, klass)
+    }
+
+  end # Digest
+end # OpenSSL
+
diff --git a/sonar-server/src/main/webapp/WEB-INF/gems/gems/jruby-openssl-0.5.1/lib/openssl/dummy.rb b/sonar-server/src/main/webapp/WEB-INF/gems/gems/jruby-openssl-0.5.1/lib/openssl/dummy.rb
new file mode 100644 (file)
index 0000000..5bea7c7
--- /dev/null
@@ -0,0 +1,34 @@
+warn "Warning: OpenSSL ASN1/PKey/X509/Netscape/PKCS7 implementation unavailable"
+warn "You need to download or install BouncyCastle jars (bc-prov-*.jar, bc-mail-*.jar)"
+warn "to fix this."
+module OpenSSL
+  module ASN1
+    class ASN1Error < OpenSSLError; end
+    class ASN1Data; end
+    class Primitive; end
+    class Constructive; end
+  end
+  module PKey
+    class PKeyError < OpenSSLError; end
+    class PKey; def initialize(*args); end; end
+    class RSA < PKey; end
+    class DSA < PKey; end
+    class DH < PKey; end
+  end
+  module X509
+    class Name; end
+    class Certificate; end
+    class Extension; end
+    class CRL; end
+    class Revoked; end
+    class Store; end
+    class Request; end
+    class Attribute; end
+  end
+  module Netscape
+    class SPKI; end
+  end
+  module PKCS7
+    class PKCS7; end
+  end
+end
\ No newline at end of file
diff --git a/sonar-server/src/main/webapp/WEB-INF/gems/gems/jruby-openssl-0.5.1/lib/openssl/dummyssl.rb b/sonar-server/src/main/webapp/WEB-INF/gems/gems/jruby-openssl-0.5.1/lib/openssl/dummyssl.rb
new file mode 100644 (file)
index 0000000..a341085
--- /dev/null
@@ -0,0 +1,13 @@
+warn "Warning: OpenSSL SSL implementation unavailable"
+warn "You must run on JDK 1.5 (Java 5) or higher to use SSL"
+module OpenSSL
+  module SSL
+    class SSLError < OpenSSLError; end
+    class SSLContext; end
+    class SSLSocket; end
+    VERIFY_NONE = 0
+    VERIFY_PEER = 1
+    VERIFY_FAIL_IF_NO_PEER_CERT = 2
+    VERIFY_CLIENT_ONCE = 4
+  end
+end
\ No newline at end of file
diff --git a/sonar-server/src/main/webapp/WEB-INF/gems/gems/jruby-openssl-0.5.1/lib/openssl/ssl.rb b/sonar-server/src/main/webapp/WEB-INF/gems/gems/jruby-openssl-0.5.1/lib/openssl/ssl.rb
new file mode 100644 (file)
index 0000000..6fcf95f
--- /dev/null
@@ -0,0 +1,135 @@
+=begin
+= $RCSfile: ssl.rb,v $ -- Ruby-space definitions that completes C-space funcs for SSL
+
+= Info
+  'OpenSSL for Ruby 2' project
+  Copyright (C) 2001 GOTOU YUUZOU <gotoyuzo@notwork.org>
+  All rights reserved.
+
+= Licence
+  This program is licenced under the same licence as Ruby.
+  (See the file 'LICENCE'.)
+
+= Version
+  $Id: ssl.rb,v 1.5.2.6 2006/05/23 18:14:05 gotoyuzo Exp $
+=end
+
+require "openssl"
+require "openssl/buffering"
+require "fcntl"
+
+module OpenSSL
+  module SSL
+    module SocketForwarder
+      def addr
+        to_io.addr
+      end
+
+      def peeraddr
+        to_io.peeraddr
+      end
+
+      def setsockopt(level, optname, optval)
+        to_io.setsockopt(level, optname, optval)
+      end
+
+      def getsockopt(level, optname)
+        to_io.getsockopt(level, optname)
+      end
+
+      def fcntl(*args)
+        to_io.fcntl(*args)
+      end
+
+      def closed?
+        to_io.closed?
+      end
+
+      def do_not_reverse_lookup=(flag)
+        to_io.do_not_reverse_lookup = flag
+      end
+    end
+
+    module Nonblock
+      def initialize(*args)
+        flag = File::NONBLOCK
+        flag |= @io.fcntl(Fcntl::F_GETFL, nil) if defined?(Fcntl::F_GETFL)
+        @io.fcntl(Fcntl::F_SETFL, flag)
+        super
+      end
+    end
+
+    class SSLSocket
+      include Buffering
+      include SocketForwarder
+      include Nonblock
+
+      def post_connection_check(hostname)
+        check_common_name = true
+        cert = peer_cert
+        cert.extensions.each{|ext|
+          next if ext.oid != "subjectAltName"
+          ext.value.split(/,\s+/).each{|general_name|
+            if /\ADNS:(.*)/ =~ general_name
+              check_common_name = false
+              reg = Regexp.escape($1).gsub(/\\\*/, "[^.]+")
+              return true if /\A#{reg}\z/i =~ hostname
+            elsif /\AIP Address:(.*)/ =~ general_name
+              check_common_name = false
+              return true if $1 == hostname
+            end
+          }
+        }
+        if check_common_name
+          cert.subject.to_a.each{|oid, value|
+            if oid == "CN"
+              reg = Regexp.escape(value).gsub(/\\\*/, "[^.]+")
+              return true if /\A#{reg}\z/i =~ hostname
+            end
+          }
+        end
+        raise SSLError, "hostname not match"
+      end
+    end
+
+    class SSLServer
+      include SocketForwarder
+      attr_accessor :start_immediately
+
+      def initialize(svr, ctx)
+        @svr = svr
+        @ctx = ctx
+        unless ctx.session_id_context
+          session_id = OpenSSL::Digest::MD5.hexdigest($0)
+          @ctx.session_id_context = session_id
+        end
+        @start_immediately = true
+      end
+
+      def to_io
+        @svr
+      end
+
+      def listen(backlog=5)
+        @svr.listen(backlog)
+      end
+
+      def accept
+        sock = @svr.accept
+        begin
+          ssl = OpenSSL::SSL::SSLSocket.new(sock, @ctx)
+          ssl.sync_close = true
+          ssl.accept if @start_immediately
+          ssl
+        rescue SSLError => ex
+          sock.close
+          raise ex
+        end
+      end
+
+      def close
+        @svr.close
+      end
+    end
+  end
+end
diff --git a/sonar-server/src/main/webapp/WEB-INF/gems/gems/jruby-openssl-0.5.1/lib/openssl/x509.rb b/sonar-server/src/main/webapp/WEB-INF/gems/gems/jruby-openssl-0.5.1/lib/openssl/x509.rb
new file mode 100644 (file)
index 0000000..2ad3f8e
--- /dev/null
@@ -0,0 +1,154 @@
+=begin
+= $RCSfile: x509.rb,v $ -- Ruby-space definitions that completes C-space funcs for X509 and subclasses
+
+= Info
+  'OpenSSL for Ruby 2' project
+  Copyright (C) 2002  Michal Rokos <m.rokos@sh.cvut.cz>
+  All rights reserved.
+
+= Licence
+  This program is licenced under the same licence as Ruby.
+  (See the file 'LICENCE'.)
+
+= Version
+  $Id: x509.rb,v 1.4.2.2 2004/12/19 08:28:33 gotoyuzo Exp $
+=end
+
+require "openssl"
+
+module OpenSSL
+  module X509
+    class ExtensionFactory
+      def create_extension(*arg)
+        if arg.size > 1
+          create_ext(*arg)
+        else
+          send("create_ext_from_"+arg[0].class.name.downcase, arg[0])
+        end
+      end
+
+      def create_ext_from_array(ary)
+        raise ExtensionError, "unexpected array form" if ary.size > 3 
+        create_ext(ary[0], ary[1], ary[2])
+      end
+
+      def create_ext_from_string(str) # "oid = critical, value"
+        oid, value = str.split(/=/, 2)
+        oid.strip!
+        value.strip!
+        create_ext(oid, value)
+      end
+      
+      def create_ext_from_hash(hash)
+        create_ext(hash["oid"], hash["value"], hash["critical"])
+      end
+    end
+    
+    class Extension
+      def to_s # "oid = critical, value"
+        str = self.oid
+        str << " = "
+        str << "critical, " if self.critical?
+        str << self.value.gsub(/\n/, ", ")
+      end
+        
+      def to_h # {"oid"=>sn|ln, "value"=>value, "critical"=>true|false}
+        {"oid"=>self.oid,"value"=>self.value,"critical"=>self.critical?}
+      end
+
+      def to_a
+        [ self.oid, self.value, self.critical? ]
+      end
+    end
+
+    class Name
+      module RFC2253DN
+        Special = ',=+<>#;'
+        HexChar = /[0-9a-fA-F]/
+        HexPair = /#{HexChar}#{HexChar}/
+        HexString = /#{HexPair}+/
+        Pair = /\\(?:[#{Special}]|\\|"|#{HexPair})/
+        StringChar = /[^#{Special}\\"]/
+        QuoteChar = /[^\\"]/
+        AttributeType = /[a-zA-Z][0-9a-zA-Z]*|[0-9]+(?:\.[0-9]+)*/
+        AttributeValue = /
+          (?!["#])((?:#{StringChar}|#{Pair})*)|
+          \#(#{HexString})|
+          "((?:#{QuoteChar}|#{Pair})*)"
+        /x
+        TypeAndValue = /\A(#{AttributeType})=#{AttributeValue}/
+
+        module_function
+
+        def expand_pair(str)
+          return nil unless str
+          return str.gsub(Pair){|pair|
+            case pair.size
+            when 2 then pair[1,1]
+            when 3 then Integer("0x#{pair[1,2]}").chr
+            else raise OpenSSL::X509::NameError, "invalid pair: #{str}"
+            end
+          }
+        end
+
+        def expand_hexstring(str)
+          return nil unless str
+          der = str.gsub(HexPair){|hex| Integer("0x#{hex}").chr }
+          a1 = OpenSSL::ASN1.decode(der)
+          return a1.value, a1.tag
+        end
+
+        def expand_value(str1, str2, str3)
+          value = expand_pair(str1)
+          value, tag = expand_hexstring(str2) unless value
+          value = expand_pair(str3) unless value
+          return value, tag
+        end
+
+        def scan(dn)
+          str = dn
+          ary = []
+          while true
+            if md = TypeAndValue.match(str)
+              matched = md.to_s
+              remain = md.post_match
+              type = md[1]
+              value, tag = expand_value(md[2], md[3], md[4]) rescue nil
+              if value
+                type_and_value = [type, value]
+                type_and_value.push(tag) if tag
+                ary.unshift(type_and_value)
+                if remain.length > 2 && remain[0] == ?,
+                  str = remain[1..-1]
+                  next
+                elsif remain.length > 2 && remain[0] == ?+
+                  raise OpenSSL::X509::NameError,
+                    "multi-valued RDN is not supported: #{dn}"
+                elsif remain.empty?
+                  break
+                end
+              end
+            end
+            msg_dn = dn[0, dn.length - str.length] + " =>" + str
+            raise OpenSSL::X509::NameError, "malformed RDN: #{msg_dn}"
+          end
+          return ary
+        end
+      end
+
+      class <<self
+        def parse_rfc2253(str, template=OBJECT_TYPE_TEMPLATE)
+          ary = OpenSSL::X509::Name::RFC2253DN.scan(str)
+          self.new(ary, template)
+        end
+
+        def parse_openssl(str, template=OBJECT_TYPE_TEMPLATE)
+          ary = str.scan(/\s*([^\/,]+)\s*/).collect{|i| i[0].split("=", 2) }
+          self.new(ary, template)
+        end
+
+        alias parse parse_openssl
+      end
+    end
+  end
+end
diff --git a/sonar-server/src/main/webapp/WEB-INF/gems/specifications/jruby-openssl-0.5.1.gemspec b/sonar-server/src/main/webapp/WEB-INF/gems/specifications/jruby-openssl-0.5.1.gemspec
new file mode 100644 (file)
index 0000000..ee98cf6
--- /dev/null
@@ -0,0 +1,31 @@
+# -*- encoding: utf-8 -*-
+
+Gem::Specification.new do |s|
+  s.name = %q{jruby-openssl}
+  s.version = "0.5.1"
+
+  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
+  s.authors = ["Ola Bini and JRuby contributors"]
+  s.date = %q{2009-06-15}
+  s.description = %q{= JRuby-OpenSSL}
+  s.email = %q{ola.bini@gmail.com}
+  s.extra_rdoc_files = ["History.txt", "README.txt", "License.txt"]
+  s.files = ["History.txt", "README.txt", "License.txt", "lib/jopenssl.jar", "lib/bcmail-jdk14-139.jar", "lib/bcprov-jdk14-139.jar", "lib/openssl.rb", "lib/jopenssl/version.rb", "lib/openssl/bn.rb", "lib/openssl/buffering.rb", "lib/openssl/cipher.rb", "lib/openssl/digest.rb", "lib/openssl/dummy.rb", "lib/openssl/dummyssl.rb", "lib/openssl/ssl.rb", "lib/openssl/x509.rb", "test/pkcs7_mime_enveloped.message", "test/pkcs7_mime_signed.message", "test/pkcs7_multipart_signed.message", "test/test_cipher.rb", "test/test_integration.rb", "test/test_java.rb", "test/test_java_attribute.rb", "test/test_java_bio.rb", "test/test_java_mime.rb", "test/test_java_pkcs7.rb", "test/test_java_smime.rb", "test/test_openssl.rb", "test/test_openssl_x509.rb", "test/test_pkey.rb", "test/ut_eof.rb", "test/fixture/cacert.pem", "test/fixture/cert_localhost.pem", "test/fixture/localhost_keypair.pem", "test/openssl/ssl_server.rb", "test/openssl/test_asn1.rb", "test/openssl/test_cipher.rb", "test/openssl/test_digest.rb", "test/openssl/test_hmac.rb", "test/openssl/test_ns_spki.rb", "test/openssl/test_pair.rb", "test/openssl/test_pkcs7.rb", "test/openssl/test_pkey_rsa.rb", "test/openssl/test_ssl.rb", "test/openssl/test_x509cert.rb", "test/openssl/test_x509crl.rb", "test/openssl/test_x509ext.rb", "test/openssl/test_x509name.rb", "test/openssl/test_x509req.rb", "test/openssl/test_x509store.rb", "test/openssl/utils.rb", "test/ref/a.out", "test/ref/compile.rb", "test/ref/pkcs1", "test/ref/pkcs1.c"]
+  s.homepage = %q{http://jruby-extras.rubyforge.org/jruby-openssl}
+  s.rdoc_options = ["--main", "README.txt"]
+  s.require_paths = ["lib"]
+  s.rubyforge_project = %q{jruby-extras}
+  s.rubygems_version = %q{1.3.4}
+  s.summary = %q{OpenSSL add-on for JRuby}
+  s.test_files = ["test/test_cipher.rb", "test/test_integration.rb", "test/test_java.rb", "test/test_java_attribute.rb", "test/test_java_bio.rb", "test/test_java_mime.rb", "test/test_java_pkcs7.rb", "test/test_java_smime.rb", "test/test_openssl.rb", "test/test_openssl_x509.rb", "test/test_pkey.rb"]
+
+  if s.respond_to? :specification_version then
+    current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
+    s.specification_version = 3
+
+    if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
+    else
+    end
+  else
+  end
+end