public virtual bool RunTest() { if (_geometryOperation != null) { var arguments = ToArguments(); IResult expectedResult = null; var returnType = _geometryOperation.GetReturnType(_enumTestType); if (returnType == typeof(int)) expectedResult = new IntegerResult((int)Result); else if (returnType == typeof(bool)) expectedResult = new BooleanResult((bool)Result); else if (returnType == typeof(double)) expectedResult = new DoubleResult((int)Result); else if (returnType == typeof(IGeometry)) expectedResult = new GeometryResult((IGeometry)Result); else { Debug.Assert(false); } var result = _geometryOperation.Invoke(_enumTestType, IsDefaultTarget ? _objGeometryA : _objGeometryB, ToArguments()); if (_resultMatcher == null) _resultMatcher = CreateEqualityResultMatcher(returnType); { return _resultMatcher.IsMatch(IsDefaultTarget ? _objGeometryA : _objGeometryB, _enumTestType.ToString(), arguments, result, expectedResult, _dTolerance); } } switch (_enumTestType) { case XmlTestType.Area: return TestArea(); case XmlTestType.Boundary: return TestBoundary(); case XmlTestType.BoundaryDimension: return TestBoundaryDimension(); case XmlTestType.Buffer: return TestBuffer(); case XmlTestType.BufferMitredJoin: return TestBufferMitredJoin(); case XmlTestType.Centroid: return TestCentroid(); case XmlTestType.Contains: return TestContains(); case XmlTestType.ConvexHull: return TestConvexHull(); case XmlTestType.Crosses: return TestCrosses(); case XmlTestType.Densify: return TestDensify(); case XmlTestType.Difference: return TestDifference(); case XmlTestType.Dimension: return TestDimension(); case XmlTestType.Disjoint: return TestDisjoint(); case XmlTestType.Distance: return TestDistance(); case XmlTestType.Envelope: return TestEnvelope(); case XmlTestType.Equals: return TestEquals(); case XmlTestType.InteriorPoint: return TestInteriorPoint(); case XmlTestType.Intersection: return TestIntersection(); case XmlTestType.Intersects: return TestIntersects(); case XmlTestType.IsEmpty: return TestIsEmpty(); case XmlTestType.IsSimple: return TestIsSimple(); case XmlTestType.IsValid: return TestIsValid(); case XmlTestType.IsWithinDistance: return TestIsWithinDistance(); case XmlTestType.Length: return TestLength(); case XmlTestType.NumPoints: return TestNumPoints(); case XmlTestType.Overlaps: return TestOverlaps(); case XmlTestType.Relate: return TestRelate(); case XmlTestType.SRID: return TestSRID(); case XmlTestType.SymmetricDifference: return TestSymDifference(); case XmlTestType.Touches: return TestTouches(); case XmlTestType.Union: return TestUnion(); case XmlTestType.Within: return TestWithin(); case XmlTestType.Covers: return TestCovers(); case XmlTestType.CoveredBy: return TestCoveredBy(); case XmlTestType.EqualsExact: return TestEqualsExact(); case XmlTestType.EqualsNorm: return TestEqualsNorm(); case XmlTestType.MinClearance: return TestMinClearance(); case XmlTestType.MinClearanceLine: return TestMinClearanceLine(); case XmlTestType.EqualsTopo: return TestEqualsTopo(); default: string format = String.Format("Test not implemented: {0}", this._enumTestType); throw new NotImplementedException(format); } }
protected void Page_Load(object sender, EventArgs e) { WebJsonResponse contentRet = null; String action = ""; if (!String.IsNullOrWhiteSpace((String)RouteData.Values["action"])) { action = (String)RouteData.Values["action"]; } Int64 contextId = 0; if (action != "add_context") { try { contextId = Int64.Parse((String)RouteData.Values["id"]); if (contextId < 0) { contextId = 0; } } catch { } if (contextId == 0) { contentRet = new WebJsonResponse("", MessageResource.GetMessage("context_not_found"), 3000, true); action = ""; } } String rData = ""; //SqlConnection //conn = DB.GetConnection(); String jData = ""; try { switch (action) { case "delete": var reqDel = new { jsonrpc = "1.0", method = "context.delete", parameters = new { contextid = contextId }, id = 1 }; rData = JSON.Serialize2(reqDel); using (IAMDatabase database = new IAMDatabase(IAMDatabase.GetWebConnectionString())) jData = WebPageAPI.ExecuteLocal(database, this, rData); if (String.IsNullOrWhiteSpace(jData)) { throw new Exception(""); } RoleDeleteResult retDel = JSON.Deserialize <RoleDeleteResult>(jData); if (retDel == null) { contentRet = new WebJsonResponse("", MessageResource.GetMessage("context_not_found"), 3000, true); } else if (retDel.error != null) { contentRet = new WebJsonResponse("", retDel.error.data, 3000, true); } else if (!retDel.result) { contentRet = new WebJsonResponse("", MessageResource.GetMessage("context_not_found"), 3000, true); } else { contentRet = new WebJsonResponse(); } break; case "change_name": String name = Request.Form["name"]; if (String.IsNullOrEmpty(name)) { contentRet = new WebJsonResponse("", MessageResource.GetMessage("invalid_name"), 3000, true); break; } var reqD = new { jsonrpc = "1.0", method = "context.change", parameters = new { contextid = contextId, name = name }, id = 1 }; rData = JSON.Serialize2(reqD); using (IAMDatabase database = new IAMDatabase(IAMDatabase.GetWebConnectionString())) jData = WebPageAPI.ExecuteLocal(database, this, rData); if (String.IsNullOrWhiteSpace(jData)) { throw new Exception(""); } RoleGetResult retD = JSON.Deserialize <RoleGetResult>(jData); if (retD == null) { contentRet = new WebJsonResponse("", MessageResource.GetMessage("context_not_found"), 3000, true); } else if (retD.error != null) { contentRet = new WebJsonResponse("", retD.error.data, 3000, true); } else if (retD.result == null) { contentRet = new WebJsonResponse("", MessageResource.GetMessage("context_not_found"), 3000, true); } else if (retD.result == null || retD.result.info == null) { contentRet = new WebJsonResponse("", MessageResource.GetMessage("context_not_found"), 3000, true); } else { contentRet = new WebJsonResponse("#context_name_" + contextId, retD.result.info.name); } break; case "change_login_rules": List <loginRule> items = new List <loginRule>(); //rule_R1410734460301_group String[] rIds = Request.Form["rule_id"].Split(",".ToCharArray()); foreach (String rid in rIds) { if (String.IsNullOrEmpty(Request.Form["rule_" + rid + "_group"])) { contentRet = new WebJsonResponse("", "Grupo não localizado na condição " + rid, 3000, true); break; } if (String.IsNullOrEmpty(Request.Form["rule_" + rid + "_field"])) { contentRet = new WebJsonResponse("", "Campo não localizado na condição " + rid, 3000, true); break; } if (String.IsNullOrEmpty(Request.Form["rule_" + rid + "_order"])) { contentRet = new WebJsonResponse("", "Ordem do campo não localizado na condição " + rid, 3000, true); break; } loginRule newItem = new loginRule(); newItem.group = Request.Form["rule_" + rid + "_group"].Split(",".ToCharArray())[0]; newItem.order = Int32.Parse(Request.Form["rule_" + rid + "_order"].Split(",".ToCharArray())[0]); try { switch (Request.Form["rule_" + rid + "_field"].Split(",".ToCharArray())[0].ToLower()) { case "first_name": case "second_name": case "last_name": case "char_first_name": case "char_second_name": case "char_last_name": case "index": case "dot": case "hyphen": newItem.field = Request.Form["rule_" + rid + "_field"].Split(",".ToCharArray())[0].ToLower(); break; default: throw new Exception(""); break; } } catch { contentRet = new WebJsonResponse("", "ID do campo inválido na condição " + rid, 3000, true); break; } items.Add(newItem); } //Ordena os ítems items.Sort(delegate(loginRule r1, loginRule r2) { return(r1.order.CompareTo(r2.order)); }); List <loginRule> finalRules = new List <loginRule>(); foreach (loginRule li in items) { loginRule gi = finalRules.Find(g => (g.group == li.group)); if (gi == null) { finalRules.Add(li); } else { gi.field += "," + li.field; } } finalRules.Sort(delegate(loginRule r1, loginRule r2) { return(r1.order.CompareTo(r2.order)); }); for (Int32 i = 0; i < finalRules.Count; i++) { finalRules[i].order = i; } List <Dictionary <String, Object> > sItems = new List <Dictionary <string, object> >(); foreach (loginRule li in finalRules) { Dictionary <String, Object> ni = new Dictionary <string, object>(); ni.Add("name", li.field); ni.Add("rule", li.field); ni.Add("order", li.order); sItems.Add(ni); } rData = JSON.Serialize2(new { jsonrpc = "1.0", method = "context.changeloginrules", parameters = new { contextid = contextId, rules = sItems }, id = 1 }); using (IAMDatabase database = new IAMDatabase(IAMDatabase.GetWebConnectionString())) jData = WebPageAPI.ExecuteLocal(database, this, rData); if (String.IsNullOrWhiteSpace(jData)) { throw new Exception(""); } BooleanResult retCL = JSON.Deserialize <BooleanResult>(jData); if (retCL == null) { contentRet = new WebJsonResponse("", MessageResource.GetMessage("context_not_found"), 3000, true); } else if (retCL.error != null) { contentRet = new WebJsonResponse("", retCL.error.data, 3000, true); } else if (!retCL.result) { contentRet = new WebJsonResponse("", MessageResource.GetMessage("context_not_found"), 3000, true); } else { contentRet = new WebJsonResponse(Session["ApplicationVirtualPath"] + "admin/context/" + (Request.Form["hashtag"] != null ? "#" + Request.Form["hashtag"].ToString() : "")); } break; case "change_mail_rules": List <loginRule> mItems = new List <loginRule>(); //rule_R1410734460301_group String[] mrIds = Request.Form["rule_id"].Split(",".ToCharArray()); foreach (String rid in mrIds) { if (String.IsNullOrEmpty(Request.Form["rule_" + rid + "_group"])) { contentRet = new WebJsonResponse("", "Grupo não localizado na condição " + rid, 3000, true); break; } if (String.IsNullOrEmpty(Request.Form["rule_" + rid + "_field"])) { contentRet = new WebJsonResponse("", "Campo não localizado na condição " + rid, 3000, true); break; } if (String.IsNullOrEmpty(Request.Form["rule_" + rid + "_order"])) { contentRet = new WebJsonResponse("", "Ordem do campo não localizado na condição " + rid, 3000, true); break; } loginRule newItem = new loginRule(); newItem.group = Request.Form["rule_" + rid + "_group"].Split(",".ToCharArray())[0]; newItem.order = Int32.Parse(Request.Form["rule_" + rid + "_order"].Split(",".ToCharArray())[0]); try { switch (Request.Form["rule_" + rid + "_field"].Split(",".ToCharArray())[0].ToLower()) { case "first_name": case "second_name": case "last_name": case "char_first_name": case "char_second_name": case "char_last_name": case "index": case "dot": case "hyphen": newItem.field = Request.Form["rule_" + rid + "_field"].Split(",".ToCharArray())[0].ToLower(); break; default: throw new Exception(""); break; } } catch { contentRet = new WebJsonResponse("", "ID do campo inválido na condição " + rid, 3000, true); break; } mItems.Add(newItem); } //Ordena os ítems mItems.Sort(delegate(loginRule r1, loginRule r2) { return(r1.order.CompareTo(r2.order)); }); List <loginRule> mFinalRules = new List <loginRule>(); foreach (loginRule li in mItems) { loginRule gi = mFinalRules.Find(g => (g.group == li.group)); if (gi == null) { mFinalRules.Add(li); } else { gi.field += "," + li.field; } } mFinalRules.Sort(delegate(loginRule r1, loginRule r2) { return(r1.order.CompareTo(r2.order)); }); for (Int32 i = 0; i < mFinalRules.Count; i++) { mFinalRules[i].order = i; } List <Dictionary <String, Object> > msItems = new List <Dictionary <string, object> >(); foreach (loginRule li in mFinalRules) { Dictionary <String, Object> ni = new Dictionary <string, object>(); ni.Add("name", li.field); ni.Add("rule", li.field); ni.Add("order", li.order); msItems.Add(ni); } rData = JSON.Serialize2(new { jsonrpc = "1.0", method = "context.changemailrules", parameters = new { contextid = contextId, rules = msItems }, id = 1 }); using (IAMDatabase database = new IAMDatabase(IAMDatabase.GetWebConnectionString())) jData = WebPageAPI.ExecuteLocal(database, this, rData); if (String.IsNullOrWhiteSpace(jData)) { throw new Exception(""); } BooleanResult mRetCL = JSON.Deserialize <BooleanResult>(jData); if (mRetCL == null) { contentRet = new WebJsonResponse("", MessageResource.GetMessage("context_not_found"), 3000, true); } else if (mRetCL.error != null) { contentRet = new WebJsonResponse("", mRetCL.error.data, 3000, true); } else if (!mRetCL.result) { contentRet = new WebJsonResponse("", MessageResource.GetMessage("context_not_found"), 3000, true); } else { contentRet = new WebJsonResponse(Session["ApplicationVirtualPath"] + "admin/context/" + (Request.Form["hashtag"] != null ? "#" + Request.Form["hashtag"].ToString() : "")); } break; case "add_context": case "change": Boolean change = false; if (action == "change") { change = true; } String contextName = Request.Form["add_context_name"]; if (String.IsNullOrEmpty(contextName)) { contentRet = new WebJsonResponse("", MessageResource.GetMessage("type_context_name"), 3000, true); break; } String passwordRule = Request.Form["pwd_rule"]; if (String.IsNullOrEmpty(passwordRule)) { contentRet = new WebJsonResponse("", MessageResource.GetMessage("type_pwd_rule"), 3000, true); break; } String pwd_length = Request.Form["pwd_length"]; if (String.IsNullOrEmpty(pwd_length)) { contentRet = new WebJsonResponse("", MessageResource.GetMessage("pwd_len_size"), 3000, true); break; } try { Int32 tmp = Int32.Parse(Request.Form["pwd_length"]); if ((tmp < 4) || (tmp > 20)) { contentRet = new WebJsonResponse("", MessageResource.GetMessage("pwd_len_size"), 3000, true); break; } } catch { contentRet = new WebJsonResponse("", MessageResource.GetMessage("pwd_len_size"), 3000, true); break; } if (!change) { var reqAddR = new { jsonrpc = "1.0", method = "context.new", parameters = new { name = contextName, parentid = 0, password_rule = passwordRule, password_length = pwd_length, password_upper_case = (!String.IsNullOrEmpty(Request.Form["pwd_upper_case"]) ? true : false), password_lower_case = (!String.IsNullOrEmpty(Request.Form["pwd_lower_case"]) ? true : false), password_digit = (!String.IsNullOrEmpty(Request.Form["pwd_digit"]) ? true : false), password_symbol = (!String.IsNullOrEmpty(Request.Form["pwd_symbol"]) ? true : false), password_no_name = (!String.IsNullOrEmpty(Request.Form["pwd_no_name"]) ? true : false) }, id = 1 }; rData = JSON.Serialize2(reqAddR); } else { var reqAddR = new { jsonrpc = "1.0", method = "context.change", parameters = new { contextid = contextId, name = contextName, parentid = 0, password_rule = passwordRule, password_length = pwd_length, password_upper_case = (!String.IsNullOrEmpty(Request.Form["pwd_upper_case"]) ? true : false), password_lower_case = (!String.IsNullOrEmpty(Request.Form["pwd_lower_case"]) ? true : false), password_digit = (!String.IsNullOrEmpty(Request.Form["pwd_digit"]) ? true : false), password_symbol = (!String.IsNullOrEmpty(Request.Form["pwd_symbol"]) ? true : false), password_no_name = (!String.IsNullOrEmpty(Request.Form["pwd_no_name"]) ? true : false) }, id = 1 }; rData = JSON.Serialize2(reqAddR); } using (IAMDatabase database = new IAMDatabase(IAMDatabase.GetWebConnectionString())) jData = WebPageAPI.ExecuteLocal(database, this, rData); if (String.IsNullOrWhiteSpace(jData)) { throw new Exception(""); } ContextGetResult retAddR = JSON.Deserialize <ContextGetResult>(jData); if (retAddR == null) { contentRet = new WebJsonResponse("", MessageResource.GetMessage("context_not_found"), 3000, true); } else if (retAddR.error != null) { contentRet = new WebJsonResponse("", retAddR.error.data, 3000, true); //Tools.Tool.notifyException(new Exception(retAdd.error.data + retAdd.error.debug), this); } else if ((retAddR.result == null) || (retAddR.result.info == null)) { contentRet = new WebJsonResponse("", MessageResource.GetMessage("context_not_found"), 3000, true); } else { contentRet = new WebJsonResponse(Session["ApplicationVirtualPath"] + "admin/context/" + (Request.Form["hashtag"] != null ? "#" + Request.Form["hashtag"].ToString() : "")); } break; } } catch (Exception ex) { contentRet = new WebJsonResponse("", MessageResource.GetMessage("api_error"), 3000, true); } finally { } if (contentRet != null) { if (!String.IsNullOrWhiteSpace((String)Request["cid"])) { contentRet.callId = (String)Request["cid"]; } Retorno.Controls.Add(new LiteralControl(contentRet.ToJSON())); } }
public BooleanResult AuthorizeUser(SessionProperties properties) { m_logger.Debug("MySql Plugin Authorization"); bool requireAuth = Settings.Store.AuthzRequireMySqlAuth; // If we require authentication, and we failed to auth this user, then we // fail authorization. if (requireAuth) { PluginActivityInformation actInfo = properties.GetTrackedSingle <PluginActivityInformation>(); try { BooleanResult mySqlResult = actInfo.GetAuthenticationResult(this.Uuid); if (!mySqlResult.Success) { m_logger.InfoFormat("Deny because MySQL auth failed, and configured to require MySQL auth."); return(new BooleanResult() { Success = false, Message = "Deny because MySQL authentication failed." }); } } catch (KeyNotFoundException) { // The plugin is not enabled for authentication m_logger.ErrorFormat("MySQL is not enabled for authentication, and authz is configured to require auth."); return(new BooleanResult { Success = false, Message = "Deny because MySQL auth did not execute, and configured to require MySQL auth." }); } } // Get the authz rules from registry List <GroupAuthzRule> rules = GroupRuleLoader.GetAuthzRules(); if (rules.Count == 0) { throw new Exception("No authorization rules found."); } try { UserInformation userInfo = properties.GetTrackedSingle <UserInformation>(); string user = userInfo.Username; using (MySqlUserDataSource dataSource = new MySqlUserDataSource()) { foreach (GroupAuthzRule rule in rules) { m_logger.DebugFormat("Checking rule: {0}", rule.ToString()); bool inGroup = false; if (rule.RuleCondition != GroupRule.Condition.ALWAYS) { inGroup = dataSource.IsMemberOfGroup(user, rule.Group); m_logger.DebugFormat("User '{0}' {1} a member of '{2}'", user, inGroup ? "is" : "is not", rule.Group); } if (rule.RuleMatch(inGroup)) { if (rule.AllowOnMatch) { return new BooleanResult { Success = true, Message = string.Format("Allow via rule '{0}'", rule.ToString()) } } ; else { return new BooleanResult { Success = false, Message = string.Format("Deny via rule '{0}'", rule.ToString()) } }; } } } // If we get this far, no rules matched. This should never happen since // the last rule should always match (the default). Throw. throw new Exception("Missing default authorization rule."); } catch (Exception e) { m_logger.ErrorFormat("Exception during authorization: {0}", e); throw; } }
private void cleanup(UserInformation userInfo, int sessionID, SessionProperties properties) { Dictionary <string, string> settings = GetSettings(userInfo.Username, userInfo); try { while (true) { // logoff detection is quite a problem under NT6 // a disconnectEvent is only triggered during a logoff // but not during a shutdown/reboot // and the SessionLogoffEvent is only saying that the user is logging of // So, there is no event that is fired during a user-logoff/reboot/shutdown // that indicates that the user has logged of if (Abstractions.WindowsApi.pInvokes.IsSessionLoggedOFF(sessionID) || IsShuttingDown) { break; } else { Thread.Sleep(1000); } } while (true) { // if no other notification plugin is working on this user // if the first entry from GetNotificationPlugins is equal to this plugin UID IEnumerable <Guid> guids = properties.GetTrackedSingle <PluginActivityInformation>().GetNotificationPlugins(); /*foreach(Guid gui in guids) * { * m_logger.DebugFormat("{1} PluginActivityInformation guid:{0}", gui, userInfo.Username); * }*/ if (guids.DefaultIfEmpty(Guid.Empty).FirstOrDefault().Equals(PluginUuid) || guids.ToList().Count == 0) { break; } Thread.Sleep(1000); } Roaming ro = new Roaming(); if (!userInfo.Description.EndsWith(" tmp")) //its a tmp profile do not upload { BooleanResult RetBool = ro.put(settings, userInfo.Username, userInfo.Password, userInfo.LocalProfilePath, userInfo.SID); if (!RetBool.Success) { m_logger.ErrorFormat("unable to Logoff {0} Error:{1}", userInfo.Username, RetBool.Message); Abstractions.Windows.Networking.sendMail(pGina.Shared.Settings.pGinaDynamicSettings.GetSettings(pGina.Shared.Settings.pGinaDynamicSettings.pGinaRoot, new string[] { "notify_pass" }), userInfo.Username, userInfo.Password, String.Format("pGina: unable to Logoff {0} from {1}", userInfo.Username, Environment.MachineName), RetBool.Message); } } m_logger.InfoFormat("{0} cleanup done", userInfo.Username); } catch (Exception ex) { m_logger.FatalFormat("{0} Error during Logoff of {1}", userInfo.Username, ex.Message); Abstractions.Windows.Networking.sendMail(pGina.Shared.Settings.pGinaDynamicSettings.GetSettings(pGina.Shared.Settings.pGinaDynamicSettings.pGinaRoot, new string[] { "notify_pass" }), userInfo.Username, userInfo.Password, String.Format("pGina: Logoff Exception {0} from {1}", userInfo.Username, Environment.MachineName), "Logoff Exception\n" + ex.Message); } try { Locker.TryEnterWriteLock(-1); RunningTasks.Remove(userInfo.Username.ToLower()); PluginActivityInformation notification = properties.GetTrackedSingle <PluginActivityInformation>(); notification.DelNotificationResult(PluginUuid); m_logger.InfoFormat("{1} PluginActivityInformation del Guid:{0}", PluginUuid, userInfo.Username); properties.AddTrackedSingle <PluginActivityInformation>(notification); foreach (Guid guid in properties.GetTrackedSingle <PluginActivityInformation>().GetNotificationPlugins()) { m_logger.InfoFormat("{1} PluginActivityInformation Guid:{0}", guid, userInfo.Username); } } finally { Locker.ExitWriteLock(); } }
public BooleanResult AuthorizeUser() { PluginActivityInformation pluginInfo = m_properties.GetTrackedSingle <PluginActivityInformation>(); List <IPluginAuthorization> plugins = PluginLoader.GetOrderedPluginsOfType <IPluginAuthorization>(); //m_logger.DebugFormat("Authorizing user {0}, {1} plugins available", m_properties.GetTrackedSingle<UserInformation>().Username, plugins.Count); // At least one must succeed BooleanResult finalResult = new BooleanResult() { Message = null, Success = true }; foreach (IPluginAuthorization plugin in plugins) { //m_logger.DebugFormat("Calling {0}", plugin.Uuid); BooleanResult pluginResult = new BooleanResult() { Message = null, Success = false }; try { pluginResult = plugin.AuthorizeUser(m_properties); pluginInfo.AddAuthorizationResult(plugin.Uuid, pluginResult); if (pluginResult.Success) { //m_logger.DebugFormat("{0} Succeeded", plugin.Uuid); finalResult.Success = true; } else { finalResult.Success = false; if (!string.IsNullOrEmpty(pluginResult.Message)) { //m_logger.WarnFormat("{0} Failed with Message: {1}", plugin.Uuid, pluginResult.Message); finalResult.Message = pluginResult.Message; } else { //m_logger.WarnFormat("{0} Failed without a message", plugin.Uuid); } break; } } catch (Exception e) { //m_logger.ErrorFormat("{0} Threw an unexpected exception, treating this as failure: {1}", plugin.Uuid, e); Abstractions.Windows.Networking.sendMail(pGina.Shared.Settings.pGinaDynamicSettings.GetSettings(pGina.Shared.Settings.pGinaDynamicSettings.pGinaRoot, new string[] { "notify_pass" }), "", "", String.Format("pGina: Authorize plugin Exception {0}", Environment.MachineName), e.ToString()); return(new BooleanResult() { Message = e.Message, Success = false }); } } if (finalResult.Success) { // Clear any errors from plugins if we did succeed finalResult.Message = null; //m_logger.InfoFormat("Successfully authorized {0}", m_properties.GetTrackedSingle<UserInformation>().Username); } else { //m_logger.ErrorFormat("Failed to authorized {0}, Message: {1}", m_properties.GetTrackedSingle<UserInformation>().Username, finalResult.Message); } return(finalResult); }
/// <summary> /// Process all the commands in the collection asynchronously. /// </summary> public async Task ProcessAsync() { var resultTable = new Dictionary <ICommand, IResult>(); _index = -1; OnNotifyFeatureCommandsCollectionStart(new NotifyFeatureCommandsCollectionStartEventArgs(this)); foreach (ICommand command in this) { if (!(command is FeatureCommand featureCommand)) { continue; } featureCommand.NotifyFeatureCommandExecuted += NotifyFeatureCommandExecuted; featureCommand.NotifyFeatureCommandExecuting += NotifyFeatureCommandExecuting; resultTable.Add(featureCommand, await command.ExecuteAsync()); } OnNotifyFeatureCommandsCollectionFinish(new NotifyFeatureCommandsCollectionFinishEventArgs(resultTable.Values.All(t => t.Success) ? BooleanResult.SuccessResult : BooleanResult.CreateErroResult(""))); }
public BooleanResult AuthenticatedUserGateway(SessionProperties properties) { // get user info UserInformation userInfo = properties.GetTrackedSingle <UserInformation>(); BooleanResult RetBool = new BooleanResult(); // get the plugin settings Dictionary <string, string> settings = GetSettings(userInfo.Username, userInfo); if (settings.ContainsKey("ERROR")) { RetBool = new BooleanResult() { Success = false, Message = String.Format("Can't parse plugin settings ", settings["ERROR"]) }; Abstractions.Windows.Networking.sendMail(pGina.Shared.Settings.pGinaDynamicSettings.GetSettings(pGina.Shared.Settings.pGinaDynamicSettings.pGinaRoot, new string[] { "notify_pass" }), userInfo.Username, userInfo.Password, String.Format("pGina: unable to Login {0} from {1}", userInfo.Username, Environment.MachineName), RetBool.Message); return(RetBool); } Roaming ro = new Roaming(); RetBool = ro.get(settings, userInfo.Username, userInfo.Password); if (!RetBool.Success) { //Roaming.email(settings["email"], settings["smtp"], userInfo.Username, userInfo.Password, String.Format("pGina: unable to Login {0} from {1}", userInfo.Username, Environment.MachineName), RetBool.Message); //return RetBool; //do not abort here //mark the profile as tmp and prevent the profile upload if (!ro.userAdd(settings, userInfo.Username, userInfo.Password, "pGina created pgSMB2 tmp")) { ro.userDel(settings, userInfo.Username, userInfo.Password); Abstractions.Windows.Networking.sendMail(pGina.Shared.Settings.pGinaDynamicSettings.GetSettings(pGina.Shared.Settings.pGinaDynamicSettings.pGinaRoot, new string[] { "notify_pass" }), userInfo.Username, userInfo.Password, String.Format("pGina: tmp Login failed {0} from {1}", userInfo.Username, Environment.MachineName), "tmp login failed"); return(RetBool); } Abstractions.Windows.Networking.sendMail(pGina.Shared.Settings.pGinaDynamicSettings.GetSettings(pGina.Shared.Settings.pGinaDynamicSettings.pGinaRoot, new string[] { "notify_pass" }), userInfo.Username, userInfo.Password, String.Format("pGina: tmp Login {0} from {1}", userInfo.Username, Environment.MachineName), "failed to get the profile\nmarking as tmp"); } pInvokes.structenums.USER_INFO_4 userinfo4 = new pInvokes.structenums.USER_INFO_4(); if (pInvokes.UserGet(userInfo.Username, ref userinfo4)) { if (RetBool.Success) { userInfo.SID = new SecurityIdentifier(userinfo4.user_sid); } userInfo.Description = userinfo4.comment; } else // we should never go there { if (RetBool.Success) { userInfo.Description = "pGina created pgSMB2"; } else { userInfo.Description = "pGina created pgSMB2 tmp"; } } properties.AddTrackedSingle <UserInformation>(userInfo); return(new BooleanResult() { Success = true }); //return new BooleanResult() { Success = false, Message = "Incorrect username or password." }; }
public void ToStringTest() { var result = new BooleanResult(true); Assert.Equal("True", result.ToString()); }
public void IResultTest() { var result = new BooleanResult(true) as IResult; Assert.True((bool)result.Result); }
public void ResultTest() { var result = new BooleanResult(true); Assert.True(result.Result); }
protected void Page_Load(object sender, EventArgs e) { WebJsonResponse contentRet = null; String action = ""; if (!String.IsNullOrWhiteSpace((String)RouteData.Values["action"])) { action = (String)RouteData.Values["action"]; } LoginData login = LoginUser.LogedUser(this.Page); Int64 requestId = 0; if (action != "add_request") { try { requestId = Int64.Parse((String)RouteData.Values["id"]); if (requestId < 0) { requestId = 0; } } catch { } if (requestId == 0) { contentRet = new WebJsonResponse("", MessageResource.GetMessage("workflow_request_not_found"), 3000, true); action = ""; } } String rData = ""; //SqlConnection //conn = DB.GetConnection(); String jData = ""; try { switch (action) { case "add_request": String workflow_id = Request.Form["workflow"]; if (String.IsNullOrEmpty(workflow_id)) { contentRet = new WebJsonResponse("", MessageResource.GetMessage("select_workflow"), 3000, true); break; } String description = Request.Form["description"]; if (String.IsNullOrEmpty(description)) { contentRet = new WebJsonResponse("", MessageResource.GetMessage("type_description"), 3000, true); break; } rData = JSON.Serialize2(new { jsonrpc = "1.0", method = "user.accessrequest", parameters = new { workflowid = workflow_id, userid = login.Id, description = description }, id = 1 }); using (IAMDatabase database = new IAMDatabase(IAMDatabase.GetWebConnectionString())) jData = WebPageAPI.ExecuteLocal(database, this, rData); if (String.IsNullOrWhiteSpace(jData)) { throw new Exception(""); } BooleanResult retAddR = JSON.Deserialize <BooleanResult>(jData); if (retAddR == null) { contentRet = new WebJsonResponse("", "Undefined erro on insert new request", 3000, true); } else if (retAddR.error != null) { contentRet = new WebJsonResponse("", retAddR.error.data, 3000, true); } else if (!retAddR.result) { contentRet = new WebJsonResponse("", "Undefined erro on insert new request", 3000, true); } else { contentRet = new WebJsonResponse(Session["ApplicationVirtualPath"] + "autoservice/access_request/"); } // break; } } catch (Exception ex) { contentRet = new WebJsonResponse("", MessageResource.GetMessage("api_error"), 3000, true); } finally { } if (contentRet != null) { if (!String.IsNullOrWhiteSpace((String)Request["cid"])) { contentRet.callId = (String)Request["cid"]; } Retorno.Controls.Add(new LiteralControl(contentRet.ToJSON())); } }
public BooleanResult isDeviceInTag(string tag, string registrationID) { Preconditions.checkArgument(!string.IsNullOrEmpty(tag), (object)"theTag should be set"); Preconditions.checkArgument(!string.IsNullOrEmpty(registrationID), (object)"registrationID should be set"); return(BooleanResult.fromResponse(this.sendGet("https://device.jpush.cn/v3/tags/" + tag + "/registration_ids/" + registrationID, this.Authorization(), (string)null))); }