Welcome to the "trac"-ing site of soap4r!
[soap4r] [httpclient] [openpgp4u] [pkcs1] [logger] [csv] [vtr]

Changeset 1185

Show
Ignore:
Timestamp:
03/27/04 01:41:49 (5 years ago)
Author:
nahi
Message:

* use soap/property instead of deprecated getopts.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/sample/soap/authheader/server.rb

    r1166 r1185  
    33require 'soap/rpc/standaloneServer' 
    44require 'soap/header/simplehandler' 
     5require 'authmgr' 
    56 
    67class AuthHeaderPortServer < SOAP::RPC::StandaloneServer 
     
    2324    super 
    2425    add_rpc_servant(AuthHeaderService.new, Name) 
    25     ServerAuthHeaderHandler.init 
    2626    add_rpc_request_headerhandler(ServerAuthHeaderHandler) 
    2727  end 
     
    3030    MyHeaderName = XSD::QName.new("http://tempuri.org/authHeader", "auth") 
    3131 
    32     class << self 
    33       def create 
    34         new 
    35       end 
    36  
    37       def init 
    38         @users = { 
    39           'NaHi' => 'passwd', 
    40           'HiNa' => 'wspass' 
    41         } 
    42         @sessions = {} 
    43       end 
    44  
    45       def login(userid, passwd) 
    46         userid and passwd and @users[userid] == passwd 
    47       end 
    48  
    49       def auth(sessionid) 
    50         @sessions[sessionid][0] 
    51       end 
    52  
    53       def create_session(userid) 
    54         while true 
    55           key = create_sessionkey 
    56           break unless @sessions[key] 
    57         end 
    58         @sessions[key] = [userid] 
    59         key 
    60       end 
    61  
    62       def destroy_session(sessionkey) 
    63         @sessions.delete(sessionkey) 
    64       end 
    65  
    66     private 
    67  
    68       def create_sessionkey 
    69         Time.now.usec.to_s 
    70       end 
     32    @authmgr = Authmgr.new 
     33    def self.create 
     34      new(@authmgr) 
    7135    end 
    7236 
    73     def initialize 
     37    def initialize(authmgr) 
    7438      super(MyHeaderName) 
     39      @authmgr = authmgr 
    7540      @userid = @sessionid = nil 
    7641    end 
     
    8449      userid = my_header["userid"] 
    8550      passwd = my_header["passwd"] 
    86       if self.class.login(userid, passwd) 
     51      if @authmgr.login(userid, passwd) 
    8752        auth = true 
    8853      elsif sessionid = my_header["sessionid"] 
    89         if userid = self.class.auth(sessionid) 
    90           self.class.destroy_session(sessionid) 
     54        if userid = @authmgr.auth(sessionid) 
     55          @authmgr.destroy_session(sessionid) 
    9156          auth = true 
    9257        end 
     
    9459      raise RuntimeError.new("authentication failed") unless auth 
    9560      @userid = userid 
    96       @sessionid = self.class.create_session(userid) 
     61      @sessionid = @authmgr.create_session(userid) 
    9762    end 
    9863  end 
  • trunk/sample/soap/calc/httpd.rb

    r966 r1185  
    22 
    33require 'webrick' 
    4 require 'getopts
     4require 'soap/property
    55 
    6 getopts "", 'r:', 'p:8808' 
     6docroot = "." 
     7port = 8808 
     8if opt = SOAP::Property.loadproperty("samplehttpd.conf") 
     9  docroot = opt["docroot"] 
     10  port = Integer(opt["port"]) 
     11end 
    712 
    813s = WEBrick::HTTPServer.new( 
    914  :BindAddress => "0.0.0.0", 
    10   :Port => $OPT_p.to_i
    11   :DocumentRoot => $OPT_r || "."
     15  :Port => port
     16  :DocumentRoot => docroot
    1217  :CGIPathEnv => ENV['PATH'] 
    1318) 
  • trunk/sample/soap/exchange/httpd.rb

    r966 r1185  
    22 
    33require 'webrick' 
    4 require 'getopts
     4require 'soap/property
    55 
    6 getopts "", 'r:', 'p:8808' 
     6docroot = "." 
     7port = 8808 
     8if opt = SOAP::Property.loadproperty("samplehttpd.conf") 
     9  docroot = opt["docroot"] 
     10  port = Integer(opt["port"]) 
     11end 
    712 
    813s = WEBrick::HTTPServer.new( 
    914  :BindAddress => "0.0.0.0", 
    10   :Port => $OPT_p.to_i
    11   :DocumentRoot => $OPT_r || "."
     15  :Port => port
     16  :DocumentRoot => docroot
    1217  :CGIPathEnv => ENV['PATH'] 
    1318) 
  • trunk/sample/soap/sampleStruct/httpd.rb

    r966 r1185  
    22 
    33require 'webrick' 
    4 require 'getopts
     4require 'soap/property
    55 
    6 getopts "", 'r:', 'p:8808' 
     6docroot = "." 
     7port = 8808 
     8if opt = SOAP::Property.loadproperty("samplehttpd.conf") 
     9  docroot = opt["docroot"] 
     10  port = Integer(opt["port"]) 
     11end 
    712 
    813s = WEBrick::HTTPServer.new( 
    914  :BindAddress => "0.0.0.0", 
    10   :Port => $OPT_p.to_i
    11   :DocumentRoot => $OPT_r || "."
     15  :Port => port
     16  :DocumentRoot => docroot
    1217  :CGIPathEnv => ENV['PATH'] 
    1318) 
  • trunk/sample/wsdl/googleSearch/httpd.rb

    r966 r1185  
    22 
    33require 'webrick' 
    4 require 'getopts
     4require 'soap/property
    55 
    6 getopts "", 'r:', 'p:8808' 
     6docroot = "." 
     7port = 8808 
     8if opt = SOAP::Property.loadproperty("samplehttpd.conf") 
     9  docroot = opt["docroot"] 
     10  port = Integer(opt["port"]) 
     11end 
    712 
    813s = WEBrick::HTTPServer.new( 
    914  :BindAddress => "0.0.0.0", 
    10   :Port => $OPT_p.to_i
    11   :DocumentRoot => $OPT_r || "."
     15  :Port => port
     16  :DocumentRoot => docroot
    1217  :CGIPathEnv => ENV['PATH'] 
    1318) 
  • trunk/test/runner.rb

    r1178 r1185  
    11require 'test/unit' 
    22 
    3 rcsid = %w$Id: runner.rb,v 1.5 2004/01/29 12:58:08 nahi Exp $ 
     3STDOUT.sync = true 
     4STDERR.sync = true 
     5rcsid = %w$Id: runner.rb,v 1.6 2004/03/26 16:41:49 nahi Exp $ 
    46Version = rcsid[2].scan(/\d+/).collect!(&method(:Integer)).freeze 
    57Release = rcsid[3].freeze 
    68 
    7 runner = Test::Unit::AutoRunner.new(true) 
    8 runner.to_run.concat(ARGV) 
    9 runner.to_run << File.dirname(__FILE__) if runner.to_run.empty? 
    10 runner.run 
     9exit Test::Unit::AutoRunner.run(false, File.dirname($0))