Beispiel #1
0
        public override int ModifyDomainCredentials(string originalGuid, ProcessAgent agent, Coupon inCoupon, Coupon outCoupon, string extra)
        {
            int status = 0;
            ProcessAgentInfo paiOld = GetProcessAgentInfo(agent.agentGuid);
            try
            {
                status = base.ModifyDomainCredentials(originalGuid, agent, inCoupon, outCoupon, extra);
            }
            catch (Exception ex)
            {
                throw new Exception("ISB: ", ex);
            }
            if (paiOld != null)
            {
                if (agent.codeBaseUrl.CompareTo(paiOld.codeBaseUrl) != 0)
                {
                    ModifyAdminUrls(paiOld.agentId, paiOld.codeBaseUrl, agent.codeBaseUrl);
                    ModifyResourceInfoURL(paiOld.agentId, paiOld.codeBaseUrl, agent.codeBaseUrl);
                    if (paiOld.agentType == ProcessAgentType.AgentType.LAB_SERVER)
                    {
                        ModifyClientScripts(paiOld.agentId, paiOld.codeBaseUrl, agent.codeBaseUrl);
                    }
                }
            }
            //Notify all ProcessAgents about the change
            ProcessAgentInfo[] domainServices = GetProcessAgentInfos();
            ProcessAgentProxy proxy = null;
            foreach (ProcessAgentInfo pi in domainServices)
            {
                // Do not send if retired this service or the service being modified since this is
                if (!pi.retired && (pi.agentGuid.CompareTo(ProcessAgentDB.ServiceGuid) != 0)
                    && (pi.agentGuid.CompareTo(agent.agentGuid) != 0))
                {
                    proxy = new ProcessAgentProxy();
                    proxy.AgentAuthHeaderValue = new AgentAuthHeader();
                    proxy.AgentAuthHeaderValue.coupon = pi.identOut;
                    proxy.Url = pi.webServiceUrl;

                    proxy.ModifyDomainCredentials(originalGuid, agent, extra, inCoupon, outCoupon);
                }
            }
            return status;
        }
Beispiel #2
0
        public override int ModifyProcessAgent(string originalGuid, ProcessAgent agent, string extra)
        {
            int status = 0;
            ProcessAgentInfo paiOld = GetProcessAgentInfo(originalGuid);

            if (paiOld != null)
            {

                try
                {
                    status = UpdateProcessAgent(paiOld.agentId, agent.agentGuid, agent.agentName, agent.type,
                        agent.domainGuid, agent.codeBaseUrl, agent.webServiceUrl);
                }
                catch (Exception ex)
                {
                    throw new Exception("ISB: ", ex);
                }

                if (agent.codeBaseUrl.CompareTo(paiOld.codeBaseUrl) != 0)
                {
                    status += ModifyAdminUrls(paiOld.agentId, paiOld.codeBaseUrl, agent.codeBaseUrl);
                    status += ModifyResourceInfoURL(paiOld.agentId, paiOld.codeBaseUrl, agent.codeBaseUrl);
                    if (paiOld.agentType == ProcessAgentType.AgentType.LAB_SERVER)
                    {
                        status += ModifyClientScripts(paiOld.agentId, paiOld.codeBaseUrl, agent.codeBaseUrl);
                    }
                }
                if (agent.agentName.CompareTo(paiOld.agentName) != 0)
                {
                    // need to update Qualifier Names
                    AuthorizationAPI.ModifyQualifierName(Qualifier.ToTypeID(agent.type), paiOld.agentId, agent.agentName);
                    int[] resourceMapIds = GetResourceMappingIdsByValue(ResourceMappingTypes.PROCESS_AGENT, paiOld.agentId);
                    foreach (int id in resourceMapIds)
                    {
                        ResourceMapping map = ResourceMapManager.GetMap(id);
                        AuthorizationAPI.ModifyQualifierName(Qualifier.resourceMappingQualifierTypeID, id, ResourceMappingToString(map));
                    }
                }
                //Notify all ProcessAgents about the change
                ProcessAgentInfo[] domainServices = GetProcessAgentInfos();
                ProcessAgentProxy proxy = null;
                foreach (ProcessAgentInfo pi in domainServices)
                {
                    // Do not send if retired this service or the service being modified since this is
                    if (!pi.retired && (pi.agentType != ProcessAgentType.AgentType.BATCH_LAB_SERVER)
                        && (pi.agentGuid.CompareTo(ProcessAgentDB.ServiceGuid) != 0)
                        && (pi.agentGuid.CompareTo(agent.agentGuid) != 0))
                    {
                        proxy = new ProcessAgentProxy();
                        proxy.AgentAuthHeaderValue = new AgentAuthHeader();
                        proxy.AgentAuthHeaderValue.agentGuid = ProcessAgentDB.ServiceGuid;
                        proxy.AgentAuthHeaderValue.coupon = pi.identOut;
                        proxy.Url = pi.webServiceUrl;
                        try
                        {
                            status += proxy.ModifyProcessAgent(originalGuid, agent, extra);
                        }
                        catch (Exception ex)
                        {
                            Exception ex2 = new Exception("ModifyProcessAgent: " + pi.webServiceUrl, ex);
                            throw ex2;
                        }
                    }
                }
            }

            return status;
        }
Beispiel #3
0
        protected void btnModify_Click(object sender, System.EventArgs e)
        {
            bool error = false;
            StringBuilder message = new StringBuilder();
            try
            {
                if (ProcessAgentDB.ServiceAgent != null)
                {
                    string originalGuid = ProcessAgentDB.ServiceAgent.agentGuid;
                    if (!(txtServiceName.Text != null && txtServiceName.Text.Length > 0))
                    {
                        error = true;
                        message.Append(" You must enter a Service Name<br/>");
                    }
                    try
                    {
                        if (!checkGuid())
                        {
                            error = true;
                            message.Append("There is an unspecified error with the GUID string.<br/>");
                        }
                    }
                    catch (Exception ex)
                    {
                        error = true;
                        message.Append("GUID Error: ");
                        message.Append(ex.Message);
                        message.Append("<br/>");
                    }

                    if (!(txtCodebaseUrl.Text != null && txtCodebaseUrl.Text.Length > 0))
                    {
                        error = true;
                        message.Append(" You must enter the base URL for the Web Site<br/>");
                    }
                    if (!(txtServiceUrl.Text != null && txtServiceUrl.Text.Length > 0))
                    {
                        error = true;
                        message.Append(" You must enter full URL of the Web Service page<br/>");
                    }
                    if (error)
                    {
                        lblResponse.Text = Utilities.FormatErrorMessage(message.ToString());
                        lblResponse.Visible = true;
                        return;
                    }
                    if (ProcessAgentDB.ServiceAgent.domainGuid != null)
                    {
                        ProcessAgentInfo originalAgent = dbTicketing.GetProcessAgentInfo(originalGuid);
                        ProcessAgentInfo sb = dbTicketing.GetProcessAgentInfo(ProcessAgentDB.ServiceAgent.domainGuid);
                        if ((sb != null) && !sb.retired)
                        {
                            ProcessAgentProxy psProxy = new ProcessAgentProxy();
                            AgentAuthHeader header = new AgentAuthHeader();
                            header.agentGuid = ProcessAgentDB.ServiceAgent.agentGuid;
                            header.coupon = sb.identOut;
                            psProxy.AgentAuthHeaderValue = header;
                            psProxy.Url = sb.webServiceUrl;
                            ProcessAgent pa = new ProcessAgent();
                            pa.agentGuid = txtServiceGuid.Text;
                            pa.agentName = txtServiceName.Text;
                            pa.domainGuid = ProcessAgentDB.ServiceAgent.domainGuid;
                            pa.codeBaseUrl = txtCodebaseUrl.Text;
                            pa.webServiceUrl = txtServiceUrl.Text;
                            pa.type = AgentType;
                            //dbTicketing.SelfRegisterProcessAgent(pa.agentGuid, pa.agentName, agentType,
                            //    pa.domainGuid, pa.codeBaseUrl, pa.webServiceUrl);
                            //message.Append("Local information has been saved. ");
                            int returnValue = psProxy.ModifyProcessAgent(originalGuid, pa, null);
                            message.Append("The changes have been sent to the ServiceBroker");
                            if (returnValue > 0)
                            {
                                dbTicketing.SelfRegisterProcessAgent(pa.agentGuid, pa.agentName, AgentType,
                                pa.domainGuid, pa.codeBaseUrl, pa.webServiceUrl);

                                message.Append(".<br />Local information has been saved. ");
                                lblResponse.Text = Utilities.FormatConfirmationMessage(message.ToString());
                                lblResponse.Visible = true;

                            }
                            else
                            {
                                message.Append(", but did not process correctly!");
                                message.Append("<br />Local information has not been saved. ");
                                lblResponse.Text = Utilities.FormatErrorMessage(message.ToString());
                                lblResponse.Visible = true;
                            }
                        }
                    }
                    else
                    {
                        dbTicketing.SelfRegisterProcessAgent(ProcessAgentDB.ServiceAgent.agentGuid, txtServiceName.Text, AgentType,
                                null, txtCodebaseUrl.Text, txtServiceUrl.Text);
                        dbTicketing.SaveSystemSupport(ProcessAgentDB.ServiceAgent.agentGuid, txtContactInfo.Text, txtBugEmail.Text,
                           txtInfoUrl.Text, txtDescription.Text, txtLocation.Text);
                    }
                }
            }
            catch (Exception ex)
            {
                Exception ex2 = new Exception("Error in  selfRegistration.modify()", ex);
                Utilities.WriteLog(Utilities.DumpException(ex2));
                throw ex2;
            }
        }
Beispiel #4
0
        protected void btnRetire_Click(object sender, System.EventArgs e)
        {
            bool error = false;
            StringBuilder message = new StringBuilder();
            try
            {
                if (ProcessAgentDB.ServiceAgent.domainGuid != null)
                {
                    ProcessAgentInfo originalAgent = dbTicketing.GetProcessAgentInfo(ProcessAgentDB.ServiceAgent.agentGuid);
                    ProcessAgentInfo sb = dbTicketing.GetProcessAgentInfo(ProcessAgentDB.ServiceAgent.domainGuid);
                    if ((sb != null) && !sb.retired)
                    {
                        ProcessAgentProxy psProxy = new ProcessAgentProxy();
                        AgentAuthHeader header = new AgentAuthHeader();
                        header.agentGuid = originalAgent.agentGuid;
                        header.coupon = sb.identOut;
                        psProxy.AgentAuthHeaderValue = header;
                        psProxy.Url = sb.webServiceUrl;

                        int returnValue = psProxy.RetireProcessAgent(originalAgent.domainGuid,
                            originalAgent.agentGuid, true);
                        message.Append("The changes have been sent to the ServiceBroker");
                        if (returnValue > 0)
                        {
                            dbTicketing.SetDomainGuid(null);
                            dbTicketing.SetSelfState(originalAgent.agentGuid, false);
                            dbTicketing.SetProcessAgentRetired(originalAgent.agentGuid, true);
                            dbTicketing.DeleteTickets(originalAgent.agentGuid);

                            message.Append(".<br />Local information has been saved. ");
                            lblResponse.Text = Utilities.FormatConfirmationMessage(message.ToString());
                            lblResponse.Visible = true;

                        }
                        else
                        {
                            message.Append(", but did not process correctly!");
                            message.Append("<br />Local information has not been saved. ");
                            lblResponse.Text = Utilities.FormatErrorMessage(message.ToString());
                            lblResponse.Visible = true;
                        }
                    }
                    else
                    {
                        dbTicketing.SelfRegisterProcessAgent(ProcessAgentDB.ServiceAgent.agentGuid, txtServiceName.Text, AgentType,
                                null, txtCodebaseUrl.Text, txtServiceUrl.Text);
                    }
                }
            }
            catch (Exception ex)
            {
                Exception ex2 = new Exception("Error in  selfRegistration.modify()", ex);
                Utilities.WriteLog(Utilities.DumpException(ex2));
                throw ex2;
            }
            clearForm();
        }
        protected void btnSave_Click(object sender, System.EventArgs e)
        {
            bool error = false;
            string webURL = null;
            StringBuilder message = new StringBuilder();
            //Check fields for valid input
            if (!(txtServiceName.Text != null && txtServiceName.Text.Length > 0))
            {
                error = true;
                message.Append(" You must enter a Service Name<br/>");
            }
            try
            {
                if (!checkGuid())
                {
                    error = true;
                    message.Append("There is an unspecified error with the GUID string.<br/>");
                }
            }
            catch (Exception exc)
            {
                error = true;
                message.Append("GUID Error: ");
                message.Append(exc.Message);
                message.Append("<br/>");
            }
            if (!(txtOutPasskey.Text != null && txtOutPasskey.Text.Length > 0))
            {
                error = true;
                message.Append(" You must enter a default passkey<br/>");
            }
            if (!(txtCodebaseUrl.Text != null && txtCodebaseUrl.Text.Length > 0))
            {
                error = true;
                message.Append(" You must enter the base URL for the Web Site<br/>");
            }
            else if (txtCodebaseUrl.Text.Contains("localhost"))
            {
                error = true;
                message.Append(" You must not use localhost in a codebase URL, if you must test on the local machine please use '127.0.0.1'.<br/>");
            }
            if (!(txtServiceUrl.Text != null && txtServiceUrl.Text.Length > 0))
            {
                error = true;
                message.Append(" You must enter full or relative URL of the Web Service page<br/>");
            }
            else if (txtServiceUrl.Text.Contains("localhost"))
            {
                error = true;
                message.Append(" You must not use localhost in a web service URL, if you must test only on the local machine please use '127.0.0.1'.<br/>");
            }
            else
            {
                //Construct webServiceUrl

                string testURL = txtServiceUrl.Text.Trim();
                if (testURL.StartsWith("http://", StringComparison.OrdinalIgnoreCase)
                    || testURL.StartsWith("https://", StringComparison.OrdinalIgnoreCase))
                {
                    webURL = testURL;
                }
                else if (testURL.StartsWith("~/", StringComparison.OrdinalIgnoreCase))
                {
                    webURL = txtCodebaseUrl.Text.Trim() + testURL.Substring(1);
                }
                else if (testURL.StartsWith("/", StringComparison.OrdinalIgnoreCase))
                {
                    webURL = txtCodebaseUrl.Text.Trim() + testURL;
                }
                else
                {
                    webURL = txtCodebaseUrl.Text.Trim() + "/" + testURL;
                }

                // Test for valid webService URL
                ProcessAgentProxy paProxy = new ProcessAgentProxy();
                paProxy.Url = webURL;
                try
                {
                    DateTime serviceTime = paProxy.GetServiceTime();
                }
                catch
                {
                    error = true;
                    message.Append(" There is an error with the web service URL: " + webURL + " Please check that it is valid and the web service is configured correctly.<br/>");
                }
            }
            if (error)
            {
                lblResponse.Text = Utilities.FormatErrorMessage(message.ToString());
                lblResponse.Visible = true;
                return;
            }
            else
            {
                //if(txtOutPasskey.Text.CompareTo(ConfigurationManager.AppSettings["defaultPasskey"]) != 0){
                //    ConfigurationManager.AppSettings.Set("defaultPasskey",txtOutPasskey.Text);
                //}

                // Check if domain is set if so only update mutable Fields
                dbTicketing.SelfRegisterProcessAgent(txtServiceGuid.Text.Trim(),
                    txtServiceName.Text, lblServiceType.Text, null,
                    txtCodebaseUrl.Text.Trim(), webURL);
                txtServiceUrl.Text = webURL;
                if (AgentType == ProcessAgentType.SERVICE_BROKER)
                {
                    dbTicketing.SetDomainGuid(txtServiceGuid.Text.Trim());
                    AuthorityUpdateSelf(txtServiceName.Text, txtServiceGuid.Text.Trim(),
                                 txtCodebaseUrl.Text.Trim(), txtDescription.Text, txtContactInfo.Text,
                                 txtBugEmail.Text, txtLocation.Text);
                }
                dbTicketing.SaveSystemSupport(ProcessAgentDB.ServiceAgent.agentGuid, txtContactInfo.Text, txtBugEmail.Text,
                            txtInfoUrl.Text, txtDescription.Text, txtLocation.Text);

                //DisplayForm();
                lblResponse.Text = Utilities.FormatConfirmationMessage("Self registration has completed!");
                lblResponse.Visible = true;
                ProcessAgentDB.RefreshServiceAgent();
            }
        }
Beispiel #6
0
        protected void modifyService(object sender, System.EventArgs e)
        {
            bool error = false;
            StringBuilder message = new StringBuilder();
            try
            {
                if (ProcessAgentDB.ServiceAgent != null)
                {
                    string originalGuid = ProcessAgentDB.ServiceAgent.agentGuid;
                    if (!(txtServiceName.Text != null && txtServiceName.Text.Trim().Length > 0))
                    {
                        error = true;
                        message.Append(" You must enter a Service Name<br/>");
                    }

                    if (!(txtCodebaseUrl.Text != null && txtCodebaseUrl.Text.Trim().Length > 0))
                    {
                        error = true;
                        message.Append(" You must enter the base URL for the Web Site<br/>");
                    }
                    if (!(txtWebServiceUrl.Text != null && txtWebServiceUrl.Text.Trim().Length > 0))
                    {
                        error = true;
                        message.Append(" You must enter full URL of the Web Service page<br/>");
                    }
                    if (error)
                    {
                        lblResponse.Text = Utilities.FormatErrorMessage(message.ToString());
                        lblResponse.Visible = true;
                        return;
                    }
                    if ((txtServiceName.Text.Trim().CompareTo(bakServiceName.Value) == 0)
                        && (txtCodebaseUrl.Text.Trim().CompareTo(bakCodebase.Value) == 0)
                        && (txtWebServiceUrl.Text.Trim().CompareTo(bakServiceUrl.Value) == 0))
                    {
                        lblResponse.Text = Utilities.FormatWarningMessage("No user editable fields have been changed, modify aborted!");
                        lblResponse.Visible = true;
                        return;
                    }
                    if (ProcessAgentDB.ServiceAgent.domainGuid != null)
                    {
                        ProcessAgentInfo originalAgent = dbTicketing.GetProcessAgentInfo(originalGuid);
                        ProcessAgentInfo sb = dbTicketing.GetProcessAgentInfo(ProcessAgentDB.ServiceAgent.domainGuid);
                        if ((sb != null) && !sb.retired)
                        {
                            ProcessAgentProxy psProxy = new ProcessAgentProxy();
                            AgentAuthHeader header = new AgentAuthHeader();
                            header.agentGuid = ProcessAgentDB.ServiceAgent.agentGuid;
                            header.coupon = sb.identOut;
                            psProxy.AgentAuthHeaderValue = header;
                            psProxy.Url = sb.webServiceUrl;
                            ProcessAgent pa = new ProcessAgent();
                            pa.agentGuid = txtServiceGUID.Text.Trim();
                            pa.agentName = txtServiceName.Text.Trim();
                            pa.domainGuid = ProcessAgentDB.ServiceAgent.domainGuid;
                            pa.codeBaseUrl = txtCodebaseUrl.Text.Trim();
                            pa.webServiceUrl = txtWebServiceUrl.Text.Trim();
                            pa.type = agentType;
                            //dbTicketing.SelfRegisterProcessAgent(pa.agentGuid, pa.agentName, agentType,
                            //    pa.domainGuid, pa.codeBaseUrl, pa.webServiceUrl);
                            //message.Append("Local information has been saved. ");
                            int returnValue = psProxy.ModifyProcessAgent(originalGuid, pa, null);
                            message.Append("The changes have been sent to the ServiceBroker");
                            if (returnValue > 0)
                            {
                                dbTicketing.SelfRegisterProcessAgent(pa.agentGuid, pa.agentName, agentType,
                                pa.domainGuid, pa.codeBaseUrl, pa.webServiceUrl);
                                bakServiceName.Value = pa.agentName;
                                bakCodebase.Value = pa.codeBaseUrl;
                                bakServiceUrl.Value = pa.webServiceUrl;
                                message.Append(".<br />Local information has been saved. ");
                                lblResponse.Text = Utilities.FormatConfirmationMessage(message.ToString());
                                lblResponse.Visible = true;

                            }
                            else
                            {
                                message.Append(", but did not process correctly!");
                                message.Append("<br />Local information has not been saved. ");
                                lblResponse.Text = Utilities.FormatErrorMessage(message.ToString());
                                lblResponse.Visible = true;
                            }
                        }
                    }
                    else
                    {
                        dbTicketing.SelfRegisterProcessAgent(ProcessAgentDB.ServiceAgent.agentGuid, txtServiceName.Text, agentType,
                                null, txtCodebaseUrl.Text, txtWebServiceUrl.Text);
                    }
                }
            }
            catch (Exception ex)
            {
                Exception ex2 = new Exception("Error in  selfRegistration.modify()",ex);
                Utilities.WriteLog(Utilities.DumpException(ex2));
                throw ex2;
            }
        }
Beispiel #7
0
        // Provider Registration methods - issued by the provider
        public static string RegisterClientServices(int sbId, Coupon lssCoupon, int lssId,
            Coupon lsCoupon, int lsId, Coupon clientCoupon, int clientId)
        {
            bool error = false;
            StringBuilder message = new StringBuilder();
            string lsDescriptor = null;
            string lssDescriptor = null;
            string clientDescriptor = null;
            ProcessAgentInfo remoteSB;
            ProcessAgentDB db = new ProcessAgentDB();
            ResourceDescriptorFactory factory = ResourceDescriptorFactory.Instance();
            try
            {
                // Check for enough information to perform the register

                    lsDescriptor = factory.CreateProcessAgentDescriptor(lsId);
                    if(lssId > 0)
                        lssDescriptor = factory.CreateProcessAgentDescriptor(lssId);

                    clientDescriptor = factory.CreateClientDescriptor(clientId);

                // What tickets do we need, create them

                string guid = Utilities.MakeGuid();
                ServiceDescription[] values = null;
                if (lssDescriptor != null)
                {
                    // Order is important
                    values = new ServiceDescription[3];
                    values[0] = new ServiceDescription(lssDescriptor, lssCoupon, null);
                    values[1] = new ServiceDescription(lsDescriptor, lsCoupon, null);
                    values[2] = new ServiceDescription(clientDescriptor, clientCoupon, null);
                }
                else
                {
                    values = new ServiceDescription[2];
                    values[0] = new ServiceDescription(lsDescriptor, lsCoupon, null);
                    values[1] = new ServiceDescription(clientDescriptor, clientCoupon, null);
                }

                // get the remote sb Proxy
                remoteSB = db.GetProcessAgentInfo(sbId);
                if (remoteSB == null || remoteSB.retired)
                {
                    throw new Exception("The remote service broker is not registered or is retired");
                }
                ProcessAgentProxy sbProxy = new ProcessAgentProxy();
                sbProxy.Url = remoteSB.webServiceUrl;
                sbProxy.AgentAuthHeaderValue = new AgentAuthHeader();
                sbProxy.AgentAuthHeaderValue.coupon = remoteSB.identOut;
                sbProxy.AgentAuthHeaderValue.agentGuid = ProcessAgentDB.ServiceGuid;
                sbProxy.Register(guid, values);
                message.AppendLine("RegisterClientServices: " + remoteSB.webServiceUrl + " \t" + guid + " \t" + "success");
            }
            catch (Exception ex)
            {
                Utilities.WriteLog("Error in cross-Register: " + ex.Message);
                message.AppendLine("Error in cross-Register: " + ex.Message);
                //throw;
            }
            return message.ToString();
        }
        protected void btnModify_Click(object sender, System.EventArgs e)
        {
            bool error = false;
            StringBuilder message = new StringBuilder();
            try
            {
                if (ProcessAgentDB.ServiceAgent != null)
                {
                    string originalGuid = ProcessAgentDB.ServiceAgent.agentGuid;
                    if (!(txtServiceName.Text != null && txtServiceName.Text.Length > 0))
                    {
                        error = true;
                        message.Append(" You must enter a Service Name<br/>");
                    }
                    try
                    {
                        if (!checkGuid())
                        {
                            error = true;
                            message.Append("There is an unspecified error with the GUID string.<br/>");
                        }
                    }
                    catch (Exception ex)
                    {
                        error = true;
                        message.Append("GUID Error: ");
                        message.Append(ex.Message);
                        message.Append("<br/>");
                    }
                    if (!(txtOutPasskey.Text != null && txtOutPasskey.Text.Length > 0))
                    {
                        error = true;
                        message.Append(" You must enter a default passkey<br/>");
                    }
                    if (!(txtCodebaseUrl.Text != null && txtCodebaseUrl.Text.Length > 0))
                    {
                        error = true;
                        message.Append(" You must enter the base URL for the Web Site<br/>");
                    }
                    else if (txtCodebaseUrl.Text.Contains("localhost"))
                    {
                        error = true;
                        message.Append(" You must not use localhost in a codebase URL, if you must test on the local machine please use '127.0.0.1'.<br/>");
                    }
                    if (!(txtServiceUrl.Text != null && txtServiceUrl.Text.Length > 0))
                    {
                        error = true;
                        message.Append(" You must enter the web Ssrvice URL for the Web Site<br/>");
                    }
                    else if (txtServiceUrl.Text.Contains("localhost"))
                    {
                        error = true;
                        message.Append(" You must not use localhost in a web service URL, if you must test only on the local machine please use '127.0.0.1'.<br/>");
                    }
                    else
                    { // Test for valid webService URL
                        ProcessAgentProxy paProxy = new ProcessAgentProxy();
                        paProxy.Url = txtServiceUrl.Text.Trim();
                        try
                        {
                            DateTime serTime = paProxy.GetServiceTime();
                        }
                        catch
                        {
                                error = true;
                                message.Append(" There is an error with the web service URL: " + txtServiceUrl.Text.Trim() + " Please check that it is valid and the web service is configured correctly.<br/>");
                        }
                    }
                    if (error)
                    {
                        lblResponse.Text = Utilities.FormatErrorMessage(message.ToString());
                        lblResponse.Visible = true;
                        return;
                    }
                    if (ProcessAgentDB.ServiceAgent.domainGuid != null)
                    {
                        ProcessAgentInfo originalAgent = dbTicketing.GetProcessAgentInfo(originalGuid);
                        ProcessAgentInfo sb = dbTicketing.GetProcessAgentInfo(ProcessAgentDB.ServiceAgent.domainGuid);
                        if ((sb != null) && !sb.retired)
                        {
                            ProcessAgentProxy psProxy = new ProcessAgentProxy();
                            AgentAuthHeader header = new AgentAuthHeader();
                            header.agentGuid = ProcessAgentDB.ServiceAgent.agentGuid;
                            header.coupon = sb.identOut;
                            psProxy.AgentAuthHeaderValue = header;
                            psProxy.Url = sb.webServiceUrl;
                            ProcessAgent pa = new ProcessAgent();
                            pa.agentGuid = txtServiceGuid.Text;
                            pa.agentName = txtServiceName.Text;
                            pa.domainGuid = ProcessAgentDB.ServiceAgent.domainGuid;
                            pa.codeBaseUrl = txtCodebaseUrl.Text;
                            pa.webServiceUrl = txtServiceUrl.Text;
                            pa.type = AgentType;
                            //dbTicketing.SelfRegisterProcessAgent(pa.agentGuid, pa.agentName, agentType,
                            //    pa.domainGuid, pa.codeBaseUrl, pa.webServiceUrl);
                            //message.Append("Local information has been saved. ");
                            int returnValue = psProxy.ModifyProcessAgent(originalGuid, pa, null);
                            message.Append("The changes have been sent to the ServiceBroker");
                            if (returnValue > 0)
                            {
                                dbTicketing.SelfRegisterProcessAgent(pa.agentGuid, pa.agentName, AgentType,
                                pa.domainGuid, pa.codeBaseUrl, pa.webServiceUrl);

                                message.Append(".<br />Local information has been saved. ");
                                lblResponse.Text = Utilities.FormatConfirmationMessage(message.ToString());
                                lblResponse.Visible = true;

                            }
                            else
                            {
                                message.Append(", but did not process correctly!");
                                message.Append("<br />Local information has not been saved. ");
                                lblResponse.Text = Utilities.FormatErrorMessage(message.ToString());
                                lblResponse.Visible = true;
                            }
                        }
                    }
                    else
                    {
                        string tmpGuid = null;
                        if (AgentType == ProcessAgentType.SERVICE_BROKER)
                        {
                            tmpGuid = ProcessAgentDB.ServiceAgent.agentGuid;
                            AuthorityUpdateSelf(txtServiceName.Text,ProcessAgentDB.ServiceAgent.agentGuid,
                                 txtCodebaseUrl.Text.Trim(), txtDescription.Text, txtContactInfo.Text,
                                 txtBugEmail.Text, txtLocation.Text);
                        }
                        dbTicketing.SelfRegisterProcessAgent(ProcessAgentDB.ServiceAgent.agentGuid, txtServiceName.Text, AgentType,
                                tmpGuid, txtCodebaseUrl.Text.Trim(), txtServiceUrl.Text.Trim());
                        dbTicketing.SaveSystemSupport(ProcessAgentDB.ServiceAgent.agentGuid, txtContactInfo.Text, txtBugEmail.Text,
                           txtInfoUrl.Text, txtDescription.Text, txtLocation.Text);
                    }
                    ProcessAgentDB.RefreshServiceAgent();
                //    if (txtOutPasskey.Text.CompareTo(ConfigurationManager.AppSettings["defaultPasskey"]) != 0)
                //    {
                //        ConfigurationManager.AppSettings.Set("defaultPasskey", txtOutPasskey.Text);
                //    }
                }
            }
            catch (Exception ex)
            {
                Exception ex2 = new Exception("Error in  selfRegistration.modify()", ex);
               Logger.WriteLine(Utilities.DumpException(ex2));
                throw ex2;
            }
        }
Beispiel #9
0
        public int RemoveTickets(List<Ticket> ticketList, BrokerDB brokerDb)
        {
            ArrayList coupons = new ArrayList();
            Coupon coupon = null;
            int ticketCount = 0;
            int couponCount = 0;
            if (ticketList.Count > 0)
            {
                Utilities.WriteLog("RemoveTickets: expired count = " + ticketList.Count);

                foreach (Ticket ticket in ticketList)
                {
                    if (!coupons.Contains(ticket.couponId))
                    {
                        coupons.Add(ticket.couponId);
                    }
                    if (coupon == null || coupon.couponId != ticket.couponId)
                    {
                        coupon = brokerDb.GetIssuedCoupon(ticket.couponId);
                    }
                    switch (ticket.type)
                    {
                        case TicketTypes.ADMINISTER_EXPERIMENT:

                            string payload = ticket.payload;
                            if (payload != null)
                            {
                                XmlQueryDoc xDoc = new XmlQueryDoc(payload);
                                string url = xDoc.Query("AdministerExperimentPayload/essURL");
                                string expStr = xDoc.Query("AdministerExperimentPayload/experimentID");
                                long expID = Convert.ToInt64(expStr);
                                ExperimentStorageProxy essProxy = new ExperimentStorageProxy();
                                essProxy.OperationAuthHeaderValue = new OperationAuthHeader();
                                essProxy.OperationAuthHeaderValue.coupon = coupon;
                                essProxy.Url = url;
                                StorageStatus expStatus = essProxy.SetExperimentStatus(expID, (int)StorageStatus.CLOSED_TIMEOUT);
                                DataStorageAPI.UpdateExperimentStatus(expStatus);
                            }
                            break;
                        case TicketTypes.RETRIEVE_RECORDS:
                        case TicketTypes.STORE_RECORDS:
                            break;
                        case TicketTypes.EXECUTE_EXPERIMENT:
                        case TicketTypes.ALLOW_EXPERIMENT_EXECUTION:
                            break;
                        default: // Every other Ticket type
                            break;
                    }
                    bool statusR = false;

                    if (ticket.redeemerGuid != brokerDb.GetIssuerGuid())
                    {
                        ProcessAgentInfo redeemer = brokerDb.GetProcessAgentInfo(ticket.redeemerGuid);
                        if ((redeemer != null) && !redeemer.retired)
                        {
                            ProcessAgentProxy paProxy = new ProcessAgentProxy();
                            paProxy.AgentAuthHeaderValue = new AgentAuthHeader();
                            paProxy.Url = redeemer.webServiceUrl;
                            paProxy.AgentAuthHeaderValue.coupon = redeemer.identOut;
                            paProxy.AgentAuthHeaderValue.agentGuid = ProcessAgentDB.ServiceGuid;
                            statusR = paProxy.CancelTicket(coupon, ticket.type, ticket.redeemerGuid);
                        }
                    }
                    if (ticket.issuerGuid == brokerDb.GetIssuerGuid())
                    {
                        brokerDb.DeleteIssuedTicket(ticket.ticketId);
                        ticketCount++;
                    }
                }
                foreach (long id in coupons)
                {
                    int count = brokerDb.GetIssuedCouponCollectionCount(id);
                    if (count == 0)
                    {
                        brokerDb.DeleteIssuedCoupon(id);
                        couponCount++;
                    }
                }
                Utilities.WriteLog("RemoveTickets: ticketCount=" + ticketCount + " \tcouponCount=" + couponCount);
            }
            return ticketCount;
        }
Beispiel #10
0
        public static string RegisterGroupCredentials(int sbId)
        {
            StringBuilder message = new StringBuilder();
            ProcessAgentInfo remoteSB = null;

            ProcessAgentDB db = new ProcessAgentDB();
            ResourceDescriptorFactory factory = ResourceDescriptorFactory.Instance();
            string guid = Utilities.MakeGuid();
            ServiceDescription[] values = null;
            // get the remote sb Proxy
            remoteSB = db.GetProcessAgentInfo(sbId);
            if (remoteSB == null || remoteSB.retired)
            {
                throw new Exception("The remote service broker is not registered or is retired");
            }
            ProcessAgentProxy sbProxy = new ProcessAgentProxy();
            sbProxy.Url = remoteSB.webServiceUrl;
            sbProxy.AgentAuthHeaderValue = new AgentAuthHeader();
            sbProxy.AgentAuthHeaderValue.coupon = remoteSB.identOut;
            sbProxy.AgentAuthHeaderValue.agentGuid = ProcessAgentDB.ServiceGuid;
            sbProxy.Register(guid, values);
            message.AppendLine("RegisterGroupCredentials: " + remoteSB.webServiceUrl + " \t" + guid + " \t" + "success");
            return message.ToString();
        }
        public override int ModifyDomainCredentials(string originalGuid, ProcessAgent agent, string extra, 
            Coupon inCoupon, Coupon outCoupon)
        {
            int status = 0;

            if (brokerDB.AuthenticateAgentHeader(agentAuthHeader))
            {
                status = brokerDB.ModifyDomainCredentials(originalGuid, agent, inCoupon, outCoupon, extra);

                //Notify all ProcessAgents about the change
                ProcessAgentInfo[] domainServices = brokerDB.GetProcessAgentInfos();
                ProcessAgentProxy proxy = null;
                foreach (ProcessAgentInfo pi in domainServices)
                {
                    // Do not send if retired this service or the service being modified since this is
                    if (!pi.retired && (pi.agentGuid.CompareTo(ProcessAgentDB.ServiceGuid) != 0)
                        && (pi.agentGuid.CompareTo(agent.agentGuid) != 0))
                    {
                        proxy = new ProcessAgentProxy();
                        proxy.AgentAuthHeaderValue = new AgentAuthHeader();
                        proxy.AgentAuthHeaderValue.agentGuid = ProcessAgentDB.ServiceGuid;
                        proxy.AgentAuthHeaderValue.coupon = pi.identOut;
                        proxy.Url = pi.webServiceUrl;

                        status += proxy.ModifyDomainCredentials(originalGuid, agent, extra, inCoupon, outCoupon);
                    }
                }
            }
            return status;
        }
        public override bool CancelTicket(Coupon coupon, string type, string redeemer)
        {
            bool status = false;
            if (brokerDB.AuthenticateAgentHeader(agentAuthHeader))
            {
                // Move all this into BrokerDB

                if (ProcessAgentDB.ServiceGuid.Equals(redeemer))
                {
                    // this ServiceBroker is the redeemer
                    status = brokerDB.CancelTicket(coupon, type, redeemer);
                }
                else
                {
                    ProcessAgentInfo target = brokerDB.GetProcessAgentInfo(redeemer);
                    if (target != null)
                    {
                        if (target.retired)
                        {
                            throw new Exception("The ProcessAgent is retired");
                        }
                        if (ProcessAgentDB.ServiceGuid.Equals(target.domainGuid))
                        {
                            // Its a local domain processAgent
                            ProcessAgentProxy paProxy = new ProcessAgentProxy();
                            paProxy.AgentAuthHeaderValue = new AgentAuthHeader();
                            paProxy.AgentAuthHeaderValue.coupon = target.identOut;
                            paProxy.AgentAuthHeaderValue.agentGuid = ProcessAgentDB.ServiceGuid;
                            paProxy.Url = target.webServiceUrl;
                            status = paProxy.CancelTicket(coupon, type, redeemer);

                        }
                        else
                        {
                            ProcessAgentInfo remoteSB = brokerDB.GetProcessAgentInfo(target.domainGuid);
                            if (remoteSB != null)
                            {
                                if (remoteSB.retired)
                                {
                                    throw new Exception("The ProcessAgent is retired");
                                }
                                // Its from a known domain
                                ProcessAgentProxy sbProxy = new ProcessAgentProxy();
                                sbProxy.AgentAuthHeaderValue = new AgentAuthHeader();
                                sbProxy.AgentAuthHeaderValue.coupon = remoteSB.identOut;
                                sbProxy.AgentAuthHeaderValue.agentGuid = ProcessAgentDB.ServiceGuid;
                                sbProxy.Url = remoteSB.webServiceUrl;
                                status = sbProxy.CancelTicket(coupon, type, redeemer);

                            }
                        }
                    }
                }
            }
            return status;
        }
Beispiel #13
0
        // Error recovery must be added to this method
        protected void btnSaveChange_Click(object sender, EventArgs e)
        {
            int id = int.Parse(ddlLabClient.SelectedValue);
            if (id > 0)
            {
                LabClient[] clients = wrapper.GetLabClientsWrapper(new int[] { id });
                if (clients.Length > 0 && clients[0].clientID > 0)
                {
                    theClient = clients[0];
                }
            }
            // objects used in try block may be required for recovery if  errors
            bool noError = true;
            ProcessAgentInfo labServer = null;
            ProcessAgentInfo uss = null;
            ProcessAgentInfo lss = null;
            long rmUss = 0;

            lblResponse.Visible = false;
            lblResponse.Text = "";
            try
            {
                if (ddlUserGroup.SelectedIndex <= 0)
                {
                    lblResponse.Visible = true;
                    lblResponse.Text = Utilities.FormatWarningMessage("Please select a user group from the corresponding drop-down list.");
                    return;
                }
                int groupID = Convert.ToInt32(ddlUserGroup.SelectedValue);
                if (groupID <= 0)
                {
                    lblResponse.Visible = true;
                    lblResponse.Text = Utilities.FormatWarningMessage("The user group is invalid.");
                    return;
                }
                //Get the user Group Name to be displayed in the repeater
                Group[] userGroup = wrapper.GetGroupsWrapper(new int[] { groupID });
                string userGroupName = userGroup[0].GroupName;

                if (theClient.labServerIDs != null && theClient.labServerIDs.Length > 0)
                {
                    labServer = issuer.GetProcessAgentInfo(theClient.labServerIDs[0]);
                }
                if (labServer == null)
                {
                    lblResponse.Visible = true;
                    lblResponse.Text = Utilities.FormatWarningMessage("Lab Client should first be associated with a Lab Server");
                    return;
                }

                if (theClient.needsScheduling)
                {
                    if (ddlAdminGroup.SelectedIndex <= 0 || ddlUserGroup.SelectedIndex <= 0)
                    {
                        lblResponse.Visible = true;
                        lblResponse.Text = Utilities.FormatWarningMessage("Please select a user and management group from the corresponding drop-down lists.");
                        return;
                    }
                    int manageID = Convert.ToInt32(ddlAdminGroup.SelectedValue);
                    if (manageID <= 0)
                    {
                        lblResponse.Visible = true;
                        lblResponse.Text = Utilities.FormatWarningMessage("The management group is invalid.");
                        return;
                    }

                    int ussId = issuer.FindProcessAgentIdForClient(theClient.clientID, ProcessAgentType.SCHEDULING_SERVER);
                    if (ussId <= 0)
                    {
                        lblResponse.Visible = true;
                        lblResponse.Text = Utilities.FormatWarningMessage("Lab Client should first be associated with a USS");
                        return;
                    }
                    int lssId = issuer.FindProcessAgentIdForAgent(theClient.labServerIDs[0], ProcessAgentType.LAB_SCHEDULING_SERVER);
                    if (lssId <= 0)
                    {
                        lblResponse.Visible = true;
                        lblResponse.Text = Utilities.FormatWarningMessage("Lab Server should first be associated with an LSS");
                        return;
                    }

                    else
                    {

                        uss = issuer.GetProcessAgentInfo(ussId);
                        if (uss.retired)
                        {
                            throw new Exception("The USS is retired");
                        }
                        lss = issuer.GetProcessAgentInfo(lssId);
                        if (lss.retired)
                        {
                            throw new Exception("The LSS is retired");
                        }

                        //Object keyObj = groupID;
                        //string keyType = ResourceMappingTypes.GROUP;
                        ResourceMappingKey key = new ResourceMappingKey(ResourceMappingTypes.GROUP, groupID);
                        ResourceMappingValue[] values = new ResourceMappingValue[3];
                        values[0] = new ResourceMappingValue(ResourceMappingTypes.CLIENT, theClient.clientID);
                        values[1] = new ResourceMappingValue(ResourceMappingTypes.TICKET_TYPE,
                            TicketTypes.GetTicketType(TicketTypes.MANAGE_USS_GROUP));
                        values[2] = new ResourceMappingValue(ResourceMappingTypes.GROUP,manageID);

                        //values[0] = new ResourceMappingValue(ResourceMappingTypes.RESOURCE_TYPE, ProcessAgentType.SCHEDULING_SERVER);
                        //values[1] = new ResourceMappingValue(ResourceMappingTypes.PROCESS_AGENT, ussId);

                        ResourceMapping newMapping = issuer.AddResourceMapping(key, values);
                        rmUss = newMapping.MappingID;

                        // add mapping to qualifier list
                        int qualifierType = Qualifier.resourceMappingQualifierTypeID;
                        string name = issuer.ResourceMappingToString(newMapping);
                        int qualifierID = AuthorizationAPI.AddQualifier(newMapping.MappingID, qualifierType, name, Qualifier.ROOT);

                        //Give the Manager Group a Grant "MANAGE_USS_GROUP" on the created resource mapping
                        string function = Function.manageUSSGroup;
                        int grantID = wrapper.AddGrantWrapper(manageID, function, qualifierID);

                        //Get the management Group Name to be displayed in the repeater
                        Group[] adminGroup = wrapper.GetGroupsWrapper(new int[] { manageID });
                        string adminGroupName = adminGroup[0].GroupName;

                        //Create the Map between user and management group
                        GroupManagerUserMap groupMap = new GroupManagerUserMap(adminGroupName, userGroupName, grantID, newMapping.MappingID);

                        TicketLoadFactory factory = TicketLoadFactory.Instance();
                        //long duration = 60;
                        // Get this SB's domain Guid
                        string domainGuid = ProcessAgentDB.ServiceGuid;
                        string sbName = ProcessAgentDB.ServiceAgent.agentName;

                        //Add Credential set on the USS

                        //string ussPayload = factory.createAdministerUSSPayload(Convert.ToInt32(Session["userTZ"]));
                        //Coupon ussCoupon = issuer.CreateTicket(TicketTypes.ADMINISTER_USS, uss.agentGuid,
                        //    issuer.GetIssuerGuid(), duration, ussPayload);
                        UserSchedulingProxy ussProxy = new UserSchedulingProxy();
                        ussProxy.Url = uss.webServiceUrl;
                        ussProxy.AgentAuthHeaderValue = new AgentAuthHeader();
                        ussProxy.AgentAuthHeaderValue.coupon = uss.identOut;
                        ussProxy.AgentAuthHeaderValue.agentGuid = domainGuid;

                        ussProxy.AddCredentialSet(domainGuid, sbName, userGroupName);

                        // Check for existing RevokeReservation ticket redeemer = USS, sponsor = LSS
                        Coupon[] revokeCoupons = issuer.RetrieveIssuedTicketCoupon(
                            TicketTypes.REVOKE_RESERVATION, uss.agentGuid, lss.agentGuid);
                        Coupon revokeCoupon = null;
                        if (revokeCoupons != null && revokeCoupons.Length > 0)
                        {
                            revokeCoupon = revokeCoupons[0];
                        }
                        else
                        {
                            // Create RevokeReservation ticket
                            revokeCoupon = issuer.CreateTicket(TicketTypes.REVOKE_RESERVATION,
                                 uss.agentGuid, lss.agentGuid, -1L, factory.createRevokeReservationPayload());
                        }

                        //Add Credential set on the LSS

                        // check if this domain
                        if (ProcessAgentDB.ServiceGuid.Equals(lss.domainGuid))
                        {
                            LabSchedulingProxy lssProxy = new LabSchedulingProxy();
                            lssProxy.Url = lss.webServiceUrl;
                            lssProxy.AgentAuthHeaderValue = new AgentAuthHeader();
                            lssProxy.AgentAuthHeaderValue.coupon = lss.identOut;
                            lssProxy.AgentAuthHeaderValue.agentGuid = domainGuid;
                            // Add the USS to the LSS, this may be called multiple times with duplicate data
                            lssProxy.AddUSSInfo(uss.AgentGuid, uss.agentName, uss.webServiceUrl, revokeCoupon);
                            int credentialSetAdded = lssProxy.AddCredentialSet(domainGuid,
                                sbName, userGroupName, uss.agentGuid);
                        }
                        else
                        { // Cross-Domain Registration needed
                            ProcessAgentInfo remoteSB = issuer.GetProcessAgentInfo(lss.domainGuid);
                            if(remoteSB.retired){
                                throw new Exception("The remote service broker is retired");
                            }
                            ResourceDescriptorFactory resourceFactory = ResourceDescriptorFactory.Instance();
                            string ussDescriptor = resourceFactory.CreateProcessAgentDescriptor(ussId);
                            string lssDescriptor = resourceFactory.CreateProcessAgentDescriptor(lssId);
                            string groupDescriptor = resourceFactory.CreateGroupCredentialDescriptor(domainGuid, sbName, userGroupName, uss.agentGuid, lss.agentGuid);

                            ServiceDescription[] info = new ServiceDescription[3];
                            info[0] = new ServiceDescription(null, revokeCoupon, ussDescriptor);
                            info[1] = new ServiceDescription(null, null, lssDescriptor);
                            info[2] = new ServiceDescription(null, null, groupDescriptor);

                            ProcessAgentProxy sbProxy = new ProcessAgentProxy();
                            sbProxy.AgentAuthHeaderValue = new AgentAuthHeader();
                            sbProxy.AgentAuthHeaderValue.agentGuid = domainGuid;
                            sbProxy.AgentAuthHeaderValue.coupon = remoteSB.identOut;
                            sbProxy.Url = remoteSB.webServiceUrl;
                            sbProxy.Register(Utilities.MakeGuid(), info);
                        }
                    }
                }

                /*Update Lab Client grants*/

                //Get qualifier for labclient
                int lcQualifierID = AuthorizationAPI.GetQualifierID(theClient.clientID, Qualifier.labClientQualifierTypeID);
                //Get all "uselabclient" grants for this labclient
                int[] lcGrantIDs = wrapper.FindGrantsWrapper(-1, Function.useLabClientFunctionType, lcQualifierID);
                Grant[] lcGrants = wrapper.GetGrantsWrapper(lcGrantIDs);
                //Get list of agents that can use labclient
                ArrayList lcAgents = new ArrayList();
                foreach (Grant g in lcGrants)
                    lcAgents.Add(g.agentID);

                //if that agent doesn't already have the uselabclient permission
                if (!lcAgents.Contains(groupID))
                    //add lab client grant
                    wrapper.AddGrantWrapper(groupID, Function.useLabClientFunctionType, lcQualifierID);

                /*Update Lab Servers grant*/

                //Update grants for each of the associated lab servers
                foreach (int lsID in theClient.labServerIDs)
                {
                    //Get qualifier for labserver
                    int lsQualifierID = AuthorizationAPI.GetQualifierID(lsID, Qualifier.labServerQualifierTypeID);
                    //Get all "uselabserver" grants for this labserver
                    int[] lsGrantIDs = wrapper.FindGrantsWrapper(-1, Function.useLabServerFunctionType, lsQualifierID);
                    Grant[] lsGrants = wrapper.GetGrantsWrapper(lsGrantIDs);
                    //Get list of agents that can use labserver
                    ArrayList lsAgents = new ArrayList();
                    foreach (Grant g in lsGrants)
                        lsAgents.Add(g.agentID);

                    //int groupID = Convert.ToInt32(ddlUserGroup.SelectedValue);

                    //if that agent doesn't already have the uselabclient permission
                    if (!lsAgents.Contains(groupID))
                        //add lab server grant
                        wrapper.AddGrantWrapper(groupID, Function.useLabServerFunctionType, lsQualifierID);
                }

                //Refresh the repeater
                RefreshAdminUserGroupsRepeater();
                LoadListBoxes();

                lblResponse.Visible = true;
                lblResponse.Text = Utilities.FormatConfirmationMessage("Lab client (& corresponding lab servers) successfully updated. ");
            }
            catch (Exception ex)
            {
                lblResponse.Visible = true;
                lblResponse.Text = Utilities.FormatErrorMessage("Cannot update Lab Client. " + ex.GetBaseException());
            }
        }
Beispiel #14
0
        /// <summary>
        /// Generate New Incoming Passkey Button
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnRegister_Click(object sender, System.EventArgs e)
        {
            int agentID = 0;
            ProcessAgent service = ProcessAgentDB.ServiceAgent;
            if (service == null)
            {
                lblErrorMessage.Visible = true;
                lblErrorMessage.Text = Utilities.FormatErrorMessage("This service broker has not been configured. You must perform selfRegistration before any other services are registered.");
                return;
            }

            if (txtServiceType.Text.Equals(ProcessAgentType.BATCH_LAB_SERVER))
            {
                bool hasError = false;
                StringBuilder errorMess = new StringBuilder();
                errorMess.AppendLine("Error: Registering a Batch LabServer you are missing the following fields:");

                if (txtWebServiceURL.Text == null || txtWebServiceURL.Text.Length == 0)
                {
                    hasError = true;
                    errorMess.Append('\t' + "Web Service URL");
                }
                if (txtServiceGUID.Text == null || txtServiceGUID.Text.Length == 0 || txtServiceGUID.Text.Length > 35)
                {
                    hasError = true;
                    errorMess.Append('\t' + "Service GUID: Batch LabServer Guids must be between 1 and 35 characters");
                }
                //if (txtBatchPassIn.Text == null || txtBatchPassIn.Text.Length == 0)
                //{
                //    hasError = true;
                //    errorMess.Append('\t' + "Passcode From LabServer");
                //}
                //if (txtBatchPassOut.Text == null || txtBatchPassOut.Text.Length == 0)
                //{
                //    hasError = true;
                //    errorMess.Append('\t' + "Passcode To LabServer");
                //}
                if (txtApplicationURL.Text == null || txtApplicationURL.Text.Length == 0)
                {
                    hasError = true;
                    errorMess.Append('\t' + "Codebase URL");
                }
                if (txtServiceName.Text == null || txtServiceName.Text.Length == 0)
                {
                    hasError = true;
                    errorMess.Append('\t' + "Service Name");
                }
                if (hasError)
                {
                    errorMess.AppendLine("");
                    lblErrorMessage.Visible = true;
                    lblErrorMessage.Text = Utilities.FormatErrorMessage(errorMess.ToString());
                    return;
                }
                // Missing fields check passed start to create the BatchLabServer records,
                // hopefully the data is correct,
                // Since InstallDomainCredentials is not supported by the 6.1 Batch labs we must
                // only do one side of the operation.
                // Batch labs have a one to one relationship with service brokers,
                // this means it must be a member of this domain
                int tstID = brokerDB.GetProcessAgentID(txtServiceGUID.Text);
                if (tstID > 0)
                {
                    lblErrorMessage.Visible = true;
                    lblErrorMessage.Text = Utilities.FormatErrorMessage("A service with the specified Guid has already been registered.");
                    return;
                }
                Coupon inCoupon = null;
                if (txtBatchPassIn.Text != null && txtBatchPassIn.Text.Length > 0)
                {
                    inCoupon = brokerDB.CreateCoupon(txtBatchPassIn.Text);
                }
                Coupon outCoupon = null;
                if (txtBatchPassOut.Text != null && txtBatchPassOut.Text.Length > 0)
                {
                    outCoupon = brokerDB.CreateCoupon(txtBatchPassOut.Text);
                }
                agentID = wrapper.AddProcessAgentWrapper(txtServiceGUID.Text, txtServiceName.Text,
                    ProcessAgentType.BATCH_LAB_SERVER, ProcessAgentDB.ServiceGuid, txtApplicationURL.Text,
                    txtWebServiceURL.Text, inCoupon, outCoupon);

                modifySystemSupport(agentID);
                if (agentID > 0)
                {
                    lblErrorMessage.Visible = true;
                    lblErrorMessage.Text = Utilities.FormatConfirmationMessage("Relationship with the service has been created and saved.");
                }
                ClearButtonScripts();

            }

            else
            { // Interactive service
                if ((txtWebServiceURL.Text == "") || (txtOutPassKey.Text == ""))
                {
                    lblErrorMessage.Visible = true;
                    lblErrorMessage.Text = Utilities.FormatErrorMessage("Please specify a Web Service URL and initial passkey before registering the service.");
                    return;
                }

                else
                {

                    try
                    {
                        Coupon inIdentCoupon = brokerDB.CreateCoupon();
                        Coupon outIdentCoupon = brokerDB.CreateCoupon();

                        ProcessAgent agent = null;

                        ProcessAgentProxy proxy = new ProcessAgentProxy();
                        InitAuthHeader data = new InitAuthHeader();
                        proxy.Url = txtWebServiceURL.Text.Trim();

                        data.initPasskey = txtOutPassKey.Text.Trim();
                        proxy.InitAuthHeaderValue = data;

                        agent = proxy.InstallDomainCredentials(service, inIdentCoupon, outIdentCoupon);
                        if (agent != null)
                        {
                            if (agent.type.Equals(ProcessAgentType.SERVICE_BROKER))
                                agent.type = ProcessAgentType.REMOTE_SERVICE_BROKER;
                            agentID = wrapper.AddProcessAgentWrapper(agent.agentGuid, agent.agentName, agent.type,
                                agent.domainGuid, agent.codeBaseUrl, agent.webServiceUrl,
                                outIdentCoupon, inIdentCoupon);

                            // Create the default AdminUrls
                            switch (agent.type)
                            {
                                case ProcessAgentType.EXPERIMENT_STORAGE_SERVER:
                                    //brokerDB.InsertAdminURL(agentId, agent.codeBaseUrl + "/administer.aspx", TicketTypes.ADMINISTER_ESS);
                                    break;
                                case ProcessAgentType.LAB_SCHEDULING_SERVER:
                                    brokerDB.InsertAdminURL(agentID, agent.codeBaseUrl + "/administer.aspx", TicketTypes.ADMINISTER_LSS);
                                    brokerDB.InsertAdminURL(agentID, agent.codeBaseUrl + "/manage.aspx", TicketTypes.MANAGE_LAB);
                                    break;
                                case ProcessAgentType.LAB_SERVER:
                                    brokerDB.InsertAdminURL(agentID, agent.codeBaseUrl + "/administer.aspx", TicketTypes.ADMINISTER_LS);
                                    brokerDB.InsertAdminURL(agentID, agent.codeBaseUrl + "/administer.aspx", TicketTypes.MANAGE_LAB);
                                    break;
                                case ProcessAgentType.SCHEDULING_SERVER:
                                    brokerDB.InsertAdminURL(agentID, agent.codeBaseUrl + "/administer.aspx", TicketTypes.ADMINISTER_USS);
                                    brokerDB.InsertAdminURL(agentID, agent.codeBaseUrl + "/manage.aspx", TicketTypes.MANAGE_USS_GROUP);
                                    brokerDB.InsertAdminURL(agentID, agent.codeBaseUrl + "/Reservation.aspx", TicketTypes.SCHEDULE_SESSION);
                                    break;
                                case ProcessAgentType.REMOTE_SERVICE_BROKER:
                                default:
                                    break;
                            }
                            SystemSupport mySS = brokerDB.RetrieveSystemSupport(ProcessAgentDB.ServiceGuid);
                            if (mySS != null)
                            {
                                ServiceDescription[] values = new ServiceDescription[1];
                                values[0] = new ServiceDescription(mySS.ToXML(), null, "requestSystemSupport");
                                proxy.AgentAuthHeaderValue = new AgentAuthHeader();
                                proxy.AgentAuthHeaderValue.coupon = inIdentCoupon;
                                proxy.AgentAuthHeaderValue.agentGuid = ProcessAgentDB.ServiceGuid;
                                proxy.Register(Utilities.MakeGuid(), values);
                            }
                            lblErrorMessage.Visible = true;
                            lblErrorMessage.Text = Utilities.FormatConfirmationMessage("Relationship with the service has been created and saved.");

                            // set the script of the "Admin URL button"
                            SetBtnScripts(agent.agentGuid,agent.type);
                        }
                    }
                    catch (Exception ex)
                    {
                        lblErrorMessage.Visible = true;
                        //lblErrorMessage.Text = Utilities.FormatErrorMessage("InstallDomainCredentials Error: " + Utilities.DumpException(ex));
                        lblErrorMessage.Text = Utilities.FormatErrorMessage("InstallDomainCredentials Error: " + ex.Message);
                    }
                }
            }
            InitializeDropDown();
            if (agentID > 0)
            {
                ddlService.Items.FindByValue(agentID.ToString()).Selected = true;
                //SetInputMode(true);
                displayService(agentID);
            }
            else
            {
                if (ddlService.Items.Count > 0)
                {
                    ddlService.Items[0].Selected = true;
                }
            }
        }
        protected virtual void register(string registerGuid, ServiceDescription[] info)
        {
            StringBuilder message = new StringBuilder("Register called on " + ProcessAgentDB.ServiceAgent.codeBaseUrl);

            if (info != null && info.Length > 0)
            {
                foreach (ServiceDescription sd in info)
                {
                    Coupon coupon = null;
                    if (sd.coupon != null)
                    {
                        coupon = sd.coupon;
                    }
                    XmlQueryDoc xdoc = new XmlQueryDoc(sd.serviceProviderInfo);
                    string descriptorType = xdoc.GetTopName();
                    if (descriptorType.Equals("systemSupport"))
                    {
                        SystemSupport ss = SystemSupport.Parse(xdoc);
                        if (ss.agentGuid != null && ss.agentGuid.Length > 0)
                        {
                            int id = dbTicketing.GetProcessAgentID(ss.agentGuid);
                            if (id > 0)
                            {
                                dbTicketing.SaveSystemSupport(ss.agentGuid, ss.contactEmail, ss.bugEmail,
                                    ss.infoUrl, ss.description, ss.location);
                                if (sd.consumerInfo != null && sd.consumerInfo.CompareTo("requestSystemSupport") == 0)
                                {
                                    ProcessAgentInfo paInfo = dbTicketing.GetProcessAgentInfo(ss.agentGuid);
                                    if (paInfo != null)
                                    {
                                        SystemSupport mySS = dbTicketing.RetrieveSystemSupport(ProcessAgentDB.ServiceGuid);
                                        if (mySS != null)
                                        {
                                            ServiceDescription[] values = new ServiceDescription[1];
                                            values[0] = new ServiceDescription(mySS.ToXML(), null, null);
                                            ProcessAgentProxy proxy = new ProcessAgentProxy();
                                            proxy.Url = paInfo.webServiceUrl;
                                            proxy.AgentAuthHeaderValue = new AgentAuthHeader();
                                            proxy.AgentAuthHeaderValue.coupon = paInfo.identOut;
                                            proxy.AgentAuthHeaderValue.agentGuid = ProcessAgentDB.ServiceGuid;
                                            proxy.Register(registerGuid, values);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }