Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / WCF / IdentityModel / System / IdentityModel / Tokens / SamlSubjectStatement.cs / 1305376 / SamlSubjectStatement.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.IdentityModel.Tokens { using System.Collections.Generic; using System.Collections.ObjectModel; using System.IdentityModel.Claims; using System.IdentityModel.Policy; using System.IdentityModel.Selectors; using System.Security.Principal; public abstract class SamlSubjectStatement : SamlStatement { SamlSubject subject; IAuthorizationPolicy policy; bool isReadOnly = false; protected SamlSubjectStatement() { } protected SamlSubjectStatement(SamlSubject samlSubject) { if (samlSubject == null) throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("samlSubject")); this.subject = samlSubject; } public SamlSubject SamlSubject { get {return this.subject; } set { if (isReadOnly) throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.ObjectIsReadOnly))); if (value == null) throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("value")); this.subject = value; } } public override bool IsReadOnly { get { return this.isReadOnly; } } public override void MakeReadOnly() { if (!this.isReadOnly) { subject.MakeReadOnly(); this.isReadOnly = true; } } public override IAuthorizationPolicy CreatePolicy(ClaimSet issuer, SamlSecurityTokenAuthenticator samlAuthenticator) { if (issuer == null) throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("issuer"); // SupportingTokenAuthenticator collection can be null when the Subject does not // contain a key. if (this.policy == null) { ListclaimSets = new List (); ClaimSet subjectKeyClaimset = this.subject.ExtractSubjectKeyClaimSet(samlAuthenticator); if (subjectKeyClaimset != null) claimSets.Add(subjectKeyClaimset); List claims = new List (); ReadOnlyCollection subjectClaims = this.subject.ExtractClaims(); for (int i = 0; i < subjectClaims.Count; ++i) { claims.Add(subjectClaims[i]); } AddClaimsToList(claims); claimSets.Add(new DefaultClaimSet(issuer, claims)); this.policy = new UnconditionalPolicy(this.subject.Identity, claimSets.AsReadOnly(), SecurityUtils.MaxUtcDateTime); } return this.policy; } protected void SetSubject(SamlSubject samlSubject) { if (samlSubject == null) throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("samlSubject")); this.subject = samlSubject; } protected abstract void AddClaimsToList(IList claims); } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.IdentityModel.Tokens { using System.Collections.Generic; using System.Collections.ObjectModel; using System.IdentityModel.Claims; using System.IdentityModel.Policy; using System.IdentityModel.Selectors; using System.Security.Principal; public abstract class SamlSubjectStatement : SamlStatement { SamlSubject subject; IAuthorizationPolicy policy; bool isReadOnly = false; protected SamlSubjectStatement() { } protected SamlSubjectStatement(SamlSubject samlSubject) { if (samlSubject == null) throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("samlSubject")); this.subject = samlSubject; } public SamlSubject SamlSubject { get {return this.subject; } set { if (isReadOnly) throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.ObjectIsReadOnly))); if (value == null) throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("value")); this.subject = value; } } public override bool IsReadOnly { get { return this.isReadOnly; } } public override void MakeReadOnly() { if (!this.isReadOnly) { subject.MakeReadOnly(); this.isReadOnly = true; } } public override IAuthorizationPolicy CreatePolicy(ClaimSet issuer, SamlSecurityTokenAuthenticator samlAuthenticator) { if (issuer == null) throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("issuer"); // SupportingTokenAuthenticator collection can be null when the Subject does not // contain a key. if (this.policy == null) { List claimSets = new List (); ClaimSet subjectKeyClaimset = this.subject.ExtractSubjectKeyClaimSet(samlAuthenticator); if (subjectKeyClaimset != null) claimSets.Add(subjectKeyClaimset); List claims = new List (); ReadOnlyCollection subjectClaims = this.subject.ExtractClaims(); for (int i = 0; i < subjectClaims.Count; ++i) { claims.Add(subjectClaims[i]); } AddClaimsToList(claims); claimSets.Add(new DefaultClaimSet(issuer, claims)); this.policy = new UnconditionalPolicy(this.subject.Identity, claimSets.AsReadOnly(), SecurityUtils.MaxUtcDateTime); } return this.policy; } protected void SetSubject(SamlSubject samlSubject) { if (samlSubject == null) throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("samlSubject")); this.subject = samlSubject; } protected abstract void AddClaimsToList(IList claims); } } // 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
- HitTestParameters3D.cs
- Token.cs
- UpdatePanelControlTrigger.cs
- DefaultMemberAttribute.cs
- XmlSchemaException.cs
- XmlSecureResolver.cs
- TextTreeUndo.cs
- SchemaLookupTable.cs
- CustomMenuItemCollection.cs
- ButtonBaseAdapter.cs
- DeviceContexts.cs
- SourceSwitch.cs
- basevalidator.cs
- UInt32Converter.cs
- SmtpMail.cs
- ISessionStateStore.cs
- FieldBuilder.cs
- Int16.cs
- ApplicationActivator.cs
- OleDbConnectionFactory.cs
- FlagPanel.cs
- EntityParameter.cs
- SafeBitVector32.cs
- WindowsClientElement.cs
- FileRecordSequence.cs
- StringConverter.cs
- SecurityTokenRequirement.cs
- ComponentManagerBroker.cs
- ToolStripLocationCancelEventArgs.cs
- ChannelManager.cs
- AlphaSortedEnumConverter.cs
- AssemblyAttributesGoHere.cs
- AxHost.cs
- WorkflowCommandExtensionItem.cs
- MenuEventArgs.cs
- WindowsToolbarAsMenu.cs
- MobileFormsAuthentication.cs
- FormattedText.cs
- TrackingServices.cs
- SoapEnumAttribute.cs
- HtmlInputPassword.cs
- TreeNodeCollection.cs
- ZoneButton.cs
- ThemeInfoAttribute.cs
- VolatileEnlistmentState.cs
- KeyGesture.cs
- WebPartManagerInternals.cs
- InternalConfigSettingsFactory.cs
- LayoutDump.cs
- StringAttributeCollection.cs
- CompoundFileStreamReference.cs
- PrtCap_Public_Simple.cs
- DrawListViewColumnHeaderEventArgs.cs
- ResourceKey.cs
- OleDbPermission.cs
- RolePrincipal.cs
- CultureSpecificStringDictionary.cs
- StaticExtension.cs
- OracleRowUpdatingEventArgs.cs
- DecimalAnimationBase.cs
- RootBrowserWindowProxy.cs
- Debug.cs
- ByteAnimation.cs
- Encoder.cs
- JsonUriDataContract.cs
- FigureParagraph.cs
- CompilerInfo.cs
- EntityFunctions.cs
- Merger.cs
- DbBuffer.cs
- ItemAutomationPeer.cs
- XmlSerializableServices.cs
- ObjectDataSourceEventArgs.cs
- XmlUtil.cs
- TraceEventCache.cs
- StyleXamlParser.cs
- RefType.cs
- NameScope.cs
- UshortList2.cs
- CurrentTimeZone.cs
- HtmlTitle.cs
- SystemUdpStatistics.cs
- XmlSchemaAny.cs
- RSACryptoServiceProvider.cs
- DuplexChannel.cs
- SoapHeader.cs
- ConfigurationSettings.cs
- TemplateColumn.cs
- DynamicMetaObjectBinder.cs
- CharacterMetricsDictionary.cs
- SymmetricSecurityProtocolFactory.cs
- XmlNamespaceMappingCollection.cs
- DetailsViewPageEventArgs.cs
- EditingScope.cs
- UInt16.cs
- ArgumentOutOfRangeException.cs
- DropDownButton.cs
- Lease.cs
- Style.cs
- EntityModelSchemaGenerator.cs