File: stomp_auth.rb

package info (click to toggle)
stompserver 0.9.9gem-5
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 424 kB
  • sloc: ruby: 2,765; sh: 162; makefile: 3
file content (22 lines) | stat: -rw-r--r-- 492 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
module StompServer

class StompAuth
attr_accessor :authorized

  def initialize(passfile='.passwd')
    @passfile = passfile
    @authorized = Hash.new
    if File.exist?(@passfile)
      file = File.read(@passfile)
      file.split(/\n/).each do |data|
        next if data =~/^\s*#/
        data.gsub(/\s/,'')
        if data =~ /^\s*(\S+)\s*:\s*(.*?)\s*$/
          @authorized[$1] = $2
        end
      end
    end
    puts "Authorized users #{@authorized.keys}" if $DEBUG
  end
end
end