Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / Security / SessionSymmetricMessageSecurityProtocolFactory.cs / 1 / SessionSymmetricMessageSecurityProtocolFactory.cs
//---------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------- namespace System.ServiceModel.Security { using System.IdentityModel.Tokens; using System.ServiceModel.Channels; using System.ServiceModel; using System.IdentityModel.Selectors; using System.ServiceModel.Security.Tokens; class SessionSymmetricMessageSecurityProtocolFactory : MessageSecurityProtocolFactory { SecurityTokenParameters securityTokenParameters; SessionDerivedKeySecurityTokenParameters derivedKeyTokenParameters; public SessionSymmetricMessageSecurityProtocolFactory() : base() { } public SecurityTokenParameters SecurityTokenParameters { get { return this.securityTokenParameters; } set { ThrowIfImmutable(); this.securityTokenParameters = value; } } public override EndpointIdentity GetIdentityOfSelf() { if (this.SecurityTokenManager is IEndpointIdentityProvider) { SecurityTokenRequirement requirement = CreateRecipientSecurityTokenRequirement(); this.SecurityTokenParameters.InitializeSecurityTokenRequirement(requirement); return ((IEndpointIdentityProvider)this.SecurityTokenManager).GetIdentityOfSelf(requirement); } else { return base.GetIdentityOfSelf(); } } protected override SecurityProtocol OnCreateSecurityProtocol(EndpointAddress target, Uri via, object listenerSecurityState, TimeSpan timeout) { if (this.ActAsInitiator) { return new InitiatorSessionSymmetricMessageSecurityProtocol(this, target, via); } else { return new AcceptorSessionSymmetricMessageSecurityProtocol(this, null); } } public override void OnOpen(TimeSpan timeout) { if (this.SecurityTokenParameters == null) { OnPropertySettingsError("SecurityTokenParameters", true); } if (this.SecurityTokenParameters.RequireDerivedKeys) { this.ExpectKeyDerivation = true; this.derivedKeyTokenParameters = new SessionDerivedKeySecurityTokenParameters(this.ActAsInitiator); } base.OnOpen(timeout); } internal SecurityTokenParameters GetTokenParameters() { if (this.derivedKeyTokenParameters != null) { return this.derivedKeyTokenParameters; } else { return this.securityTokenParameters; } } } internal class SessionDerivedKeySecurityTokenParameters : SecurityTokenParameters { bool actAsInitiator; protected SessionDerivedKeySecurityTokenParameters(SessionDerivedKeySecurityTokenParameters other) : base(other) { this.actAsInitiator = other.actAsInitiator; } public SessionDerivedKeySecurityTokenParameters(bool actAsInitiator) : base() { this.actAsInitiator = actAsInitiator; this.InclusionMode = actAsInitiator ? SecurityTokenInclusionMode.AlwaysToRecipient : SecurityTokenInclusionMode.AlwaysToInitiator; base.RequireDerivedKeys = false; } internal protected override bool SupportsClientAuthentication { get { return false; } } internal protected override bool SupportsServerAuthentication { get { return false; } } internal protected override bool SupportsClientWindowsIdentity { get { return false; } } internal protected override bool HasAsymmetricKey { get { return false; } } protected override SecurityTokenParameters CloneCore() { return new SessionDerivedKeySecurityTokenParameters(this); } internal protected override SecurityKeyIdentifierClause CreateKeyIdentifierClause(SecurityToken token, SecurityTokenReferenceStyle referenceStyle) { if (referenceStyle == SecurityTokenReferenceStyle.Internal) { return token.CreateKeyIdentifierClause(); } else { return null; } } internal protected override bool MatchesKeyIdentifierClause(SecurityToken token, SecurityKeyIdentifierClause keyIdentifierClause, SecurityTokenReferenceStyle referenceStyle) { if (referenceStyle == SecurityTokenReferenceStyle.Internal) { LocalIdKeyIdentifierClause localClause = keyIdentifierClause as LocalIdKeyIdentifierClause; if (localClause == null) { return false; } else { return (localClause.LocalId == token.Id); } } else { return false; } } protected internal override void InitializeSecurityTokenRequirement(SecurityTokenRequirement requirement) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException()); } } } // 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
- HelpInfo.cs
- ServiceModelEnumValidatorAttribute.cs
- BitmapEffectInput.cs
- UDPClient.cs
- FileNotFoundException.cs
- SqlConnectionString.cs
- RequestQueue.cs
- AsymmetricKeyExchangeFormatter.cs
- Vector3DValueSerializer.cs
- DesigntimeLicenseContext.cs
- ActivityExecutorDelegateInfo.cs
- InstanceHandleReference.cs
- xmlformatgeneratorstatics.cs
- MultilineStringConverter.cs
- WrappedReader.cs
- Size3D.cs
- BamlRecordReader.cs
- ComplexBindingPropertiesAttribute.cs
- FileSystemWatcher.cs
- COM2FontConverter.cs
- SmuggledIUnknown.cs
- ObjectDataSourceView.cs
- AssociationTypeEmitter.cs
- Converter.cs
- AppSettingsExpressionBuilder.cs
- ServiceBusyException.cs
- CollectionContainer.cs
- SoapServerProtocol.cs
- SendContent.cs
- TrueReadOnlyCollection.cs
- ToolboxItemCollection.cs
- DataGridColumn.cs
- MembershipValidatePasswordEventArgs.cs
- ASCIIEncoding.cs
- EventKeyword.cs
- CodeConstructor.cs
- exports.cs
- TextTreeTextElementNode.cs
- SchemaCollectionCompiler.cs
- ControlCachePolicy.cs
- XmlSchemaObjectTable.cs
- DataServices.cs
- SemanticValue.cs
- AuthorizationRuleCollection.cs
- ArraySortHelper.cs
- ItemsControl.cs
- SecurityHelper.cs
- CacheEntry.cs
- EventHandlersStore.cs
- MimeTypePropertyAttribute.cs
- util.cs
- PublisherIdentityPermission.cs
- RenderData.cs
- CustomAttributeBuilder.cs
- GCHandleCookieTable.cs
- DesignerToolStripControlHost.cs
- StickyNote.cs
- HtmlElementErrorEventArgs.cs
- DesignBindingPicker.cs
- AsyncPostBackTrigger.cs
- SourceCollection.cs
- __ComObject.cs
- RijndaelManagedTransform.cs
- AtomMaterializerLog.cs
- InvalidProgramException.cs
- XhtmlBasicSelectionListAdapter.cs
- parserscommon.cs
- DataGrid.cs
- CryptoKeySecurity.cs
- metadatamappinghashervisitor.cs
- XsltOutput.cs
- ConstructorExpr.cs
- Enum.cs
- LogicalExpr.cs
- Cursor.cs
- CriticalFinalizerObject.cs
- OdbcErrorCollection.cs
- HeaderedItemsControl.cs
- EnumerableCollectionView.cs
- SQLInt64.cs
- FunctionMappingTranslator.cs
- SequenceDesigner.cs
- PriorityChain.cs
- PreviewPrintController.cs
- DllNotFoundException.cs
- PropertyTabAttribute.cs
- DataSpaceManager.cs
- DotExpr.cs
- SystemFonts.cs
- SchemeSettingElementCollection.cs
- DataProtectionSecurityStateEncoder.cs
- Odbc32.cs
- Converter.cs
- ResourceIDHelper.cs
- AnonymousIdentificationSection.cs
- SponsorHelper.cs
- ComponentRenameEvent.cs
- StrokeCollection2.cs
- SerializerWriterEventHandlers.cs
- Compiler.cs