Esempio n. 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MixedRealityStsClient" /> class.
 /// </summary>
 /// <param name="accountId">The Mixed Reality service account identifier.</param>
 /// <param name="accountDomain">The Mixed Reality service account domain.</param>
 /// <param name="credential">The credential used to access the Mixed Reality service.</param>
 /// <param name="options">The options.</param>
 public MixedRealityStsClient(string accountId, string accountDomain, TokenCredential credential, MixedRealityStsClientOptions?options = null)
     : this(accountId, AuthenticationEndpoint.ConstructFromDomain(accountDomain), credential, options)
 {
 }
Esempio n. 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MixedRealityStsClient" /> class.
        /// </summary>
        /// <param name="accountId">The Mixed Reality service account identifier.</param>
        /// <param name="endpoint">The Mixed Reality STS service endpoint.</param>
        /// <param name="credential">The credential used to access the Mixed Reality service.</param>
        /// <param name="options">The options.</param>
        public MixedRealityStsClient(string accountId, Uri endpoint, TokenCredential credential, MixedRealityStsClientOptions?options = null)
        {
            Argument.AssertNotNull(accountId, nameof(accountId));
            Argument.AssertNotNull(endpoint, nameof(endpoint));
            Argument.AssertNotNull(credential, nameof(credential));

            options ??= new MixedRealityStsClientOptions();

            AccountId          = accountId;
            Endpoint           = endpoint;
            _clientDiagnostics = new ClientDiagnostics(options);
            _pipeline          = HttpPipelineBuilder.Build(options, new BearerTokenAuthenticationPolicy(credential, GetDefaultScope(endpoint)));
            _restClient        = new MixedRealityStsRestClient(_clientDiagnostics, _pipeline, endpoint, options.Version);
        }
Esempio n. 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MixedRealityStsClient" /> class.
 /// </summary>
 /// <param name="accountId">The Mixed Reality service account identifier.</param>
 /// <param name="endpoint">The Mixed Reality STS service endpoint.</param>
 /// <param name="keyCredential">The Mixed Reality service account primary or secondary key credential.</param>
 /// <param name="options">The options.</param>
 public MixedRealityStsClient(string accountId, Uri endpoint, AzureKeyCredential keyCredential, MixedRealityStsClientOptions?options = null)
     : this(accountId, endpoint, new MixedRealityAccountKeyCredential(accountId, keyCredential), options)
 {
 }
Esempio n. 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MixedRealityStsClient" /> class.
 /// </summary>
 /// <param name="accountId">The Mixed Reality service account identifier.</param>
 /// <param name="accountDomain">The Mixed Reality service account domain.</param>
 /// <param name="keyCredential">The Mixed Reality service account primary or secondary key credential.</param>
 /// <param name="options">The options.</param>
 public MixedRealityStsClient(string accountId, string accountDomain, AzureKeyCredential keyCredential, MixedRealityStsClientOptions?options = null)
     : this(accountId, AuthenticationEndpoint.ConstructFromDomain(accountDomain), new MixedRealityAccountKeyCredential(accountId, keyCredential), options)
 {
 }
        /// <summary>
        /// Gets a Mixed Reality credential using the specified <paramref name="credential"/>.
        /// Azure credentials are exchanged with the Mixed Reality STS service for Mixed Reality access tokens.
        /// In the case of a <see cref="StaticAccessTokenCredential"/>, the credential is assumed to be a Mixed Reality
        /// access token previously retrieved from the Mixed Reality STS service, so it is simply returned.
        /// </summary>
        /// <param name="accountId">The Mixed Reality service account identifier.</param>
        /// <param name="endpoint">The Mixed Reality STS service endpoint.</param>
        /// <param name="credential">The credential used to access the Mixed Reality service.</param>
        /// <param name="options">The options.</param>
        /// <returns><see cref="TokenCredential"/>.</returns>
        public static TokenCredential GetMixedRealityCredential(string accountId, Uri endpoint, TokenCredential credential, MixedRealityStsClientOptions?options = null)
        {
            if (credential is StaticAccessTokenCredential)
            {
                // Static access tokens are assumed to be Mixed Reality access tokens already, so we don't need to exchange
                // them using the MixedRealityTokenCredential.
                return(credential);
            }

            return(new MixedRealityTokenCredential(accountId, endpoint, credential, options));
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="MixedRealityTokenCredential" /> class.
 /// </summary>
 /// <param name="accountId">The Mixed Reality service account identifier.</param>
 /// <param name="endpoint">The Mixed Reality STS service endpoint.</param>
 /// <param name="credential">The credential used to access the Mixed Reality service.</param>
 /// <param name="options">The options.</param>
 private MixedRealityTokenCredential(string accountId, Uri endpoint, TokenCredential credential, MixedRealityStsClientOptions?options = null)
 {
     _stsClient = new MixedRealityStsClient(accountId, endpoint, credential, options);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="MixedRealityStsClient" /> class.
 /// </summary>
 /// <param name="accountId">The Mixed Reality service account identifier.</param>
 /// <param name="accountDomain">The Mixed Reality service account domain.</param>
 /// <param name="credential">The credential used to access the Mixed Reality service.</param>
 /// <param name="options">The options.</param>
 public MixedRealityStsClient(string accountId, string accountDomain, TokenCredential credential, MixedRealityStsClientOptions?options = null)
     : this(accountId, ConstructStsEndpointUrl(accountDomain), credential, options)
 {
 }