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
- XmlDataFileEditor.cs
- IsolatedStorageFileStream.cs
- ExcCanonicalXml.cs
- WsatConfiguration.cs
- ContractMapping.cs
- DesignTimeTemplateParser.cs
- XmlSchema.cs
- PointAnimationClockResource.cs
- SqlEnums.cs
- EasingQuaternionKeyFrame.cs
- DataGridToolTip.cs
- CellTreeSimplifier.cs
- filewebresponse.cs
- PtsHelper.cs
- String.cs
- PathFigureCollectionConverter.cs
- Decimal.cs
- RegionData.cs
- UInt32Converter.cs
- IisTraceListener.cs
- FormParameter.cs
- PartBasedPackageProperties.cs
- UnsupportedPolicyOptionsException.cs
- WindowsFont.cs
- ConnectivityStatus.cs
- BlurBitmapEffect.cs
- SqlCacheDependencyDatabase.cs
- ViewGenResults.cs
- SqlCacheDependencyDatabaseCollection.cs
- MenuItemBindingCollection.cs
- QilVisitor.cs
- ButtonFieldBase.cs
- SqlLiftIndependentRowExpressions.cs
- SuppressIldasmAttribute.cs
- RadioButton.cs
- LayoutInformation.cs
- CellLabel.cs
- TemplatingOptionsDialog.cs
- Attributes.cs
- PolicyChain.cs
- DelegatingTypeDescriptionProvider.cs
- ImageClickEventArgs.cs
- sortedlist.cs
- Gdiplus.cs
- DiscriminatorMap.cs
- SplitterPanel.cs
- Method.cs
- BlobPersonalizationState.cs
- AssemblyResolver.cs
- UpdateCompiler.cs
- DropTarget.cs
- XmlDocument.cs
- _PooledStream.cs
- Boolean.cs
- SectionInformation.cs
- LicenseException.cs
- AuthenticationServiceManager.cs
- TreeView.cs
- AtlasWeb.Designer.cs
- BaseCodeDomTreeGenerator.cs
- DesignerForm.cs
- wgx_exports.cs
- HttpApplicationStateBase.cs
- ApplicationDirectoryMembershipCondition.cs
- propertyentry.cs
- DataServiceException.cs
- EventDescriptor.cs
- InstanceDataCollectionCollection.cs
- WindowsTab.cs
- DefaultValueTypeConverter.cs
- MultipleViewPattern.cs
- ByteRangeDownloader.cs
- ScanQueryOperator.cs
- NativeMethods.cs
- WindowsTokenRoleProvider.cs
- ConfigXmlCDataSection.cs
- ImageFormatConverter.cs
- Label.cs
- DrawingContext.cs
- Style.cs
- OdbcCommandBuilder.cs
- WebPartZoneCollection.cs
- ListViewVirtualItemsSelectionRangeChangedEvent.cs
- SubMenuStyleCollection.cs
- DataObject.cs
- HttpWebResponse.cs
- DoubleAnimationClockResource.cs
- ExpressionWriter.cs
- Mappings.cs
- RenderingEventArgs.cs
- HitTestResult.cs
- ToolStripItemEventArgs.cs
- HttpFileCollection.cs
- GridEntryCollection.cs
- SmtpException.cs
- SuppressMergeCheckAttribute.cs
- TickBar.cs
- FigureHelper.cs
- TextFormatter.cs
- AnimationTimeline.cs