siffer 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/siffer.rb +5 -16
- data/lib/siffer/messages.rb +12 -40
- data/lib/siffer/messages/ack.rb +27 -162
- data/lib/siffer/messages/error.rb +168 -0
- data/lib/siffer/messages/header.rb +55 -0
- data/lib/siffer/messages/message.rb +7 -51
- data/lib/siffer/messages/status.rb +32 -0
- metadata +28 -7
- data/lib/siffer/core_ext/hash.rb +0 -15
data/lib/siffer.rb
CHANGED
@@ -1,20 +1,13 @@
|
|
1
1
|
require 'rubygems'
|
2
|
-
require 'activesupport'
|
3
2
|
require 'uuid'
|
4
|
-
require 'builder'
|
5
|
-
require 'sinatra/base'
|
6
|
-
require 'haml'
|
7
|
-
require 'rest_client'
|
8
3
|
require 'acdc'
|
9
4
|
|
10
|
-
$: << File.expand_path(File.dirname(__FILE__))
|
11
|
-
|
12
5
|
module Siffer
|
13
6
|
|
14
|
-
VENDOR = "h3o(software)"
|
15
|
-
VERSION = [0,1,
|
16
|
-
SIF_VERSION = [2,3]
|
17
|
-
SIF_XMLNS = "http://www.sifinfo.org/infrastructure/2.x"
|
7
|
+
VENDOR = "h3o(software)"
|
8
|
+
VERSION = [0,1,2]
|
9
|
+
SIF_VERSION = [2,3]
|
10
|
+
SIF_XMLNS = "http://www.sifinfo.org/infrastructure/2.x"
|
18
11
|
|
19
12
|
# The vendor of this SIF implementation (self describing for Agents)
|
20
13
|
def self.vendor() VENDOR end
|
@@ -33,9 +26,5 @@ module Siffer
|
|
33
26
|
def self.root=(value) @root = value end
|
34
27
|
|
35
28
|
autoload :Messages, "siffer/messages"
|
36
|
-
autoload :Models, "siffer/models"
|
37
29
|
|
38
|
-
end
|
39
|
-
|
40
|
-
require "siffer/agent"
|
41
|
-
require "siffer/core_ext/hash"
|
30
|
+
end
|
data/lib/siffer/messages.rb
CHANGED
@@ -1,41 +1,13 @@
|
|
1
|
-
|
2
|
-
|
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'
|
1
|
+
require 'siffer/messages/header'
|
2
|
+
require 'siffer/messages/status'
|
3
|
+
require 'siffer/messages/error'
|
33
4
|
require 'siffer/messages/ack'
|
34
|
-
require 'siffer/messages/
|
35
|
-
require 'siffer/messages/
|
36
|
-
require 'siffer/messages/
|
37
|
-
require 'siffer/messages/
|
38
|
-
require 'siffer/messages/
|
39
|
-
require 'siffer/messages/
|
40
|
-
require 'siffer/messages/
|
41
|
-
require 'siffer/messages/
|
5
|
+
require 'siffer/messages/message'
|
6
|
+
# require 'siffer/messages/event'
|
7
|
+
# require 'siffer/messages/provide'
|
8
|
+
# require 'siffer/messages/provision'
|
9
|
+
# require 'siffer/messages/register'
|
10
|
+
# require 'siffer/messages/request'
|
11
|
+
# require 'siffer/messages/response'
|
12
|
+
# require 'siffer/messages/subscribe'
|
13
|
+
# require 'siffer/messages/system_control'
|
data/lib/siffer/messages/ack.rb
CHANGED
@@ -1,168 +1,33 @@
|
|
1
1
|
module Siffer
|
2
2
|
module Messages
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
element :
|
8
|
-
element :
|
9
|
-
element :
|
4
|
+
class Ack < AcDc::Body
|
5
|
+
|
6
|
+
tag_name "SIF_Ack"
|
7
|
+
element :header, Header
|
8
|
+
element :original_source_id, String, :tag => "SIF_OriginalSourceId"
|
9
|
+
element :original_msg_id, String, :tag => "SIF_OriginalMsgId"
|
10
|
+
element :status, Status
|
11
|
+
#element :error, Error
|
12
|
+
|
13
|
+
def self.create(options = {}, &block)
|
14
|
+
ack = Ack.new
|
15
|
+
ack.header = Header.create(options)
|
16
|
+
ack.original_msg_id = options[:original_msg_id]
|
17
|
+
ack.original_source_id = options[:original_source_id]
|
18
|
+
yield ack if block_given?
|
19
|
+
raise "Original Msg Id is required" if ack.original_msg_id.nil?
|
20
|
+
raise "Original Source Id is required" if ack.original_source_id.nil?
|
21
|
+
ack
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.status(options = {}, &block)
|
25
|
+
ack = Ack.create(options)
|
26
|
+
ack.status = Status.create(options)
|
27
|
+
yield ack if block_given?
|
28
|
+
ack
|
29
|
+
end
|
30
|
+
|
10
31
|
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
32
|
end
|
168
33
|
end
|
@@ -0,0 +1,168 @@
|
|
1
|
+
module Siffer
|
2
|
+
module Messages
|
3
|
+
|
4
|
+
class Error < AcDc::Body
|
5
|
+
tag_name "SIF_Error"
|
6
|
+
element :category, Integer, :tag => "SIF_Category"
|
7
|
+
element :code, Integer, :tag => "SIF_Code"
|
8
|
+
element :description, String, :tag => "SIF_Desc"
|
9
|
+
element :extended_description, String, :tag => "SIF_Extended_Desc"
|
10
|
+
|
11
|
+
def self.create(options = {}, &block)
|
12
|
+
error = Error.new
|
13
|
+
error.category = options[:error_category]
|
14
|
+
error.code = options[:error_code]
|
15
|
+
error.description = options[:error_desc]
|
16
|
+
yield error if block_given?
|
17
|
+
raise "Error Category is required" if error.category.nil?
|
18
|
+
raise "Error Code is required" if error.code.nil?
|
19
|
+
raise "Error Description is required" if error.description.nil?
|
20
|
+
raise "Error Category is invalid" unless ERROR_CATEGORY.keys.include?(error.category)
|
21
|
+
raise "Error Code is invalid" unless ERROR_CODES[error.category].any?{|codes| codes.keys.include?(error.code)}
|
22
|
+
error
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
ERROR_CATEGORY = {
|
27
|
+
0 => "Unknown (This should NEVER be used if possible)",
|
28
|
+
1 => "XML Validation",
|
29
|
+
2 => "Encryption",
|
30
|
+
3 => "Authentication",
|
31
|
+
4 => "Access and Permissions",
|
32
|
+
5 => "Registration",
|
33
|
+
6 => "Provision",
|
34
|
+
7 => "Subscription",
|
35
|
+
8 => "Request and Response",
|
36
|
+
9 => "Event Reporting and Processing",
|
37
|
+
10 => "Transport",
|
38
|
+
11 => "System (OS, Database, Vendor localized, etc.)",
|
39
|
+
12 => "Generic Message Handling",
|
40
|
+
13 => "SMB Handling"
|
41
|
+
}
|
42
|
+
|
43
|
+
XML_VALIDATION_ERROR = {
|
44
|
+
1 => "Generic error",
|
45
|
+
2 => "Message is not well-formed",
|
46
|
+
3 => "Generic validation error",
|
47
|
+
4 => "Invalid value for element/attribute",
|
48
|
+
6 => "Missing mandatory element/attribute"
|
49
|
+
}
|
50
|
+
|
51
|
+
ENCRYPTION_ERROR = { 1 => "Generic Error" }
|
52
|
+
|
53
|
+
AUTHENTICATION_ERROR = {
|
54
|
+
1 => "Generic error",
|
55
|
+
2 => "Generic authentication error (with signature)",
|
56
|
+
3 => "Missing sender's certificate",
|
57
|
+
4 => "Invalid certificate",
|
58
|
+
5 => "Sender's certificate is not trusted",
|
59
|
+
6 => "Expired certificate",
|
60
|
+
7 => "Invalid signature",
|
61
|
+
8 => "Invalid encryption algorithm (only accepts MD4)",
|
62
|
+
9 => "Missing public key of the receiver (when decrypting message)",
|
63
|
+
10 => "Missing receiver's private key (when decrypting message)"
|
64
|
+
}
|
65
|
+
|
66
|
+
ACCESS_AND_PERMISSION_ERROR = {
|
67
|
+
1 => "Generic error",
|
68
|
+
2 => "No permission to register",
|
69
|
+
3 => "No permission to provide this object",
|
70
|
+
4 => "No permission to subscribe to this SIF_Event",
|
71
|
+
5 => "No permission to request this object",
|
72
|
+
6 => "No permission to respond to this object request",
|
73
|
+
7 => "No permission to publish SIF_Event",
|
74
|
+
8 => "No permission to administer policies",
|
75
|
+
9 => "SIF_SourceId is not registered",
|
76
|
+
10 => "No permission to publish SIF_Event Add",
|
77
|
+
11 => "No permission to publish SIF_Event Change",
|
78
|
+
12 => "No permission to publish SIF_Event Delete"
|
79
|
+
}
|
80
|
+
|
81
|
+
REGISTRATION_ERROR = {
|
82
|
+
1 => "Generic error",
|
83
|
+
2 => "The SIF_SourceId is invalid",
|
84
|
+
3 => "Requested transport protocol is unsupported",
|
85
|
+
4 => "Requested SIF_Version(s) not supported.",
|
86
|
+
6 => "Requested SIF_MaxBufferSize is too small",
|
87
|
+
7 => "ZIS requires a secure transport",
|
88
|
+
9 => "Agent is registered for push mode (returned when a push-mode agent sends a SIF_GetMessage).",
|
89
|
+
10 => "ZIS does not support the requested Accept-Encoding value."
|
90
|
+
}
|
91
|
+
|
92
|
+
PROVISION_ERROR = {
|
93
|
+
1 => "Generic error",
|
94
|
+
3 => "Invalid object",
|
95
|
+
4 => "Object already has a provider (SIF_Provide message)"
|
96
|
+
}
|
97
|
+
|
98
|
+
SUBSCRIPTION_ERROR = {
|
99
|
+
1 => "Generic error",
|
100
|
+
3 => "Invalid object"
|
101
|
+
}
|
102
|
+
|
103
|
+
REQUEST_AND_RESPONSE_ERROR = {
|
104
|
+
1 => "Generic error",
|
105
|
+
3 => "Invalid object",
|
106
|
+
4 => "No provider",
|
107
|
+
7 => "Responder does not support requested SIF_Version",
|
108
|
+
8 => "Responder does not support requested SIF_MaxBufferSize",
|
109
|
+
9 => "Unsupported query in request",
|
110
|
+
10 => "Invalid SIF_RequestMsgId specified in SIF_Response",
|
111
|
+
11 => "SIF_Response is larger than requested SIF_MaxBufferSize",
|
112
|
+
12 => "SIF_PacketNumber is invalid in SIF_Response",
|
113
|
+
13 => "SIF_Response does not match any SIF_Version from SIF_Request",
|
114
|
+
14 => "SIF_DestinationId does not match SIF_SourceId from SIF_Request",
|
115
|
+
15 => "No support for SIF_ExtendedQuery",
|
116
|
+
16 => "SIF_RequestMsgId deleted from cache due to timeout",
|
117
|
+
17 => "SIF_RequestMsgId deleted from cache by administrator",
|
118
|
+
18 => "SIF_Request cancelled by requesting agent"
|
119
|
+
}
|
120
|
+
|
121
|
+
EVENT_REPORTING_AND_PROCESSING_ERROR = {
|
122
|
+
1 => "Generic error",
|
123
|
+
3 => "Invalid event"
|
124
|
+
}
|
125
|
+
|
126
|
+
TRANSPORT_ERROR = {
|
127
|
+
1 => "Generic error",
|
128
|
+
2 => "Requested protocol is not supported",
|
129
|
+
3 => "Secure channel requested and no secure path exists",
|
130
|
+
4 => "Unable to establish connection"
|
131
|
+
}
|
132
|
+
|
133
|
+
SYSTEM_ERROR = { 1 => "Generic error" }
|
134
|
+
|
135
|
+
GENERIC_MESSAGE_HANDLING_ERROR = {
|
136
|
+
1 => "Generic error",
|
137
|
+
2 => "Message not supported",
|
138
|
+
3 => "Version not supported",
|
139
|
+
4 => "Context not supported",
|
140
|
+
5 => "Protocol error",
|
141
|
+
6 => "No such message (as identified by SIF_OriginalMsgId)",
|
142
|
+
7 => "Multiple contexts not supported"
|
143
|
+
}
|
144
|
+
|
145
|
+
SMB_ERROR = {
|
146
|
+
1 => "Generic error",
|
147
|
+
2 => "SMB can only be invoked during a SIF_Event acknowledgement",
|
148
|
+
3 => "Final SIF_Ack expected from Push-Mode Agent",
|
149
|
+
4 => "Incorrect SIF_MsgId in final SIF_Ack"
|
150
|
+
}
|
151
|
+
|
152
|
+
ERROR_CODES = {
|
153
|
+
1 => XML_VALIDATION_ERROR,
|
154
|
+
2 => ENCRYPTION_ERROR,
|
155
|
+
3 => AUTHENTICATION_ERROR,
|
156
|
+
4 => ACCESS_AND_PERMISSION_ERROR,
|
157
|
+
5 => REGISTRATION_ERROR,
|
158
|
+
6 => PROVISION_ERROR,
|
159
|
+
7 => SUBSCRIPTION_ERROR,
|
160
|
+
8 => REQUEST_AND_RESPONSE_ERROR,
|
161
|
+
9 => EVENT_REPORTING_AND_PROCESSING_ERROR,
|
162
|
+
10 => TRANSPORT_ERROR,
|
163
|
+
11 => SYSTEM_ERROR,
|
164
|
+
12 => GENERIC_MESSAGE_HANDLING_ERROR,
|
165
|
+
13 => SMB_ERROR}
|
166
|
+
|
167
|
+
end
|
168
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module Siffer
|
2
|
+
module Messages
|
3
|
+
|
4
|
+
class SecureChannel < AcDc::Body
|
5
|
+
tag_name "SIF_SecureChannel"
|
6
|
+
element :authentication_level, Integer, :tag => "SIF_AuthenticationLevel"
|
7
|
+
element :encryption_level, Integer, :tag => "SIF_EncryptionLevel"
|
8
|
+
end
|
9
|
+
|
10
|
+
class Security < AcDc::Body
|
11
|
+
tag_name "SIF_Security"
|
12
|
+
element :secure_channel, SecureChannel
|
13
|
+
|
14
|
+
def self.create(options = {}, &block)
|
15
|
+
security = Security.new
|
16
|
+
security.secure_channel = SecureChannel.new
|
17
|
+
security.secure_channel.encryption_level = options[:encryption] || 0
|
18
|
+
security.secure_channel.authentication_level = options[:authentication] || 0
|
19
|
+
yield security if block_given?
|
20
|
+
security
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
class Contexts < AcDc::Body
|
25
|
+
tag_name "SIF_Contexts"
|
26
|
+
element :context, String, :tag => "SIF_Context", :single => false
|
27
|
+
end
|
28
|
+
|
29
|
+
class Header < AcDc::Body
|
30
|
+
|
31
|
+
tag_name "SIF_Header"
|
32
|
+
|
33
|
+
element :msg_id, String, :tag => "SIF_MsgId"
|
34
|
+
element :timestamp, DateTime, :tag => "SIF_Timestamp"
|
35
|
+
element :security, Security
|
36
|
+
element :source_id, String, :tag => "SIF_SourceId"
|
37
|
+
element :destination_id, String, :tag => "SIF_DestinationId"
|
38
|
+
element :contexts, Contexts
|
39
|
+
|
40
|
+
def self.create(options = {}, &block)
|
41
|
+
head = Header.new
|
42
|
+
head.source_id = options[:source]
|
43
|
+
head.msg_id = options[:msg_id] || UUID.generate(:compact).upcase
|
44
|
+
head.timestamp = options[:timestamp] || Time.now.strftime("%Y-%m-%dT%H:%M:%SZ")
|
45
|
+
head.security = Security.create(options)
|
46
|
+
yield head if block_given?
|
47
|
+
raise "Source is required for Header" if head.source_id.nil?
|
48
|
+
raise "Message Id is required for Header" if head.msg_id.nil?
|
49
|
+
raise "Timestamp is require for Header" if head.timestamp.nil?
|
50
|
+
head
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -1,60 +1,16 @@
|
|
1
1
|
module Siffer
|
2
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"
|
3
|
+
class Message < AcDc::Body
|
31
4
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
end
|
5
|
+
namespace Siffer.sif_xmlns
|
6
|
+
tag_name "SIF_Message"
|
7
|
+
attribute :Version, String
|
8
|
+
element :ack, Ack
|
37
9
|
|
38
|
-
|
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)
|
10
|
+
def initialize
|
11
|
+
self.Version = Siffer.sif_version
|
47
12
|
end
|
48
13
|
|
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
14
|
end
|
58
|
-
|
59
15
|
end
|
60
16
|
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Siffer
|
2
|
+
module Messages
|
3
|
+
|
4
|
+
class Status < AcDc::Body
|
5
|
+
tag_name "SIF_Status"
|
6
|
+
element :code, Integer, :tag => "SIF_Code"
|
7
|
+
element :description, String, :tag => "SIF_Desc"
|
8
|
+
# element :data ====== can be Message, AgentACL or ZoneStatus
|
9
|
+
|
10
|
+
def self.create(options = {}, &block)
|
11
|
+
status = Status.new
|
12
|
+
status.code = options[:status_code] || 0
|
13
|
+
status.description = STATUS_CODE[status.code]
|
14
|
+
yield status if block_given?
|
15
|
+
raise "Status Code not valid" unless STATUS_CODE.keys.include?(status.code)
|
16
|
+
status
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
STATUS_CODE = {
|
22
|
+
0 => "Success (ZIS ONLY). SIF_Status/SIF_Data may contain additional data.",
|
23
|
+
1 => "Immediate SIF_Ack (AGENT ONLY). Message is persisted or processing is complete. Discard the referenced message.",
|
24
|
+
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.",
|
25
|
+
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.",
|
26
|
+
7 => "Already have a message with this SIF_MsgId from you.",
|
27
|
+
8 => "Receiver is sleeping.",
|
28
|
+
9 => "No messages available. This is returned when an agent is trying to pull messages from a ZIS and there are no messages available."
|
29
|
+
}
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: siffer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Clint Hill
|
@@ -9,10 +9,29 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-12-10 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
|
-
dependencies:
|
15
|
-
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: uuid
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 2.1.0
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: acdc
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.7.2
|
34
|
+
version:
|
16
35
|
description: " Siffer is a SIF that plans to remove the complexity from the implementation.\n Siffer is SIF done easy. It's also the first entirely done in Ruby!\n"
|
17
36
|
email: clint.hill@h3osoftware.com
|
18
37
|
executables: []
|
@@ -23,15 +42,17 @@ extra_rdoc_files: []
|
|
23
42
|
|
24
43
|
files:
|
25
44
|
- lib/siffer/agent.rb
|
26
|
-
- lib/siffer/core_ext/hash.rb
|
27
45
|
- lib/siffer/messages/ack.rb
|
46
|
+
- lib/siffer/messages/error.rb
|
28
47
|
- lib/siffer/messages/event.rb
|
48
|
+
- lib/siffer/messages/header.rb
|
29
49
|
- lib/siffer/messages/message.rb
|
30
50
|
- lib/siffer/messages/provide.rb
|
31
51
|
- lib/siffer/messages/provision.rb
|
32
52
|
- lib/siffer/messages/register.rb
|
33
53
|
- lib/siffer/messages/request.rb
|
34
54
|
- lib/siffer/messages/response.rb
|
55
|
+
- lib/siffer/messages/status.rb
|
35
56
|
- lib/siffer/messages/subscribe.rb
|
36
57
|
- lib/siffer/messages/system_control.rb
|
37
58
|
- lib/siffer/messages.rb
|
@@ -44,7 +65,7 @@ has_rdoc: true
|
|
44
65
|
homepage: http://h3osoftware.com/siffer
|
45
66
|
licenses: []
|
46
67
|
|
47
|
-
post_install_message:
|
68
|
+
post_install_message: Thanks for installing Siffer! It's still incomplete but take a look!
|
48
69
|
rdoc_options: []
|
49
70
|
|
50
71
|
require_paths:
|
@@ -67,6 +88,6 @@ rubyforge_project:
|
|
67
88
|
rubygems_version: 1.3.5
|
68
89
|
signing_key:
|
69
90
|
specification_version: 3
|
70
|
-
summary: Siffer - School Interoperability Framework by h3o(software)
|
91
|
+
summary: Siffer 0.1.2 - School Interoperability Framework by h3o(software)
|
71
92
|
test_files: []
|
72
93
|
|
data/lib/siffer/core_ext/hash.rb
DELETED
@@ -1,15 +0,0 @@
|
|
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
|