Changeset 604
- Timestamp:
- 03/30/07 17:12:03 (2 years ago)
- Files:
-
- trunk/src/hefeweizen_big_ania.rb (modified) (1 diff)
- trunk/src/hefeweizen_library_business_logic.rb (modified) (7 diffs)
- trunk/src/hefeweizen_library_cpa.rb (modified) (1 diff)
- trunk/src/hefeweizen_library_ebMS_message2.rb (modified) (3 diffs)
- trunk/src/hefeweizen_library_exchange_point.rb (modified) (2 diffs)
- trunk/src/hefeweizen_library_integration_point.rb (modified) (2 diffs)
- trunk/src/hefeweizen_library_utils.rb (modified) (1 diff)
- trunk/src/taskers/hefeweizen_tasker_application_decrypt_ebXML_message.rb (modified) (5 diffs)
- trunk/src/taskers/hefeweizen_tasker_application_dir_observer.rb (modified) (1 diff)
- trunk/src/taskers/hefeweizen_tasker_application_encrypt_ebXML_message.rb (modified) (5 diffs)
- trunk/src/taskers/hefeweizen_tasker_application_http_server.rb (modified) (6 diffs)
- trunk/src/taskers/hefeweizen_tasker_application_send_ebXML_message.rb (modified) (3 diffs)
- trunk/src/taskers/hefeweizen_tasker_application_sign_ebXML_message.rb (modified) (1 diff)
- trunk/src/taskers/hefeweizen_tasker_application_wake_up_call.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/hefeweizen_big_ania.rb
r557 r604 365 365 366 366 def say_to_ania command 367 my_command = "echo \"#{command}\" >> #{@pipe_to_ania} " 368 system my_command 367 HefeWeizen::HefeWeizenLibrary::Execution.write_to_pipe command, @pipe_to_ania 369 368 end 370 369 trunk/src/hefeweizen_library_business_logic.rb
r557 r604 1975 1975 "uuid" => HefeWeizen::HefeWeizenLibrary::HefeWeizenUUID.uuid 1976 1976 } 1977 command = "echo \"#{HefeWeizen::HefeWeizenLibrary::HefeWeizenCommand.hash_to_command(command_to_http_server)}\" > #{instruction_pipe}" 1978 system command 1977 1978 command = HefeWeizen::HefeWeizenLibrary::HefeWeizenCommand.hash_to_command(command_to_http_server) 1979 HefeWeizen::HefeWeizenLibrary::Execution.write_to_pipe command, instruction_pipe 1979 1980 1980 1981 # TODO … … 2014 2015 if true then 2015 2016 2016 command = "hefeweizen_sign_ebXML_signal_message \"#{file_path}\" \"#{hash['private_key_file']}\" \"#{hash['password_file']}\" \"#{hash['certificate_file']}\" \"#{temp_file_path}\"" 2017 2018 @logger.debug "#{me}: #{command}" if @debug 2017 2018 binary = "hefeweizen_sign_ebXML_signal_message" 2019 arguments = "\"#{file_path}\" \"#{hash['private_key_file']}\" \"#{hash['password_file']}\" \"#{hash['certificate_file']}\" \"#{temp_file_path}\"" 2020 2021 @logger.debug "#{me}: #{binary} #{arguments}" if @debug 2019 2022 2020 2023 # blocking call 2021 system command 2024 HefeWeizen::HefeWeizenLibrary::Execution.execute_binary binary, arguments 2025 2022 2026 if $? == 0 then 2023 2027 @logger.debug "#{me}: Signing of ebXML signal message done." if @debug … … 2050 2054 # TODO 2051 2055 # fix 2052 command = "echo \"#{HefeWeizen::HefeWeizenLibrary::HefeWeizenCommand.hash_to_command(command_to_http_server)}\" > #{instruction_pipe}"2053 system command2056 command = HefeWeizen::HefeWeizenLibrary::HefeWeizenCommand.hash_to_command command_to_http_server 2057 HefeWeizen::HefeWeizenLibrary::Execution.write_to_pipe command, instruction_pipe 2054 2058 2055 2059 end … … 2459 2463 # this should be run in a tasker 2460 2464 my_pipe = "#{@config['PIPE_DIR']}/pipe_to_core_#{Time.now.to_f.to_s}" 2461 command = "mkfifo #{my_pipe}" 2462 system(command) 2463 command = "chmod 600 #{my_pipe}" 2464 system(command) 2465 binary = "mkfifo" 2466 HefeWeizen::HefeWeizenLibrary::Execution.execute_binary binary, my_pipe 2467 FileUtils.chmod 0600, my_pipe 2465 2468 2466 2469 command_hash = { … … 2476 2479 } 2477 2480 2478 command = "#{HefeWeizen::HefeWeizenLibrary::HefeWeizenCommand.hash_to_command command_hash}" 2479 new_command = "echo \"#{command}\" > #{@config['PIPE_TO_ANIA']}" 2480 2481 system new_command 2481 command = HefeWeizen::HefeWeizenLibrary::HefeWeizenCommand.hash_to_command command_hash 2482 HefeWeizen::HefeWeizenLibrary::Execution.write_to_pipe command, @config['PIPE_TO_ANIA'] 2482 2483 2483 2484 pipe_to_me = File.open(my_pipe, "r+") … … 2556 2557 temp_dir = @config['TEMP_FILE_DIR'] 2557 2558 @logger.debug "#{me}: ebXML message with id '#{ebXML_message_object.message_id}' is digitally signed. Validating digital signature." if @debug 2559 2558 2560 # TODO Blocking system call to validate XML Digital Signature. 2559 command = "hefeweizen_validate_signature_ebXML_user_message \"#{ebXML_message_file_path}\" \"#{temp_dir}\" #{hash['certificate_file']}" 2560 result = system command 2561 binary = "hefeweizen_validate_signature_ebXML_user_message" 2562 arguments = "\"#{ebXML_message_file_path}\" \"#{temp_dir}\" #{hash['certificate_file']}" 2563 HefeWeizen::HefeWeizenLibrary::Execution.execute_binary binary, arguments 2564 2561 2565 if $? == 0 then 2562 2566 @logger.debug "#{me}: Successfully validated the digitally signed ebXML user messsage." if @debug … … 2836 2840 2837 2841 def say_to_ania command 2838 my_command = "echo \"#{command}\" >> #{@config['PIPE_DIR']}/pipe_to_ania" 2839 system my_command 2842 HefeWeizen::HefeWeizenLibrary::Execution.write_to_pipe command, @config['PIPE_TO_ANIA'] 2840 2843 end 2841 2844 trunk/src/hefeweizen_library_cpa.rb
r557 r604 140 140 # TODO a system command 141 141 # Not criticial right here. 142 command = "c_rehash #{cpa_runtime_dir}/#{security_id}" 143 system command 142 command = "c_rehash" 143 arguments = "#{cpa_runtime_dir}/#{security_id}" 144 HefeWeizen::HefeWeizenLibrary::Execution.execute_binary command, arguments 144 145 end 145 146 } trunk/src/hefeweizen_library_ebMS_message2.rb
r566 r604 425 425 426 426 def EBMessage2.get_good_message_id 427 %x(uuid).strip.gsub( /-/, "")427 HefeWeizen::HefeWeizenLibrary::Execution.uuid.strip.gsub( /-/, "") 428 428 end 429 429 … … 658 658 logger.debug "#{me}: mime_type is: #{mime_type} with encoding: #{mime_type.encoding}" if debug 659 659 660 # command = "file -bi #{payload_path.strip}"661 # result = (%x{ #{command} } ).strip662 663 660 # adding multi-part mime part 664 661 # -> seems default content-transfer-encoding is binary, no matter what. … … 716 713 # TODO use Linux Tool file to try to get mime_type. 717 714 command = "file -bi #{payload_path}" 718 result = (%x{#{command}}).strip715 result = HefeWeizen::HefeWeizenLibrary::Execution.execute_binary_get_output command 719 716 logger.debug "#{me}: File command returned : #{result}" 720 717 if result.nil? or result.empty? then trunk/src/hefeweizen_library_exchange_point.rb
r557 r604 138 138 "uuid" => HefeWeizen::HefeWeizenLibrary::HefeWeizenUUID.uuid 139 139 } 140 my_command = "echo \"#{HefeWeizen::HefeWeizenLibrary::HefeWeizenCommand.hash_to_command command_hash}\" >> #{@config['PIPE_TO_ANIA'].strip} " 141 write_to_ania my_command 140 141 command = HefeWeizen::HefeWeizenLibrary::HefeWeizenCommand.hash_to_command command_hash 142 HefeWeizen::HefeWeizenLibrary::Execution.write_to_pipe command, @config['PIPE_TO_ANIA'] 142 143 else 143 144 @logger.warn "#{me}: Protocol #{exchange_point_config[:protocol]} is not supported." if @warn … … 152 153 end 153 154 154 private155 156 def write_to_ania my_command157 system my_command158 end159 160 155 end 161 156 end trunk/src/hefeweizen_library_integration_point.rb
r557 r604 138 138 } 139 139 140 my_command = "echo \"#{HefeWeizen::HefeWeizenLibrary::HefeWeizenCommand.hash_to_command command_hash}\" >> #{@config['PIPE_TO_ANIA'].strip} "141 write_to_ania my_command140 command = HefeWeizen::HefeWeizenLibrary::HefeWeizenCommand.hash_to_command command_hash 141 HefeWeizen::HefeWeizenLibrary::Execution.write_to_pipe command, @config['PIPE_TO_ANIA'] 142 142 end 143 143 … … 180 180 end 181 181 182 private183 184 def write_to_ania my_command185 system my_command186 end187 188 182 end 189 183 end trunk/src/hefeweizen_library_utils.rb
r553 r604 92 92 class HefeWeizenUUID 93 93 def HefeWeizenUUID.uuid 94 HefeWeizen::HefeWeizenLibrary::Execution.uuid 95 end 96 97 end 98 99 # This utility class is used to perform platform dependent code. 100 # HefeWeizen::HefeWeizenLibrary::Execution.write_to_pipe 101 # HefeWeizen::HefeWeizenLibrary::Execution.execute_binary 102 # HefeWeizen::HefeWeizenLibrary::Execution.execute_binary_get_output 103 # HefeWeizen::HefeWeizenLibrary::Execution.uuid 104 class Execution 105 def self.write_to_pipe command, pipe 106 # pipe = File.open(PIPE_TO_BIG_ANIA, "a"); pipe << 'system shutdown'; pipe.sync; pipe.close; 107 my_command = "echo \"#{command}\" >> #{pipe}" 108 system my_command 109 end 110 111 def self.execute_binary binary, arguments_as_string 112 system "#{binary} #{arguments_as_string}" 113 return $? 114 end 115 116 def self.execute_binary_get_output binary, arguments_as_string 117 118 end 119 120 def self.uuid 94 121 %x( uuid ).strip 95 122 end 96 97 123 end 98 124 trunk/src/taskers/hefeweizen_tasker_application_decrypt_ebXML_message.rb
r569 r604 175 175 end 176 176 177 my_command = "echo \"#{HefeWeizen::HefeWeizenLibrary::HefeWeizenCommand.hash_to_command command_hash}\" > #{@pipe_to_ania}"178 @logger.debug "#{me}: Sending result to Big Ania: #{ my_command}" if @debug179 system my_command177 command = HefeWeizen::HefeWeizenLibrary::HefeWeizenCommand.hash_to_command command_hash 178 @logger.debug "#{me}: Sending result to Big Ania: #{command}" if @debug 179 HefeWeizen::HefeWeizenLibrary::Execution.write_to_pipe command, @pipe_to_ania 180 180 181 181 FileUtils.rm files_to_delete … … 186 186 private 187 187 188 def get_id 189 HefeWeizen::HefeWeizenLibrary::Execution.uuid 190 end 191 188 192 def repackage decrypted_file_paths 189 193 old_ebMS = File.open @ebXML_message_file_path, "r" 190 id = %x( "uuid" ).strip194 id = get_id 191 195 new_ebXML_message_file_path = "#{@config['TEMP_FILE_DIR']}/new_ebXML_message_#{id}.bin" 192 196 new_ebMS = File.new new_ebXML_message_file_path, "w" … … 245 249 files_for_repackage = Hash.new 246 250 content_hash.each_pair{ | content_id, content | 247 id = %x( "uuid" ).strip251 id = get_id 248 252 content_file_path = "#{@config['TEMP_FILE_DIR']}/encrypted_content_#{id}.bin" 249 253 file = File.new content_file_path, "w" … … 252 256 files_to_delete << content_file_path 253 257 254 id = %x( "uuid" ).strip258 id = get_id 255 259 output_file_path = "#{@config['TEMP_FILE_DIR']}/decrypted_output_#{id}.bin" 256 260 257 261 # xmlsec1 decrypt --privkey-pem coronation_encryption_cert/Coronation_encryption_private_key.pem --output debian-logo-2.png out2.xml 258 command = "xmlsec1 decrypt --privkey-pem #{@private_key_file_path} --output #{output_file_path} #{content_file_path}" 259 @logger.debug "#{me}: Calling decryption code: #{command}" if @debug 260 system command 262 binary = "xmlsec1" 263 arguments = "decrypt --privkey-pem #{@private_key_file_path} --output #{output_file_path} #{content_file_path}" 264 @logger.debug "#{me}: Calling decryption code: #{binary} #{arguments}" if @debug 265 HefeWeizen::HefeWeizenLibrary::Execution.execute_binary binary, arguments 266 261 267 if $? == 0 then 262 268 files_to_delete << output_file_path … … 271 277 272 278 def get_xmlenc_template 273 filename = "#{@config['TEMP_FILE_DIR']}/encryption_template_#{ %x( "uuid").strip}"279 filename = "#{@config['TEMP_FILE_DIR']}/encryption_template_#{get_id}" 274 280 file = File.new filename, "w" 275 281 # <EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#tripledes-cbc"/> trunk/src/taskers/hefeweizen_tasker_application_dir_observer.rb
r569 r604 145 145 146 146 def get_a_new_transaction 147 %x( uuid )147 HefeWeizen::HefeWeizenLibrary::Execution.uuid 148 148 end 149 149 trunk/src/taskers/hefeweizen_tasker_application_encrypt_ebXML_message.rb
r569 r604 191 191 end 192 192 193 my_command = "echo \"#{HefeWeizen::HefeWeizenLibrary::HefeWeizenCommand.hash_to_command command_hash}\" > #{@pipe_to_ania}"194 @logger.debug "#{me}: Sending result back to Big Ania: #{ my_command}" if @debug195 system my_command193 command = HefeWeizen::HefeWeizenLibrary::HefeWeizenCommand.hash_to_command command_hash 194 @logger.debug "#{me}: Sending result back to Big Ania: #{command}" if @debug 195 HefeWeizen::HefeWeizenLibrary::Execution.write_to_pipe command, @pipe_to_ania 196 196 197 197 FileUtils.rm files_to_delete … … 204 204 private 205 205 206 def get_id 207 HefeWeizen::HefeWeizenLibrary::Execution.uuid 208 end 209 210 206 211 def repackage files_to_repackage 207 212 old_ebMS = File.open @ebXML_message_file_path, "r" 208 id = %x( "uuid" ).strip213 id = get_id 209 214 new_ebXML_message_file_path = "#{@config['TEMP_FILE_DIR']}/new_ebXML_message_#{id}.bin" 210 215 new_ebMS = File.new new_ebXML_message_file_path, "w" … … 263 268 files_for_repackage = Hash.new 264 269 content_hash.each_pair{ | content_id, content | 265 id = %x( "uuid" ).strip270 id = get_id 266 271 content_file_path = "#{@config['TEMP_FILE_DIR']}/content_#{id}.bin" 267 272 file = File.new content_file_path, "w" … … 270 275 files_to_delete << content_file_path 271 276 272 id = %x( "uuid" ).strip277 id = get_id 273 278 output_file_path = "#{@config['TEMP_FILE_DIR']}/encrypted_output_#{id}.xml" 274 command = "xmlsec1 encrypt --binary-data #{content_file_path} --session-key des-192 --pubkey-cert-pem #{@certificate} --output #{output_file_path} #{template_filename}" 275 system command 279 binary = "xmlsec1" 280 arguments = "encrypt --binary-data #{content_file_path} --session-key des-192 --pubkey-cert-pem #{@certificate} --output #{output_file_path} #{template_filename}" 281 @logger.debug "#{me}: Calling encryp code: #{binary} #{arguments}" if @debug 282 HefeWeizen::HefeWeizenLibrary::Execution.execute_binary binary, arguments 283 276 284 if $? == 0 then 277 285 files_to_delete << output_file_path … … 286 294 287 295 def get_xmlenc_template 288 filename = "#{@config['TEMP_FILE_DIR']}/encryption_template_#{ %x( "uuid").strip}"296 filename = "#{@config['TEMP_FILE_DIR']}/encryption_template_#{get_id}" 289 297 file = File.new filename, "w" 290 298 # <EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#tripledes-cbc"/> trunk/src/taskers/hefeweizen_tasker_application_http_server.rb
r580 r604 39 39 require 'logger' 40 40 require 'pp' 41 require 'monitor'42 41 43 42 $exit = false 44 43 45 $instance = 0 46 $pipes = [] 47 $pipes.extend MonitorMixin 48 49 $mutex = Mutex.new 50 51 52 Signal.trap("INT") do $stdout.puts "#{$0}: HefeWeizen Tasker HTTP Server caught INT signal. not exitting"; end 44 Signal.trap("INT") do $stderr.puts "#{$0}: HefeWeizen Tasker HTTP Server caught INT signal. not exitting"; end 45 # Signal.trap("USR1") do $stderr.puts "#{$0}: HefeWeizen Tasker HTTP Server caught USR1 signal. Exitting ... "; $exit = true; end 53 46 Signal.trap("USR1") { 54 $std out.puts "#{$0}: HefeWeizen Tasker HTTP Server caught USR1 signal. Exitting ... "47 $stderr.puts "#{$0}: HefeWeizen Tasker HTTP Server caught USR1 signal. Exitting ... " 55 48 # TODO check where process is. Eg clean up pipe to HTTP Server. 56 57 $mutex.synchronize do 58 if $instance > 0 then 59 $pipes.synchronize do 60 $stdout.puts "HTTP Server Tasker needs to cleanup files." 61 $pipes.each{ | pipe | 62 begin 63 FileUtils.rm_rf(pipe) 64 rescue Exception => e 65 $stdout.puts "Exception: #{e.to_s}" 66 end 67 } 68 end 69 end 70 $stdout.puts "HTTP Server Taserk Exitting." 71 Process.exit! 0 72 end 49 Process.exit! 0 73 50 } 74 51 … … 98 75 99 76 def do_POST(req, resp) 100 101 $mutex.synchronize do 102 $instance += 1 103 end 77 104 78 # 0. if we are in the testing environment 105 79 if @config['BIG_ANIA_LOAD_TEST_ENVIRONMENT'] == 'true' then … … 117 91 # resp.body = "blah blah blah" 118 92 # resp.status = 204 119 return finished93 return 120 94 end 121 95 end … … 159 133 # 2. 160 134 # create a named pipe so big ania (via ania) can tell us how to proceed. 161 162 135 my_pipe = "#{@config['PIPE_DIR']}/pipe_to_http_server_#{now.to_f.to_s}" 163 $pipes.synchronize do 164 $pipes.push my_pipe 165 end 166 command = "mkfifo #{my_pipe}" 167 system(command) 168 command = "chmod 600 #{my_pipe}" 169 system(command) 136 binary = "mkfifo" 137 HefeWeizen::HefeWeizenLibrary::Execution.execute_binary binary, my_pipe 138 FileUtils.chmod 0600, my_pipe 139 170 140 171 141 # 3. … … 278 248 pipe_to_me.close 279 249 FileUtils.rm(my_pipe) 280 $pipes.synchronize do 281 $pipes.delete my_pipe 282 end 283 return finished 284 end 285 286 private 287 def finished 288 $mutex.synchronize do 289 $instance -= 1 290 end 291 end 292 250 251 return true 252 end 293 253 end 294 254 … … 309 269 310 270 def write_to_ania string 311 my_command = "echo \"#{string}\" > #{@pipe_to_ania}" 312 system my_command 271 HefeWeizen::HefeWeizenLibrary::Execution.write_to_pipe string, @pipe_to_ania 313 272 end 314 273 trunk/src/taskers/hefeweizen_tasker_application_send_ebXML_message.rb
r567 r604 147 147 148 148 @ebXML_message_id = @ebXML_message_parameters['ebXML_message']['ebXML_message_id'] 149 149 150 150 if @ebXML_message_parameters['info']['transport-protocol-name'].upcase == "HTTP" then 151 151 # HTTP settings … … 205 205 @logger.debug "#{me}: Extra headers for HTTP post: #{extra_header}" if @debug 206 206 # added ignore-length ... had problems with it when using webrick and setting code 204 to it. 207 command = "wget -S #{ssl_configurations} --ignore-length --user-agent=\"HefeWeizen\" --post-file=\"#{@ebXML_message_file_path}\" --header='#{extra_header}' --header='SOAPAction: \"ebXML\"' --output-document=\"#{response_file_path}\" --append-output=\"#{transfer_info_file_path}\" #{http_url}"208 209 @logger.debug "#{me}: Complete HTTP post command: #{command}" if @debug210 system(command)211 success = $?207 binary = "wget" 208 arguments = "-S #{ssl_configurations} --ignore-length --user-agent=\"HefeWeizen\" --post-file=\"#{@ebXML_message_file_path}\" --header='#{extra_header}' --header='SOAPAction: \"ebXML\"' --output-document=\"#{response_file_path}\" --append-output=\"#{transfer_info_file_path}\" #{http_url} " 209 210 @logger.debug "#{me}: Complete HTTP post command: #{binary} #{arguments}" if @debug 211 success = HefeWeizen::HefeWeizenLibrary::Execution.execute_binary binary, arguments 212 212 213 213 elsif @ebXML_message_parameters['info']['transport-protocol-name'].upcase == "SMTP" then … … 291 291 end 292 292 293 my_command = "echo \"#{HefeWeizen::HefeWeizenLibrary::HefeWeizenCommand.hash_to_command command_hash}\" > #{@pipe_to_ania}"294 @logger.debug "#{me}: Sending back result to Big Ania: #{ my_command}" if @debug295 system my_command293 command = HefeWeizen::HefeWeizenLibrary::HefeWeizenCommand.hash_to_command command_hash 294 @logger.debug "#{me}: Sending back result to Big Ania: #{command}" if @debug 295 HefeWeizen::HefeWeizenLibrary::Execution.write_to_pipe command, @pipe_to_ania 296 296 297 297 return 0 trunk/src/taskers/hefeweizen_tasker_application_sign_ebXML_message.rb
r569 r604 241 241 242 242 def get_id 243 %x( "uuid" ).strip243 HefeWeizen::HefeWeizenLibrary::Execution.uuid 244 244 end 245 245 trunk/src/taskers/hefeweizen_tasker_application_wake_up_call.rb
r569 r604 163 163 end 164 164 165 my_command = "echo \"#{HefeWeizen::HefeWeizenLibrary::HefeWeizenCommand.hash_to_command command_hash}\" > #{@pipe_to_ania}"166 @logger.debug "#{me}: Sending result back to Big Ania: #{ my_command}" if @debug167 system my_command165 command = HefeWeizen::HefeWeizenLibrary::HefeWeizenCommand.hash_to_command command_hash 166 @logger.debug "#{me}: Sending result back to Big Ania: #{command}" if @debug 167 HefeWeizen::HefeWeizenLibrary::Execution.write_to_pipe command, @pipe_to_ania 168 168 169 169 return 0
