private AttestationMechanism(AttestationMechanismType type, TpmAttestation tpm, X509Attestation x509, SymmetricKeyAttestation symmetricKey) { switch (type) { case AttestationMechanismType.Tpm: if (tpm == null) { /* SRS_ATTESTATION_MECHANISM_21_013: [The constructor shall throw ProvisioningServiceClientException if the * provided AttestationMechanismType is `TPM` but the TPM attestation is null.] */ throw new ProvisioningServiceClientException("Invalid TPM attestation mechanism."); } /* SRS_ATTESTATION_MECHANISM_21_014: [If the provided AttestationMechanismType is `TPM`, the constructor * shall store the provided TPM attestation.] */ Tpm = tpm; break; case AttestationMechanismType.X509: if (x509 == null) { /* SRS_ATTESTATION_MECHANISM_21_015: [The constructor shall throw ProvisioningServiceClientException if the * provided AttestationMechanismType is `X509` but the X509 attestation is null.] */ throw new ProvisioningServiceClientException("Invalid X509 attestation mechanism."); } /* SRS_ATTESTATION_MECHANISM_21_016: [If the provided AttestationMechanismType is `X509`, the constructor * shall store the provided X509 attestation.] */ X509 = x509; break; case AttestationMechanismType.None: break; case AttestationMechanismType.SymmetricKey: // In some cases symmetric keys are nulled out by the service if (symmetricKey == null) { SymmetricKey = new SymmetricKeyAttestation(string.Empty, string.Empty); } else { SymmetricKey = symmetricKey; } break; default: /* SRS_ATTESTATION_MECHANISM_21_017: [The constructor shall throw ProvisioningServiceClientException if the * provided ProvisioningServiceClientException is not `TPM` or `X509`.] */ throw new ProvisioningServiceClientException("Unknown attestation mechanism."); } }
private AttestationMechanism(AttestationMechanismType type, TpmAttestation tpm, X509Attestation x509, SymmetricKeyAttestation symmetricKey) { switch (type) { case AttestationMechanismType.Tpm: if (tpm == null) { throw new ProvisioningServiceClientException("Invalid TPM attestation mechanism."); } Tpm = tpm; break; case AttestationMechanismType.X509: if (x509 == null) { throw new ProvisioningServiceClientException("Invalid X509 attestation mechanism."); } X509 = x509; break; case AttestationMechanismType.None: break; case AttestationMechanismType.SymmetricKey: // In some cases symmetric keys are nulled out by the service SymmetricKey = symmetricKey ?? new SymmetricKeyAttestation(string.Empty, string.Empty); break; default: throw new ProvisioningServiceClientException("Unknown attestation mechanism."); } }