コード例 #1
0
        public AuthenticationResponce TokenAuthenticate(EntrustRequest _param)
        {
            try
            {
                logger.Debug("Entrust validation started");
                string Url          = ConfigurationManager.AppSettings["Token_ENDPOINT"].ToString();
                bool   Token_Islive = Convert.ToBoolean(ConfigurationManager.AppSettings["Token_Islive"]);
                string sb           = TokenRequest.TokenRequestPayload; // File.ReadAllText(HttpContext.Current.Server.MapPath("~/XML/TokenAuthRequest.xml"));
                sb = string.Format(sb, _param.response, _param.userGroup, _param.username, _param.requesterId, _param.requesterIp);

                string authentication         = ConfigurationManager.AppSettings["upm_Authentication"].ToString();
                AuthenticationResponce result = XmlHelpers.XmlProcessor(Url, sb, Token_Islive, authentication);
                logger.Debug("AuthenticationService::TokenAuthenticate::Responce:: " + result.isSuccessful);
                //using (StringReader stringreader = new StringReader(XmlHelpers.XmlGetPayload(result)))
                //{
                //    var serializer = new XmlSerializer(typeof(AuthenticationResponce));
                //    var s = (AuthenticationResponce)serializer.Deserialize(stringreader);
                //    return s;
                //}

                return(result);
            }
            catch (Exception ex)
            {
                logger.Error(ex.StackTrace.ToString());
                throw new Exception(ex.Message + "\n" + ex.StackTrace);
            }
        }
コード例 #2
0
        public string[] VerifyUser(string username, string password, string tokenValue, int portalID, string portalName, string hostName)
        {
            logger.Info("validation started");
            string[] result   = new string[2];
            string   staffid  = string.Empty;
            UserInfo userInfo = null;
            User     user     = null;

            try
            {
                user     = User.Login(username, password);
                userInfo = UserController.GetUserByName(portalID, user.Username);
            }
            catch (Exception ex)
            {
                logger.Debug("Exception on User.Login");
                logger.Error(ex.StackTrace.ToString());
                //throw;
            }
            Employee employee;

            //string finacleID = "";
            if (userInfo == null)
            {
                //this.Navigate(user.Username, returnUrl);
                //Logger.Info("Hello123");
                result[0] = "You're not authorized to use this application.";
                result[1] = "";
                return(result);
            }
            else
            {
                string finacleid = "";
                staffid = user.EmployeeNumber.ToString().Trim();
                string usernametrim = user.Email.Trim().ToLower().Replace("@ubagroup.com", "");
                ProcessManager.WorkItems.Util.AD_Data da = new ProcessManager.WorkItems.Util.AD_Data();
                da.ActiveDirectoryWrapper();
                da.PopulateUserDataStruct(da.GetUserDirectoryEntryDetails(usernametrim));
                ProcessManager.WorkItems.Util.AD_Data.ApplicationUserData user_data = da.userData;
                string countrycode = string.Empty;
                string solid       = string.Empty;
                logger.Info("Usermail: " + user_data.personEmail);
                try
                {
                    countrycode = (user_data.personLocation.ToString().Substring(0, 3).ToString()).ToUpper();
                }
                catch (Exception)
                {
                    countrycode = "NGA";
                }
                try
                {
                    solid = (user_data.personLocation.ToString().Substring(4, 4).ToString()).ToUpper();
                }
                catch (Exception)
                {
                    solid = "0999";
                }
                getlivefinacleid(staffid, countrycode);


                try
                {
                    //Get user details by mail
                    DataAccess dataAccess = new DataAccess();
                    employee  = dataAccess.GetEmployeeDetails(username);
                    finacleid = employee.FinacleID;
                    logger.Debug("Finacle ID:" + employee.FinacleID);
                }
                catch (Exception ex)
                {
                    logger.Error("User does not exist");
                    logger.Error("Data access:" + ex.ToString());
                }

                if ((finacleid.Trim() == string.Empty) || (finacleid.Trim() == null))
                {
                    result[0] = "Invalid Finacle User for " + staffid.Trim() + "!";
                    result[1] = "";
                    return(result);
                }
                else
                {
                    var entrustReq = new EntrustRequest
                    {
                        requesterId = "",
                        requesterIp = "",
                        response    = tokenValue,
                        userGroup   = ConfigurationManager.AppSettings["Token_UserGroup"],
                        username    = finacleid
                    };
                    EntrustRP entrust          = new EntrustRP();
                    var       entrust_response = entrust.TokenAuthenticate(entrustReq);
                    logger.Debug("Entrust value:" + entrust_response.isSuccessful);
                    if (entrust_response.isSuccessful == "true")
                    {
                        UserController.UserLogin(portalID, userInfo, portalName, hostName, false);
                        result[0] = "true";
                        result[1] = solid;
                    }
                    else
                    {
                        result[0] = "Invalid login attempt";
                        result[1] = "";
                    }
                    logger.Info("Result is {0} and {1}", result[0], result[1]);
                    return(result);
                }
            }

            //Session["SolID"] = solid;
            //return usernametrim+":"+solid+":"+countrycode;
            //return staffid;
        }