siffer 0.0.7 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. data/LICENSE +1 -1
  2. data/README +63 -93
  3. data/Rakefile +60 -0
  4. data/bin/siffer +12 -0
  5. data/lib/sif.rb +38 -0
  6. data/lib/sif/code_sets.rb +9 -0
  7. data/lib/sif/code_sets/access_permission_error_codes.rb +17 -0
  8. data/lib/sif/code_sets/authentication_error_codes.rb +15 -0
  9. data/lib/sif/code_sets/base_code_set.rb +75 -0
  10. data/lib/sif/code_sets/encryption_error_codes.rb +6 -0
  11. data/lib/sif/code_sets/error_category_codes.rb +20 -0
  12. data/lib/sif/code_sets/event_reporting_processing_error_codes.rb +7 -0
  13. data/lib/sif/code_sets/generic_message_handling_error_codes.rb +12 -0
  14. data/lib/sif/code_sets/provision_error_codes.rb +8 -0
  15. data/lib/sif/code_sets/registration_error_codes.rb +13 -0
  16. data/lib/sif/code_sets/request_response_error_codes.rb +20 -0
  17. data/lib/sif/code_sets/smb_error_codes.rb +9 -0
  18. data/lib/sif/code_sets/status_codes.rb +13 -0
  19. data/lib/sif/code_sets/subscription_error_codes.rb +7 -0
  20. data/lib/sif/code_sets/system_error_codes.rb +6 -0
  21. data/lib/sif/code_sets/transport_error_codes.rb +9 -0
  22. data/lib/sif/code_sets/xml_validation_error_codes.rb +10 -0
  23. data/lib/sif/config.rb +100 -0
  24. data/lib/sif/core_ext/array.rb +12 -0
  25. data/lib/sif/error.rb +34 -0
  26. data/lib/sif/exceptions.rb +9 -0
  27. data/lib/sif/messages.rb +3 -0
  28. data/lib/sif/messages/ack.rb +29 -0
  29. data/lib/sif/messages/message.rb +32 -0
  30. data/lib/sif/messages/register.rb +38 -0
  31. data/lib/sif/protocols.rb +15 -0
  32. data/lib/sif/status.rb +17 -0
  33. data/lib/siffer.rb +1 -41
  34. data/spec/base_code_set_spec.rb +35 -0
  35. data/spec/config_spec.rb +42 -0
  36. data/spec/error_spec.rb +11 -0
  37. data/spec/messages/ack_spec.rb +25 -0
  38. data/spec/messages/header_spec.rb +21 -0
  39. data/spec/messages/message_spec.rb +27 -0
  40. data/spec/messages/register_spec.rb +53 -0
  41. data/spec/protocol_spec.rb +11 -0
  42. data/spec/spec_helper.rb +8 -0
  43. metadata +66 -31
  44. data/lib/siffer/agent.rb +0 -53
  45. data/lib/siffer/core_ext/hash.rb +0 -15
  46. data/lib/siffer/messages.rb +0 -41
  47. data/lib/siffer/messages/ack.rb +0 -168
  48. data/lib/siffer/messages/event.rb +0 -20
  49. data/lib/siffer/messages/message.rb +0 -60
  50. data/lib/siffer/messages/provide.rb +0 -25
  51. data/lib/siffer/messages/provision.rb +0 -17
  52. data/lib/siffer/messages/register.rb +0 -50
  53. data/lib/siffer/messages/request.rb +0 -138
  54. data/lib/siffer/messages/response.rb +0 -48
  55. data/lib/siffer/messages/subscribe.rb +0 -17
  56. data/lib/siffer/messages/system_control.rb +0 -94
  57. data/lib/siffer/models.rb +0 -1
  58. data/lib/siffer/models/address.rb +0 -39
@@ -1,41 +0,0 @@
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'
@@ -1,168 +0,0 @@
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
@@ -1,20 +0,0 @@
1
- module Siffer
2
- module Messages
3
-
4
- # Message for SIF_Event, used to deliver objects defined in SIF.
5
- # Events represent the availability of new data object, changes to
6
- # or deletions of data object
7
- #@see EventObject
8
- class Event < Message
9
- element :object_data
10
- end
11
-
12
- # Message Element that holds the data object that is add/change/delete
13
- #@see Event
14
- class EventObject < AcDc::Body
15
- attribute :object_name
16
- attribute :action
17
- end
18
-
19
- end
20
- end
@@ -1,60 +0,0 @@
1
- module Siffer
2
- module Messages
3
-
4
- # Security Element for the Header Element
5
- #@see Header
6
- class Security < SifBody
7
- element :secure_channel
8
- end
9
-
10
- # SecureChannel Element for the Security Element
11
- #@see Security
12
- class SecureChannel < SifBody
13
- element :encryption_level
14
- element :authentication_level
15
- end
16
-
17
- # List of Contexts for the Message
18
- class Contexts < SifBody
19
- element :context
20
- end
21
-
22
- # Header for all SIF_Message types
23
- #@see Message
24
- class Header < SifBody
25
- element :msg_id, :tag => "SIF_MsgId"
26
- element :timestamp, :tag => "SIF_Timestamp"
27
- element :security, :tag => "SIF_security"
28
- element :source_id, :tag => "SIF_SourceId", :required => true
29
- element :destination_id, :tag => "SIF_DestinationId"
30
- element :contexts, :tag => "SIF_Contexts"
31
-
32
- def initialize(values = {})
33
- values.update(:msg_id => UUID.generate(:compact).upcase) unless values.has_key?(:msg_id)
34
- values.update(:timestamp => Time.now.strftime("%Y-%m-%dT%H:%M:%SZ")) unless values.has_key?(:timestamp)
35
- super(values)
36
- end
37
-
38
- end
39
-
40
- # Base Message for all SIF_Message types
41
- class Message < SifBody
42
- element :header, Header
43
-
44
- def initialize(values={})
45
- values.update(:header => Header.new(:source_id => values[:header])) unless values[:header].nil?
46
- super(values)
47
- end
48
-
49
- alias_method :old_acdc, :acdc
50
- def acdc
51
- xml = Builder::XmlMarkup.new
52
- attrs = { :Version => Siffer.sif_version, :xmlns => Siffer.sif_xmlns }
53
- xml.tag!("SIF_Message", attrs){|body| body << old_acdc}
54
- xml.target!
55
- end
56
-
57
- end
58
-
59
- end
60
- end
@@ -1,25 +0,0 @@
1
- module Siffer
2
- module Messages
3
-
4
- # Element used by SIF_Provide to represent the object being provided
5
- #@see Provide
6
- class Object < SifBody
7
- attribute :object_name
8
- element :extended_query_support
9
- element :contexts
10
- end
11
-
12
- # Message used to attempt registering as a provider of one or more data objects
13
- #@see Object
14
- class Provide < Message
15
- element :object
16
- end
17
-
18
- # This message performs the opposite function of SIF_Provide.
19
- #@see Object
20
- class UnProvide < Message
21
- element :object
22
- end
23
-
24
- end
25
- end
@@ -1,17 +0,0 @@
1
- module Siffer
2
- module Messages
3
-
4
- # This message allows an agent to announce to the ZIS the functionality the agent will provide.
5
- #@see Object
6
- class Provision < Message
7
- element :provide_objects
8
- element :subscribe_objects
9
- element :publish_add_objects
10
- element :publish_change_objects
11
- element :publish_delete_objects
12
- element :request_objects
13
- element :respond_objects
14
- end
15
-
16
- end
17
- end
@@ -1,50 +0,0 @@
1
- module Siffer
2
- module Messages
3
-
4
- # Used by Protocol to describe the protocol used by the agent
5
- DEFINED_PROTOCOLS_TYPE = {
6
- :http => "HTTP",
7
- :https => "HTTPS"
8
- }
9
-
10
- # Used by Protocl to describe any protocol settings
11
- class Property < SifBody
12
- element :name
13
- element :value
14
- end
15
-
16
- # Contains protocol information regarding a ZIS or Agent.
17
- class Protocol < SifBody
18
- attribute :type, DEFINED_PROTOCOLS_TYPE[:https]
19
- attribute :secure, true
20
- element :url
21
- element :property
22
- end
23
-
24
- # Contains information about the vendor of the product that the agent represents
25
- class Application < SifBody
26
- element :vendor
27
- element :product
28
- element :version
29
- end
30
-
31
- # Register is a message for registering an agent with a ZIS.
32
- # An agent must be registered before it sends out messages.
33
- class Register < Message
34
- element :name
35
- element :version
36
- element :max_buffer_size
37
- element :mode
38
- element :protocol
39
- element :node_vendor
40
- element :node_version
41
- element :application
42
- element :icon
43
- end
44
-
45
- # This message allows an agent to remove any association it has with the ZIS.
46
- #@see Register
47
- class Unregister < Message; end
48
-
49
- end
50
- end
@@ -1,138 +0,0 @@
1
- module Siffer
2
- module Messages
3
-
4
- CONDITION_GROUP_TYPES = {
5
- :and => "And",
6
- :or => "Or",
7
- :none => "None"
8
- }
9
-
10
- OPERATORS = {
11
- :equals => "EQ",
12
- :less_than => "LT",
13
- :greater_than => "GT",
14
- :less_than_or_equals => "LE",
15
- :greater_than_or_equals => "GE",
16
- :not_equals => "NE"
17
- }
18
-
19
- ORDERING = {
20
- :asc => "Ascending",
21
- :des => "Descending"
22
- }
23
-
24
- # Represents a condition used in a Query
25
- #@see Conditions
26
- class Condition < SifBody
27
- element :element
28
- element :operator
29
- element :value
30
- end
31
-
32
- # List of Conditions
33
- #@see ConditionGroup
34
- class Conditions < SifBody
35
- attribute :type, CONDITION_GROUP_TYPES[:none]
36
- element :condition
37
- end
38
-
39
- # Represents a group conditions that the queried objects must meet.
40
- # If conditions are not specified all objects named are returned
41
- class ConditionGroup < SifBody
42
- attribute :type, CONDITION_GROUP_TYPES[:none]
43
- element :conditions
44
- end
45
-
46
- # The object that is being queried for
47
- class QueryObject < SifBody
48
- attribute :object_name
49
- element :element
50
- end
51
-
52
- # SIF's default query mechanism
53
- class Query < SifBody
54
- element :query_object
55
- element :condition_group
56
- element :example
57
- end
58
-
59
- # Element used in Select to identify the element/attribute
60
- #@see Select
61
- #@see Condition
62
- #@see OrderBy
63
- #@see QueryObject
64
- class Element < SifBody
65
- attribute :alias
66
- attribute :object_name
67
- attribute :ordering, ORDERING[:asc]
68
- attribute :xsi_type # need to work this out , it should be xsi:type
69
- end
70
-
71
- # Identifies elements to be returned as columns in a query
72
- #@see ExtendedQuery
73
- class Select < SifBody
74
- attribute :distinct, false
75
- attribute :row_count, 0 # This represents a number, 0 for all rows
76
- element :element
77
- end
78
-
79
- # Specifies left join on which to constrain the join
80
- #@see JoinOn
81
- class LeftElement < SifBody
82
- attribute :object_name
83
- end
84
-
85
- # Specifies right join on which to constrain the join
86
- #@see JoinOn
87
- class RightElement < SifBody
88
- attribute :object_name
89
- end
90
-
91
- # Specifies conditions to limit/filter rows
92
- #@see ExtendedQuery
93
- class Where < SifBody
94
- element :condition_group
95
- end
96
-
97
- # Optional list of elements/attributes by which to sort the resulting rows
98
- #@see ExtendedQuery
99
- class OrderBy < SifBody
100
- element :element
101
- end
102
-
103
- # Specifies conditions for the join
104
- #@see From
105
- class JoinOn < SifBody
106
- element :left_element
107
- element :right_element
108
- end
109
-
110
- # Join specification for the query if more than one object is being queried
111
- #@see ExtendedQuery
112
- class From < SifBody
113
- attribute :object_name
114
- element :join
115
- end
116
-
117
- # A more advanced form of Query that allows for joins and retrieval of data
118
- # in row/column form.
119
- class ExtendedQuery < SifBody
120
- element :destination_provider
121
- element :select
122
- element :from
123
- element :where
124
- element :order_by
125
- end
126
-
127
- # Message used to request information in SIF data objects from other SIF nodes.
128
- #@see Query
129
- #@see ExtendedQuery
130
- class Request < Message
131
- element :version
132
- element :max_buffer_size
133
- element :query
134
- element :extended_query
135
- end
136
-
137
- end
138
- end