Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / IdentityModel / System / IdentityModel / Tokens / GenericXmlSecurityToken.cs / 1 / GenericXmlSecurityToken.cs
//------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------- namespace System.IdentityModel.Tokens { using System; using System.Collections.ObjectModel; using System.Globalization; using System.IO; using System.IdentityModel.Claims; using System.IdentityModel.Policy; using System.Security.Cryptography; using System.Security.Principal; using System.Xml; using System.Runtime.Serialization; using System.Collections.Generic; public class GenericXmlSecurityToken : SecurityToken { const int SupportedPersistanceVersion = 1; string id; SecurityToken proofToken; SecurityKeyIdentifierClause internalTokenReference; SecurityKeyIdentifierClause externalTokenReference; XmlElement tokenXml; ReadOnlyCollectionauthorizationPolicies; DateTime effectiveTime; DateTime expirationTime; public GenericXmlSecurityToken( XmlElement tokenXml, SecurityToken proofToken, DateTime effectiveTime, DateTime expirationTime, SecurityKeyIdentifierClause internalTokenReference, SecurityKeyIdentifierClause externalTokenReference, ReadOnlyCollection authorizationPolicies ) { if (tokenXml == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("tokenXml"); } this.id = GetWsuId(tokenXml); this.tokenXml = tokenXml; this.proofToken = proofToken; this.effectiveTime = effectiveTime.ToUniversalTime(); this.expirationTime = expirationTime.ToUniversalTime(); if (internalTokenReference == null) { if (this.id != null) { internalTokenReference = new LocalIdKeyIdentifierClause(this.id); } } this.internalTokenReference = internalTokenReference; this.externalTokenReference = externalTokenReference; this.authorizationPolicies = authorizationPolicies ?? EmptyReadOnlyCollection .Instance; } public override string Id { get { return this.id; } } public override DateTime ValidFrom { get { return this.effectiveTime; } } public override DateTime ValidTo { get { return this.expirationTime; } } public SecurityKeyIdentifierClause InternalTokenReference { get { return this.internalTokenReference; } } public SecurityKeyIdentifierClause ExternalTokenReference { get { return this.externalTokenReference; } } public XmlElement TokenXml { get { return this.tokenXml; } } public SecurityToken ProofToken { get { return this.proofToken; } } public ReadOnlyCollection AuthorizationPolicies { get { return this.authorizationPolicies; } } public override ReadOnlyCollection SecurityKeys { get { if (this.proofToken != null) return this.proofToken.SecurityKeys; else return EmptyReadOnlyCollection .Instance; } } public override string ToString() { StringWriter writer = new StringWriter(CultureInfo.InvariantCulture); writer.WriteLine("Generic XML token:"); writer.WriteLine(" validFrom: {0}", this.ValidFrom); writer.WriteLine(" validTo: {0}", this.ValidTo); if (this.internalTokenReference != null) writer.WriteLine(" InternalTokenReference: {0}", this.internalTokenReference); if (this.externalTokenReference != null) writer.WriteLine(" ExternalTokenReference: {0}", this.externalTokenReference); writer.WriteLine(" Token Element: ({0}, {1})", this.tokenXml.LocalName, this.tokenXml.NamespaceURI); return writer.ToString(); } static string GetWsuId(XmlElement tokenXml) { if (tokenXml != null) { string id = tokenXml.GetAttribute(UtilityStrings.IdAttribute, UtilityStrings.Namespace); if (id != null && id.Length != 0) { return id; } } return null; } public override bool CanCreateKeyIdentifierClause () { if (this.internalTokenReference != null && typeof(T) == this.internalTokenReference.GetType()) return true; if (this.externalTokenReference != null && typeof(T) == this.externalTokenReference.GetType()) return true; return false; } public override T CreateKeyIdentifierClause () { if (this.internalTokenReference != null && typeof(T) == this.internalTokenReference.GetType()) return (T)this.internalTokenReference; if (this.externalTokenReference != null && typeof(T) == this.externalTokenReference.GetType()) return (T)this.externalTokenReference; throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SecurityTokenException(SR.GetString(SR.UnableToCreateTokenReference))); } public override bool MatchesKeyIdentifierClause(SecurityKeyIdentifierClause keyIdentifierClause) { if (this.internalTokenReference != null && this.internalTokenReference.Matches(keyIdentifierClause)) { return true; } else if (this.externalTokenReference != null && this.externalTokenReference.Matches(keyIdentifierClause)) { return true; } return false; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- X509CertificateTrustedIssuerElement.cs
- EntityDataSourceViewSchema.cs
- BindingManagerDataErrorEventArgs.cs
- WindowsListViewItemCheckBox.cs
- Pair.cs
- AxisAngleRotation3D.cs
- PngBitmapEncoder.cs
- ToolStripItemTextRenderEventArgs.cs
- Timer.cs
- MarkupCompilePass1.cs
- ObjectSet.cs
- SqlDataSourceQueryEditor.cs
- FigureParaClient.cs
- returneventsaver.cs
- WebPartActionVerb.cs
- Matrix3DValueSerializer.cs
- NavigationPropertyEmitter.cs
- login.cs
- XmlRawWriterWrapper.cs
- complextypematerializer.cs
- MatrixIndependentAnimationStorage.cs
- SettingsProviderCollection.cs
- ReadContentAsBinaryHelper.cs
- InvokeMethodActivity.cs
- SortableBindingList.cs
- SrgsToken.cs
- ResourceSet.cs
- WebConvert.cs
- DefaultEventAttribute.cs
- MappingMetadataHelper.cs
- TextFormatterImp.cs
- DelegatingStream.cs
- QueryTask.cs
- BinaryConverter.cs
- TargetParameterCountException.cs
- EnumValAlphaComparer.cs
- TrimSurroundingWhitespaceAttribute.cs
- XmlHierarchicalDataSourceView.cs
- ItemsPresenter.cs
- ImageCollectionEditor.cs
- TabControlCancelEvent.cs
- ConstraintEnumerator.cs
- MailWriter.cs
- DbConnectionFactory.cs
- SatelliteContractVersionAttribute.cs
- HostedHttpContext.cs
- InstallerTypeAttribute.cs
- SiteMapProvider.cs
- ThicknessAnimationUsingKeyFrames.cs
- MobileCapabilities.cs
- WindowsSlider.cs
- SByteConverter.cs
- SingleResultAttribute.cs
- ProtocolsConfigurationEntry.cs
- TableItemProviderWrapper.cs
- DateTimeOffsetAdapter.cs
- ELinqQueryState.cs
- PersonalizationState.cs
- ShaderEffect.cs
- PageEventArgs.cs
- SqlClientFactory.cs
- ServiceModelPerformanceCounters.cs
- Inline.cs
- ClickablePoint.cs
- PointCollectionConverter.cs
- ProfilePropertySettings.cs
- SettingsBindableAttribute.cs
- PageCache.cs
- AnnotationDocumentPaginator.cs
- DateTimeFormatInfoScanner.cs
- ReliableSessionBindingElementImporter.cs
- Int32AnimationUsingKeyFrames.cs
- ScrollPattern.cs
- Math.cs
- ComNativeDescriptor.cs
- RouteParametersHelper.cs
- OrElse.cs
- DataGridViewCellConverter.cs
- XmlSchemaAnnotated.cs
- ViewgenGatekeeper.cs
- FrameworkContentElement.cs
- SafeBuffer.cs
- CompilationUtil.cs
- SettingsPropertyValueCollection.cs
- ImmutableObjectAttribute.cs
- SizeConverter.cs
- XpsSerializerFactory.cs
- StringBlob.cs
- SQLInt64.cs
- OracleMonthSpan.cs
- SqlDependencyListener.cs
- Script.cs
- CompilerParameters.cs
- DataGridViewButtonCell.cs
- DataSourceControl.cs
- PrivilegedConfigurationManager.cs
- InstallHelper.cs
- Or.cs
- DebugControllerThread.cs
- ErrorEventArgs.cs