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
- AnnouncementEndpointElement.cs
- XmlExpressionDumper.cs
- BufferedReadStream.cs
- MimeBasePart.cs
- AnnotationComponentChooser.cs
- RedistVersionInfo.cs
- CodeTypeReferenceCollection.cs
- InvalidWMPVersionException.cs
- ByeOperation11AsyncResult.cs
- Dynamic.cs
- Point3DKeyFrameCollection.cs
- BamlLocalizerErrorNotifyEventArgs.cs
- UICuesEvent.cs
- PackageStore.cs
- ProcessExitedException.cs
- RealizationDrawingContextWalker.cs
- StringArrayConverter.cs
- FilterEventArgs.cs
- FontUnit.cs
- WindowsImpersonationContext.cs
- ForceCopyBuildProvider.cs
- BitFlagsGenerator.cs
- SiteMapNode.cs
- __Error.cs
- CssStyleCollection.cs
- Int16AnimationBase.cs
- AspNetRouteServiceHttpHandler.cs
- AutomationAttributeInfo.cs
- GenericWebPart.cs
- TextEditorContextMenu.cs
- CapabilitiesPattern.cs
- ChangeDirector.cs
- WindowsButton.cs
- SqlClientWrapperSmiStream.cs
- PartitionResolver.cs
- PersistStreamTypeWrapper.cs
- RegistrationServices.cs
- QuaternionIndependentAnimationStorage.cs
- ImmComposition.cs
- ExpressionBuilder.cs
- FlowDocumentPageViewerAutomationPeer.cs
- ExpressionQuoter.cs
- PtsHost.cs
- MediaContext.cs
- NamespaceImport.cs
- DodSequenceMerge.cs
- DynamicDataRoute.cs
- WindowsFormsSectionHandler.cs
- SrgsSubset.cs
- QilParameter.cs
- MsmqInputChannelBase.cs
- Context.cs
- AnnotationStore.cs
- KnownColorTable.cs
- wgx_sdk_version.cs
- IdleTimeoutMonitor.cs
- DockAndAnchorLayout.cs
- ControlEvent.cs
- ItemCheckEvent.cs
- SqlIdentifier.cs
- NotifyIcon.cs
- TextEditorContextMenu.cs
- Point3DCollectionConverter.cs
- TextHidden.cs
- BitmapEffectDrawing.cs
- ComponentEditorPage.cs
- InternalDispatchObject.cs
- LinqDataSourceStatusEventArgs.cs
- RelatedCurrencyManager.cs
- FormsAuthentication.cs
- WindowExtensionMethods.cs
- Inflater.cs
- DataGridViewCellToolTipTextNeededEventArgs.cs
- InnerItemCollectionView.cs
- PowerStatus.cs
- PanelStyle.cs
- LinkLabel.cs
- IIS7UserPrincipal.cs
- UrlParameterReader.cs
- XmlCharacterData.cs
- FormViewInsertedEventArgs.cs
- RegionData.cs
- InvalidPrinterException.cs
- PropertyPathConverter.cs
- TextFormatter.cs
- XmlObjectSerializerWriteContext.cs
- AspNetSynchronizationContext.cs
- InputScope.cs
- SizeIndependentAnimationStorage.cs
- ReadOnlyDictionary.cs
- Base64Stream.cs
- DataGridViewCellConverter.cs
- SyndicationDeserializer.cs
- XmlAttributeCollection.cs
- RowsCopiedEventArgs.cs
- RegexNode.cs
- ClassHandlersStore.cs
- AsyncOperation.cs
- EntitySqlException.cs
- WbmpConverter.cs