siffer 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. data/LICENSE +1 -1
  2. data/README +93 -63
  3. data/lib/siffer.rb +41 -1
  4. data/lib/siffer/agent.rb +53 -0
  5. data/lib/siffer/core_ext/hash.rb +15 -0
  6. data/lib/siffer/messages.rb +41 -0
  7. data/lib/siffer/messages/ack.rb +168 -0
  8. data/lib/siffer/messages/event.rb +20 -0
  9. data/lib/siffer/messages/message.rb +60 -0
  10. data/lib/siffer/messages/provide.rb +25 -0
  11. data/lib/siffer/messages/provision.rb +17 -0
  12. data/lib/siffer/messages/register.rb +50 -0
  13. data/lib/siffer/messages/request.rb +138 -0
  14. data/lib/siffer/messages/response.rb +48 -0
  15. data/lib/siffer/messages/subscribe.rb +17 -0
  16. data/lib/siffer/messages/system_control.rb +94 -0
  17. data/lib/siffer/models.rb +1 -0
  18. data/lib/siffer/models/address.rb +39 -0
  19. metadata +31 -66
  20. data/Rakefile +0 -60
  21. data/bin/siffer +0 -12
  22. data/lib/sif.rb +0 -38
  23. data/lib/sif/code_sets.rb +0 -9
  24. data/lib/sif/code_sets/access_permission_error_codes.rb +0 -17
  25. data/lib/sif/code_sets/authentication_error_codes.rb +0 -15
  26. data/lib/sif/code_sets/base_code_set.rb +0 -75
  27. data/lib/sif/code_sets/encryption_error_codes.rb +0 -6
  28. data/lib/sif/code_sets/error_category_codes.rb +0 -20
  29. data/lib/sif/code_sets/event_reporting_processing_error_codes.rb +0 -7
  30. data/lib/sif/code_sets/generic_message_handling_error_codes.rb +0 -12
  31. data/lib/sif/code_sets/provision_error_codes.rb +0 -8
  32. data/lib/sif/code_sets/registration_error_codes.rb +0 -13
  33. data/lib/sif/code_sets/request_response_error_codes.rb +0 -20
  34. data/lib/sif/code_sets/smb_error_codes.rb +0 -9
  35. data/lib/sif/code_sets/status_codes.rb +0 -13
  36. data/lib/sif/code_sets/subscription_error_codes.rb +0 -7
  37. data/lib/sif/code_sets/system_error_codes.rb +0 -6
  38. data/lib/sif/code_sets/transport_error_codes.rb +0 -9
  39. data/lib/sif/code_sets/xml_validation_error_codes.rb +0 -10
  40. data/lib/sif/config.rb +0 -100
  41. data/lib/sif/core_ext/array.rb +0 -12
  42. data/lib/sif/error.rb +0 -34
  43. data/lib/sif/exceptions.rb +0 -9
  44. data/lib/sif/messages.rb +0 -3
  45. data/lib/sif/messages/ack.rb +0 -29
  46. data/lib/sif/messages/message.rb +0 -32
  47. data/lib/sif/messages/register.rb +0 -38
  48. data/lib/sif/protocols.rb +0 -15
  49. data/lib/sif/status.rb +0 -17
  50. data/spec/base_code_set_spec.rb +0 -35
  51. data/spec/config_spec.rb +0 -42
  52. data/spec/error_spec.rb +0 -11
  53. data/spec/messages/ack_spec.rb +0 -25
  54. data/spec/messages/header_spec.rb +0 -21
  55. data/spec/messages/message_spec.rb +0 -27
  56. data/spec/messages/register_spec.rb +0 -53
  57. data/spec/protocol_spec.rb +0 -11
  58. data/spec/spec_helper.rb +0 -8
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2008 h3o(software)
1
+ Copyright (c) 2008-2009 Clint Hill - h3o(software)
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README CHANGED
@@ -1,63 +1,93 @@
1
- = Project: Siffer - h3o(software) SIF Implementation
2
-
3
- == Welcome to Siffer
4
-
5
- This is the h3o(software) implementation of the SIF (School Interoperability Framework) in Ruby.
6
- The project is Ruby based and includes all of the SIF infrastructure (Data Model, Agents, Zone Integration
7
- Servers and even database stores).
8
-
9
- == Goal
10
-
11
- The overriding goal of this project is to provide anyone in the education industry a quick, easy and
12
- small SIF implementation tool. Sane Defaults in front of easy Configurations.
13
-
14
- === Setup and Deployment
15
-
16
- Siffer is easy to install and setup. Zone Integration Servers and Agents can be created at the command
17
- line. Zone Integration Servers are managed by web based interfaces and Agents will be centrally managed
18
- by a web based interface. Administrators will be able to manage all components of their deployment from a browser.
19
-
20
- == Philosophy
21
-
22
- Remove the complexity from the implementation. Make the execution and deployment of SIF easy.
23
-
24
- == Implementation Information (sifinfo.org)
25
-
26
- This implementation is based on version 2.2 of the SIF Specification. The Specification is in
27
- {PDF}[link:../SIF%20ImplementationSpecification.pdf] format inside the docs folder.
28
-
29
-
30
- More information here: http://sifinfo.org.
31
-
32
- == Description of Contents
33
-
34
- == Useage
35
-
36
- == License
37
-
38
- Siffer is released under the MIT License
39
-
40
- == Installation
41
-
42
- Siffer can be installed from the siffer gem:
43
-
44
- % [sudo] gem install siffer
45
-
46
- == Support
47
-
48
- Please contact the author (mailto://clint.hill@h3osoftware.com) for support issues. If you want to
49
- contribute do the same.
50
-
51
- === Contributors
52
-
53
- This project is developed by spec. Build spec tests for all of your features. Document everything.
54
-
55
- == Contact
56
-
57
- Author:: Clint Hill
58
- Email:: mailto://clint.hill@h3osoftware.com
59
- Home Page:: http://h3osoftware.com/siffer
60
- SVN:: http://svn.h3osoftware.com/siffer
61
-
62
-
63
-
1
+ = Siffer - h3o(software) SIF Implementation
2
+
3
+ == Welcome to Siffer
4
+
5
+ This is the h3o(software) implementation of the SIF (School Interoperability
6
+ Framework) in Ruby. The project is Ruby based and includes all of the SIF
7
+ infrastructure (Data Model, Agents, Zone Integration Servers and even database
8
+ stores).
9
+
10
+ Siffer is a platform - not a development kit. Certainly it's open source and
11
+ you can take this code and do as you wish. However, Siffer provides out of the
12
+ box all the things you need to run a SIF environment.
13
+
14
+ Simply put you can do one of two things with Siffer:
15
+
16
+ 1) You can download it and run the admin server and setup Servers and Agents.
17
+ 2) You can download it and write the code to build your own Servers and Agents.
18
+
19
+
20
+ It's currently incomplete - Stay Tuned!
21
+
22
+ == Goal
23
+
24
+ The overriding goal of this project is to provide anyone in the education
25
+ industry a quick, easy and simple SIF implementation tool.
26
+
27
+ == Philosophy
28
+
29
+ Remove the complexity from the implementation. Make the execution and
30
+ deployment of SIF easy.
31
+
32
+ Make SIF more REST'ful. As much as possible expose the actions and data models
33
+ through the URI and URL of ZIS and Agent components.
34
+
35
+ Make SIF more useful. As much as possible remove the "XML" and "Database"
36
+ questions out of the equation.
37
+
38
+ Make it simple. Make it easy. Make it fun. Make it intuitive.
39
+ Make it do exactly what needs to be done.
40
+ You're too busy for anything else.
41
+
42
+ == Implementation Information (sifinfo.org)
43
+
44
+ This implementation is based on version 2.3 of the SIF Specification.
45
+ It can be found here: http://specification.sifinfo.org/Implementation/2.3/
46
+
47
+ More information here: http://sifinfo.org.
48
+
49
+ == Description of Contents
50
+
51
+ == Useage
52
+
53
+ % siffer start agent "default agent" -p 8001 -d
54
+ % siffer start server "default zis" -p 8002 -d
55
+
56
+ % siffer stop agent "default agent"
57
+ % siffer stop server "default zis"
58
+
59
+ Or from the admin browser !!!
60
+
61
+ % siffer start admin
62
+
63
+ open http://0.0.0.0:2828 from any browser and enjoy!
64
+
65
+ == License
66
+
67
+ Siffer is released under the MIT License
68
+
69
+ == Installation
70
+
71
+ Siffer can be installed from the siffer gem:
72
+
73
+ % [sudo] gem install siffer
74
+
75
+ == Support
76
+
77
+ Please contact the author (clint.hill@h3osoftware.com) for support
78
+ issues. If you want to contribute do the same.
79
+
80
+ === Contributors
81
+
82
+ This project is developed by spec. Build spec tests (RSpec) for all of
83
+ your features. Document everything.
84
+
85
+ Fork the project and then make a pull request.
86
+ http://github.com/clinth3o/siffer
87
+
88
+ == Contact
89
+
90
+ - Author:: Clint Hill clint.hill@h3osoftware.com
91
+ - Home Page:: http://h3osoftware.com/siffer
92
+ - GitHub:: git://github.com/clinth3o/siffer.git
93
+ - RubyForge:: http://rubyforge.org/projects/siffer/
@@ -1 +1,41 @@
1
- require 'sif'
1
+ require 'rubygems'
2
+ require 'activesupport'
3
+ require 'uuid'
4
+ require 'builder'
5
+ require 'sinatra/base'
6
+ require 'haml'
7
+ require 'rest_client'
8
+ require 'acdc'
9
+
10
+ $: << File.expand_path(File.dirname(__FILE__))
11
+
12
+ module Siffer
13
+
14
+ VENDOR = "h3o(software)" unless defined?(Siffer::VENDOR)
15
+ VERSION = [0,1,1] unless defined?(Siffer::VERSION)
16
+ SIF_VERSION = [2,3] unless defined?(Siffer::SIF_VERSION)
17
+ SIF_XMLNS = "http://www.sifinfo.org/infrastructure/2.x" unless defined?(Siffer::SIF_XMLNS)
18
+
19
+ # The vendor of this SIF implementation (self describing for Agents)
20
+ def self.vendor() VENDOR end
21
+
22
+ # The version of the h3o(software) SIF implementation
23
+ def self.version() VERSION.join(".") end
24
+
25
+ # The version of SIF being implemented - based on the specification
26
+ def self.sif_version() SIF_VERSION.join(".") end
27
+
28
+ # The SIF XML namespace to be used across this implementation
29
+ def self.sif_xmlns() SIF_XMLNS end
30
+
31
+ # The root directory that the SIF implementation is running from
32
+ def self.root() @root ||= Dir.pwd end
33
+ def self.root=(value) @root = value end
34
+
35
+ autoload :Messages, "siffer/messages"
36
+ autoload :Models, "siffer/models"
37
+
38
+ end
39
+
40
+ require "siffer/agent"
41
+ require "siffer/core_ext/hash"
@@ -0,0 +1,53 @@
1
+ module Siffer
2
+
3
+ class Agent < Sinatra::Base
4
+
5
+ enable :static
6
+
7
+ set :root, File.join(File.dirname(__FILE__),"agent")
8
+ set :port, 2828
9
+ set :haml, {:format => :html5 }
10
+ set :agent_name, "Not Named"
11
+ set :zis_url, "Not Set"
12
+
13
+ before do
14
+ @agent_name = options.agent_name
15
+ @zis_url = options.zis_url
16
+ #redirect '/' unless registered? or request.path == "/register" or request.path == "/"
17
+ end
18
+
19
+ helpers do
20
+ def registered?
21
+ @zis_url != "Not Set"
22
+ end
23
+ end
24
+
25
+ get "/" do
26
+ haml :index
27
+ end
28
+
29
+ post "/register" do
30
+ url = params[:zis_url]
31
+ msg = SystemControl.get_zone_status(@agent_name)
32
+ # msg = Register.new(
33
+ # :header => @agent_name,
34
+ # :version => Siffer.sif_version,
35
+ # :mode => "Pull",
36
+ # :max_buffer_size => 1024,
37
+ # :name => @agent_name,
38
+ # :application => Application.new(
39
+ # :vendor => "h3o(software)",
40
+ # :version => Siffer.version,
41
+ # :product => "Siffer"
42
+ # )
43
+ # )
44
+ puts msg
45
+ raw = RestClient.post(url, msg, :content_type => 'application/xml')
46
+ puts raw
47
+ return_msg = Message.parse(raw)
48
+ return_msg
49
+ end
50
+
51
+ end
52
+
53
+ end
@@ -0,0 +1,15 @@
1
+ class Hash
2
+
3
+ # Recursively changes key names to underscored symbols
4
+ def recursively_underscore
5
+ keys.each do |key|
6
+ if self[key].is_a?(Hash)
7
+ self[key.underscore.to_sym] = delete(key).recursively_underscore
8
+ else
9
+ self[key.underscore.to_sym] = delete(key)
10
+ end
11
+ end
12
+ self
13
+ end
14
+
15
+ end
@@ -0,0 +1,41 @@
1
+ module Siffer
2
+ module Messages
3
+
4
+ class SifBody < AcDc::Body
5
+ def tag_name
6
+ "SIF_#{super}"
7
+ end
8
+
9
+ class << self
10
+ def acdc(xml)
11
+ super(xml.gsub(/SIF_/,''))
12
+ end
13
+ end
14
+ end
15
+
16
+ class SifElement < AcDc::Element
17
+ def initialize(values=nil, options={})
18
+ @required = options[:required] || false
19
+ super(value,options)
20
+ end
21
+ def required?
22
+ @required
23
+ end
24
+ def tag_name
25
+ "SIF_#{super}"
26
+ end
27
+ end
28
+
29
+ end
30
+ end
31
+
32
+ require 'siffer/messages/message'
33
+ require 'siffer/messages/ack'
34
+ require 'siffer/messages/event'
35
+ require 'siffer/messages/provide'
36
+ require 'siffer/messages/provision'
37
+ require 'siffer/messages/register'
38
+ require 'siffer/messages/request'
39
+ require 'siffer/messages/response'
40
+ require 'siffer/messages/subscribe'
41
+ require 'siffer/messages/system_control'
@@ -0,0 +1,168 @@
1
+ module Siffer
2
+ module Messages
3
+
4
+ # Element containing Status information
5
+ #@see Ack
6
+ class Status < SifBody
7
+ element :code
8
+ element :desc
9
+ element :data
10
+ end
11
+
12
+ # Element containing Error information
13
+ #@see Ack
14
+ class Error < SifBody
15
+ element :category
16
+ element :code
17
+ element :desc
18
+ element :extended_desc
19
+ end
20
+
21
+ # Message used as an acknowledgement for infrastructure messages.
22
+ # Ack must contain either a SIF_Status or a SIF_Error
23
+ #@see Status
24
+ #@see Error
25
+ class Ack < Message
26
+ element :original_source_id
27
+ element :original_msg_id
28
+ element :status
29
+ element :error
30
+ end
31
+
32
+ STATUS_CODE = {
33
+ 0 => "Success (ZIS ONLY). SIF_Status/SIF_Data may contain additional data.",
34
+ 1 => "Immediate SIF_Ack (AGENT ONLY). Message is persisted or processing is complete. Discard the referenced message.",
35
+ 2 => "Intermediate SIF_Ack (AGENT ONLY). Only valid in response to SIF_Event delivery. Invokes Selective Message Blocking. The event referenced must still be persisted, and no other events must be delivered, until the agent sends a \"Final\" SIF_Ack at a later time.",
36
+ 3 => "Final SIF_Ack (AGENT ONLY). Sent (a SIF_Ack with this value is never returned by an agent in response to a delivered message) by an agent to the ZIS to end Selective Message Blocking. Discard the referenced event and allow for delivery of other events.",
37
+ 7 => "Already have a message with this SIF_MsgId from you.",
38
+ 8 => "Receiver is sleeping.",
39
+ 9 => "No messages available. This is returned when an agent is trying to pull messages from a ZIS and there are no messages available."
40
+ }
41
+
42
+ ERROR_CATEGORY = {
43
+ 0 => "Unknown (This should NEVER be used if possible)",
44
+ 1 => "XML Validation",
45
+ 2 => "Encryption",
46
+ 3 => "Authentication",
47
+ 4 => "Access and Permissions",
48
+ 5 => "Registration",
49
+ 6 => "Provision",
50
+ 7 => "Subscription",
51
+ 8 => "Request and Response",
52
+ 9 => "Event Reporting and Processing",
53
+ 10 => "Transport",
54
+ 11 => "System (OS, Database, Vendor localized, etc.)",
55
+ 12 => "Generic Message Handling",
56
+ 13 => "SMB Handling"
57
+ }
58
+
59
+ XML_VALIDATION_ERROR = {
60
+ 1 => "Generic error",
61
+ 2 => "Message is not well-formed",
62
+ 3 => "Generic validation error",
63
+ 4 => "Invalid value for element/attribute",
64
+ 6 => "Missing mandatory element/attribute"
65
+ }
66
+
67
+ ENCRYPTION_ERROR = { 1 => "Generic Error" }
68
+
69
+ AUTHENTICATION_ERROR = {
70
+ 1 => "Generic error",
71
+ 2 => "Generic authentication error (with signature)",
72
+ 3 => "Missing sender's certificate",
73
+ 4 => "Invalid certificate",
74
+ 5 => "Sender's certificate is not trusted",
75
+ 6 => "Expired certificate",
76
+ 7 => "Invalid signature",
77
+ 8 => "Invalid encryption algorithm (only accepts MD4)",
78
+ 9 => "Missing public key of the receiver (when decrypting message)",
79
+ 10 => "Missing receiver's private key (when decrypting message)"
80
+ }
81
+
82
+ ACCESS_AND_PERMISSION_ERROR = {
83
+ 1 => "Generic error",
84
+ 2 => "No permission to register",
85
+ 3 => "No permission to provide this object",
86
+ 4 => "No permission to subscribe to this SIF_Event",
87
+ 5 => "No permission to request this object",
88
+ 6 => "No permission to respond to this object request",
89
+ 7 => "No permission to publish SIF_Event",
90
+ 8 => "No permission to administer policies",
91
+ 9 => "SIF_SourceId is not registered",
92
+ 10 => "No permission to publish SIF_Event Add",
93
+ 11 => "No permission to publish SIF_Event Change",
94
+ 12 => "No permission to publish SIF_Event Delete"
95
+ }
96
+
97
+ REGISTRATION_ERROR = {
98
+ 1 => "Generic error",
99
+ 2 => "The SIF_SourceId is invalid",
100
+ 3 => "Requested transport protocol is unsupported",
101
+ 4 => "Requested SIF_Version(s) not supported.",
102
+ 6 => "Requested SIF_MaxBufferSize is too small",
103
+ 7 => "ZIS requires a secure transport",
104
+ 9 => "Agent is registered for push mode (returned when a push-mode agent sends a SIF_GetMessage).",
105
+ 10 => "ZIS does not support the requested Accept-Encoding value."
106
+ }
107
+
108
+ PROVISION_ERROR = {
109
+ 1 => "Generic error",
110
+ 3 => "Invalid object",
111
+ 4 => "Object already has a provider (SIF_Provide message)"
112
+ }
113
+
114
+ SUBSCRIPTION_ERROR = {
115
+ 1 => "Generic error",
116
+ 3 => "Invalid object"
117
+ }
118
+
119
+ REQUEST_AND_RESPONSE_ERROR = {
120
+ 1 => "Generic error",
121
+ 3 => "Invalid object",
122
+ 4 => "No provider",
123
+ 7 => "Responder does not support requested SIF_Version",
124
+ 8 => "Responder does not support requested SIF_MaxBufferSize",
125
+ 9 => "Unsupported query in request",
126
+ 10 => "Invalid SIF_RequestMsgId specified in SIF_Response",
127
+ 11 => "SIF_Response is larger than requested SIF_MaxBufferSize",
128
+ 12 => "SIF_PacketNumber is invalid in SIF_Response",
129
+ 13 => "SIF_Response does not match any SIF_Version from SIF_Request",
130
+ 14 => "SIF_DestinationId does not match SIF_SourceId from SIF_Request",
131
+ 15 => "No support for SIF_ExtendedQuery",
132
+ 16 => "SIF_RequestMsgId deleted from cache due to timeout",
133
+ 17 => "SIF_RequestMsgId deleted from cache by administrator",
134
+ 18 => "SIF_Request cancelled by requesting agent"
135
+ }
136
+
137
+ EVENT_REPORTING_AND_PROCESSING_ERROR = {
138
+ 1 => "Generic error",
139
+ 3 => "Invalid event"
140
+ }
141
+
142
+ TRANSPORT_ERROR = {
143
+ 1 => "Generic error",
144
+ 2 => "Requested protocol is not supported",
145
+ 3 => "Secure channel requested and no secure path exists",
146
+ 4 => "Unable to establish connection"
147
+ }
148
+
149
+ SYSTEM_ERROR = { 1 => "Generic error" }
150
+
151
+ GENERIC_MESSAGE_HANDLING_ERROR = {
152
+ 1 => "Generic error",
153
+ 2 => "Message not supported",
154
+ 3 => "Version not supported",
155
+ 4 => "Context not supported",
156
+ 5 => "Protocol error",
157
+ 6 => "No such message (as identified by SIF_OriginalMsgId)",
158
+ 7 => "Multiple contexts not supported"
159
+ }
160
+
161
+ SMB_ERROR = {
162
+ 1 => "Generic error",
163
+ 2 => "SMB can only be invoked during a SIF_Event acknowledgement",
164
+ 3 => "Final SIF_Ack expected from Push-Mode Agent",
165
+ 4 => "Incorrect SIF_MsgId in final SIF_Ack"
166
+ }
167
+ end
168
+ end