mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-19 01:31:17 -10:00
Adding reference source for System.Data System.Data.DataSetExtensions System.Data.Entity System.Data.Entity.Design System.Data.Linq System.Data.SqlXml System.ServiceModel System.ServiceModel.Activation System.ServiceModel.Activities System.ServiceModel.Channels System.ServiceModel.Discovery System.ServiceModel.Internals System.ServiceModel.Routing System.ServiceModel.WasHosting System.ServiceModel.Web System.Web System.Web.ApplicationServices System.Web.DynamicData System.Web.Entity System.Web.Entity.Design System.Web.Extensions System.Web.Mobile System.Web.Routing System.Web.Services System.Xml System.Xml.Linq
70 lines
2.3 KiB
C#
70 lines
2.3 KiB
C#
//------------------------------------------------------------
|
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
//------------------------------------------------------------
|
|
|
|
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
|
|
using System.IdentityModel.Policy;
|
|
using System.IdentityModel.Selectors;
|
|
using System.IdentityModel.Tokens;
|
|
|
|
using System.Security.Claims;
|
|
|
|
|
|
namespace System.ServiceModel.Security
|
|
{
|
|
internal class SecurityTokenAuthenticatorAdapter : SecurityTokenAuthenticator
|
|
{
|
|
SecurityTokenHandler _securityTokenHandler;
|
|
ExceptionMapper _exceptionMapper;
|
|
|
|
public SecurityTokenAuthenticatorAdapter(SecurityTokenHandler securityTokenHandler, ExceptionMapper exceptionMapper)
|
|
{
|
|
if (securityTokenHandler == null)
|
|
{
|
|
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("securityTokenHandler");
|
|
}
|
|
|
|
if (exceptionMapper == null)
|
|
{
|
|
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("exceptionMapper");
|
|
}
|
|
|
|
_securityTokenHandler = securityTokenHandler;
|
|
_exceptionMapper = exceptionMapper;
|
|
}
|
|
|
|
protected override bool CanValidateTokenCore(SecurityToken token)
|
|
{
|
|
if (token == null)
|
|
{
|
|
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("token");
|
|
}
|
|
|
|
return ((token.GetType() == _securityTokenHandler.TokenType) && (_securityTokenHandler.CanValidateToken));
|
|
}
|
|
|
|
protected sealed override ReadOnlyCollection<IAuthorizationPolicy> ValidateTokenCore(SecurityToken token)
|
|
{
|
|
IEnumerable<ClaimsIdentity> subjectCollection = null;
|
|
|
|
try
|
|
{
|
|
subjectCollection = _securityTokenHandler.ValidateToken(token);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
if (!_exceptionMapper.HandleSecurityTokenProcessingException(ex))
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
List<IAuthorizationPolicy> policies = new List<IAuthorizationPolicy>(1);
|
|
policies.Add(new AuthorizationPolicy(subjectCollection));
|
|
return policies.AsReadOnly();
|
|
}
|
|
}
|
|
}
|