demo centralized
This commit is contained in:
parent
a99dce361d
commit
93aa6bc904
|
@ -69,6 +69,7 @@ VERBOSE = 0
|
||||||
|
|
||||||
include APDU
|
include APDU
|
||||||
|
|
||||||
|
# tell APDU methods how to send
|
||||||
def transmit_apdu(apdu)
|
def transmit_apdu(apdu)
|
||||||
return @client.apdu(apdu)
|
return @client.apdu(apdu)
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,60 @@
|
||||||
|
#!/usr/bin/env ruby
|
||||||
|
=begin
|
||||||
|
This file is part of SAP.
|
||||||
|
|
||||||
|
SAP is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
SAP is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with SAP. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Copyright (C) 2011 Kevin "tsaitgaist" Redon kevredon@mail.tsaitgaist.info
|
||||||
|
=end
|
||||||
|
# this program is there to start a server
|
||||||
|
require 'socket'
|
||||||
|
require 'pcsc_server'
|
||||||
|
require 'sim_server'
|
||||||
|
|
||||||
|
# the io the server should use (:tcp, :unix)
|
||||||
|
io_type = :tcp
|
||||||
|
# the server to use (:pcsc, :sim)
|
||||||
|
server_type = :pcsc
|
||||||
|
|
||||||
|
# create the IO
|
||||||
|
case io_type
|
||||||
|
when :tcp
|
||||||
|
TCP_HOST = "localhost"
|
||||||
|
TCP_PORT = "1337"
|
||||||
|
socket = TCPServer.new(TCP_HOST,TCP_PORT)
|
||||||
|
when :unix
|
||||||
|
UNIX = "/tmp/sap_server.socket"
|
||||||
|
socket = UNIXServer.new(APDU_SOCKET)
|
||||||
|
else
|
||||||
|
raise "unkown IO type"
|
||||||
|
end
|
||||||
|
|
||||||
|
# wait for a client to connect
|
||||||
|
io = socket.accept
|
||||||
|
|
||||||
|
case server_type
|
||||||
|
when :pcsc
|
||||||
|
server = PCSCServer.new(io)
|
||||||
|
when :sim
|
||||||
|
server = SIMServer.new(io)
|
||||||
|
else
|
||||||
|
raise "unkown server type"
|
||||||
|
end
|
||||||
|
|
||||||
|
# starting the server
|
||||||
|
server.start
|
||||||
|
|
||||||
|
# close IO when finished
|
||||||
|
io.close
|
||||||
|
server.close
|
|
@ -18,7 +18,6 @@ along with SAP. If not, see <http://www.gnu.org/licenses/>.
|
||||||
Copyright (C) 2011 Kevin "tsaitgaist" Redon kevredon@mail.tsaitgaist.info
|
Copyright (C) 2011 Kevin "tsaitgaist" Redon kevredon@mail.tsaitgaist.info
|
||||||
=end
|
=end
|
||||||
require 'lib/server'
|
require 'lib/server'
|
||||||
require 'socket'
|
|
||||||
require 'rubygems'
|
require 'rubygems'
|
||||||
require 'smartcard'
|
require 'smartcard'
|
||||||
=begin
|
=begin
|
||||||
|
@ -109,9 +108,3 @@ class PCSCServer < Server
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# demo application, using TCP socket
|
|
||||||
socket = TCPServer.new("localhost",1337)
|
|
||||||
io = socket.accept
|
|
||||||
server = PCSCServer.new(io)
|
|
||||||
server.start
|
|
||||||
|
|
|
@ -140,7 +140,7 @@ class SIMServer < Server
|
||||||
# select file using the file ID
|
# select file using the file ID
|
||||||
# node representing the file is returned
|
# node representing the file is returned
|
||||||
# nil is return if file does not exist or is unaccessible
|
# nil is return if file does not exist or is unaccessible
|
||||||
def select (id)
|
def select(id)
|
||||||
response = nil
|
response = nil
|
||||||
# get the current directory
|
# get the current directory
|
||||||
dfs = [0x3f,0x5f,0x7f]
|
dfs = [0x3f,0x5f,0x7f]
|
||||||
|
@ -179,9 +179,3 @@ class SIMServer < Server
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# demo application, using TCP socket
|
|
||||||
socket = TCPServer.new("localhost",1337)
|
|
||||||
io = socket.accept
|
|
||||||
server = SIMServer.new(io)
|
|
||||||
server.start
|
|
||||||
|
|
Loading…
Reference in New Issue