Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / clr / src / BCL / System / Security / Policy / FirstMatchCodeGroup.cs / 1 / FirstMatchCodeGroup.cs
// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== // FirstMatchCodeGroup.cs // // Representation for code groups used for the policy mechanism // namespace System.Security.Policy { using System; using System.Security.Util; using System.Security; using System.Collections; [Serializable] [System.Runtime.InteropServices.ComVisible(true)] sealed public class FirstMatchCodeGroup : CodeGroup { internal FirstMatchCodeGroup() : base() { } public FirstMatchCodeGroup( IMembershipCondition membershipCondition, PolicyStatement policy ) : base( membershipCondition, policy ) { } public override PolicyStatement Resolve( Evidence evidence ) { if (evidence == null) throw new ArgumentNullException("evidence"); if (this.MembershipCondition.Check( evidence )) { PolicyStatement childPolicy = null; IEnumerator enumerator = this.Children.GetEnumerator(); while (enumerator.MoveNext()) { childPolicy = ((CodeGroup)enumerator.Current).Resolve( evidence ); // If the child has a policy, we are done. if (childPolicy != null) break; } PolicyStatement thisPolicy = this.PolicyStatement; if (thisPolicy == null) { return childPolicy; } else if (childPolicy != null) { // Combine the child and this policy and return it. PolicyStatement combined = new PolicyStatement(); combined.SetPermissionSetNoCopy( thisPolicy.GetPermissionSetNoCopy().Union( childPolicy.GetPermissionSetNoCopy() ) ); // if both this group and matching child group are exclusive we need to throw an exception if (((thisPolicy.Attributes & childPolicy.Attributes) & PolicyStatementAttribute.Exclusive) == PolicyStatementAttribute.Exclusive) throw new PolicyException( Environment.GetResourceString( "Policy_MultipleExclusive" ) ); combined.Attributes = thisPolicy.Attributes | childPolicy.Attributes; return combined; } else { // Otherwise we just copy the this policy. return this.PolicyStatement; } } else { return null; } } public override CodeGroup ResolveMatchingCodeGroups( Evidence evidence ) { if (evidence == null) throw new ArgumentNullException("evidence"); if (this.MembershipCondition.Check( evidence )) { CodeGroup retGroup = this.Copy(); retGroup.Children = new ArrayList(); IEnumerator enumerator = this.Children.GetEnumerator(); while (enumerator.MoveNext()) { CodeGroup matchingGroups = ((CodeGroup)enumerator.Current).ResolveMatchingCodeGroups( evidence ); // If the child has a policy, we are done. if (matchingGroups != null) { retGroup.AddChild( matchingGroups ); break; } } return retGroup; } else { return null; } } public override CodeGroup Copy() { FirstMatchCodeGroup group = new FirstMatchCodeGroup(); group.MembershipCondition = this.MembershipCondition; group.PolicyStatement = this.PolicyStatement; group.Name = this.Name; group.Description = this.Description; IEnumerator enumerator = this.Children.GetEnumerator(); while (enumerator.MoveNext()) { group.AddChild( (CodeGroup)enumerator.Current ); } return group; } public override String MergeLogic { get { return Environment.GetResourceString( "MergeLogic_FirstMatch" ); } } internal override String GetTypeName() { return "System.Security.Policy.FirstMatchCodeGroup"; } } }
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- SemanticBasicElement.cs
- NGCSerializationManagerAsync.cs
- RemoteWebConfigurationHost.cs
- DataPagerFieldCommandEventArgs.cs
- securestring.cs
- Tool.cs
- SessionEndingEventArgs.cs
- SQLCharsStorage.cs
- Style.cs
- OdbcEnvironmentHandle.cs
- ThemeDictionaryExtension.cs
- EpmContentSerializerBase.cs
- GenerateScriptTypeAttribute.cs
- SerializationAttributes.cs
- TileModeValidation.cs
- QueryInterceptorAttribute.cs
- StoreItemCollection.Loader.cs
- TabletDeviceInfo.cs
- SqlDataSourceQuery.cs
- EventLogTraceListener.cs
- ByeOperationCD1AsyncResult.cs
- FtpWebRequest.cs
- SystemIPGlobalProperties.cs
- ChangeProcessor.cs
- ThreadStaticAttribute.cs
- Renderer.cs
- MethodCallConverter.cs
- Win32PrintDialog.cs
- SQLDouble.cs
- RuntimeHelpers.cs
- ControlParameter.cs
- KeyValueConfigurationCollection.cs
- FormatSettings.cs
- XPathSelfQuery.cs
- TrueReadOnlyCollection.cs
- XmlWellformedWriterHelpers.cs
- ApplicationCommands.cs
- compensatingcollection.cs
- DesignerGeometryHelper.cs
- COM2ICategorizePropertiesHandler.cs
- BitmapEffectCollection.cs
- GridViewColumn.cs
- RectIndependentAnimationStorage.cs
- XmlSchemaSimpleTypeUnion.cs
- MediaCommands.cs
- AnnotationComponentChooser.cs
- NGCSerializer.cs
- Console.cs
- ProfileGroupSettingsCollection.cs
- SecureUICommand.cs
- Drawing.cs
- CodeTypeReferenceExpression.cs
- ComplexLine.cs
- RootCodeDomSerializer.cs
- Rotation3D.cs
- CodeObject.cs
- TextEffect.cs
- ToolStripControlHost.cs
- UpdatePanelTrigger.cs
- TreeViewBindingsEditorForm.cs
- BehaviorEditorPart.cs
- Timeline.cs
- DocumentPageHost.cs
- PropertyPushdownHelper.cs
- StringConcat.cs
- WindowsGraphics.cs
- WebScriptEnablingBehavior.cs
- RoleGroup.cs
- QilFactory.cs
- AssemblyInfo.cs
- SapiRecoInterop.cs
- DisplayToken.cs
- XmlIncludeAttribute.cs
- BuilderPropertyEntry.cs
- StringUtil.cs
- MsmqSecureHashAlgorithm.cs
- IdentityManager.cs
- AdapterDictionary.cs
- TextFormatter.cs
- BinaryFormatter.cs
- LoadedEvent.cs
- arc.cs
- ResponseBodyWriter.cs
- RemotingException.cs
- FixUpCollection.cs
- EditorPartCollection.cs
- ZipIOCentralDirectoryBlock.cs
- ClientSettingsStore.cs
- GraphicsState.cs
- BamlWriter.cs
- DeclaredTypeElement.cs
- TextPointer.cs
- CompilationUtil.cs
- COM2Properties.cs
- BuildResult.cs
- WebFaultClientMessageInspector.cs
- WebPartConnection.cs
- DocumentXmlWriter.cs
- UIElement3DAutomationPeer.cs
- Array.cs