/
AttestationResponse.cs
52 lines (46 loc) · 2.06 KB
/
AttestationResponse.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
using System;
using System.Collections.Generic;
using System.IO;
using Azure;
using Azure.Core;
namespace Azure.Security.Attestation
{
/// <summary>
/// Represents a response from an Attestation Service API.
/// </summary>
public class AttestationResponse<T> : Response<T>
where T: class
{
private readonly AttestationToken _token;
private readonly Response _response;
private readonly T _body;
/// <summary>
/// Represents a response from the Microsoft Azure Attestation service.
/// </summary>
/// <param name="response">The underlying response object corresponding to the original request,</param>
/// <param name="underlyingToken">The attestation token returned from the attestation service.</param>
/// <param name="body">The optional value of the body of the token to be returned to the customer. If none is provided, then the body will be retrieved from the attestation token.</param>
internal AttestationResponse(Response response, AttestationToken underlyingToken, T body = default(T)) : base()
{
_response = response;
_token = underlyingToken;
_body = body;
}
/// <summary>
/// Returns the body of the response. This normally corresponds to the structure returned by the attestation
/// service.
/// </summary>
public override T Value => _body ?? _token.GetBody<T>();
/// <summary>
/// Returns the raw attestation token returned from the Microsoft Azure Attestation service.
/// </summary>
public AttestationToken Token => _token;
/// <summary>
/// Returns the underlying <see cref="Response"/> returned from the remote service.
/// </summary>
/// <returns>The response returned from the remote service. <see cref="Response{T}.GetRawResponse"/></returns>
public override Response GetRawResponse() => _response;
}
}