Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / WCF / IdentityModel / System / IdentityModel / Selectors / KerberosSecurityTokenProvider.cs / 1305376 / KerberosSecurityTokenProvider.cs
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------
namespace System.IdentityModel.Selectors
{
using System.IdentityModel.Tokens;
using System.Net;
using System.Security.Authentication.ExtendedProtection;
using System.Security.Principal;
public class KerberosSecurityTokenProvider : SecurityTokenProvider
{
string servicePrincipalName;
TokenImpersonationLevel tokenImpersonationLevel;
NetworkCredential networkCredential;
public KerberosSecurityTokenProvider(string servicePrincipalName)
: this(servicePrincipalName, TokenImpersonationLevel.Identification)
{
}
public KerberosSecurityTokenProvider(string servicePrincipalName, TokenImpersonationLevel tokenImpersonationLevel)
: this(servicePrincipalName, tokenImpersonationLevel, null)
{
}
public KerberosSecurityTokenProvider(string servicePrincipalName, TokenImpersonationLevel tokenImpersonationLevel, NetworkCredential networkCredential)
{
if (servicePrincipalName == null)
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("servicePrincipalName");
if (tokenImpersonationLevel != TokenImpersonationLevel.Identification && tokenImpersonationLevel != TokenImpersonationLevel.Impersonation)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("tokenImpersonationLevel",
SR.GetString(SR.ImpersonationLevelNotSupported, tokenImpersonationLevel)));
}
this.servicePrincipalName = servicePrincipalName;
this.tokenImpersonationLevel = tokenImpersonationLevel;
this.networkCredential = networkCredential;
}
public string ServicePrincipalName
{
get { return this.servicePrincipalName; }
}
public TokenImpersonationLevel TokenImpersonationLevel
{
get { return this.tokenImpersonationLevel; }
}
public NetworkCredential NetworkCredential
{
get { return this.networkCredential; }
}
internal SecurityToken GetToken(TimeSpan timeout, ChannelBinding channelbinding)
{
return new KerberosRequestorSecurityToken(this.ServicePrincipalName,
this.TokenImpersonationLevel, this.NetworkCredential,
SecurityUniqueId.Create().Value, channelbinding);
}
protected override SecurityToken GetTokenCore(TimeSpan timeout)
{
return this.GetToken(timeout, null);
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------
namespace System.IdentityModel.Selectors
{
using System.IdentityModel.Tokens;
using System.Net;
using System.Security.Authentication.ExtendedProtection;
using System.Security.Principal;
public class KerberosSecurityTokenProvider : SecurityTokenProvider
{
string servicePrincipalName;
TokenImpersonationLevel tokenImpersonationLevel;
NetworkCredential networkCredential;
public KerberosSecurityTokenProvider(string servicePrincipalName)
: this(servicePrincipalName, TokenImpersonationLevel.Identification)
{
}
public KerberosSecurityTokenProvider(string servicePrincipalName, TokenImpersonationLevel tokenImpersonationLevel)
: this(servicePrincipalName, tokenImpersonationLevel, null)
{
}
public KerberosSecurityTokenProvider(string servicePrincipalName, TokenImpersonationLevel tokenImpersonationLevel, NetworkCredential networkCredential)
{
if (servicePrincipalName == null)
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("servicePrincipalName");
if (tokenImpersonationLevel != TokenImpersonationLevel.Identification && tokenImpersonationLevel != TokenImpersonationLevel.Impersonation)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("tokenImpersonationLevel",
SR.GetString(SR.ImpersonationLevelNotSupported, tokenImpersonationLevel)));
}
this.servicePrincipalName = servicePrincipalName;
this.tokenImpersonationLevel = tokenImpersonationLevel;
this.networkCredential = networkCredential;
}
public string ServicePrincipalName
{
get { return this.servicePrincipalName; }
}
public TokenImpersonationLevel TokenImpersonationLevel
{
get { return this.tokenImpersonationLevel; }
}
public NetworkCredential NetworkCredential
{
get { return this.networkCredential; }
}
internal SecurityToken GetToken(TimeSpan timeout, ChannelBinding channelbinding)
{
return new KerberosRequestorSecurityToken(this.ServicePrincipalName,
this.TokenImpersonationLevel, this.NetworkCredential,
SecurityUniqueId.Create().Value, channelbinding);
}
protected override SecurityToken GetTokenCore(TimeSpan timeout)
{
return this.GetToken(timeout, null);
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- bidPrivateBase.cs
- PropertyOverridesDialog.cs
- SecurityRuntime.cs
- TableParaClient.cs
- CapabilitiesSection.cs
- MemberRestriction.cs
- Parser.cs
- VScrollBar.cs
- ScriptManagerProxy.cs
- ZipIORawDataFileBlock.cs
- ImageKeyConverter.cs
- WebBrowserEvent.cs
- EdmPropertyAttribute.cs
- RegistryPermission.cs
- StateManagedCollection.cs
- XsltSettings.cs
- CmsInterop.cs
- CreateUserErrorEventArgs.cs
- ScriptServiceAttribute.cs
- NullReferenceException.cs
- UnauthorizedAccessException.cs
- SystemShuttingDownException.cs
- BuildResultCache.cs
- MimeMapping.cs
- TraceListeners.cs
- _OSSOCK.cs
- DefinitionUpdate.cs
- EntityDataSourceWrapperPropertyDescriptor.cs
- Debugger.cs
- TableLayoutStyleCollection.cs
- ValidatedControlConverter.cs
- PrintControllerWithStatusDialog.cs
- WindowsGrip.cs
- XamlFxTrace.cs
- DetailsViewInsertEventArgs.cs
- ButtonFieldBase.cs
- WebCategoryAttribute.cs
- PropertyMetadata.cs
- SecUtil.cs
- AppDomainGrammarProxy.cs
- DataControlExtensions.cs
- oledbmetadatacolumnnames.cs
- XmlDocumentType.cs
- EncoderExceptionFallback.cs
- TextSelectionHighlightLayer.cs
- AsyncWaitHandle.cs
- QilGeneratorEnv.cs
- ResourceSetExpression.cs
- OleServicesContext.cs
- PointKeyFrameCollection.cs
- XmlAnyAttributeAttribute.cs
- SingleAnimation.cs
- PropertyInfoSet.cs
- Transform3DGroup.cs
- PropertyEntry.cs
- ConfigXmlElement.cs
- StylusOverProperty.cs
- DefaultTraceListener.cs
- UndoEngine.cs
- HtmlTableRowCollection.cs
- FillRuleValidation.cs
- LinearGradientBrush.cs
- Stopwatch.cs
- NamedPipeConnectionPoolSettings.cs
- ResolvePPIDRequest.cs
- MouseButtonEventArgs.cs
- DataGridViewHitTestInfo.cs
- TypeDelegator.cs
- PathData.cs
- DataGridRowHeaderAutomationPeer.cs
- SafeHandle.cs
- HtmlFormWrapper.cs
- SecureUICommand.cs
- SqlAliasesReferenced.cs
- GridSplitterAutomationPeer.cs
- ShaderEffect.cs
- CommandHelper.cs
- EventTrigger.cs
- ListDictionary.cs
- TextProperties.cs
- ResourceFallbackManager.cs
- PropertyBuilder.cs
- TextRangeProviderWrapper.cs
- TickBar.cs
- HttpHeaderCollection.cs
- COM2ExtendedUITypeEditor.cs
- File.cs
- XmlUrlResolver.cs
- Win32Exception.cs
- WebPartExportVerb.cs
- TreeViewImageGenerator.cs
- ResourceSet.cs
- ArrayWithOffset.cs
- XmlSchemaSimpleContent.cs
- Peer.cs
- MimeBasePart.cs
- HttpFormatExtensions.cs
- DiscoveryClientDocuments.cs
- MemberAccessException.cs
- EndpointAddress.cs