blob: 1ad229092876b57fae9376db06100ea04bd6f416 [file] [log] [blame]
Jan Tattermusch189fcf82015-12-02 13:41:12 -08001#region Copyright notice and license
2
Craig Tiller6169d5f2016-03-31 07:46:18 -07003// Copyright 2015, Google Inc.
Jan Tattermusch189fcf82015-12-02 13:41:12 -08004// All rights reserved.
5//
6// Redistribution and use in source and binary forms, with or without
7// modification, are permitted provided that the following conditions are
8// met:
9//
10// * Redistributions of source code must retain the above copyright
11// notice, this list of conditions and the following disclaimer.
12// * Redistributions in binary form must reproduce the above
13// copyright notice, this list of conditions and the following disclaimer
14// in the documentation and/or other materials provided with the
15// distribution.
16// * Neither the name of Google Inc. nor the names of its
17// contributors may be used to endorse or promote products derived from
18// this software without specific prior written permission.
19//
20// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
32#endregion
33
34using System;
35using System.Collections.Generic;
36using System.Threading.Tasks;
37
38using Grpc.Core.Internal;
39using Grpc.Core.Utils;
40
41namespace Grpc.Core
42{
43 /// <summary>
44 /// Asynchronous authentication interceptor for <see cref="CallCredentials"/>.
45 /// </summary>
46 /// <param name="context">The interceptor context.</param>
47 /// <param name="metadata">Metadata to populate with entries that will be added to outgoing call's headers.</param>
48 /// <returns></returns>
49 public delegate Task AsyncAuthInterceptor(AuthInterceptorContext context, Metadata metadata);
50
51 /// <summary>
52 /// Context for an RPC being intercepted by <see cref="AsyncAuthInterceptor"/>.
53 /// </summary>
54 public class AuthInterceptorContext
55 {
56 readonly string serviceUrl;
57 readonly string methodName;
58
59 /// <summary>
60 /// Initializes a new instance of <c>AuthInterceptorContext</c>.
61 /// </summary>
62 public AuthInterceptorContext(string serviceUrl, string methodName)
63 {
Jan Tattermusch7a3ee6a2016-02-18 10:36:02 -080064 this.serviceUrl = GrpcPreconditions.CheckNotNull(serviceUrl);
65 this.methodName = GrpcPreconditions.CheckNotNull(methodName);
Jan Tattermusch189fcf82015-12-02 13:41:12 -080066 }
67
68 /// <summary>
69 /// The fully qualified service URL for the RPC being called.
70 /// </summary>
71 public string ServiceUrl
72 {
73 get { return serviceUrl; }
74 }
75
76 /// <summary>
77 /// The method name of the RPC being called.
78 /// </summary>
79 public string MethodName
80 {
81 get { return methodName; }
82 }
83 }
84}