def from_dict(cls, dict_repr, return_obj=None):
     if not dict_repr:
         return None
     
     if not return_obj:
         return_obj = cls()
     
     identity_dict = dict_repr.get('identity', None)
     time_dict = dict_repr.get('time', None)
     
     if identity_dict:
         xsi_type = identity_dict.get('xsi:type')
         if xsi_type:
             type_name = xsi_type.split(":")[1]
             if  type_name == CIQIdentity3_0Instance._XML_TYPE:
                 return_obj.identity = CIQIdentity3_0Instance.from_dict(identity_dict)
             else:
                 raise TypeError('No known class for xsi:type: %s' % (xsi_type))
         else:
             return_obj.identity = Identity.from_dict(identity_dict)
             
     if time_dict:
         return_obj.time = Time.from_dict(time_dict)
     
     return return_obj
Exemple #2
0
    def from_dict(cls, dict_repr, return_obj=None):
        if not dict_repr:
            return None

        if not return_obj:
            return_obj = cls()

        identity_dict = dict_repr.get('identity')
        time_dict = dict_repr.get('time')
        tools_list = dict_repr.get('tools')

        if identity_dict:
            xsi_type = identity_dict.get('xsi:type')
            if xsi_type:
                type_name = xsi_type.split(":")[1]
                if type_name == CIQIdentity3_0Instance._XML_TYPE:
                    return_obj.identity = CIQIdentity3_0Instance.from_dict(
                        identity_dict)
                else:
                    raise TypeError('No known class for xsi:type: %s' %
                                    (xsi_type))
            else:
                return_obj.identity = Identity.from_dict(identity_dict)

        if time_dict:
            return_obj.time = Time.from_dict(time_dict)

        if tools_list:
            return_obj.tools = ToolInformationList.from_list(tools_list)

        return return_obj
 def from_obj(cls, obj, return_obj=None):
     if not obj:
         return None
     
     if not return_obj:
         return_obj = cls()
     
     if obj.get_Identity():
         identity_obj = obj.get_Identity()
         if isinstance(identity_obj, ciq_identity_binding.CIQIdentity3_0InstanceType):
             return_obj.identity = CIQIdentity3_0Instance.from_obj(identity_obj)
         elif type(identity_obj) == stix_common_binding.IdentityType:
             return_obj.identity = Identity.from_obj(identity_obj)
     
     if obj.get_Time():
         return_obj.time = Time.from_obj(obj.get_Time())
         
     return return_obj
Exemple #4
0
 def from_obj(cls, obj, return_obj=None):
     if not obj:
         return None
     
     if not return_obj:
         return_obj = cls()
         
     super(RelatedIdentity, cls).from_obj(obj, return_obj)
     
     if obj.get_Identity():
         identity_obj = obj.get_Identity()
         if isinstance(identity_obj, ciq_identity_binding.CIQIdentity3_0InstanceType):
             from stix.extensions.identity import CIQIdentity3_0Instance
             return_obj.identity = CIQIdentity3_0Instance.from_obj(identity_obj)
         elif isinstance(identity_obj, stix_common_binding.IdentityType):
             return_obj.identity = Identity.from_obj(identity_obj)
         else:
             raise ValueError('unable to instantiate the correct type for identity')
     
     return return_obj
Exemple #5
0
    def from_obj(cls, obj, return_obj=None):
        if not obj:
            return None

        if not return_obj:
            return_obj = cls()

        if obj.get_Identity():
            identity_obj = obj.get_Identity()
            if isinstance(identity_obj,
                          ciq_identity_binding.CIQIdentity3_0InstanceType):
                return_obj.identity = CIQIdentity3_0Instance.from_obj(
                    identity_obj)
            elif type(identity_obj) == stix_common_binding.IdentityType:
                return_obj.identity = Identity.from_obj(identity_obj)

        if obj.get_Time():
            return_obj.time = Time.from_obj(obj.get_Time())

        if obj.get_Tools():
            return_obj.tools = ToolInformationList.from_obj(obj.get_Tools())

        return return_obj
Exemple #6
0
    def from_obj(cls, obj, return_obj=None):
        if not obj:
            return None

        if not return_obj:
            return_obj = cls()

        super(RelatedIdentity, cls).from_obj(obj, return_obj)

        if obj.get_Identity():
            identity_obj = obj.get_Identity()
            if isinstance(identity_obj,
                          ciq_identity_binding.CIQIdentity3_0InstanceType):
                from stix.extensions.identity import CIQIdentity3_0Instance
                return_obj.identity = CIQIdentity3_0Instance.from_obj(
                    identity_obj)
            elif isinstance(identity_obj, stix_common_binding.IdentityType):
                return_obj.identity = Identity.from_obj(identity_obj)
            else:
                raise ValueError(
                    'unable to instantiate the correct type for identity')

        return return_obj