private static void CheckIfSecurityDescriptorInterfaceIsSupported(ISecurityDescriptorCmdletProvider permissionProvider) { if (permissionProvider == null) { throw PSTraceSource.NewNotSupportedException("ProviderBaseSecurity", "ISecurityDescriptorCmdletProvider_NotSupported", new object[0]); } }
private static void CheckIfSecurityDescriptorInterfaceIsSupported(ISecurityDescriptorCmdletProvider permissionProvider) { if (permissionProvider == null) { throw PSTraceSource.NewNotSupportedException("ProviderBaseSecurity", "ISecurityDescriptorCmdletProvider_NotSupported", new object[0]); } }
private static void CheckIfSecurityDescriptorInterfaceIsSupported( ISecurityDescriptorCmdletProvider permissionProvider) { if (permissionProvider == null) { throw CmdletProvider.providerBaseTracer.NewNotSupportedException("ProviderBaseSecurity", "ISecurityDescriptorCmdletProvider_NotSupported"); } }
internal void SetSecurityDescriptor(string path, ObjectSecurity securityDescriptor, CmdletProviderContext context) { this.Context = context; ISecurityDescriptorCmdletProvider permissionProvider = this as ISecurityDescriptorCmdletProvider; CheckIfSecurityDescriptorInterfaceIsSupported(permissionProvider); permissionProvider.SetSecurityDescriptor(path, securityDescriptor); }
internal void GetSecurityDescriptor(string path, AccessControlSections sections, CmdletProviderContext context) { this.Context = context; ISecurityDescriptorCmdletProvider permissionProvider = this as ISecurityDescriptorCmdletProvider; CheckIfSecurityDescriptorInterfaceIsSupported(permissionProvider); permissionProvider.GetSecurityDescriptor(path, sections); }
private static void CheckIfSecurityDescriptorInterfaceIsSupported(ISecurityDescriptorCmdletProvider permissionProvider) { if (permissionProvider is null) { throw PSTraceSource.NewNotSupportedException( ProviderBaseSecurity.ISecurityDescriptorCmdletProvider_NotSupported); } }
} // NewSecurityDescriptor private ObjectSecurity NewSecurityDescriptorFromPath( CmdletProvider providerInstance, string path, AccessControlSections sections) { ObjectSecurity sd = null; // All parameters should have been validated by caller Diagnostics.Assert( providerInstance != null, "Caller should validate providerInstance before calling this method"); Diagnostics.Assert( path != null, "Caller should validate path before calling this method"); Diagnostics.Assert( ExecutionContext != null, "Caller should validate context before calling this method"); // This just verifies that the provider supports the interface. ISecurityDescriptorCmdletProvider sdProvider = GetPermissionProviderInstance(providerInstance); try { sd = sdProvider.NewSecurityDescriptorFromPath(path, sections); } catch (LoopFlowException) { throw; } catch (PipelineStoppedException) { throw; } catch (ActionPreferenceStopException) { throw; } catch (Exception e) // Catch-all OK, 3rd party callout. { CommandProcessorBase.CheckForSevereException(e); throw NewProviderInvocationException( "NewSecurityDescriptorProviderException", SessionStateStrings.GetSecurityDescriptorProviderException, providerInstance.ProviderInfo, path, e); } return(sd); } // NewSecurityDescriptor
/// <summary> /// Gets the security descriptor from the specified item. /// </summary> /// /// <param name="type"> /// The type of the item which corresponds to the security /// descriptor that we want to create. /// </param> /// /// <param name="providerInstance"> /// The type of the item which corresponds to the security /// descriptor that we want to create. /// </param> /// /// <param name="sections"> /// Specifies the parts of a security descriptor to retrieve. /// </param> /// /// <returns> /// Nothing. The security descriptor for the item at the specified type is /// written to the context. /// </returns> /// internal ObjectSecurity NewSecurityDescriptorOfType( CmdletProvider providerInstance, string type, AccessControlSections sections) { ObjectSecurity sd = null; if (type == null) { throw PSTraceSource.NewArgumentNullException("type"); } if (providerInstance == null) { throw PSTraceSource.NewArgumentNullException("providerInstance"); } // This just verifies that the provider supports the interface. ISecurityDescriptorCmdletProvider sdProvider = GetPermissionProviderInstance(providerInstance); try { sd = sdProvider.NewSecurityDescriptorOfType(type, sections); } catch (LoopFlowException) { throw; } catch (PipelineStoppedException) { throw; } catch (ActionPreferenceStopException) { throw; } catch (Exception e) // Catch-all OK, 3rd party callout. { CommandProcessorBase.CheckForSevereException(e); throw NewProviderInvocationException( "NewSecurityDescriptorProviderException", SessionStateStrings.GetSecurityDescriptorProviderException, providerInstance.ProviderInfo, type, e); } return(sd); } // NewSecurityDescriptorOfType
internal void SetSecurityDescriptor( string path, ObjectSecurity securityDescriptor, CmdletProviderContext context) { using (CmdletProvider.providerBaseTracer.TraceMethod(path, new object[0])) { this.Context = context; ISecurityDescriptorCmdletProvider permissionProvider = this as ISecurityDescriptorCmdletProvider; CmdletProvider.CheckIfSecurityDescriptorInterfaceIsSupported(permissionProvider); permissionProvider.SetSecurityDescriptor(path, securityDescriptor); } }
} // GetSecurityDescriptor /// <summary> /// Internal wrapper for the SetSecurityDescriptor protected method. This method will /// only be called if the provider implements the ISecurityDescriptorCmdletProvider interface. /// </summary> /// /// <param name="path"> /// The path to the item to set the new security descriptor on. /// </param> /// /// <param name="securityDescriptor"> /// The new security descriptor for the item. /// </param> /// /// <param name="context"> /// The context under which this method is being called. /// </param> /// /// <returns> /// Nothing. The security descriptor object that was set should be written /// to the context. /// </returns> /// internal void SetSecurityDescriptor( string path, ObjectSecurity securityDescriptor, CmdletProviderContext context) { Context = context; ISecurityDescriptorCmdletProvider permissionProvider = this as ISecurityDescriptorCmdletProvider; // // if this is not supported, the fn will throw // CheckIfSecurityDescriptorInterfaceIsSupported(permissionProvider); // Call interface method permissionProvider.SetSecurityDescriptor(path, securityDescriptor); } // SetSecurityDescriptor
/// <summary> /// Internal wrapper for the GetSecurityDescriptor protected method. This method will /// only be called if the provider implements the ISecurityDescriptorCmdletProvider interface. /// </summary> /// /// <param name="path"> /// The path to the item to retrieve the security descriptor from. /// </param> /// /// <param name="sections"> /// Specifies the parts of a security descriptor to retrieve. /// </param> /// /// <param name="context"> /// The context under which this method is being called. /// </param> /// /// <returns> /// Nothing. An instance of an object that represents the security descriptor /// for the item specified by the path should be written to the context. /// </returns> /// internal void GetSecurityDescriptor( string path, AccessControlSections sections, CmdletProviderContext context) { Context = context; ISecurityDescriptorCmdletProvider permissionProvider = this as ISecurityDescriptorCmdletProvider; // // if this is not supported, the fn will throw // CheckIfSecurityDescriptorInterfaceIsSupported(permissionProvider); // Call interface method permissionProvider.GetSecurityDescriptor(path, sections); } // GetSecurityDescriptor
/// <summary> /// Gets an instance of an ISecurityDescriptorCmdletProvider given the provider ID. /// </summary> /// <param name="providerInstance"> /// An instance of a CmdletProvider. /// </param> /// <returns> /// An instance of a ISecurityDescriptorCmdletProvider for the specified provider ID. /// </returns> /// <throws> /// ArgumentNullException if providerId is null. /// NotSupportedException if the providerId is not for a provider /// that is derived from ISecurityDescriptorCmdletProvider. /// </throws> internal static ISecurityDescriptorCmdletProvider GetPermissionProviderInstance(CmdletProvider providerInstance) { if (providerInstance == null) { throw PSTraceSource.NewArgumentNullException("providerInstance"); } ISecurityDescriptorCmdletProvider permissionCmdletProvider = providerInstance as ISecurityDescriptorCmdletProvider; if (permissionCmdletProvider == null) { throw PSTraceSource.NewNotSupportedException( ProviderBaseSecurity.ISecurityDescriptorCmdletProvider_NotSupported); } return(permissionCmdletProvider); }