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
- LinkedResourceCollection.cs
- ObjRef.cs
- IUnknownConstantAttribute.cs
- _ConnectionGroup.cs
- TemplatedMailWebEventProvider.cs
- AssemblyAssociatedContentFileAttribute.cs
- ToolboxComponentsCreatedEventArgs.cs
- CheckBoxField.cs
- SmtpReplyReader.cs
- PropertyEmitterBase.cs
- TdsParserSessionPool.cs
- PropertyRecord.cs
- DbProviderFactoriesConfigurationHandler.cs
- filewebresponse.cs
- VirtualStackFrame.cs
- DisposableCollectionWrapper.cs
- XmlCountingReader.cs
- Enlistment.cs
- PropertyChangedEventManager.cs
- SendMessageChannelCache.cs
- XmlUtil.cs
- CompilerState.cs
- InvokePattern.cs
- RangeContentEnumerator.cs
- XmlNodeWriter.cs
- VectorAnimationUsingKeyFrames.cs
- Content.cs
- TreeNodeClickEventArgs.cs
- DecimalStorage.cs
- EventSourceCreationData.cs
- EnumBuilder.cs
- DiscoveryClientDocuments.cs
- httpstaticobjectscollection.cs
- WebEvents.cs
- IssuerInformation.cs
- AuthorizationRuleCollection.cs
- KeyValueInternalCollection.cs
- ConstantCheck.cs
- HMAC.cs
- DetailsViewInsertedEventArgs.cs
- XmlUrlEditor.cs
- NativeRightsManagementAPIsStructures.cs
- DrawingVisualDrawingContext.cs
- Int64Storage.cs
- EventsTab.cs
- EntityContainerAssociationSet.cs
- XmlQualifiedNameTest.cs
- OdbcException.cs
- ErrorView.xaml.cs
- Vector3DValueSerializer.cs
- FontWeight.cs
- activationcontext.cs
- Choices.cs
- BinaryWriter.cs
- CloudCollection.cs
- Tuple.cs
- BinaryObjectWriter.cs
- AsymmetricKeyExchangeDeformatter.cs
- OrderByBuilder.cs
- NativeWrapper.cs
- XmlLinkedNode.cs
- EventsTab.cs
- OptionUsage.cs
- DbFunctionCommandTree.cs
- NameValueConfigurationElement.cs
- MobileDeviceCapabilitiesSectionHandler.cs
- FigureParaClient.cs
- HtmlTitle.cs
- DataColumnCollection.cs
- ellipse.cs
- Run.cs
- PointIndependentAnimationStorage.cs
- HitTestWithGeometryDrawingContextWalker.cs
- LocatorPart.cs
- _ListenerResponseStream.cs
- EntityProxyTypeInfo.cs
- VisualBrush.cs
- InfoCardBaseException.cs
- DataGridViewComboBoxCell.cs
- ContextMenu.cs
- FakeModelItemImpl.cs
- Scene3D.cs
- RemotingAttributes.cs
- RegistryExceptionHelper.cs
- ContentWrapperAttribute.cs
- GroupItemAutomationPeer.cs
- HwndHostAutomationPeer.cs
- EditorAttribute.cs
- XMLSyntaxException.cs
- SHA384Managed.cs
- BasicAsyncResult.cs
- ListViewContainer.cs
- TrackBar.cs
- XmlSchemaSimpleTypeUnion.cs
- FilterInvalidBodyAccessException.cs
- FirstMatchCodeGroup.cs
- SoapExtensionTypeElement.cs
- TextBoxAutomationPeer.cs
- TabControl.cs
- ToolStripItem.cs