siffer 0.1.0 → 0.1.1

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 +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
@@ -0,0 +1,20 @@
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
@@ -0,0 +1,60 @@
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
@@ -0,0 +1,25 @@
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
@@ -0,0 +1,17 @@
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
@@ -0,0 +1,50 @@
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
@@ -0,0 +1,138 @@
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
@@ -0,0 +1,48 @@
1
+ module Siffer
2
+ module Messages
3
+
4
+ MORE_PACKETS = {
5
+ :yes => "Yes",
6
+ :no => "No"
7
+ }
8
+
9
+ # Provides element/attribute caption information for each column supplied in
10
+ # ExtendedQuery. The order must correspend to the order in the ExtendedQuery
11
+ #@see ExtendedQueryResults
12
+ #@see Element
13
+ class ColumnHeaders < SifBody
14
+ element :element
15
+ end
16
+
17
+ class R < SifBody
18
+ element :c
19
+ end
20
+
21
+ class Rows < SifBody
22
+ element :r
23
+ end
24
+
25
+ # Element provides a wrapper for data returned in response to
26
+ # an ExtendedQuery
27
+ #@see Response
28
+ #@see ReportObject
29
+ class ExtendedQueryResults < SifBody
30
+ element :column_headers
31
+ element :rows
32
+ end
33
+
34
+ # Used to respond to a SIF_Request message.
35
+ # May span multiple SIF_Response messages.
36
+ #@see Error
37
+ #@see ExtendedQueryResults
38
+ class Response < Message
39
+ element :request_msg_id
40
+ element :packet_number
41
+ element :more_packets
42
+ element :error
43
+ element :object_data
44
+ element :extended_query_results
45
+ end
46
+
47
+ end
48
+ end
@@ -0,0 +1,17 @@
1
+ module Siffer
2
+ module Messages
3
+
4
+ # Message is used to subscribe to event objects that are contained in this message
5
+ #@see Object
6
+ class Subscribe < Message
7
+ element :object
8
+ end
9
+
10
+ # This message performs the opposite function of SIF_Subscribe.
11
+ #@see Object
12
+ class Unsubscribe < Message
13
+ element :object
14
+ end
15
+
16
+ end
17
+ end
@@ -0,0 +1,94 @@
1
+ module Siffer
2
+ module Messages
3
+
4
+ NOTIFICATION_TYPES = {
5
+ :standard => "Standard",
6
+ :none => "None"
7
+ }
8
+
9
+ # Sent to detect if a ZIS or push-mode agent is ready to receive and process messages.
10
+ #@see SystemControl
11
+ class Ping < SifElement; end
12
+
13
+ # Allows an agent to notify a ZIS or a ZIS to notify a push-mode agent that it must not send any more messages to the sender of the SIF_Sleep.
14
+ #@see SystemControl
15
+ class Sleep < SifElement; end
16
+
17
+ # This will signal the receiver that the sender is now able to process messages.
18
+ #@see SystemControl
19
+ class Wakeup < SifElement; end
20
+
21
+ # This message tells the ZIS to return the first available message to the agent, subject to Selective Message Blocking.
22
+ #@see SystemControl
23
+ class GetMessage < SifElement; end
24
+
25
+ # This message tells the ZIS to return the current SIF_ZoneStatus in a SIF_Ack.
26
+ #@see SystemControl
27
+ class GetZoneStatus < SifElement; end
28
+
29
+ # This message tells the ZIS to return the Agent's ACL permissions in a SIF_Ack.
30
+ #@see SystemControl
31
+ class GetAgentACL < SifElement; end
32
+
33
+ # The list of SIF_Requests to cancel
34
+ #@see CancelRequests
35
+ class RequestMsgIds < SifBody
36
+ element :request_msg_id
37
+ end
38
+
39
+ # Asks a receiver (ZIS or Push-Mode Agent) to cancel the specified SIF_Requests, pending or in process
40
+ #@see SystemControl
41
+ class CancelRequests < SifBody
42
+ element :notification_type
43
+ element :request_msg_ids
44
+ end
45
+
46
+
47
+ # Message designed to control the flow of data between an agent and ZIS or vice-versa.
48
+ class SystemControl < Message
49
+ element :system_control_data, :tag => "SIF_SystemControlData"
50
+
51
+ class << self
52
+
53
+ # Returns a SIF_Ping
54
+ def ping(source)
55
+ SystemControl.new(:header => source, :system_control_data => Ping.new)
56
+ end
57
+
58
+ # Returns a SIF_Sleep
59
+ def sleep(source)
60
+ SystemControl.new(:header => source, :system_control_data => Sleep.new)
61
+ end
62
+
63
+ # Returns a SIF_Wakeup
64
+ def wake_up(source)
65
+ SystemControl.new(:header => source, :system_control_data => Wakeup.new)
66
+ end
67
+
68
+ # Returns a SIF_GetMessage
69
+ def get_message(source)
70
+ SystemControl.new(:header => source, :system_control_data => GetMessage.new)
71
+ end
72
+
73
+ # Returns a SIF_GetZoneStatus
74
+ def get_zone_status(source)
75
+ SystemControl.new(:header => source, :system_control_data => GetZoneStatus.new)
76
+ end
77
+
78
+ # Returns a SIF_GetAgentACL
79
+ def get_agent_acl(source)
80
+ SystemControl.new(:header => source, :system_control_data => GetAgentACL.new)
81
+ end
82
+
83
+ # Returns a SIF_CancelRequest
84
+ def cancel_requests(source, notification, *ids)
85
+ cancel = CancelRequests.new(
86
+ :notification_type => notification,
87
+ :request_msg_ids => RequestMsgIds.new(:request_msg_id => ids))
88
+ SystemControl.new(:header => source, :system_control_data => cancel)
89
+ end
90
+ end
91
+ end
92
+
93
+ end
94
+ end