private string ToCanonicalString(DirectExecutionRequestApiModel apiModel) =>
 $"{apiModel.ExecutionId}|" +
 $"{apiModel.ExtensionId}|" +
 $"{apiModel.ExtensionVersionId}|" +
 $"{apiModel.ExecutionModelName}|" +
 $"{apiModel.ExecutionProfileName}|" +
 $"{apiModel.ObjectProviderName}|" +
 $"{apiModel.GetExecutionStatusUrl}|" +
 $"{apiModel.ExpirationDateTimeUtc.ToString("s")}";
예제 #2
0
        private async Task <DirectExecutionRequestApiModel> CreateDirectExecutionRequestAsync(IExecutionRequestContext erContext)
        {
            // Convert the API request context to a core execution request...

            var execRequest = ToExecutionRequestAsync(erContext);

            // Then, convert the core execution request into a direct execution token...

            var directExecRequest = new DirectExecutionRequestApiModel
            {
                ExecutionId           = execRequest.ExecutionId,
                ExecutionModelName    = execRequest.ExecutionModelName,
                ExecutionProfileName  = execRequest.ExecutionProfileName,
                ExecutionSettings     = execRequest.ExtensionSettings,
                ExtensionId           = execRequest.ExtensionId,
                ExtensionVersionId    = execRequest.ExtensionVersionId,
                GetExecutionStatusUrl = execRequest.GetExecutionStatusUrl,
                ObjectProviderName    = execRequest.ObjectProviderName,
                ExecutorProperties    = execRequest.ExecutorProperties,
                Services = await execServiceProvider.GetServiceConfigurationAsync(execRequest)
            };

            // Based on the selected execution profile, set the expiration date/time (how long the client can use the extension directly for)
            // and digitally sign the execution request using the hub's private key. In this model, we assume that the target execution has the hub's
            // public key and can us it to verify the authenticity of the token and all the information contained therein.
            // For more information, see /doc/architecture/direct-execution.md.

            directExecRequest.ExpirationDateTimeUtc = DateTime.UtcNow.Add(erContext.ExecutionProfile.DirectExecutionTokenDuration.Value);
            directExecRequest.Signature             = await directExecRequestSigner.GenerateSignatureAsync(execRequest.SignatureRsaKeyXml, directExecRequest);

            // Update the execution to indicate that a direct access token is being provided...

            erContext.Execution.ExecutionTimeoutDateTimeUtc = directExecRequest.ExpirationDateTimeUtc;
            erContext.Execution.Status = ExecutionStatus.DirectExecutionTokenProvided;
            erContext.Execution.LastUpdatedDateTimeUtc = DateTime.UtcNow;

            // Persist the execution and return the direct execution token...

            await UpdateExecutionAsync(erContext.Execution);

            return(directExecRequest);
        }