/// <summary> /// Initialize global controller that will be used for all /// security-related operations. /// </summary> /// <remarks> /// Initialize global controller that will be used for all /// security-related operations. The global controller takes precedence /// over already installed /// <see cref="Context">Context</see> /// -specific controllers and cause /// any subsequent call to /// <see cref="Context.SetSecurityController(SecurityController)">Context.SetSecurityController(SecurityController)</see> /// to throw an exception. /// <p> /// The method can only be called once. /// </remarks> /// <seealso cref="HasGlobal()">HasGlobal()</seealso> public static void InitGlobal(SecurityController controller) { if (controller == null) { throw new ArgumentException(); } if (global != null) { throw new SecurityException("Cannot overwrite already installed global SecurityController"); } global = controller; }
private InterpretedFunction(InterpreterData idata, object staticSecurityDomain) { this.idata = idata; // Always get Context from the current thread to // avoid security breaches via passing mangled Context instances // with bogus SecurityController Context cx = Context.GetContext(); SecurityController sc = cx.GetSecurityController(); object dynamicDomain; if (sc != null) { dynamicDomain = sc.GetDynamicSecurityDomain(staticSecurityDomain); } else { if (staticSecurityDomain != null) { throw new ArgumentException(); } dynamicDomain = null; } this.securityController = sc; this.securityDomain = dynamicDomain; }
private InterpretedFunction(Rhino.InterpretedFunction parent, int index) { this.idata = parent.idata.itsNestedFunctions[index]; this.securityController = parent.securityController; this.securityDomain = parent.securityDomain; }
/// <summary>Set the security controller for this context.</summary> /// <remarks> /// Set the security controller for this context. /// <p> SecurityController may only be set if it is currently null /// and /// <see cref="SecurityController.HasGlobal()">SecurityController.HasGlobal()</see> /// is <tt>false</tt>. /// Otherwise a SecurityException is thrown. /// </remarks> /// <param name="controller">a SecurityController object</param> /// <exception cref="System.Security.SecurityException"> /// if there is already a SecurityController /// object for this Context or globally installed. /// </exception> /// <seealso cref="SecurityController.InitGlobal(SecurityController)">SecurityController.InitGlobal(SecurityController)</seealso> /// <seealso cref="SecurityController.HasGlobal()">SecurityController.HasGlobal()</seealso> public void SetSecurityController(SecurityController controller) { if (@sealed) { OnSealedMutation(); } if (controller == null) { throw new ArgumentException(); } if (securityController != null) { throw new SecurityException("Can not overwrite existing SecurityController object"); } if (SecurityController.HasGlobal()) { throw new SecurityException("Can not overwrite existing global SecurityController object"); } securityController = controller; }