Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / WCF / IdentityModel / System / IdentityModel / Selectors / SecurityTokenSerializer.cs / 1305376 / SecurityTokenSerializer.cs
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------
namespace System.IdentityModel.Selectors
{
using System.Xml;
using System.IdentityModel.Tokens;
///
/// SecurityTokenSerializer is responsible for writing and reading SecurityKeyIdentifiers, SecurityKeyIdentifierClauses and SecurityTokens.
/// In order to read SecurityTokens the SecurityTokenSerializer may need to resolve token references using the SecurityTokenResolvers that get passed in.
/// The SecurityTokenSerializer is stateless
/// Exceptions: XmlException, SecurityTokenException, NotSupportedException, InvalidOperationException, ArgumentException
///
public abstract class SecurityTokenSerializer
{
// public methods
public bool CanReadToken(XmlReader reader)
{
if (reader == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("reader");
}
return CanReadTokenCore(reader); ;
}
public bool CanWriteToken(SecurityToken token)
{
if (token == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("token");
}
return CanWriteTokenCore(token); ;
}
public bool CanReadKeyIdentifier(XmlReader reader)
{
if (reader == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("reader");
}
return CanReadKeyIdentifierCore(reader); ;
}
public bool CanWriteKeyIdentifier(SecurityKeyIdentifier keyIdentifier)
{
if (keyIdentifier == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("keyIdentifier");
}
return CanWriteKeyIdentifierCore(keyIdentifier); ;
}
public bool CanReadKeyIdentifierClause(XmlReader reader)
{
if (reader == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("reader");
}
return CanReadKeyIdentifierClauseCore(reader); ;
}
public bool CanWriteKeyIdentifierClause(SecurityKeyIdentifierClause keyIdentifierClause)
{
if (keyIdentifierClause == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("keyIdentifierClause");
}
return CanWriteKeyIdentifierClauseCore(keyIdentifierClause); ;
}
public SecurityToken ReadToken(XmlReader reader, SecurityTokenResolver tokenResolver)
{
if (reader == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("reader");
}
return ReadTokenCore(reader, tokenResolver);
}
public void WriteToken(XmlWriter writer, SecurityToken token)
{
if (writer == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("writer");
}
if (token == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("token");
}
WriteTokenCore(writer, token);
}
public SecurityKeyIdentifier ReadKeyIdentifier(XmlReader reader)
{
if (reader == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("reader");
}
return ReadKeyIdentifierCore(reader);
}
public void WriteKeyIdentifier(XmlWriter writer, SecurityKeyIdentifier keyIdentifier)
{
if (writer == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("writer");
}
if (keyIdentifier == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("keyIdentifier");
}
WriteKeyIdentifierCore(writer, keyIdentifier);
}
public SecurityKeyIdentifierClause ReadKeyIdentifierClause(XmlReader reader)
{
if (reader == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("reader");
}
return ReadKeyIdentifierClauseCore(reader);
}
public void WriteKeyIdentifierClause(XmlWriter writer, SecurityKeyIdentifierClause keyIdentifierClause)
{
if (writer == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("writer");
}
if (keyIdentifierClause == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("keyIdentifierClause");
}
WriteKeyIdentifierClauseCore(writer, keyIdentifierClause);
}
// protected abstract methods
protected abstract bool CanReadTokenCore(XmlReader reader);
protected abstract bool CanWriteTokenCore(SecurityToken token);
protected abstract bool CanReadKeyIdentifierCore(XmlReader reader);
protected abstract bool CanWriteKeyIdentifierCore(SecurityKeyIdentifier keyIdentifier);
protected abstract bool CanReadKeyIdentifierClauseCore(XmlReader reader);
protected abstract bool CanWriteKeyIdentifierClauseCore(SecurityKeyIdentifierClause keyIdentifierClause);
protected abstract SecurityToken ReadTokenCore(XmlReader reader, SecurityTokenResolver tokenResolver);
protected abstract void WriteTokenCore(XmlWriter writer, SecurityToken token);
protected abstract SecurityKeyIdentifier ReadKeyIdentifierCore(XmlReader reader);
protected abstract void WriteKeyIdentifierCore(XmlWriter writer, SecurityKeyIdentifier keyIdentifier);
protected abstract SecurityKeyIdentifierClause ReadKeyIdentifierClauseCore(XmlReader reader);
protected abstract void WriteKeyIdentifierClauseCore(XmlWriter writer, SecurityKeyIdentifierClause keyIdentifierClause);
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------
namespace System.IdentityModel.Selectors
{
using System.Xml;
using System.IdentityModel.Tokens;
///
/// SecurityTokenSerializer is responsible for writing and reading SecurityKeyIdentifiers, SecurityKeyIdentifierClauses and SecurityTokens.
/// In order to read SecurityTokens the SecurityTokenSerializer may need to resolve token references using the SecurityTokenResolvers that get passed in.
/// The SecurityTokenSerializer is stateless
/// Exceptions: XmlException, SecurityTokenException, NotSupportedException, InvalidOperationException, ArgumentException
///
public abstract class SecurityTokenSerializer
{
// public methods
public bool CanReadToken(XmlReader reader)
{
if (reader == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("reader");
}
return CanReadTokenCore(reader); ;
}
public bool CanWriteToken(SecurityToken token)
{
if (token == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("token");
}
return CanWriteTokenCore(token); ;
}
public bool CanReadKeyIdentifier(XmlReader reader)
{
if (reader == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("reader");
}
return CanReadKeyIdentifierCore(reader); ;
}
public bool CanWriteKeyIdentifier(SecurityKeyIdentifier keyIdentifier)
{
if (keyIdentifier == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("keyIdentifier");
}
return CanWriteKeyIdentifierCore(keyIdentifier); ;
}
public bool CanReadKeyIdentifierClause(XmlReader reader)
{
if (reader == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("reader");
}
return CanReadKeyIdentifierClauseCore(reader); ;
}
public bool CanWriteKeyIdentifierClause(SecurityKeyIdentifierClause keyIdentifierClause)
{
if (keyIdentifierClause == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("keyIdentifierClause");
}
return CanWriteKeyIdentifierClauseCore(keyIdentifierClause); ;
}
public SecurityToken ReadToken(XmlReader reader, SecurityTokenResolver tokenResolver)
{
if (reader == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("reader");
}
return ReadTokenCore(reader, tokenResolver);
}
public void WriteToken(XmlWriter writer, SecurityToken token)
{
if (writer == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("writer");
}
if (token == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("token");
}
WriteTokenCore(writer, token);
}
public SecurityKeyIdentifier ReadKeyIdentifier(XmlReader reader)
{
if (reader == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("reader");
}
return ReadKeyIdentifierCore(reader);
}
public void WriteKeyIdentifier(XmlWriter writer, SecurityKeyIdentifier keyIdentifier)
{
if (writer == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("writer");
}
if (keyIdentifier == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("keyIdentifier");
}
WriteKeyIdentifierCore(writer, keyIdentifier);
}
public SecurityKeyIdentifierClause ReadKeyIdentifierClause(XmlReader reader)
{
if (reader == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("reader");
}
return ReadKeyIdentifierClauseCore(reader);
}
public void WriteKeyIdentifierClause(XmlWriter writer, SecurityKeyIdentifierClause keyIdentifierClause)
{
if (writer == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("writer");
}
if (keyIdentifierClause == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("keyIdentifierClause");
}
WriteKeyIdentifierClauseCore(writer, keyIdentifierClause);
}
// protected abstract methods
protected abstract bool CanReadTokenCore(XmlReader reader);
protected abstract bool CanWriteTokenCore(SecurityToken token);
protected abstract bool CanReadKeyIdentifierCore(XmlReader reader);
protected abstract bool CanWriteKeyIdentifierCore(SecurityKeyIdentifier keyIdentifier);
protected abstract bool CanReadKeyIdentifierClauseCore(XmlReader reader);
protected abstract bool CanWriteKeyIdentifierClauseCore(SecurityKeyIdentifierClause keyIdentifierClause);
protected abstract SecurityToken ReadTokenCore(XmlReader reader, SecurityTokenResolver tokenResolver);
protected abstract void WriteTokenCore(XmlWriter writer, SecurityToken token);
protected abstract SecurityKeyIdentifier ReadKeyIdentifierCore(XmlReader reader);
protected abstract void WriteKeyIdentifierCore(XmlWriter writer, SecurityKeyIdentifier keyIdentifier);
protected abstract SecurityKeyIdentifierClause ReadKeyIdentifierClauseCore(XmlReader reader);
protected abstract void WriteKeyIdentifierClauseCore(XmlWriter writer, SecurityKeyIdentifierClause keyIdentifierClause);
}
}
// 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
- webproxy.cs
- BypassElement.cs
- TextFragmentEngine.cs
- Storyboard.cs
- ItemChangedEventArgs.cs
- XmlStreamStore.cs
- IODescriptionAttribute.cs
- AssemblyContextControlItem.cs
- EtwTrackingParticipant.cs
- ConfigurationConverterBase.cs
- XPathConvert.cs
- DataAdapter.cs
- OleDbWrapper.cs
- ClientScriptManagerWrapper.cs
- TableStyle.cs
- ViewService.cs
- Symbol.cs
- TextBounds.cs
- OleDbDataAdapter.cs
- AsmxEndpointPickerExtension.cs
- ColumnPropertiesGroup.cs
- MenuItem.cs
- CodePageUtils.cs
- EntityTypeEmitter.cs
- EntityDataSourceWrapperCollection.cs
- Viewport3DVisual.cs
- CodeDelegateInvokeExpression.cs
- HideDisabledControlAdapter.cs
- ADMembershipProvider.cs
- ExcCanonicalXml.cs
- DataGridTextBox.cs
- HwndTarget.cs
- ParentUndoUnit.cs
- ReachUIElementCollectionSerializerAsync.cs
- ComponentChangingEvent.cs
- QilChoice.cs
- TextEffect.cs
- WebPartConnection.cs
- SByte.cs
- RoleProviderPrincipal.cs
- RowParagraph.cs
- HwndStylusInputProvider.cs
- UIElement3D.cs
- WindowsHyperlink.cs
- BeginStoryboard.cs
- JsonEnumDataContract.cs
- ImmComposition.cs
- FontStretches.cs
- DataMemberFieldEditor.cs
- BinaryFormatter.cs
- ContextQuery.cs
- GroupDescription.cs
- ThemeDirectoryCompiler.cs
- VisualBasicValue.cs
- SkewTransform.cs
- QueryRewriter.cs
- HtmlTableCell.cs
- FileDataSourceCache.cs
- DEREncoding.cs
- IntSecurity.cs
- COAUTHINFO.cs
- FormsAuthenticationCredentials.cs
- TabControlDesigner.cs
- DataServiceClientException.cs
- LiteralText.cs
- MenuCommands.cs
- CounterSampleCalculator.cs
- Point4DValueSerializer.cs
- FormViewPageEventArgs.cs
- PathFigureCollectionConverter.cs
- Span.cs
- ConfigurationStrings.cs
- ServiceDescriptionReflector.cs
- NativeMethodsCLR.cs
- QilUnary.cs
- MultiBinding.cs
- ContainerParaClient.cs
- SqlClientMetaDataCollectionNames.cs
- PersistenceProvider.cs
- EntityDataSourceMemberPath.cs
- CompileXomlTask.cs
- TreeView.cs
- QilDataSource.cs
- TextEditorDragDrop.cs
- ManagementObjectSearcher.cs
- MaskedTextBox.cs
- SystemIPv4InterfaceProperties.cs
- WebPartMenuStyle.cs
- MenuItemCollection.cs
- PersonalizationStateInfoCollection.cs
- TimeEnumHelper.cs
- NetDataContractSerializer.cs
- OleDbWrapper.cs
- SystemNetworkInterface.cs
- CollectionEditorDialog.cs
- XmlNamespaceMapping.cs
- ProxyHwnd.cs
- LabelEditEvent.cs
- SiteMapNodeItem.cs
- RoleServiceManager.cs