Exemplo n.º 1
0
    def SaveClaim(self, claimJson):      
      claim = ClaimParser(claimJson)
      self.__logger.debug("Processing {0} claim ...".format(claim.schemaName))

      # If the claim type has not been registered, reject the claim.
      verifiableClaimType = self.__get_VerifiableClaimType(claim)
      if not verifiableClaimType:
        raise ClaimTypeNotRegisteredException()

      # Look up the organization ...
      verifiableOrg = self.__get_VerifiableOrg(claim)

      # ToDo:
      # - Don't hard code the claim types at this level.  Get things working and refactor.
      # - Create claim processors that know how to deal with given claims.
      if claim.schemaName == "incorporation.bc_registries":
        verifiableOrg = self.__CreateOrUpdateVerifiableOrg(claim, verifiableOrg)
        location = self.__CreateOrUpdateLocation(claim, verifiableOrg, None, "Headquarters")

      # All claims following the initial 'incorporation.bc_registries' claim MUST have an legal_entity_id (or'corp_num') field to relate the claim to the business.
      # If a mathcing VerifiableOrg record does not exist at this point, reject the claim.
      if not verifiableOrg:
        raise OrganizationNotRegisteredException()

      # Process the claim and store it in the wallet ...
      self.__CreateOrUpdateVerifiableClaim(claim, verifiableClaimType, verifiableOrg)
      eventloop.do(self.__StoreClaim(claim.json))

      # Process all other parsable claim types ...
      if claim.schemaName == "doing_business_as.bc_registries":
        doingBusinessAs = self.__CreateOrUpdateDoingBusinessAs(claim, verifiableOrg)
        location = self.__CreateOrUpdateLocation(claim, verifiableOrg, doingBusinessAs, "Location")

      return verifiableOrg
Exemplo n.º 2
0
    def SaveClaim(self, claimJson):      
      self.__logger.debug("Parsing claim ...")
      claimParser = ClaimParser(claimJson)      

      self.__logger.debug("Creating or updating the associated Verifiable Organization ...")
      verifiableOrg = self.__CreateOrUpdateVerifiableOrg(claimParser.claim)

      self.__logger.debug("Creating or updating the associated Verifiable Claim ...")
      self.__CreateOrUpdateVerifiableClaim(claimParser, verifiableOrg)

      self.__logger.debug("Storing the claim in the wallet ...")
      eventloop.do(self.__StoreClaim(claimParser.rawClaim))
Exemplo n.º 3
0
 def __init__(self):
     if not Agent.instance:
         Agent.instance = Agent.__Agent()
         eventloop.do(Agent.instance.start())
Exemplo n.º 4
0
 def GenerateClaimRequest(self):
     return eventloop.do(self.__GenerateRequest())
Exemplo n.º 5
0
 def ConstructProof(self):
     return eventloop.do(self.__ConstructProof())
Exemplo n.º 6
0
    def SaveClaim(self, claimJson):
        claim = ClaimParser(claimJson)
        print(claimJson)
        self.__logger.debug(">>> Processing {0} claim ...\n{1}".format(
            claim.schemaName, claimJson))
        start_time = time.time()

        # If the claim type has not been registered, reject the claim.
        verifiableClaimType = self.__get_VerifiableClaimType(claim)
        if not verifiableClaimType:
            raise ClaimTypeNotRegisteredException()

        # Look up the organization ...
        verifiableOrg = self.__get_VerifiableOrg(claim)
        elapsed_time = time.time() - start_time
        self.__logger.debug('Claim elapsed time 1 >>> {}'.format(elapsed_time))
        start_time = time.time()

        # ToDo:
        # - Don't hard code the claim types at this level.  Get things working and refactor.
        # - Create claim processors that know how to deal with given claims.
        if "incorporation" in claim.schemaName:
            verifiableOrg = self.__CreateOrUpdateVerifiableOrg(
                claim, verifiableOrg)
            location = self.__CreateOrUpdateLocation(claim, verifiableOrg,
                                                     None, "Headquarters")
        elapsed_time = time.time() - start_time
        self.__logger.debug('Claim elapsed time 2 >>> {}'.format(elapsed_time))
        start_time = time.time()

        #todo extra code added for testing, to be removed, line 298 shd get this value
        verifiableOrg = self.__CreateOrUpdateVerifiableOrg(
            claim, verifiableOrg)

        # All claims following the initial 'incorporation.bc_registries' claim MUST have an legal_entity_id (or'corp_num') field to relate the claim to the business.
        # If a mathcing VerifiableOrg record does not exist at this point, reject the claim.
        if not verifiableOrg:
            raise OrganizationNotRegisteredException()

        # Process the claim and store it in the wallet ...
        self.__CreateOrUpdateVerifiableClaim(claim, verifiableClaimType,
                                             verifiableOrg)
        elapsed_time = time.time() - start_time
        self.__logger.debug('Claim elapsed time 3 >>> {}'.format(elapsed_time))
        start_time = time.time()

        eventloop.do(self.__StoreClaim(claim.json))
        elapsed_time = time.time() - start_time
        self.__logger.debug('Claim elapsed time 4 >>> {}'.format(elapsed_time))
        start_time = time.time()

        self.__logger.debug(
            "---------------------------------------before NEW code----------------------------"
        )
        # Process all other parsable claim types ...
        if claim.schemaName == "doing_business_as.onbis":
            doingBusinessAs = self.__CreateOrUpdateDoingBusinessAs(
                claim, verifiableOrg)
            location = self.__CreateOrUpdateLocation(claim, verifiableOrg,
                                                     doingBusinessAs,
                                                     "Location")
        elapsed_time = time.time() - start_time
        self.__logger.debug('Claim elapsed time 5 >>> {}'.format(elapsed_time))

        # Process all other parsable claim types ...
        if claim.schemaName == "doing_business_as.bc_registries":
            doingBusinessAs = self.__CreateOrUpdateDoingBusinessAs(
                claim, verifiableOrg)
            location = self.__CreateOrUpdateLocation(claim, verifiableOrg,
                                                     doingBusinessAs,
                                                     "Location")
        elapsed_time = time.time() - start_time
        self.__logger.debug('Claim elapsed time 5 >>> {}'.format(elapsed_time))

        self.__logger.debug("<<< Processing {0} claim.")
        return verifiableOrg