Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / WCF / IdentityModel / System / IdentityModel / Selectors / SecurityTokenRequirement.cs / 1305376 / SecurityTokenRequirement.cs
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------
namespace System.IdentityModel.Selectors
{
using System.Globalization;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.IdentityModel.Tokens;
public class SecurityTokenRequirement
{
const string Namespace = "http://schemas.microsoft.com/ws/2006/05/identitymodel/securitytokenrequirement";
const string tokenTypeProperty = Namespace + "/TokenType";
const string keyUsageProperty = Namespace + "/KeyUsage";
const string keyTypeProperty = Namespace + "/KeyType";
const string keySizeProperty = Namespace + "/KeySize";
const string requireCryptographicTokenProperty = Namespace + "/RequireCryptographicToken";
const string peerAuthenticationMode = Namespace + "/PeerAuthenticationMode";
const bool defaultRequireCryptographicToken = false;
const SecurityKeyUsage defaultKeyUsage = SecurityKeyUsage.Signature;
const SecurityKeyType defaultKeyType = SecurityKeyType.SymmetricKey;
const int defaultKeySize = 0;
Dictionary properties;
public SecurityTokenRequirement()
{
properties = new Dictionary();
this.Initialize();
}
static public string TokenTypeProperty { get { return tokenTypeProperty; } }
static public string KeyUsageProperty { get { return keyUsageProperty; } }
static public string KeyTypeProperty { get { return keyTypeProperty; } }
static public string KeySizeProperty { get { return keySizeProperty; } }
static public string RequireCryptographicTokenProperty { get { return requireCryptographicTokenProperty; } }
static public string PeerAuthenticationMode { get { return peerAuthenticationMode; } }
public string TokenType
{
get
{
string result;
return (this.TryGetProperty(TokenTypeProperty, out result)) ? result : null;
}
set
{
this.properties[TokenTypeProperty] = value;
}
}
public bool RequireCryptographicToken
{
get
{
bool result;
return (this.TryGetProperty(RequireCryptographicTokenProperty, out result)) ? result : defaultRequireCryptographicToken;
}
set
{
this.properties[RequireCryptographicTokenProperty] = (object)value;
}
}
public SecurityKeyUsage KeyUsage
{
get
{
SecurityKeyUsage result;
return (this.TryGetProperty(KeyUsageProperty, out result)) ? result : defaultKeyUsage;
}
set
{
SecurityKeyUsageHelper.Validate(value);
this.properties[KeyUsageProperty] = (object)value;
}
}
public SecurityKeyType KeyType
{
get
{
SecurityKeyType result;
return (this.TryGetProperty(KeyTypeProperty, out result)) ? result : defaultKeyType;
}
set
{
SecurityKeyTypeHelper.Validate(value);
this.properties[KeyTypeProperty] = (object)value;
}
}
public int KeySize
{
get
{
int result;
return (this.TryGetProperty(KeySizeProperty, out result)) ? result : defaultKeySize;
}
set
{
if (value < 0)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("value", SR.GetString(SR.ValueMustBeNonNegative)));
}
this.Properties[KeySizeProperty] = value;
}
}
public IDictionary Properties
{
get
{
return this.properties;
}
}
void Initialize()
{
this.KeyType = defaultKeyType;
this.KeyUsage = defaultKeyUsage;
this.RequireCryptographicToken = defaultRequireCryptographicToken;
this.KeySize = defaultKeySize;
}
public TValue GetProperty(string propertyName)
{
TValue result;
if (!TryGetProperty(propertyName, out result))
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.GetString(SR.SecurityTokenRequirementDoesNotContainProperty, propertyName)));
}
return result;
}
public bool TryGetProperty(string propertyName, out TValue result)
{
object dictionaryValue;
if (!Properties.TryGetValue(propertyName, out dictionaryValue))
{
result = default(TValue);
return false;
}
if (dictionaryValue != null && !typeof(TValue).IsAssignableFrom(dictionaryValue.GetType()))
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.GetString(SR.SecurityTokenRequirementHasInvalidTypeForProperty, propertyName, dictionaryValue.GetType(), typeof(TValue))));
}
result = (TValue)dictionaryValue;
return true;
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------
namespace System.IdentityModel.Selectors
{
using System.Globalization;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.IdentityModel.Tokens;
public class SecurityTokenRequirement
{
const string Namespace = "http://schemas.microsoft.com/ws/2006/05/identitymodel/securitytokenrequirement";
const string tokenTypeProperty = Namespace + "/TokenType";
const string keyUsageProperty = Namespace + "/KeyUsage";
const string keyTypeProperty = Namespace + "/KeyType";
const string keySizeProperty = Namespace + "/KeySize";
const string requireCryptographicTokenProperty = Namespace + "/RequireCryptographicToken";
const string peerAuthenticationMode = Namespace + "/PeerAuthenticationMode";
const bool defaultRequireCryptographicToken = false;
const SecurityKeyUsage defaultKeyUsage = SecurityKeyUsage.Signature;
const SecurityKeyType defaultKeyType = SecurityKeyType.SymmetricKey;
const int defaultKeySize = 0;
Dictionary properties;
public SecurityTokenRequirement()
{
properties = new Dictionary();
this.Initialize();
}
static public string TokenTypeProperty { get { return tokenTypeProperty; } }
static public string KeyUsageProperty { get { return keyUsageProperty; } }
static public string KeyTypeProperty { get { return keyTypeProperty; } }
static public string KeySizeProperty { get { return keySizeProperty; } }
static public string RequireCryptographicTokenProperty { get { return requireCryptographicTokenProperty; } }
static public string PeerAuthenticationMode { get { return peerAuthenticationMode; } }
public string TokenType
{
get
{
string result;
return (this.TryGetProperty(TokenTypeProperty, out result)) ? result : null;
}
set
{
this.properties[TokenTypeProperty] = value;
}
}
public bool RequireCryptographicToken
{
get
{
bool result;
return (this.TryGetProperty(RequireCryptographicTokenProperty, out result)) ? result : defaultRequireCryptographicToken;
}
set
{
this.properties[RequireCryptographicTokenProperty] = (object)value;
}
}
public SecurityKeyUsage KeyUsage
{
get
{
SecurityKeyUsage result;
return (this.TryGetProperty(KeyUsageProperty, out result)) ? result : defaultKeyUsage;
}
set
{
SecurityKeyUsageHelper.Validate(value);
this.properties[KeyUsageProperty] = (object)value;
}
}
public SecurityKeyType KeyType
{
get
{
SecurityKeyType result;
return (this.TryGetProperty(KeyTypeProperty, out result)) ? result : defaultKeyType;
}
set
{
SecurityKeyTypeHelper.Validate(value);
this.properties[KeyTypeProperty] = (object)value;
}
}
public int KeySize
{
get
{
int result;
return (this.TryGetProperty(KeySizeProperty, out result)) ? result : defaultKeySize;
}
set
{
if (value < 0)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("value", SR.GetString(SR.ValueMustBeNonNegative)));
}
this.Properties[KeySizeProperty] = value;
}
}
public IDictionary Properties
{
get
{
return this.properties;
}
}
void Initialize()
{
this.KeyType = defaultKeyType;
this.KeyUsage = defaultKeyUsage;
this.RequireCryptographicToken = defaultRequireCryptographicToken;
this.KeySize = defaultKeySize;
}
public TValue GetProperty(string propertyName)
{
TValue result;
if (!TryGetProperty(propertyName, out result))
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.GetString(SR.SecurityTokenRequirementDoesNotContainProperty, propertyName)));
}
return result;
}
public bool TryGetProperty(string propertyName, out TValue result)
{
object dictionaryValue;
if (!Properties.TryGetValue(propertyName, out dictionaryValue))
{
result = default(TValue);
return false;
}
if (dictionaryValue != null && !typeof(TValue).IsAssignableFrom(dictionaryValue.GetType()))
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.GetString(SR.SecurityTokenRequirementHasInvalidTypeForProperty, propertyName, dictionaryValue.GetType(), typeof(TValue))));
}
result = (TValue)dictionaryValue;
return true;
}
}
}
// 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
- StructuredCompositeActivityDesigner.cs
- InfoCardSchemas.cs
- SystemInformation.cs
- CompilerState.cs
- PowerModeChangedEventArgs.cs
- PointCollection.cs
- Rfc2898DeriveBytes.cs
- Journaling.cs
- LabelDesigner.cs
- FactoryRecord.cs
- DynamicActionMessageFilter.cs
- Pen.cs
- MemberMaps.cs
- ResourceContainerWrapper.cs
- HttpPostedFileWrapper.cs
- ObjectListItemCollection.cs
- NullableDoubleMinMaxAggregationOperator.cs
- BaseValidatorDesigner.cs
- VerificationAttribute.cs
- ConnectionStringsSection.cs
- ConnectionPoolManager.cs
- Scripts.cs
- WrappedIUnknown.cs
- TagNameToTypeMapper.cs
- EnumValAlphaComparer.cs
- MetadataSerializer.cs
- ZipIORawDataFileBlock.cs
- WebPartDisplayMode.cs
- HwndAppCommandInputProvider.cs
- ToolStripPanelRow.cs
- ConsoleKeyInfo.cs
- SystemWebSectionGroup.cs
- KeyToListMap.cs
- FormatException.cs
- LogReservationCollection.cs
- CheckPair.cs
- TypeForwardedToAttribute.cs
- DocumentApplicationJournalEntry.cs
- DesignerSerializationVisibilityAttribute.cs
- HtmlInputFile.cs
- ImageKeyConverter.cs
- SerializerProvider.cs
- Camera.cs
- ApplicationManager.cs
- Binding.cs
- BufferedResponseStream.cs
- SynchronizationLockException.cs
- DataGridColumnHeaderAutomationPeer.cs
- QueryGeneratorBase.cs
- XmlSortKeyAccumulator.cs
- DetailsViewDeletedEventArgs.cs
- RequestNavigateEventArgs.cs
- TransactionBridgeSection.cs
- WebPartConnectionsConfigureVerb.cs
- XslCompiledTransform.cs
- ActivationWorker.cs
- BuildProvider.cs
- ToolStripRendererSwitcher.cs
- HitTestParameters3D.cs
- Environment.cs
- Module.cs
- SchemaHelper.cs
- ClientBuildManagerCallback.cs
- WebSysDefaultValueAttribute.cs
- ADConnectionHelper.cs
- DictionaryManager.cs
- OSFeature.cs
- FixedNode.cs
- Formatter.cs
- OracleNumber.cs
- CharKeyFrameCollection.cs
- CodeDomSerializerException.cs
- ContentOnlyMessage.cs
- LinkLabel.cs
- LinearQuaternionKeyFrame.cs
- COMException.cs
- Compiler.cs
- ObjectHandle.cs
- SHA512.cs
- HwndSubclass.cs
- ConstraintEnumerator.cs
- WebBrowser.cs
- PerformanceCounterManager.cs
- OutputCacheSettings.cs
- StackSpiller.Bindings.cs
- FloaterBaseParagraph.cs
- HandleCollector.cs
- RequestNavigateEventArgs.cs
- CodeTypeOfExpression.cs
- ObjectDataSourceStatusEventArgs.cs
- DoubleLinkListEnumerator.cs
- RoleGroupCollectionEditor.cs
- HtmlTableCellCollection.cs
- TreeWalkHelper.cs
- ComplexBindingPropertiesAttribute.cs
- IntranetCredentialPolicy.cs
- ImageDesigner.cs
- CqlParserHelpers.cs
- latinshape.cs
- UMPAttributes.cs