@@ 3068-3098 (lines=31) @@ | ||
3065 | ||
3066 | __repr__ = __str__ |
|
3067 | ||
3068 | ||
3069 | class AnonymousIdentityToken(FrozenClass): |
|
3070 | ''' |
|
3071 | A token representing an anonymous user. |
|
3072 | ||
3073 | :ivar PolicyId: |
|
3074 | :vartype PolicyId: String |
|
3075 | ''' |
|
3076 | def __init__(self, binary=None): |
|
3077 | if binary is not None: |
|
3078 | self._binary_init(binary) |
|
3079 | self._freeze = True |
|
3080 | return |
|
3081 | self.PolicyId = None |
|
3082 | self._freeze = True |
|
3083 | ||
3084 | def to_binary(self): |
|
3085 | packet = [] |
|
3086 | packet.append(pack_string(self.PolicyId)) |
|
3087 | return b''.join(packet) |
|
3088 | ||
3089 | @staticmethod |
|
3090 | def from_binary(data): |
|
3091 | return AnonymousIdentityToken(data) |
|
3092 | ||
3093 | def _binary_init(self, data): |
|
3094 | self.PolicyId = unpack_string(data) |
|
3095 | ||
3096 | def __str__(self): |
|
3097 | return 'AnonymousIdentityToken(' + 'PolicyId:' + str(self.PolicyId) + ')' |
|
3098 | ||
3099 | __repr__ = __str__ |
|
3100 | ||
3101 | ||
@@ 3035-3065 (lines=31) @@ | ||
3032 | ||
3033 | __repr__ = __str__ |
|
3034 | ||
3035 | ||
3036 | class UserIdentityToken(FrozenClass): |
|
3037 | ''' |
|
3038 | A base type for a user identity token. |
|
3039 | ||
3040 | :ivar PolicyId: |
|
3041 | :vartype PolicyId: String |
|
3042 | ''' |
|
3043 | def __init__(self, binary=None): |
|
3044 | if binary is not None: |
|
3045 | self._binary_init(binary) |
|
3046 | self._freeze = True |
|
3047 | return |
|
3048 | self.PolicyId = None |
|
3049 | self._freeze = True |
|
3050 | ||
3051 | def to_binary(self): |
|
3052 | packet = [] |
|
3053 | packet.append(pack_string(self.PolicyId)) |
|
3054 | return b''.join(packet) |
|
3055 | ||
3056 | @staticmethod |
|
3057 | def from_binary(data): |
|
3058 | return UserIdentityToken(data) |
|
3059 | ||
3060 | def _binary_init(self, data): |
|
3061 | self.PolicyId = unpack_string(data) |
|
3062 | ||
3063 | def __str__(self): |
|
3064 | return 'UserIdentityToken(' + 'PolicyId:' + str(self.PolicyId) + ')' |
|
3065 | ||
3066 | __repr__ = __str__ |
|
3067 | ||
3068 |
@@ 1043-1068 (lines=26) @@ | ||
1040 | except AttributeError: |
|
1041 | return VariantType.ExtensionObject |
|
1042 | else: |
|
1043 | raise UaError("Could not guess UA type of {} with type {}, specify UA type".format(val, type(val))) |
|
1044 | ||
1045 | def __str__(self): |
|
1046 | return "Variant(val:{!s},type:{})".format(self.Value, self.VariantType) |
|
1047 | __repr__ = __str__ |
|
1048 | ||
1049 | def to_binary(self): |
|
1050 | b = [] |
|
1051 | encoding = self.VariantType.value & 0b111111 |
|
1052 | if type(self.Value) in (list, tuple): |
|
1053 | if self.Dimensions is not None: |
|
1054 | encoding = set_bit(encoding, 6) |
|
1055 | encoding = set_bit(encoding, 7) |
|
1056 | b.append(uatype_UInt8.pack(encoding)) |
|
1057 | b.append(pack_uatype_array(self.VariantType.name, flatten(self.Value))) |
|
1058 | if self.Dimensions is not None: |
|
1059 | b.append(pack_uatype_array("Int32", self.Dimensions)) |
|
1060 | else: |
|
1061 | b.append(uatype_UInt8.pack(encoding)) |
|
1062 | b.append(pack_uatype(self.VariantType.name, self.Value)) |
|
1063 | ||
1064 | return b"".join(b) |
|
1065 | ||
1066 | @staticmethod |
|
1067 | def from_binary(data): |
|
1068 | dimensions = None |
|
1069 | encoding = ord(data.read(1)) |
|
1070 | int_type = encoding & 0b00111111 |
|
1071 | vtype = DataType_to_VariantType(int_type) |