Jan Tattermusch | 189fcf8 | 2015-12-02 13:41:12 -0800 | [diff] [blame] | 1 | #region Copyright notice and license |
| 2 | |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 3 | // Copyright 2015 gRPC authors. |
Jan Tattermusch | 189fcf8 | 2015-12-02 13:41:12 -0800 | [diff] [blame] | 4 | // |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 5 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | // you may not use this file except in compliance with the License. |
| 7 | // You may obtain a copy of the License at |
Jan Tattermusch | 189fcf8 | 2015-12-02 13:41:12 -0800 | [diff] [blame] | 8 | // |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 9 | // http://www.apache.org/licenses/LICENSE-2.0 |
Jan Tattermusch | 189fcf8 | 2015-12-02 13:41:12 -0800 | [diff] [blame] | 10 | // |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 11 | // Unless required by applicable law or agreed to in writing, software |
| 12 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | // See the License for the specific language governing permissions and |
| 15 | // limitations under the License. |
Jan Tattermusch | 189fcf8 | 2015-12-02 13:41:12 -0800 | [diff] [blame] | 16 | |
| 17 | #endregion |
| 18 | |
| 19 | using System; |
| 20 | using System.Collections.Generic; |
| 21 | using System.Threading.Tasks; |
| 22 | |
| 23 | using Grpc.Core.Internal; |
| 24 | using Grpc.Core.Utils; |
| 25 | |
| 26 | namespace Grpc.Core |
| 27 | { |
| 28 | /// <summary> |
| 29 | /// Asynchronous authentication interceptor for <see cref="CallCredentials"/>. |
| 30 | /// </summary> |
| 31 | /// <param name="context">The interceptor context.</param> |
| 32 | /// <param name="metadata">Metadata to populate with entries that will be added to outgoing call's headers.</param> |
| 33 | /// <returns></returns> |
| 34 | public delegate Task AsyncAuthInterceptor(AuthInterceptorContext context, Metadata metadata); |
| 35 | |
| 36 | /// <summary> |
| 37 | /// Context for an RPC being intercepted by <see cref="AsyncAuthInterceptor"/>. |
| 38 | /// </summary> |
| 39 | public class AuthInterceptorContext |
| 40 | { |
| 41 | readonly string serviceUrl; |
| 42 | readonly string methodName; |
| 43 | |
| 44 | /// <summary> |
| 45 | /// Initializes a new instance of <c>AuthInterceptorContext</c>. |
| 46 | /// </summary> |
| 47 | public AuthInterceptorContext(string serviceUrl, string methodName) |
| 48 | { |
Jan Tattermusch | 7a3ee6a | 2016-02-18 10:36:02 -0800 | [diff] [blame] | 49 | this.serviceUrl = GrpcPreconditions.CheckNotNull(serviceUrl); |
| 50 | this.methodName = GrpcPreconditions.CheckNotNull(methodName); |
Jan Tattermusch | 189fcf8 | 2015-12-02 13:41:12 -0800 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | /// <summary> |
| 54 | /// The fully qualified service URL for the RPC being called. |
| 55 | /// </summary> |
| 56 | public string ServiceUrl |
| 57 | { |
| 58 | get { return serviceUrl; } |
| 59 | } |
| 60 | |
| 61 | /// <summary> |
| 62 | /// The method name of the RPC being called. |
| 63 | /// </summary> |
| 64 | public string MethodName |
| 65 | { |
| 66 | get { return methodName; } |
| 67 | } |
| 68 | } |
| 69 | } |