public virtual async Task <ApiSecretDto> AddSecretAsync(ApiSecretCreateDto apiSecretCreate)
        {
            var apiResource = await ApiResourceRepository.GetAsync(apiSecretCreate.ApiResourceId);

            var apiSecretValue    = apiSecretCreate.Value;
            var apiResourceSecret = apiResource.FindSecret(apiSecretValue, apiSecretCreate.Type);

            if (apiResourceSecret == null)
            {
                if (IdentityServerConstants.SecretTypes.SharedSecret.Equals(apiSecretCreate.Type))
                {
                    if (apiSecretCreate.HashType == HashType.Sha256)
                    {
                        apiSecretValue = apiSecretCreate.Value.Sha256();
                    }
                    else if (apiSecretCreate.HashType == HashType.Sha512)
                    {
                        apiSecretValue = apiSecretCreate.Value.Sha512();
                    }
                }
                apiResource.AddSecret(apiSecretValue, apiSecretCreate.Expiration, apiSecretCreate.Type, apiSecretCreate.Description);
                apiResourceSecret = apiResource.FindSecret(apiSecretValue, apiSecretCreate.Type);
            }

            return(ObjectMapper.Map <ApiSecret, ApiSecretDto>(apiResourceSecret));
        }
Пример #2
0
 public virtual async Task <ApiSecretDto> AddSecretAsync(ApiSecretCreateDto apiSecretCreate)
 {
     return(await ApiResourceAppService.AddSecretAsync(apiSecretCreate));
 }