Пример #1
0
        public GenerateTokensInfo GenerateTokens(GenerateTokensSpec spec)
        {
            // first we will try to lookup the cache value of the prover object.
            Prover prover = null;

            if (spec.ProverInstanceID != null)
            {
                ProverInstanceData proverInstance;
                bool ok = proverInstanceDB.TryGetValue(spec.ProverInstanceID, out proverInstance);
                if (ok)
                {
                    prover = proverInstance.Prover;
                }
                else
                {
                    //XXX add log about Prover not found in cache.
                }
            }

            if (prover != null)
            {
                return(HandleGenerateTokens(prover, spec.ThirdMessage));
            }

            if (spec.SecondMessageState != null && spec.IssuerParameter != null)
            {
                prover = new Prover(spec.IssuerParameter, spec.SecondMessageState);
                proverInstanceDB.TryAdd(spec.ProverInstanceID, new ProverInstanceData(prover));
                return(HandleGenerateTokens(prover, spec.ThirdMessage));
            }

            ApiArgumentFault fault = new ApiArgumentFault();

            fault.Details       = "Prover with unique ID was found or SecondMessageState and IssuerParameter not provided.";
            fault.Argument      = "GenerateTokensSpec.ProverInstanceID/GenerateTokensSpec.SecondMessageState/GenerateTokensSpec.IssuerParameter";
            fault.ArgumentValue = spec.ProverInstanceID.ToString();
            throw new FaultException <ApiArgumentFault>(fault);
        }
    public GenerateTokensInfo GenerateTokens(GenerateTokensSpec spec)
    {
      // first we will try to lookup the cache value of the prover object.
      Prover prover = null;
      if (spec.ProverInstanceID != null)
      {
        ProverInstanceData proverInstance;
        bool ok = proverInstanceDB.TryGetValue(spec.ProverInstanceID, out proverInstance);
        if (ok)
        {
          prover = proverInstance.Prover;
        }
        else
        {
          //XXX add log about Prover not found in cache.
        }
      }

      if (prover != null)
      {
        return HandleGenerateTokens(prover, spec.ThirdMessage);
      }

      if (spec.SecondMessageState != null && spec.IssuerParameter != null)
      {
        prover = new Prover(spec.IssuerParameter, spec.SecondMessageState);
        proverInstanceDB.TryAdd(spec.ProverInstanceID, new ProverInstanceData(prover));
        return HandleGenerateTokens(prover, spec.ThirdMessage);

      }

      ApiArgumentFault fault = new ApiArgumentFault();
      fault.Details = "Prover with unique ID was found or SecondMessageState and IssuerParameter not provided.";
      fault.Argument = "GenerateTokensSpec.ProverInstanceID/GenerateTokensSpec.SecondMessageState/GenerateTokensSpec.IssuerParameter";
      fault.ArgumentValue = spec.ProverInstanceID.ToString();
      throw new FaultException<ApiArgumentFault>(fault);

    }