Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / Security / Tokens / X509SecurityTokenParameters.cs / 1 / X509SecurityTokenParameters.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.ServiceModel.Security.Tokens { using System.IdentityModel.Tokens; using System.ServiceModel; using System.IdentityModel.Selectors; using System.ServiceModel.Security; using System.Text; using System.Globalization; public class X509SecurityTokenParameters : SecurityTokenParameters { internal const X509KeyIdentifierClauseType defaultX509ReferenceStyle = X509KeyIdentifierClauseType.Any; X509KeyIdentifierClauseType x509ReferenceStyle; protected X509SecurityTokenParameters(X509SecurityTokenParameters other) : base(other) { this.x509ReferenceStyle = other.x509ReferenceStyle; } public X509SecurityTokenParameters() : this(X509SecurityTokenParameters.defaultX509ReferenceStyle, SecurityTokenParameters.defaultInclusionMode) { // empty } public X509SecurityTokenParameters(X509KeyIdentifierClauseType x509ReferenceStyle) : this(x509ReferenceStyle, SecurityTokenParameters.defaultInclusionMode) { // empty } public X509SecurityTokenParameters(X509KeyIdentifierClauseType x509ReferenceStyle, SecurityTokenInclusionMode inclusionMode) : this(x509ReferenceStyle, inclusionMode, SecurityTokenParameters.defaultRequireDerivedKeys) { } internal X509SecurityTokenParameters(X509KeyIdentifierClauseType x509ReferenceStyle, SecurityTokenInclusionMode inclusionMode, bool requireDerivedKeys) : base() { this.X509ReferenceStyle = x509ReferenceStyle; this.InclusionMode = inclusionMode; this.RequireDerivedKeys = requireDerivedKeys; } internal protected override bool HasAsymmetricKey { get { return true; } } public X509KeyIdentifierClauseType X509ReferenceStyle { get { return this.x509ReferenceStyle; } set { X509SecurityTokenReferenceStyleHelper.Validate(value); this.x509ReferenceStyle = value; } } internal protected override bool SupportsClientAuthentication { get { return true; } } internal protected override bool SupportsServerAuthentication { get { return true; } } internal protected override bool SupportsClientWindowsIdentity { get { return true; } } protected override SecurityTokenParameters CloneCore() { return new X509SecurityTokenParameters(this); } internal protected override SecurityKeyIdentifierClause CreateKeyIdentifierClause(SecurityToken token, SecurityTokenReferenceStyle referenceStyle) { SecurityKeyIdentifierClause result = null; switch (this.x509ReferenceStyle) { default: case X509KeyIdentifierClauseType.Any: if (referenceStyle == SecurityTokenReferenceStyle.External) { X509SecurityToken x509Token = token as X509SecurityToken; if (x509Token != null) { X509SubjectKeyIdentifierClause x509KeyIdentifierClause; if (X509SubjectKeyIdentifierClause.TryCreateFrom(x509Token.Certificate, out x509KeyIdentifierClause)) { result = x509KeyIdentifierClause; } } else { X509WindowsSecurityToken windowsX509Token = token as X509WindowsSecurityToken; if (windowsX509Token != null) { X509SubjectKeyIdentifierClause x509KeyIdentifierClause; if (X509SubjectKeyIdentifierClause.TryCreateFrom(windowsX509Token.Certificate, out x509KeyIdentifierClause)) { result = x509KeyIdentifierClause; } } } if (result == null) result = token.CreateKeyIdentifierClause(); if (result == null) result = token.CreateKeyIdentifierClause (); } else result = token.CreateKeyIdentifierClause (); break; case X509KeyIdentifierClauseType.Thumbprint: result = this.CreateKeyIdentifierClause (token, referenceStyle); break; case X509KeyIdentifierClauseType.SubjectKeyIdentifier: result = this.CreateKeyIdentifierClause (token, referenceStyle); break; case X509KeyIdentifierClauseType.IssuerSerial: result = this.CreateKeyIdentifierClause (token, referenceStyle); break; case X509KeyIdentifierClauseType.RawDataKeyIdentifier: result = this.CreateKeyIdentifierClause (token, referenceStyle); break; } return result; } protected internal override void InitializeSecurityTokenRequirement(SecurityTokenRequirement requirement) { requirement.TokenType = SecurityTokenTypes.X509Certificate; requirement.RequireCryptographicToken = true; requirement.KeyType = SecurityKeyType.AsymmetricKey; } public override string ToString() { StringBuilder sb = new StringBuilder(); sb.AppendLine(base.ToString()); sb.Append(String.Format(CultureInfo.InvariantCulture, "X509ReferenceStyle: {0}", this.x509ReferenceStyle.ToString())); return sb.ToString(); } } } // 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
- UnaryNode.cs
- SHA384Managed.cs
- LocalIdCollection.cs
- WorkflowMessageEventHandler.cs
- OleServicesContext.cs
- QueryOutputWriter.cs
- ServicePointManagerElement.cs
- TitleStyle.cs
- IncrementalHitTester.cs
- PassportIdentity.cs
- List.cs
- ProfessionalColorTable.cs
- IChannel.cs
- LocalizableAttribute.cs
- PropertyCondition.cs
- RawStylusInput.cs
- TableParaClient.cs
- DynamicPropertyReader.cs
- CodeSubDirectory.cs
- AuthenticationModuleElementCollection.cs
- CodeDOMProvider.cs
- CollectionBuilder.cs
- FixedSOMContainer.cs
- SqlParameterCollection.cs
- DocumentGrid.cs
- DesignerView.xaml.cs
- EdmEntityTypeAttribute.cs
- Mutex.cs
- EventListener.cs
- DispatcherExceptionFilterEventArgs.cs
- VolatileEnlistmentState.cs
- AutoScrollExpandMessageFilter.cs
- BoundField.cs
- LocatorPart.cs
- FontFamilyConverter.cs
- ResXResourceWriter.cs
- errorpatternmatcher.cs
- XmlStreamNodeWriter.cs
- CodeExpressionRuleDeclaration.cs
- GPPOINT.cs
- BindingsCollection.cs
- SafeLibraryHandle.cs
- COMException.cs
- StringUtil.cs
- StoragePropertyMapping.cs
- COM2PropertyBuilderUITypeEditor.cs
- SQLGuid.cs
- Privilege.cs
- XmlBoundElement.cs
- ColorMap.cs
- OpCopier.cs
- ICollection.cs
- StringHelper.cs
- Comparer.cs
- TripleDESCryptoServiceProvider.cs
- PointLightBase.cs
- ConfigXmlCDataSection.cs
- _ContextAwareResult.cs
- UiaCoreApi.cs
- CompilerTypeWithParams.cs
- wgx_exports.cs
- XmlSchemaExternal.cs
- OptimalTextSource.cs
- ManagementException.cs
- ImageMapEventArgs.cs
- LinqDataSourceStatusEventArgs.cs
- SoapAttributes.cs
- WeakReference.cs
- X509CertificateStore.cs
- StringConverter.cs
- TextEndOfSegment.cs
- ProxyWebPartManager.cs
- sqlnorm.cs
- BaseProcessProtocolHandler.cs
- Drawing.cs
- BackStopAuthenticationModule.cs
- RawStylusActions.cs
- DSACryptoServiceProvider.cs
- TreeView.cs
- BinaryObjectWriter.cs
- TempFiles.cs
- Single.cs
- streamingZipPartStream.cs
- RemotingConfigParser.cs
- MessageVersion.cs
- dataprotectionpermissionattribute.cs
- PrefixQName.cs
- Visual3D.cs
- DataBindEngine.cs
- ObjRef.cs
- XmlUtil.cs
- RoleGroupCollection.cs
- Material.cs
- PenThreadPool.cs
- Substitution.cs
- NativeMethods.cs
- AssertSection.cs
- JoinQueryOperator.cs
- DynamicContractTypeBuilder.cs
- XmlSchemaExternal.cs