def __init__(self, identifier: Identifier, endorser: Identifier = None, verkey=None, role=None, last_synced=None, seq_no=None): """ :param identifier: :param endorser: :param verkey: :param role: If role is explicitly passed as `null` then in the request to ledger, `role` key would be sent as None which would stop the Identity's ability to do any privileged actions. If role is not passed, `role` key will not be included in the request to the ledger :param last_synced: :param seq_no: """ self.identity = DidIdentity(identifier, verkey=verkey) self.endorser = endorser # if role and role not in (ENDORSER, STEWARD): if not Authoriser.isValidRole(self.correctRole(role)): raise AttributeError("Invalid role {}".format(role)) self._role = role # timestamp for when the ledger was last checked for key replacement or # revocation self.last_synced = last_synced # sequence number of the latest key management transaction for this # identifier self.seqNo = seq_no
def __init__(self, identifier: Identifier, trust_anchor: Identifier=None, verkey=None, role=None, last_synced=None, seq_no=None): """ :param identifier: :param trust_anchor: :param verkey: :param role: If role is explicitly passed as `null` then in the request to ledger, `role` key would be sent as None which would stop the Identity's ability to do any privileged actions. If role is not passed, `role` key will not be included in the request to the ledger :param last_synced: :param seq_no: """ self.identity = DidIdentity(identifier, verkey=verkey) self.trustAnchor = trust_anchor # if role and role not in (TRUST_ANCHOR, STEWARD): if not Authoriser.isValidRole(self.correctRole(role)): raise AttributeError("Invalid role {}".format(role)) self._role = role # timestamp for when the ledger was last checked for key replacement or # revocation self.last_synced = last_synced # sequence number of the latest key management transaction for this # identifier self.seqNo = seq_no
def _doStaticValidationNym(self, identifier, reqId, operation): role = operation.get(ROLE) nym = operation.get(TARGET_NYM) if not nym: raise InvalidClientRequest( identifier, reqId, "{} needs to be present".format(TARGET_NYM)) if not Authoriser.isValidRole(role): raise InvalidClientRequest(identifier, reqId, "{} not a valid role".format(role))
def _doStaticValidationNym(self, identifier, reqId, operation): role = operation.get(ROLE) nym = operation.get(TARGET_NYM) if not nym: raise InvalidClientRequest(identifier, reqId, "{} needs to be present". format(TARGET_NYM)) if not Authoriser.isValidRole(role): raise InvalidClientRequest(identifier, reqId, "{} not a valid role". format(role))
def _doStaticValidationNym(self, identifier, reqId, operation): role = operation.get(ROLE) nym = operation.get(TARGET_NYM) if not nym: raise InvalidClientRequest( identifier, reqId, "{} needs to be present".format(TARGET_NYM)) if not Authoriser.isValidRole(role): raise InvalidClientRequest(identifier, reqId, "{} not a valid role".format(role)) # TODO: This is not static validation as it involves state s, reason = self.canNymRequestBeProcessed(identifier, operation) if not s: raise InvalidClientRequest(identifier, reqId, reason)
def static_validation(self, request: Request): self._validate_request_type(request) identifier, req_id, operation = get_request_data(request) role = operation.get(ROLE) nym = operation.get(TARGET_NYM) if isinstance(nym, str): nym = nym.strip() if not nym: raise InvalidClientRequest( identifier, req_id, "{} needs to be present".format(TARGET_NYM)) if not Authoriser.isValidRole(role): raise InvalidClientRequest(identifier, req_id, "{} not a valid role".format(role))
def role(self, role): if not Authoriser.isValidRole(self.correctRole(role)): raise AttributeError("Invalid role {}".format(role)) self._role = role