public WorkflowOperationInvoker(OperationDescription operationDescription, WorkflowOperationBehavior workflowOperationBehavior,
            WorkflowRuntime workflowRuntime, DispatchRuntime dispatchRuntime)
        {
            if (operationDescription == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("operationDescription");
            }

            if (workflowRuntime == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("workflowRuntime");
            }

            if (workflowOperationBehavior == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("workflowOperationBehavior");
            }

            this.isOneWay = operationDescription.IsOneWay;

            if (operationDescription.BeginMethod != null)
            {
                this.syncMethod = operationDescription.BeginMethod;
                inParameterCount = GetFlowedInParameterCount(operationDescription.BeginMethod.GetParameters()) - 2;
            }
            else
            {
                this.syncMethod = operationDescription.SyncMethod;
                inParameterCount = GetFlowedInParameterCount(operationDescription.SyncMethod.GetParameters());
            }

            this.operationDescription = operationDescription;
            this.workflowRuntime = workflowRuntime;
            this.canCreateInstance = workflowOperationBehavior.CanCreateInstance;
            this.serviceAuthorizationManager = workflowOperationBehavior.ServiceAuthorizationManager;
            this.dispatchRuntime = dispatchRuntime;
            staticQueueName = QueueNameHelper.Create(this.syncMethod.DeclaringType, operationDescription.Name);
        }
Esempio n. 2
0
        public virtual void TestServiceAclsRefreshWithFileSystemBasedConfigurationProvider
            ()
        {
            configuration.SetBoolean(CommonConfigurationKeysPublic.HadoopSecurityAuthorization
                                     , true);
            configuration.Set(YarnConfiguration.RmConfigurationProviderClass, "org.apache.hadoop.yarn.FileSystemBasedConfigurationProvider"
                              );
            ResourceManager resourceManager = null;

            try
            {
                //upload default configurations
                UploadDefaultConfiguration();
                Configuration conf = new Configuration();
                conf.SetBoolean(CommonConfigurationKeysPublic.HadoopSecurityAuthorization, true);
                UploadConfiguration(conf, "core-site.xml");
                try
                {
                    resourceManager = new ResourceManager();
                    resourceManager.Init(configuration);
                    resourceManager.Start();
                }
                catch (Exception)
                {
                    NUnit.Framework.Assert.Fail("Should not get any exceptions");
                }
                string        aclsString = "alice,bob users,wheel";
                Configuration newConf    = new Configuration();
                newConf.Set("security.applicationclient.protocol.acl", aclsString);
                UploadConfiguration(newConf, "hadoop-policy.xml");
                resourceManager.adminService.RefreshServiceAcls(RefreshServiceAclsRequest.NewInstance
                                                                    ());
                // verify service Acls refresh for AdminService
                ServiceAuthorizationManager adminServiceServiceManager = resourceManager.adminService
                                                                         .GetServer().GetServiceAuthorizationManager();
                VerifyServiceACLsRefresh(adminServiceServiceManager, typeof(ApplicationClientProtocolPB
                                                                            ), aclsString);
                // verify service ACLs refresh for ClientRMService
                ServiceAuthorizationManager clientRMServiceServiceManager = resourceManager.GetRMContext
                                                                                ().GetClientRMService().GetServer().GetServiceAuthorizationManager();
                VerifyServiceACLsRefresh(clientRMServiceServiceManager, typeof(ApplicationClientProtocolPB
                                                                               ), aclsString);
                // verify service ACLs refresh for ApplicationMasterService
                ServiceAuthorizationManager appMasterService = resourceManager.GetRMContext().GetApplicationMasterService
                                                                   ().GetServer().GetServiceAuthorizationManager();
                VerifyServiceACLsRefresh(appMasterService, typeof(ApplicationClientProtocolPB), aclsString
                                         );
                // verify service ACLs refresh for ResourceTrackerService
                ServiceAuthorizationManager RTService = resourceManager.GetRMContext().GetResourceTrackerService
                                                            ().GetServer().GetServiceAuthorizationManager();
                VerifyServiceACLsRefresh(RTService, typeof(ApplicationClientProtocolPB), aclsString
                                         );
            }
            finally
            {
                if (resourceManager != null)
                {
                    resourceManager.Stop();
                }
            }
        }
Esempio n. 3
0
        protected override void OnLoad(EventArgs e)
        {
            if (!SecurityHelper.CanRunApplication("PowerShell/PowerShellIse") ||
                ServiceAuthorizationManager.TerminateUnauthorizedRequest(WebServiceSettings.ServiceClient,
                                                                         Context.User.Name))
            {
                PowerShellLog.Warn($"User {Context.User?.Name} attempt to access PowerShell ISE - denied.");
                return;
            }

            base.OnLoad(e);

            if (Monitor == null)
            {
                if (!Context.ClientPage.IsEvent)
                {
                    Monitor = new SpeJobMonitor {
                        ID = "Monitor"
                    };
                    Context.ClientPage.Controls.Add(Monitor);
                }
                else
                {
                    Monitor = (SpeJobMonitor)Context.ClientPage.FindControl("Monitor");
                }
            }
            Monitor.JobFinished += MonitorOnJobFinished;
            if (Context.ClientPage.IsEvent)
            {
                return;
            }

            var settings = ApplicationSettings.GetInstance(ApplicationNames.ISE);

            if (settings.SaveLastScript)
            {
                Editor.Value = settings.LastScript;
            }

            var itemId = WebUtil.GetQueryString("id");
            var itemDb = WebUtil.GetQueryString("db");

            if (itemId.Length > 0)
            {
                ScriptItemId = itemId;
                ScriptItemDb = itemDb;
                LoadItem(itemDb, itemId);
            }

            ContextItemDb = Context.ContentDatabase.Name;
            var contextItem = Context.ContentDatabase.GetItem(Context.Site.ContentStartPath) ??
                              UIUtil.GetHomeItem(Context.User);

            ContextItemId = contextItem?.ID.ToString() ?? String.Empty;

            CurrentSessionId = DefaultSessionName;
            CurrentUser      = DefaultUser;
            CurrentLanguage  = DefaultLanguage;
            ParentFrameName  = WebUtil.GetQueryString("pfn");
            UpdateRibbon();
        }
Esempio n. 4
0
 public override CommandState QueryState(CommandContext context)
 {
     return(ServiceAuthorizationManager.IsUserAuthorized(WebServiceSettings.ServiceExecution, Context.User.Name)
         ? CommandState.Enabled
         : CommandState.Hidden);
 }
        protected override void OnLoad(EventArgs e)
        {
            Assert.ArgumentNotNull(e, "e");
            Assert.IsTrue(ServiceAuthorizationManager.IsUserAuthorized(WebServiceSettings.ServiceExecution, Context.User.Name, false), "Application access denied.");
            base.OnLoad(e);

            Context.ClientPage.ClientResponse.SetDialogValue(Hidden.Value);
            if (Context.ClientPage.IsEvent)
            {
                return;
            }

            UrlHandle handle = null;

            if (!UrlHandle.TryGetHandle(out handle))
            {
                FileNameLabel.Text =
                    "Invalid dialog invocation.";
                SizeLabel.Visible     = false;
                PathPrefix.Visible    = false;
                SizePrefix.Visible    = false;
                OK.Visible            = false;
                DownloadImage.Visible = false;
                ErrorImage.Visible    = true;
                return;
            }

            FileName = handle["fn"];

            ItemUri = handle["uri"];
            ItemDb  = handle["db"];

            bool showFullPath;

            if (!bool.TryParse(handle["fp"], out showFullPath))
            {
                showFullPath = false;
            }

            Text.Text = handle["te"];

            if (!string.IsNullOrEmpty(ItemUri))
            {
                var item = Factory.GetDatabase(ItemDb).GetItem(new DataUri(ItemUri));
                if (MediaManager.HasMediaContent(item))
                {
                    FileNameLabel.Text = (showFullPath ? item.GetProviderPath() : item.Name)
                                         + "." + item["Extension"];
                    long size;
                    SizeLabel.Text = Int64.TryParse(item["size"], out size) ? ToFileSize(size) : "unknown";
                }
                else
                {
                    SheerResponse.Alert("There is no file attached.");
                }
            }
            else if (!string.IsNullOrEmpty(FileName))
            {
                // check if file in approved location
                var filePath    = FileUtil.MapPath(FileName);
                var webSitePath = FileUtil.MapPath("/");
                var dataPath    = FileUtil.MapPath(Settings.DataFolder);

                if (!filePath.StartsWith(webSitePath, StringComparison.InvariantCultureIgnoreCase) &&
                    !filePath.StartsWith(dataPath, StringComparison.InvariantCultureIgnoreCase))
                {
                    FileNameLabel.Text =
                        "Files from outside of the Sitecore Data and Website folders cannot be downloaded.\n\n" +
                        "Copy the file to the Sitecore Data folder and try again.";
                    SizeLabel.Visible     = false;
                    PathPrefix.Visible    = false;
                    SizePrefix.Visible    = false;
                    OK.Visible            = false;
                    DownloadImage.Visible = false;
                    ErrorImage.Visible    = true;
                    return;
                }

                FileNameLabel.Text = showFullPath ? FileName : Path.GetFileName(FileName);
                SheerResponse.Download(FileName);
                Hidden.Value = "downloaded";
                var file = new FileInfo(FileName);
                SizeLabel.Text = ToFileSize(file.Length);
            }

            var caption = handle["cp"];

            Context.ClientPage.Title = caption;
            Assert.ArgumentNotNull(e, "e");
            base.OnLoad(e);
            Text.Text    = handle["te"];
            Hidden.Value = "cancelled";
            Context.ClientPage.ClientResponse.SetDialogValue(Hidden.Value);
            UrlHandle.DisposeHandle(handle);
        }