@@ 162-187 (lines=26) @@ | ||
159 | return ack |
|
160 | ||
161 | ||
162 | class AsymmetricAlgorithmHeader(uatypes.FrozenClass): |
|
163 | ||
164 | def __init__(self): |
|
165 | self.SecurityPolicyURI = "http://opcfoundation.org/UA/SecurityPolicy#None" |
|
166 | self.SenderCertificate = None |
|
167 | self.ReceiverCertificateThumbPrint = None |
|
168 | self._freeze = True |
|
169 | ||
170 | def to_binary(self): |
|
171 | b = [] |
|
172 | b.append(uatypes.pack_string(self.SecurityPolicyURI)) |
|
173 | b.append(uatypes.pack_string(self.SenderCertificate)) |
|
174 | b.append(uatypes.pack_string(self.ReceiverCertificateThumbPrint)) |
|
175 | return b"".join(b) |
|
176 | ||
177 | @staticmethod |
|
178 | def from_binary(data): |
|
179 | hdr = AsymmetricAlgorithmHeader() |
|
180 | hdr.SecurityPolicyURI = uatypes.unpack_string(data) |
|
181 | hdr.SenderCertificate = uatypes.unpack_bytes(data) |
|
182 | hdr.ReceiverCertificateThumbPrint = uatypes.unpack_bytes(data) |
|
183 | return hdr |
|
184 | ||
185 | def __str__(self): |
|
186 | return "{}(SecurityPolicy:{}, certificatesize:{}, receiverCertificatesize:{} )".format(self.__class__.__name__, self.SecurityPolicyURI, len(self.SenderCertificate), len(self.ReceiverCertificateThumbPrint)) |
|
187 | __repr__ = __str__ |
|
188 | ||
189 | ||
190 | class SymmetricAlgorithmHeader(uatypes.FrozenClass): |
|
@@ 110-132 (lines=23) @@ | ||
107 | __repr__ = __str__ |
|
108 | ||
109 | ||
110 | class ErrorMessage(uatypes.FrozenClass): |
|
111 | ||
112 | def __init__(self): |
|
113 | self.Error = uatypes.StatusCode() |
|
114 | self.Reason = "" |
|
115 | self._freeze = True |
|
116 | ||
117 | def to_binary(self): |
|
118 | b = [] |
|
119 | b.append(self.Error.to_binary()) |
|
120 | b.append(uatypes.pack_string(self.Reason)) |
|
121 | return b"".join(b) |
|
122 | ||
123 | @staticmethod |
|
124 | def from_binary(data): |
|
125 | ack = ErrorMessage() |
|
126 | ack.Error = uatypes.StatusCode.from_binary(data) |
|
127 | ack.Reason = uatypes.unpack_string(data) |
|
128 | return ack |
|
129 | ||
130 | def __str__(self): |
|
131 | return "MessageAbort(error:{}, reason:{})".format(self.Error, self.Reason) |
|
132 | __repr__ = __str__ |
|
133 | ||
134 | ||
135 | class Acknowledge(uatypes.FrozenClass): |