Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / WCF / IdentityModel / System / IdentityModel / Selectors / CustomUserNameSecurityTokenAuthenticator.cs / 1305376 / CustomUserNameSecurityTokenAuthenticator.cs
//------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------- namespace System.IdentityModel.Selectors { using System.Collections.Generic; using System.Collections.ObjectModel; using System.IdentityModel.Claims; using System.IdentityModel.Policy; using System.IdentityModel.Tokens; using System.Security.Principal; public class CustomUserNameSecurityTokenAuthenticator : UserNameSecurityTokenAuthenticator { UserNamePasswordValidator validator; public CustomUserNameSecurityTokenAuthenticator(UserNamePasswordValidator validator) { if (validator == null) throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("validator"); this.validator = validator; } protected override ReadOnlyCollectionValidateUserNamePasswordCore(string userName, string password) { this.validator.Validate(userName, password); return SecurityUtils.CreateAuthorizationPolicies(new UserNameClaimSet(userName, validator.GetType().Name)); } class UserNameClaimSet : DefaultClaimSet, IIdentityInfo { IIdentity identity; public UserNameClaimSet(string userName, string authType) { if (userName == null) throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("userName"); this.identity = SecurityUtils.CreateIdentity(userName, authType); List claims = new List (2); claims.Add(new Claim(ClaimTypes.Name, userName, Rights.Identity)); claims.Add(Claim.CreateNameClaim(userName)); Initialize(ClaimSet.System, claims); } public IIdentity Identity { get { return this.identity; } } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------- namespace System.IdentityModel.Selectors { using System.Collections.Generic; using System.Collections.ObjectModel; using System.IdentityModel.Claims; using System.IdentityModel.Policy; using System.IdentityModel.Tokens; using System.Security.Principal; public class CustomUserNameSecurityTokenAuthenticator : UserNameSecurityTokenAuthenticator { UserNamePasswordValidator validator; public CustomUserNameSecurityTokenAuthenticator(UserNamePasswordValidator validator) { if (validator == null) throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("validator"); this.validator = validator; } protected override ReadOnlyCollection ValidateUserNamePasswordCore(string userName, string password) { this.validator.Validate(userName, password); return SecurityUtils.CreateAuthorizationPolicies(new UserNameClaimSet(userName, validator.GetType().Name)); } class UserNameClaimSet : DefaultClaimSet, IIdentityInfo { IIdentity identity; public UserNameClaimSet(string userName, string authType) { if (userName == null) throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("userName"); this.identity = SecurityUtils.CreateIdentity(userName, authType); List claims = new List (2); claims.Add(new Claim(ClaimTypes.Name, userName, Rights.Identity)); claims.Add(Claim.CreateNameClaim(userName)); Initialize(ClaimSet.System, claims); } public IIdentity Identity { get { return this.identity; } } } } } // 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
- Executor.cs
- RoutedEventValueSerializer.cs
- PhysicalAddress.cs
- Config.cs
- DataGridViewTextBoxColumn.cs
- WebRequestModuleElement.cs
- TryCatch.cs
- regiisutil.cs
- storepermissionattribute.cs
- SendKeys.cs
- TreeNode.cs
- ToolStripItemClickedEventArgs.cs
- RegexBoyerMoore.cs
- XmlText.cs
- Rfc2898DeriveBytes.cs
- StringCollection.cs
- RegexMatchCollection.cs
- NativeConfigurationLoader.cs
- ConfigurationSectionGroup.cs
- FixedSOMElement.cs
- DataObject.cs
- ValueType.cs
- TabControl.cs
- NamedPermissionSet.cs
- BamlReader.cs
- backend.cs
- ContentPresenter.cs
- NetworkInterface.cs
- SignatureTargetIdManager.cs
- WCFServiceClientProxyGenerator.cs
- BindingList.cs
- ValidatorCollection.cs
- Constant.cs
- InternalEnumValidatorAttribute.cs
- itemelement.cs
- GeometryGroup.cs
- ColumnReorderedEventArgs.cs
- DateTimeOffset.cs
- AnchoredBlock.cs
- Fx.cs
- Stack.cs
- ContentPlaceHolder.cs
- AxHost.cs
- TableLayoutStyle.cs
- RtfControlWordInfo.cs
- RenderData.cs
- RuleRefElement.cs
- RijndaelManagedTransform.cs
- FileDataSourceCache.cs
- RoleServiceManager.cs
- IdleTimeoutMonitor.cs
- MembershipSection.cs
- OleServicesContext.cs
- EmbeddedMailObjectCollectionEditor.cs
- SoapEnumAttribute.cs
- OutputCacheModule.cs
- ScrollContentPresenter.cs
- ProtocolsConfigurationHandler.cs
- ScriptManagerProxy.cs
- ParallelTimeline.cs
- ConfigurationStrings.cs
- ObjectContext.cs
- OracleInfoMessageEventArgs.cs
- SendKeys.cs
- RegexGroup.cs
- CodeAssignStatement.cs
- Stylus.cs
- _ListenerRequestStream.cs
- Context.cs
- AdornedElementPlaceholder.cs
- FontCollection.cs
- GlobalizationSection.cs
- FontFamilyConverter.cs
- WorkflowViewManager.cs
- ConnectionManagementSection.cs
- AttributeCollection.cs
- DataGridTextBox.cs
- SystemUdpStatistics.cs
- BitmapCodecInfo.cs
- HttpServerUtilityBase.cs
- CategoryGridEntry.cs
- HtmlGenericControl.cs
- Viewport3DAutomationPeer.cs
- SyndicationDeserializer.cs
- MasterPage.cs
- GlobalProxySelection.cs
- DBAsyncResult.cs
- XPathItem.cs
- CurrentTimeZone.cs
- InkCollectionBehavior.cs
- DataSourceConverter.cs
- StringToken.cs
- DictionaryGlobals.cs
- DataGridHeaderBorder.cs
- RepeaterItem.cs
- Parameter.cs
- BasePropertyDescriptor.cs
- DataControlField.cs
- BitmapEffectState.cs
- CreateParams.cs