Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / WCF / IdentityModel / System / IdentityModel / EnvelopedSignatureTransform.cs / 1305376 / EnvelopedSignatureTransform.cs
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------
namespace System.IdentityModel
{
using System.Xml;
using System.Security.Cryptography;
sealed class EnvelopedSignatureTransform : Transform
{
string prefix = XmlSignatureStrings.Prefix;
public EnvelopedSignatureTransform()
{
}
public override string Algorithm
{
get { return XD.XmlSignatureDictionary.EnvelopedSignature.Value; }
}
public override object Process(object input, SignatureResourcePool resourcePool, DictionaryManager dictionaryManager)
{
XmlTokenStream tokenStream = input as XmlTokenStream;
if (tokenStream != null)
{
tokenStream.SetElementExclusion(XmlSignatureStrings.Signature, XmlSignatureStrings.Namespace);
return tokenStream;
}
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException(SR.GetString(SR.UnsupportedInputTypeForTransform, input.GetType())));
}
// this transform is not allowed as the last one in a chain
public override byte[] ProcessAndDigest(object input, SignatureResourcePool resourcePool, string digestAlgorithm, DictionaryManager dictionaryManager)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException(SR.GetString(SR.UnsupportedLastTransform)));
}
public override void ReadFrom(XmlDictionaryReader reader, DictionaryManager dictionaryManager)
{
reader.MoveToContent();
string algorithm = XmlHelper.ReadEmptyElementAndRequiredAttribute(reader,
dictionaryManager.XmlSignatureDictionary.Transform, dictionaryManager.XmlSignatureDictionary.Namespace, dictionaryManager.XmlSignatureDictionary.Algorithm, out this.prefix);
if (algorithm != this.Algorithm)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new CryptographicException(SR.GetString(SR.AlgorithmMismatchForTransform)));
}
}
public override void WriteTo(XmlDictionaryWriter writer, DictionaryManager dictionaryManager)
{
writer.WriteStartElement(this.prefix, dictionaryManager.XmlSignatureDictionary.Transform, dictionaryManager.XmlSignatureDictionary.Namespace);
writer.WriteAttributeString(dictionaryManager.XmlSignatureDictionary.Algorithm, null, this.Algorithm);
writer.WriteEndElement(); // Transform
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------
namespace System.IdentityModel
{
using System.Xml;
using System.Security.Cryptography;
sealed class EnvelopedSignatureTransform : Transform
{
string prefix = XmlSignatureStrings.Prefix;
public EnvelopedSignatureTransform()
{
}
public override string Algorithm
{
get { return XD.XmlSignatureDictionary.EnvelopedSignature.Value; }
}
public override object Process(object input, SignatureResourcePool resourcePool, DictionaryManager dictionaryManager)
{
XmlTokenStream tokenStream = input as XmlTokenStream;
if (tokenStream != null)
{
tokenStream.SetElementExclusion(XmlSignatureStrings.Signature, XmlSignatureStrings.Namespace);
return tokenStream;
}
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException(SR.GetString(SR.UnsupportedInputTypeForTransform, input.GetType())));
}
// this transform is not allowed as the last one in a chain
public override byte[] ProcessAndDigest(object input, SignatureResourcePool resourcePool, string digestAlgorithm, DictionaryManager dictionaryManager)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException(SR.GetString(SR.UnsupportedLastTransform)));
}
public override void ReadFrom(XmlDictionaryReader reader, DictionaryManager dictionaryManager)
{
reader.MoveToContent();
string algorithm = XmlHelper.ReadEmptyElementAndRequiredAttribute(reader,
dictionaryManager.XmlSignatureDictionary.Transform, dictionaryManager.XmlSignatureDictionary.Namespace, dictionaryManager.XmlSignatureDictionary.Algorithm, out this.prefix);
if (algorithm != this.Algorithm)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new CryptographicException(SR.GetString(SR.AlgorithmMismatchForTransform)));
}
}
public override void WriteTo(XmlDictionaryWriter writer, DictionaryManager dictionaryManager)
{
writer.WriteStartElement(this.prefix, dictionaryManager.XmlSignatureDictionary.Transform, dictionaryManager.XmlSignatureDictionary.Namespace);
writer.WriteAttributeString(dictionaryManager.XmlSignatureDictionary.Algorithm, null, this.Algorithm);
writer.WriteEndElement(); // Transform
}
}
}
// 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
- PerfService.cs
- ScrollProperties.cs
- PrintPreviewDialog.cs
- DataColumnPropertyDescriptor.cs
- contentDescriptor.cs
- TiffBitmapDecoder.cs
- Number.cs
- SqlConnectionString.cs
- BitHelper.cs
- MsmqReceiveHelper.cs
- Encoding.cs
- DBCSCodePageEncoding.cs
- XPathAxisIterator.cs
- EnterpriseServicesHelper.cs
- DispatcherTimer.cs
- TrackingValidationObjectDictionary.cs
- HtmlInputRadioButton.cs
- EventlogProvider.cs
- WsdlHelpGeneratorElement.cs
- ComponentResourceKeyConverter.cs
- ReliableSessionBindingElement.cs
- XmlNavigatorFilter.cs
- ReferencedAssembly.cs
- ObjectAnimationBase.cs
- ObjectQuery.cs
- ByteStream.cs
- DecimalKeyFrameCollection.cs
- InProcStateClientManager.cs
- PropertyPathConverter.cs
- CodeTypeReference.cs
- WmlLiteralTextAdapter.cs
- HttpWebRequest.cs
- PaperSize.cs
- ToolStripDropDownClosingEventArgs.cs
- IpcServerChannel.cs
- VariableDesigner.xaml.cs
- sqlstateclientmanager.cs
- Thickness.cs
- ValueOfAction.cs
- EntitySetBase.cs
- ProcessHostMapPath.cs
- SemanticResolver.cs
- ValueProviderWrapper.cs
- BitmapEffectGroup.cs
- VectorCollection.cs
- UntypedNullExpression.cs
- ContextQuery.cs
- TextFormatterHost.cs
- SmtpMail.cs
- MasterPageCodeDomTreeGenerator.cs
- EntityTypeEmitter.cs
- SemanticKeyElement.cs
- ZipIORawDataFileBlock.cs
- SmuggledIUnknown.cs
- AnonymousIdentificationSection.cs
- TextTreeFixupNode.cs
- TreeNodeSelectionProcessor.cs
- ColorMatrix.cs
- JobStaple.cs
- SqlColumnizer.cs
- SelectionRange.cs
- ChangeConflicts.cs
- Size.cs
- lengthconverter.cs
- RotateTransform.cs
- DoubleAnimationClockResource.cs
- TableRow.cs
- MenuTracker.cs
- ControlParameter.cs
- DataGridViewRowsAddedEventArgs.cs
- DataGrid.cs
- URLString.cs
- SecurityIdentifierElementCollection.cs
- OperationInvokerTrace.cs
- WebPartConnectionsCancelEventArgs.cs
- JoinSymbol.cs
- CorrelationKey.cs
- TagPrefixCollection.cs
- DateTimeFormatInfoScanner.cs
- SingleStorage.cs
- Variable.cs
- ClientSettings.cs
- BuilderPropertyEntry.cs
- WorkflowWebHostingModule.cs
- DataSourceCache.cs
- Root.cs
- ToolBarTray.cs
- ResourceWriter.cs
- PixelFormats.cs
- PersonalizationEntry.cs
- CodeDOMUtility.cs
- AdornerDecorator.cs
- DataGridViewLinkColumn.cs
- ReachDocumentReferenceCollectionSerializerAsync.cs
- XmlDataSourceDesigner.cs
- JsonCollectionDataContract.cs
- SamlAssertion.cs
- ListViewItemSelectionChangedEvent.cs
- odbcmetadatafactory.cs
- GraphicsPath.cs