def get_result(self, request: Request):
     self._validate_request_type(request)
     identifier, req_id, operation = get_request_data(request)
     if not validate_attrib_keys(operation):
         raise InvalidClientRequest(identifier, req_id,
                                    '{} should have one and only one of '
                                    '{}, {}, {}'
                                    .format(ATTRIB, RAW, ENC, HASH))
     nym = operation[TARGET_NYM]
     if RAW in operation:
         attr_type = RAW
     elif ENC in operation:
         # If attribute is encrypted, it will be queried by its hash
         attr_type = ENC
     else:
         attr_type = HASH
     attr_key = operation[attr_type]
     value, last_seq_no, last_update_time, proof = \
         self.get_attr(did=nym, key=attr_key, attr_type=attr_type)
     attr = None
     if value is not None:
         if HASH in operation:
             attr = attr_key
         else:
             attr = value
     return self.make_result(request=request,
                             data=attr,
                             last_seq_no=last_seq_no,
                             update_time=last_update_time,
                             proof=proof)
Beispiel #2
0
    def static_validation(self, request: Request):
        self._validate_request_type(request)
        identifier, req_id, operation = get_request_data(request)

        if not validate_attrib_keys(operation):
            raise InvalidClientRequest(
                identifier, req_id, '{} should have one and only one of '
                '{}, {}, {}'.format(ATTRIB, RAW, ENC, HASH))
Beispiel #3
0
    def static_validation(self, request: Request):
        self._validate_request_type(request)
        identifier, req_id, operation = get_request_data(request)

        if not validate_attrib_keys(operation):
            raise InvalidClientRequest(identifier, req_id,
                                       '{} should have one and only one of '
                                       '{}, {}, {}'
                                       .format(ATTRIB, RAW, ENC, HASH))

        if RAW in operation:
            try:
                get_key = attrib_raw_data_serializer.deserialize(operation[RAW])
                if len(get_key) == 0:
                    raise InvalidClientRequest(identifier, request.reqId,
                                               '"row" attribute field must contain non-empty dict'.
                                               format(TARGET_NYM))
            except JSONDecodeError:
                raise InvalidClientRequest(identifier, request.reqId,
                                           'Attribute field must be dict while adding it as a row field'.
                                           format(TARGET_NYM))