/// <summary> /// Method to create the extended info for the vault. /// </summary> /// <returns>returns the object as task</returns> private ResourceExtendedInfo CreateVaultExtendedInformation() { ResourceExtendedInfo extendedInfo = new ResourceExtendedInfo(); extendedInfo.GenerateSecurityInfo(); ResourceExtendedInformationArgs extendedInfoArgs = extendedInfo.Translate(); this.CreateExtendedInfo(extendedInfoArgs); return(extendedInfo); }
/// <summary> /// Get the Integrity key /// </summary> /// <returns>key as string.</returns> private async Task <string> GetChannelIntegrityKey() { ResourceExtendedInformation extendedInformation = null; try { extendedInformation = await this.GetExtendedInfo(); } catch (Exception exception) { CloudException cloudException = exception as CloudException; if (cloudException != null && cloudException.Response != null && !string.IsNullOrEmpty(cloudException.Response.Content)) { JavaScriptSerializer serializer = new JavaScriptSerializer(); rpError.Error error = serializer.Deserialize <rpError.Error>(cloudException.Response.Content); // rpError.Error error = (rpError.Error)Utilities.Deserialize<rpError.Error>(cloudException.Response.Content); if (error.ErrorCode.Equals(RpErrorCode.ResourceExtendedInfoNotFound.ToString(), StringComparison.InvariantCultureIgnoreCase)) { extendedInformation = new ResourceExtendedInformation(); } } } ResourceExtendedInfo extendedInfo = Utilities.Deserialize <ResourceExtendedInfo>(extendedInformation.ExtendedInfo); if (extendedInfo == null) { extendedInfo = this.CreateVaultExtendedInformation(); } else { if (!extendedInfo.Algorithm.Equals(CryptoAlgorithm.None.ToString(), StringComparison.InvariantCultureIgnoreCase)) { // In case this condition is true that means the credential was first generated in portal // and hence can not be fetched here. throw new CloudException(Resources.VaultSettingsGenerationUnSupported); } } return(extendedInfo.ChannelIntegrityKey); }