/// <summary> /// Initializes a new instance of the <see cref="ASRVaultCreds"/> class. /// </summary> /// <param name="subscriptionId">subscription Id</param> /// <param name="resourceName">resource name</param> /// <param name="managementCert">management cert</param> /// <param name="acsNamespace">authenticating service namespace</param> /// <param name="channelIntegrityKey">Agent Channel Integrity Key</param> /// <param name="resourceGroupName">cloud service name</param> /// <param name="siteId">custom site Id</param> /// <param name="siteName">custom site name</param> public ASRVaultCreds( string subscriptionId, string resourceName, string managementCert, AcsNamespace acsNamespace, string channelIntegrityKey, string resourceGroupName, string siteId, string siteName, string resourceNamespace, string resourceType, string location) : base(subscriptionId, resourceName, managementCert, acsNamespace) { this.ChannelIntegrityKey = channelIntegrityKey; this.ResourceGroupName = resourceGroupName; //this.Version = Constants.VaultCredentialVersion; this.SiteId = siteId != null ? siteId : string.Empty; this.SiteName = siteName != null ? siteName : string.Empty; this.ResourceNamespace = resourceNamespace; this.ARMResourceType = resourceType; this.Location = location; }
/// <summary> /// Initializes a new instance of the <see cref="VaultCreds" /> class. /// </summary> /// <param name="subscriptionId">subscription Id</param> /// <param name="resourceName">resource name</param> /// <param name="managementCert">management cert</param> /// <param name="acsNamespace">authenticating service namespace</param> public VaultCreds( string subscriptionId, string resourceName, string managementCert, AcsNamespace acsNamespace) { this.SubscriptionId = subscriptionId; this.ResourceType = Constants.ASRVaultType; this.ResourceName = resourceName; this.ManagementCert = managementCert; this.AcsNamespace = acsNamespace; }
/// <summary> /// Initializes a new instance of the <see cref="ASRVaultCreds"/> class. /// </summary> /// <param name="subscriptionId">subscription Id</param> /// <param name="resourceName">resource name</param> /// <param name="managementCert">management cert</param> /// <param name="acsNamespace">authenticating service namespace</param> /// <param name="channelIntegrityKey">Agent Channel Integrity Key</param> /// <param name="cloudServiceName">cloud service name</param> /// <param name="siteId">custom site Id</param> /// <param name="siteName">custom site name</param> public ASRVaultCreds( string subscriptionId, string resourceName, string managementCert, AcsNamespace acsNamespace, string channelIntegrityKey, string cloudServiceName) : base(subscriptionId, resourceName, managementCert, acsNamespace) { this.ChannelIntegrityKey = channelIntegrityKey; this.ResourceGroupName = cloudServiceName; this.Version = Constants.VaultCredentialVersion; }
/// <summary> /// Initializes a new instance of the <see cref="ASRVaultCreds"/> class. /// </summary> /// <param name="subscriptionId">subscription Id</param> /// <param name="resourceName">resource name</param> /// <param name="managementCert">management cert</param> /// <param name="acsNamespace">authenticating service namespace</param> /// <param name="channelIntegrityKey">Agent Channel Integrity Key</param> /// <param name="cloudServiceName">cloud service name</param> /// <param name="siteId">custom site Id</param> /// <param name="siteName">custom site name</param> public ASRVaultCreds( string subscriptionId, string resourceName, string managementCert, AcsNamespace acsNamespace, string channelIntegrityKey, string cloudServiceName, string siteId, string siteName) : base(subscriptionId, resourceName, managementCert, acsNamespace) { this.ChannelIntegrityKey = channelIntegrityKey; this.CloudServiceName = cloudServiceName; this.Version = Constants.VaultCredentialVersion; this.SiteId = siteId != null ? siteId : string.Empty; this.SiteName = siteName != null ? siteName : string.Empty; }
/// <summary> /// Initializes a new instance of the <see cref="VaultCreds"/> class. /// </summary> /// <param name="subscriptionId">subscription Id</param> /// <param name="resourceName">resource name</param> /// <param name="managementCert">management cert</param> /// <param name="acsNamespace">authenticating service namespace</param> public VaultCreds(string subscriptionId, string resourceName, string managementCert, AcsNamespace acsNamespace) { this.SubscriptionId = subscriptionId; this.ResourceType = Constants.ASRVaultType; this.ResourceName = resourceName; this.ManagementCert = managementCert; this.AcsNamespace = acsNamespace; }
/// <summary> /// Initializes a new instance of the <see cref="VaultCreds"/> class. /// </summary> /// <param name="subscriptionId">subscription Id</param> /// <param name="resourceName">resource name</param> /// <param name="managementCert">management cert</param> /// <param name="acsNamespace">authenticating service namespace</param> /// <param name="resourceType">resource type backup vault or ASR vault</param> public VaultCreds(string subscriptionId, string resourceName, string managementCert, AcsNamespace acsNamespace, string resourceType = null) { this.SubscriptionId = subscriptionId; //this.ResourceType = string.IsNullOrEmpty(resourceType) ? Constants.VaultType : resourceType; this.ResourceName = resourceName; this.ManagementCert = managementCert; this.AcsNamespace = acsNamespace; }
/// <summary> /// Initializes a new instance of the <see cref="VaultCreds"/> class. /// </summary> /// <param name="subscriptionId">subscription Id</param> /// <param name="resourceName">resource name</param> /// <param name="managementCert">management cert</param> /// <param name="acsNamespace">authenticating service namespace</param> /// <param name="resourceType">resource type backup vault or ASR vault</param> public VaultCreds(string subscriptionId, string resourceName, string managementCert, AcsNamespace acsNamespace, string resourceType = null) { this.SubscriptionId = subscriptionId; this.ResourceType = string.IsNullOrEmpty(resourceType) ? Constants.VaultType : resourceType; this.ResourceName = resourceName; this.ManagementCert = managementCert; this.AcsNamespace = acsNamespace; }
/// <summary> /// Initializes a new instance of the BackupVaultCreds class /// </summary> /// <param name="subscriptionId">subscription Id</param> /// <param name="resourceType">resource type</param> /// <param name="resourceName">resource name</param> /// <param name="managementCert">management cert</param> /// <param name="acsNamespace">acs namespace</param> /// <param name="agentLinks">agent links</param> public BackupVaultCreds(string subscriptionId, string resourceName, string managementCert, AcsNamespace acsNamespace, string agentLinks) : this(subscriptionId, resourceName, managementCert, acsNamespace) { AgentLinks = agentLinks; }
/// <summary> /// Initializes a new instance of the BackupVaultCreds class /// </summary> /// <param name="subscriptionId">subscription Id</param> /// <param name="resourceType">resource type</param> /// <param name="resourceName">resource name</param> /// <param name="managementCert">management cert</param> /// <param name="acsNamespace">acs namespace</param> public BackupVaultCreds(string subscriptionId, string resourceName, string managementCert, AcsNamespace acsNamespace) : base(subscriptionId, resourceName, managementCert, acsNamespace, Constants.BackupVaultType) { }
/// <summary> /// Initializes a new instance of the <see cref="ASRVaultCreds"/> class. /// </summary> /// <param name="subscriptionId">subscription Id</param> /// <param name="resourceName">resource name</param> /// <param name="managementCert">management cert</param> /// <param name="acsNamespace">authenticating service namespace</param> /// <param name="channelIntegrityKey">Agent Channel Integrity Key</param> /// <param name="resourceGroupName">cloud service name</param> /// <param name="siteId">custom site Id</param> /// <param name="siteName">custom site name</param> public ASRVaultCreds( string subscriptionId, string resourceName, string managementCert, AcsNamespace acsNamespace, string channelIntegrityKey, string resourceGroupName, string siteId, string siteName, string resourceNamespace, string resourceType, string location) : base(subscriptionId, resourceName, managementCert, acsNamespace) { this.ChannelIntegrityKey = channelIntegrityKey; this.ResourceGroupName = resourceGroupName; this.Version = Constants.VaultCredentialVersion; this.SiteId = siteId != null ? siteId : string.Empty; this.SiteName = siteName != null ? siteName : string.Empty; this.ResourceNamespace = resourceNamespace; this.ARMResourceType = resourceType; this.Location = location; }
/// <summary> /// Generates vault creds file /// </summary> /// <param name="cert">management certificate</param> /// <param name="subscriptionId">subscription Id</param> /// <param name="acsNamespace">acs namespace</param> /// <returns>xml file in string format</returns> private string GenerateVaultCreds(X509Certificate2 cert, string subscriptionId, AcsNamespace acsNamespace) { try { return GenerateVaultCredsForBackup(cert, subscriptionId, acsNamespace); } catch (Exception exception) { throw exception; } }
/// <summary> /// Method to generate the credential file content /// </summary> /// <param name="managementCert">management cert</param> /// <param name="acsDetails">ACS details</param> /// <param name="channelIntegrityKey">Integrity key</param> /// <param name="vault">vault object</param> /// <param name="site">site object</param> /// <returns>vault credential object</returns> private ASRVaultCreds GenerateCredentialObject(X509Certificate2 managementCert, UploadCertificateResponse acsDetails, string channelIntegrityKey, ARSVault vault, ASRSite site) { string serializedCertifivate = Convert.ToBase64String(managementCert.Export(X509ContentType.Pfx)); AcsNamespace acsNamespace = new AcsNamespace(acsDetails); string resourceProviderNamespace = string.Empty; string resourceType = string.Empty; Utilities.GetResourceProviderNamespaceAndType(vault.ID, out resourceProviderNamespace, out resourceType); ASRVaultCreds vaultCreds = new ASRVaultCreds( vault.SubscriptionId, vault.Name, serializedCertifivate, acsNamespace, channelIntegrityKey, vault.ResourceGroupName, site.ID, site.Name, resourceProviderNamespace, resourceType, vault.Location); return vaultCreds; }
/// <summary> /// Generates vault creds file content for backup Vault /// </summary> /// <param name="cert">management certificate</param> /// <param name="subscriptionId">subscription Id</param> /// <param name="acsNamespace">acs namespace</param> /// <returns>xml file in string format</returns> private string GenerateVaultCredsForBackup(X509Certificate2 cert, string subscriptionId, AcsNamespace acsNamespace) { using (var output = new MemoryStream()) { using (var writer = XmlWriter.Create(output, GetXmlWriterSettings())) { BackupVaultCreds backupVaultCreds = new BackupVaultCreds(subscriptionId, this.Vault.Name, CertUtils.SerializeCert(cert, X509ContentType.Pfx), acsNamespace, GetAgentLinks()); DataContractSerializer serializer = new DataContractSerializer(typeof(BackupVaultCreds)); serializer.WriteObject(writer, backupVaultCreds); WriteDebug(string.Format(CultureInfo.InvariantCulture, Resources.BackupVaultSerialized)); } return Encoding.UTF8.GetString(output.ToArray()); } }
/// <summary> /// Method to generate the credential file content /// </summary> /// <param name="managementCert">management cert</param> /// <param name="acsDetails">ACS details</param> /// <param name="channelIntegrityKey">Integrity key</param> /// <param name="vault">vault object</param> /// <param name="site">site object</param> /// <returns>vault credential object</returns> private ASRVaultCreds GenerateCredentialObject(X509Certificate2 managementCert, UploadCertificateResponse acsDetails, string channelIntegrityKey, ASRVault vault) { string serializedCertifivate = Convert.ToBase64String(managementCert.Export(X509ContentType.Pfx)); AcsNamespace acsNamespace = new AcsNamespace(acsDetails); ASRVaultCreds vaultCreds = new ASRVaultCreds( vault.SubscriptionId, vault.Name, serializedCertifivate, acsNamespace, channelIntegrityKey, vault.ResouceGroupName); return vaultCreds; }