Пример #1
0
 public virtual Task AuthenticateAsServerAsync(
     NetworkCredential credential, ExtendedProtectionPolicy?policy,
     ProtectionLevel requiredProtectionLevel,
     TokenImpersonationLevel requiredImpersonationLevel)
 {
     return(Task.Factory.FromAsync((callback, state) => BeginAuthenticateAsServer(credential, policy, requiredProtectionLevel, requiredImpersonationLevel, callback, state), EndAuthenticateAsClient, null));
 }
Пример #2
0
        internal void ValidateCreateContext(
            string package,
            NetworkCredential credential,
            string servicePrincipalName,
            ExtendedProtectionPolicy?policy,
            ProtectionLevel protectionLevel,
            TokenImpersonationLevel impersonationLevel)
        {
            if (policy != null)
            {
                // One of these must be set if EP is turned on
                if (policy.CustomChannelBinding == null && policy.CustomServiceNames == null)
                {
                    throw new ArgumentException(SR.net_auth_must_specify_extended_protection_scheme, nameof(policy));
                }

                _extendedProtectionPolicy = policy;
            }
            else
            {
                _extendedProtectionPolicy = new ExtendedProtectionPolicy(PolicyEnforcement.Never);
            }

            ValidateCreateContext(package, true, credential, servicePrincipalName, _extendedProtectionPolicy !.CustomChannelBinding, protectionLevel, impersonationLevel);
        }
Пример #3
0
        public virtual void AuthenticateAsServer(NetworkCredential credential, ExtendedProtectionPolicy?policy, ProtectionLevel requiredProtectionLevel, TokenImpersonationLevel requiredImpersonationLevel)
        {
#if DEBUG
            using (DebugThreadTracking.SetThreadKind(ThreadKinds.User | ThreadKinds.Sync))
            {
#endif
            _negoState.ValidateCreateContext(_package, credential, string.Empty, policy, requiredProtectionLevel, requiredImpersonationLevel);
            _negoState.ProcessAuthentication(null);
#if DEBUG
        }
#endif
        }
Пример #4
0
        public virtual IAsyncResult BeginAuthenticateAsServer(
            NetworkCredential credential,
            ExtendedProtectionPolicy?policy,
            ProtectionLevel requiredProtectionLevel,
            TokenImpersonationLevel requiredImpersonationLevel,
            AsyncCallback?asyncCallback,
            object?asyncState)
        {
#if DEBUG
            using (DebugThreadTracking.SetThreadKind(ThreadKinds.User | ThreadKinds.Async))
            {
#endif
            _negoState.ValidateCreateContext(_package, credential, string.Empty, policy, requiredProtectionLevel, requiredImpersonationLevel);

            LazyAsyncResult result = new LazyAsyncResult(_negoState, asyncState, asyncCallback);
            _negoState.ProcessAuthentication(result);

            return(result);

#if DEBUG
        }
#endif
        }
Пример #5
0
 public virtual Task AuthenticateAsServerAsync(
     NetworkCredential credential, ExtendedProtectionPolicy?policy, ProtectionLevel requiredProtectionLevel, TokenImpersonationLevel requiredImpersonationLevel)
 {
     ValidateCreateContext(DefaultPackage, credential, string.Empty, policy, requiredProtectionLevel, requiredImpersonationLevel);
     return(AuthenticateAsync(new AsyncReadWriteAdapter(InnerStream, cancellationToken: default)));
 }
Пример #6
0
 public virtual Task AuthenticateAsServerAsync(ExtendedProtectionPolicy?policy) =>
 AuthenticateAsServerAsync((NetworkCredential)CredentialCache.DefaultCredentials, policy, ProtectionLevel.EncryptAndSign, TokenImpersonationLevel.Identification);
Пример #7
0
 public virtual IAsyncResult BeginAuthenticateAsServer(
     NetworkCredential credential, ExtendedProtectionPolicy?policy, ProtectionLevel requiredProtectionLevel, TokenImpersonationLevel requiredImpersonationLevel,
     AsyncCallback?asyncCallback, object?asyncState) =>
 TaskToApm.Begin(AuthenticateAsServerAsync(credential, policy, requiredProtectionLevel, requiredImpersonationLevel), asyncCallback, asyncState);
Пример #8
0
 public virtual IAsyncResult BeginAuthenticateAsServer(ExtendedProtectionPolicy?policy, AsyncCallback?asyncCallback, object?asyncState) =>
 BeginAuthenticateAsServer((NetworkCredential)CredentialCache.DefaultCredentials, policy, ProtectionLevel.EncryptAndSign, TokenImpersonationLevel.Identification, asyncCallback, asyncState);
Пример #9
0
 public virtual void AuthenticateAsServer(NetworkCredential credential, ExtendedProtectionPolicy?policy, ProtectionLevel requiredProtectionLevel, TokenImpersonationLevel requiredImpersonationLevel)
 {
     ValidateCreateContext(DefaultPackage, credential, string.Empty, policy, requiredProtectionLevel, requiredImpersonationLevel);
     AuthenticateAsync(new SyncReadWriteAdapter(InnerStream)).GetAwaiter().GetResult();
 }
Пример #10
0
 public virtual Task AuthenticateAsServerAsync(ExtendedProtectionPolicy?policy)
 {
     return(Task.Factory.FromAsync(BeginAuthenticateAsServer, EndAuthenticateAsServer, policy, null));
 }