{"action":"created","comment":{"url":"https://api.github.com/repos/dotnet/corefx/pulls/comments/54489390","id":54489390,"diff_hunk":"@@ -0,0 +1,286 @@\n+// Licensed to the .NET Foundation under one or more agreements.\n+// The .NET Foundation licenses this file to you under the MIT license.\n+// See the LICENSE file in the project root for more information.\n+\n+using System.IO;\n+using System.Security;\n+using System.Security.Principal;\n+using System.Threading;\n+using System.ComponentModel;\n+using System.Diagnostics;\n+using System.Runtime.InteropServices;\n+using System.Security.Authentication;\n+using System.Security.Authentication.ExtendedProtection;\n+using Microsoft.Win32.SafeHandles;\n+\n+namespace System.Net.Security\n+{\n+    //\n+    // The class maintains the state of the authentication process and the security context.\n+    // It encapsulates security context and does the real work in authentication and\n+    // user data encryption with NEGO SSPI package.\n+    //\n+    internal static class NegotiateStreamPal\n+    {\n+        // value should match the Windows sspicli NTE_FAIL value\n+        // defined in winerror.h\n+        private const int NTE_FAIL = unchecked((int)0x80090020);\n+\n+        internal static IIdentity GetIdentity(NTAuthentication context)\n+        {\n+            Debug.Assert(!context.IsServer, \"GetIdentity: Server is not supported\");\n+\n+            string name = context.Spn;\n+            string protocol = context.ProtocolName;\n+\n+            return new GenericIdentity(name, protocol);\n+\n+        }\n+\n+        internal static string QueryContextAssociatedName(SafeDeleteContext securityContext)\n+        {\n+            throw new PlatformNotSupportedException();\n+        }\n+\n+        internal static string QueryContextAuthenticationPackage(SafeDeleteContext securityContext)\n+        {\n+            return NegotiationInfoClass.Kerberos;\n+        }\n+\n+        internal static int QueryMaxTokenSize(string package)\n+        {\n+            // This value is not used on Unix\n+            return 0;\n+        }\n+\n+        internal static string QueryContextClientSpecifiedSpn(SafeDeleteContext securityContext)\n+        {\n+            throw new PlatformNotSupportedException();\n+        }\n+\n+        internal static SafeFreeCredentials AcquireDefaultCredential(string package, bool isServer)\n+        {\n+            return AcquireCredentialsHandle(package, isServer, new NetworkCredential(string.Empty, string.Empty, string.Empty));\n+        }\n+\n+        internal static SafeFreeCredentials AcquireCredentialsHandle(string package, bool isServer, NetworkCredential credential)\n+        {\n+            if (isServer)\n+            {\n+                throw new PlatformNotSupportedException(SR.net_nego_server_not_supported);\n+            }\n+\n+            bool isNtlm = string.Equals(package, NegotiationInfoClass.NTLM);\n+\n+            if (isNtlm)\n+            {\n+                throw new PlatformNotSupportedException(SR.net_nego_ntlm_not_supported);\n+            }\n+\n+            // Note: In client case, equivalent of default credentials is to use previous, cached Kerberos TGT to get service-specific ticket.\n+            return (string.IsNullOrEmpty(credential.UserName) || string.IsNullOrEmpty(credential.Password)) ?\n+                new SafeFreeNegoCredentials(string.Empty, string.Empty, string.Empty) :\n+                new SafeFreeNegoCredentials(credential.UserName, credential.Password, credential.Domain);\n+        }\n+\n+        internal static SecurityStatusPal InitializeSecurityContext(\n+            SafeFreeCredentials credentialsHandle,\n+            ref SafeDeleteContext securityContext,\n+            string spn,\n+            ContextFlagsPal requestedContextFlags,\n+            SecurityBuffer[] inSecurityBufferArray,\n+            SecurityBuffer outSecurityBuffer,\n+            ref ContextFlagsPal contextFlags)\n+        {\n+            // TODO (Issue #3718): The second buffer can contain a channel binding which is not supported\n+            if ((null != inSecurityBufferArray) && (inSecurityBufferArray.Length > 1))\n+            {\n+                throw new PlatformNotSupportedException(SR.net_nego_channel_binding_not_supported);\n+            }\n+\n+            return EstablishSecurityContext(\n+                (SafeFreeNegoCredentials)credentialsHandle,\n+                ref securityContext,\n+                false,\n+                spn,\n+                requestedContextFlags,\n+                ((inSecurityBufferArray != null && inSecurityBufferArray.Length != 0) ? inSecurityBufferArray[0] : null),\n+                outSecurityBuffer,\n+                ref contextFlags);\n+        }\n+\n+        internal static SecurityStatusPal CompleteAuthToken(\n+            ref SafeDeleteContext securityContext,\n+            SecurityBuffer[] inSecurityBufferArray)\n+        {\n+            return SecurityStatusPal.OK;\n+        }\n+\n+        internal static SecurityStatusPal AcceptSecurityContext(\n+            SafeFreeCredentials credentialsHandle,\n+            ref SafeDeleteContext securityContext,\n+            ContextFlagsPal requestedContextFlags,\n+            SecurityBuffer[] inSecurityBufferArray,\n+            SecurityBuffer outSecurityBuffer,\n+            ref ContextFlagsPal contextFlags)\n+        {\n+            throw new PlatformNotSupportedException();\n+        }\n+\n+        internal static void ValidateImpersonationLevel(TokenImpersonationLevel impersonationLevel)\n+        {\n+            if (impersonationLevel != TokenImpersonationLevel.Identification)\n+            {\n+                throw new ArgumentOutOfRangeException(\"impersonationLevel\", impersonationLevel.ToString(),\n+                    SR.net_auth_supported_impl_levels);\n+            }\n+\n+        }","path":"src/System.Net.Security/src/System/Net/NegotiateStreamPal.Unix.cs","position":138,"original_position":138,"commit_id":"0b656f1456884f8e30aa2bfd084f0f761f012103","original_commit_id":"0b656f1456884f8e30aa2bfd084f0f761f012103","user":{"login":"bartonjs","id":10642668,"avatar_url":"https://avatars.githubusercontent.com/u/10642668?v=3","gravatar_id":"","url":"https://api.github.com/users/bartonjs","html_url":"https://github.com/bartonjs","followers_url":"https://api.github.com/users/bartonjs/followers","following_url":"https://api.github.com/users/bartonjs/following{/other_user}","gists_url":"https://api.github.com/users/bartonjs/gists{/gist_id}","starred_url":"https://api.github.com/users/bartonjs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bartonjs/subscriptions","organizations_url":"https://api.github.com/users/bartonjs/orgs","repos_url":"https://api.github.com/users/bartonjs/repos","events_url":"https://api.github.com/users/bartonjs/events{/privacy}","received_events_url":"https://api.github.com/users/bartonjs/received_events","type":"User","site_admin":false},"body":"NIt: Extra blank line in closing brace sequence.","created_at":"2016-02-29T22:23:03Z","updated_at":"2016-02-29T22:23:03Z","html_url":"https://github.com/dotnet/corefx/pull/6469#discussion_r54489390","pull_request_url":"https://api.github.com/repos/dotnet/corefx/pulls/6469","_links":{"self":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/comments/54489390"},"html":{"href":"https://github.com/dotnet/corefx/pull/6469#discussion_r54489390"},"pull_request":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/6469"}}},"pull_request":{"url":"https://api.github.com/repos/dotnet/corefx/pulls/6469","id":60885522,"html_url":"https://github.com/dotnet/corefx/pull/6469","diff_url":"https://github.com/dotnet/corefx/pull/6469.diff","patch_url":"https://github.com/dotnet/corefx/pull/6469.patch","issue_url":"https://api.github.com/repos/dotnet/corefx/issues/6469","number":6469,"state":"open","locked":false,"title":"Enable NegotiateStream For Unix","user":{"login":"kapilash","id":113322,"avatar_url":"https://avatars.githubusercontent.com/u/113322?v=3","gravatar_id":"","url":"https://api.github.com/users/kapilash","html_url":"https://github.com/kapilash","followers_url":"https://api.github.com/users/kapilash/followers","following_url":"https://api.github.com/users/kapilash/following{/other_user}","gists_url":"https://api.github.com/users/kapilash/gists{/gist_id}","starred_url":"https://api.github.com/users/kapilash/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kapilash/subscriptions","organizations_url":"https://api.github.com/users/kapilash/orgs","repos_url":"https://api.github.com/users/kapilash/repos","events_url":"https://api.github.com/users/kapilash/events{/privacy}","received_events_url":"https://api.github.com/users/kapilash/received_events","type":"User","site_admin":false},"body":"\r\n# Problem\r\n\r\nEnabling ```System.Net.Security.NegotiateStream```  for Unix.\r\n\r\n# Solution\r\n\r\nThis PR introduces the implementation of ```NegotiateStream``` based on native implementations of [gssapi] (https://tools.ietf.org/html/rfc2743)\r\n\r\nThe native implementations used are mit-krb5 on linux and the built-in GSS.Framework for OSX.\r\n\r\nAlso included are scripts to configure and deploy KDC on the host machine so as to run the associated tests.\r\n\r\ncc: @stephentoub @bartonjs @CIPop @davidsh @vijaykota  @shrutigarg \r\n","created_at":"2016-02-26T18:48:15Z","updated_at":"2016-02-29T22:23:03Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9afad6de9a065296df5fcd08609a3f10d806a29f","assignee":null,"milestone":{"url":"https://api.github.com/repos/dotnet/corefx/milestones/4","html_url":"https://github.com/dotnet/corefx/milestones/1.0.0-rtm","labels_url":"https://api.github.com/repos/dotnet/corefx/milestones/4/labels","id":1248719,"number":4,"title":"1.0.0-rtm","description":"Q1 2016 (https://github.com/aspnet/Home/wiki/Roadmap)","creator":{"login":"joshfree","id":1302850,"avatar_url":"https://avatars.githubusercontent.com/u/1302850?v=3","gravatar_id":"","url":"https://api.github.com/users/joshfree","html_url":"https://github.com/joshfree","followers_url":"https://api.github.com/users/joshfree/followers","following_url":"https://api.github.com/users/joshfree/following{/other_user}","gists_url":"https://api.github.com/users/joshfree/gists{/gist_id}","starred_url":"https://api.github.com/users/joshfree/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joshfree/subscriptions","organizations_url":"https://api.github.com/users/joshfree/orgs","repos_url":"https://api.github.com/users/joshfree/repos","events_url":"https://api.github.com/users/joshfree/events{/privacy}","received_events_url":"https://api.github.com/users/joshfree/received_events","type":"User","site_admin":false},"open_issues":322,"closed_issues":320,"state":"open","created_at":"2015-08-10T18:04:00Z","updated_at":"2016-02-29T19:57:06Z","due_on":"2016-03-31T07:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/dotnet/corefx/pulls/6469/commits","review_comments_url":"https://api.github.com/repos/dotnet/corefx/pulls/6469/comments","review_comment_url":"https://api.github.com/repos/dotnet/corefx/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dotnet/corefx/issues/6469/comments","statuses_url":"https://api.github.com/repos/dotnet/corefx/statuses/0b656f1456884f8e30aa2bfd084f0f761f012103","head":{"label":"kapilash:negotiatestream","ref":"negotiatestream","sha":"0b656f1456884f8e30aa2bfd084f0f761f012103","user":{"login":"kapilash","id":113322,"avatar_url":"https://avatars.githubusercontent.com/u/113322?v=3","gravatar_id":"","url":"https://api.github.com/users/kapilash","html_url":"https://github.com/kapilash","followers_url":"https://api.github.com/users/kapilash/followers","following_url":"https://api.github.com/users/kapilash/following{/other_user}","gists_url":"https://api.github.com/users/kapilash/gists{/gist_id}","starred_url":"https://api.github.com/users/kapilash/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kapilash/subscriptions","organizations_url":"https://api.github.com/users/kapilash/orgs","repos_url":"https://api.github.com/users/kapilash/repos","events_url":"https://api.github.com/users/kapilash/events{/privacy}","received_events_url":"https://api.github.com/users/kapilash/received_events","type":"User","site_admin":false},"repo":{"id":32931025,"name":"corefx","full_name":"kapilash/corefx","owner":{"login":"kapilash","id":113322,"avatar_url":"https://avatars.githubusercontent.com/u/113322?v=3","gravatar_id":"","url":"https://api.github.com/users/kapilash","html_url":"https://github.com/kapilash","followers_url":"https://api.github.com/users/kapilash/followers","following_url":"https://api.github.com/users/kapilash/following{/other_user}","gists_url":"https://api.github.com/users/kapilash/gists{/gist_id}","starred_url":"https://api.github.com/users/kapilash/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kapilash/subscriptions","organizations_url":"https://api.github.com/users/kapilash/orgs","repos_url":"https://api.github.com/users/kapilash/repos","events_url":"https://api.github.com/users/kapilash/events{/privacy}","received_events_url":"https://api.github.com/users/kapilash/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kapilash/corefx","description":"This repo contains the .NET Core foundational libraries, called CoreFX. It includes classes for collections, file systems, console, XML, async and many others.","fork":true,"url":"https://api.github.com/repos/kapilash/corefx","forks_url":"https://api.github.com/repos/kapilash/corefx/forks","keys_url":"https://api.github.com/repos/kapilash/corefx/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kapilash/corefx/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kapilash/corefx/teams","hooks_url":"https://api.github.com/repos/kapilash/corefx/hooks","issue_events_url":"https://api.github.com/repos/kapilash/corefx/issues/events{/number}","events_url":"https://api.github.com/repos/kapilash/corefx/events","assignees_url":"https://api.github.com/repos/kapilash/corefx/assignees{/user}","branches_url":"https://api.github.com/repos/kapilash/corefx/branches{/branch}","tags_url":"https://api.github.com/repos/kapilash/corefx/tags","blobs_url":"https://api.github.com/repos/kapilash/corefx/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kapilash/corefx/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kapilash/corefx/git/refs{/sha}","trees_url":"https://api.github.com/repos/kapilash/corefx/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kapilash/corefx/statuses/{sha}","languages_url":"https://api.github.com/repos/kapilash/corefx/languages","stargazers_url":"https://api.github.com/repos/kapilash/corefx/stargazers","contributors_url":"https://api.github.com/repos/kapilash/corefx/contributors","subscribers_url":"https://api.github.com/repos/kapilash/corefx/subscribers","subscription_url":"https://api.github.com/repos/kapilash/corefx/subscription","commits_url":"https://api.github.com/repos/kapilash/corefx/commits{/sha}","git_commits_url":"https://api.github.com/repos/kapilash/corefx/git/commits{/sha}","comments_url":"https://api.github.com/repos/kapilash/corefx/comments{/number}","issue_comment_url":"https://api.github.com/repos/kapilash/corefx/issues/comments{/number}","contents_url":"https://api.github.com/repos/kapilash/corefx/contents/{+path}","compare_url":"https://api.github.com/repos/kapilash/corefx/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kapilash/corefx/merges","archive_url":"https://api.github.com/repos/kapilash/corefx/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kapilash/corefx/downloads","issues_url":"https://api.github.com/repos/kapilash/corefx/issues{/number}","pulls_url":"https://api.github.com/repos/kapilash/corefx/pulls{/number}","milestones_url":"https://api.github.com/repos/kapilash/corefx/milestones{/number}","notifications_url":"https://api.github.com/repos/kapilash/corefx/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kapilash/corefx/labels{/name}","releases_url":"https://api.github.com/repos/kapilash/corefx/releases{/id}","deployments_url":"https://api.github.com/repos/kapilash/corefx/deployments","created_at":"2015-03-26T14:08:29Z","updated_at":"2016-01-11T04:01:08Z","pushed_at":"2016-02-29T16:22:20Z","git_url":"git://github.com/kapilash/corefx.git","ssh_url":"git@github.com:kapilash/corefx.git","clone_url":"https://github.com/kapilash/corefx.git","svn_url":"https://github.com/kapilash/corefx","homepage":"","size":57608,"stargazers_count":0,"watchers_count":0,"language":"C#","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"dotnet:master","ref":"master","sha":"3efb8ea77cbb5f1716472ed8c9ca025b2c916203","user":{"login":"dotnet","id":9141961,"avatar_url":"https://avatars.githubusercontent.com/u/9141961?v=3","gravatar_id":"","url":"https://api.github.com/users/dotnet","html_url":"https://github.com/dotnet","followers_url":"https://api.github.com/users/dotnet/followers","following_url":"https://api.github.com/users/dotnet/following{/other_user}","gists_url":"https://api.github.com/users/dotnet/gists{/gist_id}","starred_url":"https://api.github.com/users/dotnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dotnet/subscriptions","organizations_url":"https://api.github.com/users/dotnet/orgs","repos_url":"https://api.github.com/users/dotnet/repos","events_url":"https://api.github.com/users/dotnet/events{/privacy}","received_events_url":"https://api.github.com/users/dotnet/received_events","type":"Organization","site_admin":false},"repo":{"id":26295345,"name":"corefx","full_name":"dotnet/corefx","owner":{"login":"dotnet","id":9141961,"avatar_url":"https://avatars.githubusercontent.com/u/9141961?v=3","gravatar_id":"","url":"https://api.github.com/users/dotnet","html_url":"https://github.com/dotnet","followers_url":"https://api.github.com/users/dotnet/followers","following_url":"https://api.github.com/users/dotnet/following{/other_user}","gists_url":"https://api.github.com/users/dotnet/gists{/gist_id}","starred_url":"https://api.github.com/users/dotnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dotnet/subscriptions","organizations_url":"https://api.github.com/users/dotnet/orgs","repos_url":"https://api.github.com/users/dotnet/repos","events_url":"https://api.github.com/users/dotnet/events{/privacy}","received_events_url":"https://api.github.com/users/dotnet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dotnet/corefx","description":"This repo contains the .NET Core foundational libraries, called CoreFX. It includes classes for collections, file systems, console, XML, async and many others.","fork":false,"url":"https://api.github.com/repos/dotnet/corefx","forks_url":"https://api.github.com/repos/dotnet/corefx/forks","keys_url":"https://api.github.com/repos/dotnet/corefx/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dotnet/corefx/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dotnet/corefx/teams","hooks_url":"https://api.github.com/repos/dotnet/corefx/hooks","issue_events_url":"https://api.github.com/repos/dotnet/corefx/issues/events{/number}","events_url":"https://api.github.com/repos/dotnet/corefx/events","assignees_url":"https://api.github.com/repos/dotnet/corefx/assignees{/user}","branches_url":"https://api.github.com/repos/dotnet/corefx/branches{/branch}","tags_url":"https://api.github.com/repos/dotnet/corefx/tags","blobs_url":"https://api.github.com/repos/dotnet/corefx/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dotnet/corefx/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dotnet/corefx/git/refs{/sha}","trees_url":"https://api.github.com/repos/dotnet/corefx/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dotnet/corefx/statuses/{sha}","languages_url":"https://api.github.com/repos/dotnet/corefx/languages","stargazers_url":"https://api.github.com/repos/dotnet/corefx/stargazers","contributors_url":"https://api.github.com/repos/dotnet/corefx/contributors","subscribers_url":"https://api.github.com/repos/dotnet/corefx/subscribers","subscription_url":"https://api.github.com/repos/dotnet/corefx/subscription","commits_url":"https://api.github.com/repos/dotnet/corefx/commits{/sha}","git_commits_url":"https://api.github.com/repos/dotnet/corefx/git/commits{/sha}","comments_url":"https://api.github.com/repos/dotnet/corefx/comments{/number}","issue_comment_url":"https://api.github.com/repos/dotnet/corefx/issues/comments{/number}","contents_url":"https://api.github.com/repos/dotnet/corefx/contents/{+path}","compare_url":"https://api.github.com/repos/dotnet/corefx/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dotnet/corefx/merges","archive_url":"https://api.github.com/repos/dotnet/corefx/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dotnet/corefx/downloads","issues_url":"https://api.github.com/repos/dotnet/corefx/issues{/number}","pulls_url":"https://api.github.com/repos/dotnet/corefx/pulls{/number}","milestones_url":"https://api.github.com/repos/dotnet/corefx/milestones{/number}","notifications_url":"https://api.github.com/repos/dotnet/corefx/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dotnet/corefx/labels{/name}","releases_url":"https://api.github.com/repos/dotnet/corefx/releases{/id}","deployments_url":"https://api.github.com/repos/dotnet/corefx/deployments","created_at":"2014-11-06T23:42:48Z","updated_at":"2016-02-29T16:20:44Z","pushed_at":"2016-02-29T22:04:56Z","git_url":"git://github.com/dotnet/corefx.git","ssh_url":"git@github.com:dotnet/corefx.git","clone_url":"https://github.com/dotnet/corefx.git","svn_url":"https://github.com/dotnet/corefx","homepage":"http://dotnet.github.io/","size":77244,"stargazers_count":9213,"watchers_count":9213,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2152,"mirror_url":null,"open_issues_count":884,"forks":2152,"open_issues":884,"watchers":9213,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/6469"},"html":{"href":"https://github.com/dotnet/corefx/pull/6469"},"issue":{"href":"https://api.github.com/repos/dotnet/corefx/issues/6469"},"comments":{"href":"https://api.github.com/repos/dotnet/corefx/issues/6469/comments"},"review_comments":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/6469/comments"},"review_comment":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/6469/commits"},"statuses":{"href":"https://api.github.com/repos/dotnet/corefx/statuses/0b656f1456884f8e30aa2bfd084f0f761f012103"}}}}