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
- ImageFormatConverter.cs
- _WinHttpWebProxyDataBuilder.cs
- PropertyItem.cs
- RenderOptions.cs
- StateManagedCollection.cs
- ContactManager.cs
- DrawListViewColumnHeaderEventArgs.cs
- XmlAnyElementAttribute.cs
- ObjectAnimationBase.cs
- IntermediatePolicyValidator.cs
- Frame.cs
- MarkedHighlightComponent.cs
- TrackingQuery.cs
- NameHandler.cs
- HtmlTableRowCollection.cs
- ReferenceEqualityComparer.cs
- XamlWriterExtensions.cs
- ProxyAttribute.cs
- TextEditorSpelling.cs
- IssuedTokenClientElement.cs
- InternalCache.cs
- URI.cs
- SimpleTextLine.cs
- WebPartDescription.cs
- StringPropertyBuilder.cs
- Menu.cs
- OpenFileDialog.cs
- TemplatePagerField.cs
- XmlSchemaComplexContentRestriction.cs
- Rotation3D.cs
- RequiredAttributeAttribute.cs
- TargetInvocationException.cs
- HyperlinkAutomationPeer.cs
- XmlSerializableReader.cs
- WhitespaceRuleLookup.cs
- DrawingAttributeSerializer.cs
- DisplayInformation.cs
- BrowserCapabilitiesFactory.cs
- WindowsRebar.cs
- EntityDataSourceChangingEventArgs.cs
- ProfessionalColorTable.cs
- WeakHashtable.cs
- AxisAngleRotation3D.cs
- PasswordRecovery.cs
- _AuthenticationState.cs
- DiscoveryReference.cs
- XmlSchemaSimpleType.cs
- SourceFilter.cs
- ParallelTimeline.cs
- CannotUnloadAppDomainException.cs
- XmlPropertyBag.cs
- Connector.cs
- AutoResetEvent.cs
- Int32RectConverter.cs
- EventMap.cs
- WorkerRequest.cs
- CodeExpressionStatement.cs
- SecurityContext.cs
- Memoizer.cs
- RuntimeIdentifierPropertyAttribute.cs
- DBConnection.cs
- TrackingMemoryStream.cs
- ConnectionManagementElement.cs
- HtmlTableCellCollection.cs
- __Filters.cs
- RadioButtonPopupAdapter.cs
- HitTestResult.cs
- DataGridHeaderBorder.cs
- DatagridviewDisplayedBandsData.cs
- FrameworkElement.cs
- ToolboxCategory.cs
- MouseEvent.cs
- TextTreeInsertUndoUnit.cs
- InvalidWorkflowException.cs
- DbConnectionClosed.cs
- WebBrowserSiteBase.cs
- ParenthesizePropertyNameAttribute.cs
- SecureEnvironment.cs
- ExpressionBuilder.cs
- IndentTextWriter.cs
- RequestNavigateEventArgs.cs
- PropertyIDSet.cs
- VerificationException.cs
- WindowsIPAddress.cs
- TagPrefixCollection.cs
- ObjectToIdCache.cs
- EventMappingSettingsCollection.cs
- DomainUpDown.cs
- AmbientLight.cs
- TextRangeProviderWrapper.cs
- PasswordPropertyTextAttribute.cs
- CollectionViewGroupInternal.cs
- ZipFileInfo.cs
- WeakKeyDictionary.cs
- InvalidEnumArgumentException.cs
- DateTimePickerDesigner.cs
- Section.cs
- ComboBox.cs
- PersianCalendar.cs
- Span.cs