Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / IdentityModel / System / IdentityModel / Tokens / RsaKeyIdentifierClause.cs / 1 / RsaKeyIdentifierClause.cs
//------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------- namespace System.IdentityModel.Tokens { using System.Globalization; using System.Security.Cryptography; using System.Xml; public class RsaKeyIdentifierClause : SecurityKeyIdentifierClause { static string clauseType = XmlSignatureStrings.Namespace + XmlSignatureStrings.RsaKeyValue; readonly RSA rsa; readonly RSAParameters rsaParameters; RsaSecurityKey rsaSecurityKey; public RsaKeyIdentifierClause(RSA rsa) : base(clauseType) { if (rsa == null) throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("rsa"); this.rsa = rsa; this.rsaParameters = rsa.ExportParameters(false); } public override bool CanCreateKey { get { return true; } } public RSA Rsa { get { return this.rsa; } } public override SecurityKey CreateKey() { if (this.rsaSecurityKey == null) { this.rsaSecurityKey = new RsaSecurityKey(this.rsa); } return this.rsaSecurityKey; } public byte[] GetExponent() { return SecurityUtils.CloneBuffer(this.rsaParameters.Exponent); } public byte[] GetModulus() { return SecurityUtils.CloneBuffer(this.rsaParameters.Modulus); } public override bool Matches(SecurityKeyIdentifierClause keyIdentifierClause) { RsaKeyIdentifierClause that = keyIdentifierClause as RsaKeyIdentifierClause; // PreSharp Bug: Parameter 'that' to this public method must be validated: A null-dereference can occur here. #pragma warning suppress 56506 return ReferenceEquals(this, that) || (that != null && that.Matches(this.rsa)); } public bool Matches(RSA rsa) { if (rsa == null) return false; RSAParameters rsaParameters = rsa.ExportParameters(false); return SecurityUtils.MatchesBuffer(this.rsaParameters.Modulus, rsaParameters.Modulus) && SecurityUtils.MatchesBuffer(this.rsaParameters.Exponent, rsaParameters.Exponent); } public override string ToString() { return string.Format(CultureInfo.InvariantCulture, "RsaKeyIdentifierClause(Modulus = {0}, Exponent = {1})", Convert.ToBase64String(this.rsaParameters.Modulus), Convert.ToBase64String(this.rsaParameters.Exponent)); } public void WriteExponentAsBase64(XmlWriter writer) { if (writer == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("writer"); } writer.WriteBase64(this.rsaParameters.Exponent, 0, this.rsaParameters.Exponent.Length); } public void WriteModulusAsBase64(XmlWriter writer) { if (writer == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("writer"); } writer.WriteBase64(this.rsaParameters.Modulus, 0, this.rsaParameters.Modulus.Length); } } } // 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
- RemotingAttributes.cs
- SourceElementsCollection.cs
- BaseInfoTable.cs
- _ProxyChain.cs
- CalendarKeyboardHelper.cs
- OpacityConverter.cs
- HttpResponseBase.cs
- DataGridViewCellFormattingEventArgs.cs
- SymbolTable.cs
- ParagraphResult.cs
- XmlCustomFormatter.cs
- DataGridViewHeaderCell.cs
- SqlBuffer.cs
- XmlTextWriter.cs
- MessageQueueTransaction.cs
- Nodes.cs
- ClientSponsor.cs
- AnnotationAdorner.cs
- TextRunTypographyProperties.cs
- Helper.cs
- HtmlTextArea.cs
- TypeGeneratedEventArgs.cs
- DesignerDataColumn.cs
- FixedDocumentSequencePaginator.cs
- Cursor.cs
- ResourceAssociationSet.cs
- ICspAsymmetricAlgorithm.cs
- SerialStream.cs
- _MultipleConnectAsync.cs
- AutoResetEvent.cs
- IImplicitResourceProvider.cs
- SBCSCodePageEncoding.cs
- ToggleButton.cs
- PipelineModuleStepContainer.cs
- CodeTypeReferenceExpression.cs
- LinqDataSourceHelper.cs
- ExpandSegmentCollection.cs
- ConsoleTraceListener.cs
- AdvancedBindingEditor.cs
- RuntimeConfig.cs
- RegularExpressionValidator.cs
- PageParserFilter.cs
- ToolStripGrip.cs
- SafeRightsManagementEnvironmentHandle.cs
- BorderGapMaskConverter.cs
- ReadOnlyTernaryTree.cs
- AssemblyCache.cs
- DataGridItemEventArgs.cs
- TripleDESCryptoServiceProvider.cs
- XmlNamespaceDeclarationsAttribute.cs
- ThreadInterruptedException.cs
- WinInetCache.cs
- FormClosedEvent.cs
- EncryptedType.cs
- SubpageParagraph.cs
- ping.cs
- WpfWebRequestHelper.cs
- NavigatingCancelEventArgs.cs
- ConfigXmlAttribute.cs
- SizeAnimationBase.cs
- MenuItemAutomationPeer.cs
- ErasingStroke.cs
- XmlIlVisitor.cs
- HttpValueCollection.cs
- DEREncoding.cs
- AccessDataSource.cs
- Configuration.cs
- EncodingTable.cs
- ImpersonateTokenRef.cs
- ContentValidator.cs
- WebPartVerbCollection.cs
- ValueTable.cs
- COM2IPerPropertyBrowsingHandler.cs
- mactripleDES.cs
- WebPartConnectionsConfigureVerb.cs
- SortableBindingList.cs
- MissingMethodException.cs
- CategoryAttribute.cs
- PageThemeParser.cs
- XmlAnyElementAttributes.cs
- SyndicationSerializer.cs
- LinqDataSourceContextEventArgs.cs
- QilScopedVisitor.cs
- DataGridView.cs
- HtmlInputFile.cs
- ConfigLoader.cs
- NativeWindow.cs
- ZipIOCentralDirectoryFileHeader.cs
- _DigestClient.cs
- ValidatedMobileControlConverter.cs
- EditorAttributeInfo.cs
- TextWriter.cs
- ControlDesignerState.cs
- ResponseBodyWriter.cs
- DataSourceExpression.cs
- __ComObject.cs
- FixedDSBuilder.cs
- DropDownList.cs
- _RequestCacheProtocol.cs
- HtmlWindowCollection.cs