Jan Tattermusch | 189fcf8 | 2015-12-02 13:41:12 -0800 | [diff] [blame] | 1 | #region Copyright notice and license |
| 2 | |
Craig Tiller | 6169d5f | 2016-03-31 07:46:18 -0700 | [diff] [blame] | 3 | // Copyright 2015, Google Inc. |
Jan Tattermusch | 189fcf8 | 2015-12-02 13:41:12 -0800 | [diff] [blame] | 4 | // 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 | |
| 34 | using System; |
| 35 | using System.Collections.Generic; |
| 36 | using System.Threading.Tasks; |
| 37 | |
| 38 | using Grpc.Core.Internal; |
| 39 | using Grpc.Core.Utils; |
| 40 | |
| 41 | namespace 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 Tattermusch | 7a3ee6a | 2016-02-18 10:36:02 -0800 | [diff] [blame] | 64 | this.serviceUrl = GrpcPreconditions.CheckNotNull(serviceUrl); |
| 65 | this.methodName = GrpcPreconditions.CheckNotNull(methodName); |
Jan Tattermusch | 189fcf8 | 2015-12-02 13:41:12 -0800 | [diff] [blame] | 66 | } |
| 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 | } |