Esempio n. 1
0
        public EAuthRequestViewModel CreateRequestAsync(string requestUrl, string callbackUrl, string serviceOid, string providerOid,
                                                        string signatureNsPrefix, bool includePublicKey, string sslCertificateThumbprint)
        {
            XmlDocument doc = EAuthPersonUtil.CreateSamlRequest(
                _eAuthUrl, ThisSystem.Oid, ThisSystem.Name, ThisSystem.Name, requestUrl, callbackUrl, serviceOid, providerOid,
                signatureNsPrefix, includePublicKey, sslCertificateThumbprint, out string requestId);

            string samlRequest = doc.OuterXml;
            string relayState  = null;

            SignUtil.Status signatureStatus = SignUtil.ValidateText(samlRequest);

            return(new EAuthRequestViewModel
            {
                RequestId = requestId,
                // Полета, необходими за скритата форма, която се POST-ва към еАвт.
                EAuthUrl = _eAuthUrl,
                SAMLRequest = EncodeSamlParameter(samlRequest),
                RelayState = EncodeSamlParameter(relayState),
                // Допълнителни полета за потребителя и за debug цели.
                SamlRequestBeautified = XmlUtil.BeautifyXml(samlRequest),
                SamlRequestDecoded = samlRequest,
                RelayStateDecoded = relayState,
                SignatureStatusName = SignUtil.FormatStatus(signatureStatus)
            });
        }
Esempio n. 2
0
        public static void ImportManagers(XmlDocument xmlDoc)
        {
            try
            {
                Logger.LogEvent(" Checking if file exists");
                string bat = ConfigurationManager.AppSettings["BAT"];
                if (File.Exists(file))
                {
                    string contents = XmlUtil.BeautifyXml(xmlDoc);
                    Logger.LogEvent(" File exists!");
                    Logger.LogEvent(" Starting import");
                    File.WriteAllText(file, contents, Encoding.UTF8);

                    try
                    {
                        StringBuilder sbOut = new StringBuilder();
                        ExecuteImport(sbOut);
                    }
                    catch (Exception ex)
                    {
                        EmailUtility.SendEmail("Error executing Optial Data Import. " + "\r\n" + ex.Message, "Import Failed!");
                        Logger.LogEvent(" Error executing Optial Data Import: " + ex.Message);
                    }

                    if (File.Exists(bat))
                    {
                        try
                        {
                            Logger.LogEvent(" Bat found! Starting bat execution");
                            Process.Start(bat);
                            Logger.LogEvent(" Finished bat execution");
                        }
                        catch (Exception ex)
                        {
                            Logger.LogEvent(" Error executing bat file: ");
                            Logger.LogException(ex.Message);
                            Logger.WriteLogToFile();
                        }
                    }
                }

                Logger.Log.Append("**************** FINISHED MANAGER UPDATE ****************" + "\r\n" + "\r\n");
                Logger.WriteLogToFile();
            }
            catch (Exception e)
            {
                EmailUtility.SendEmail("Error executing import part: " + "\r\n" + e.Message, "Import Failed!");
                Logger.LogException(e.Message);
                Logger.WriteLogToFile();
            }
        }