private static object SystemData(RequestInfo info) { var browserlanguage = RESTHandler.ParseDefaultRequestCulture(info) ?? System.Globalization.CultureInfo.InvariantCulture; return(new { APIVersion = 1, PasswordPlaceholder = Duplicati.Server.WebServer.Server.PASSWORD_PLACEHOLDER, ServerVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(), ServerVersionName = Duplicati.License.VersionNumbers.Version, ServerVersionType = Duplicati.Library.AutoUpdater.UpdaterManager.SelfVersion.ReleaseType, StartedBy = Duplicati.Server.Program.Origin, BaseVersionName = Duplicati.Library.AutoUpdater.UpdaterManager.BaseVersion.Displayname, DefaultUpdateChannel = Duplicati.Library.AutoUpdater.AutoUpdateSettings.DefaultUpdateChannel, DefaultUsageReportLevel = Duplicati.Library.UsageReporter.Reporter.DefaultReportLevel, ServerTime = DateTime.Now, OSType = Platform.IsClientPosix ? (Platform.IsClientOSX ? "OSX" : "Linux") : "Windows", DirectorySeparator = System.IO.Path.DirectorySeparatorChar, PathSeparator = System.IO.Path.PathSeparator, CaseSensitiveFilesystem = Duplicati.Library.Utility.Utility.IsFSCaseSensitive, MonoVersion = Duplicati.Library.Utility.Utility.IsMono ? Duplicati.Library.Utility.Utility.MonoVersion.ToString() : null, MachineName = System.Environment.MachineName, UserName = System.Environment.UserName, NewLine = System.Environment.NewLine, CLRVersion = System.Environment.Version.ToString(), CLROSInfo = new { Platform = System.Environment.OSVersion.Platform.ToString(), ServicePack = System.Environment.OSVersion.ServicePack, Version = System.Environment.OSVersion.Version.ToString(), VersionString = System.Environment.OSVersion.VersionString }, Options = Serializable.ServerSettings.Options, CompressionModules = Serializable.ServerSettings.CompressionModules, EncryptionModules = Serializable.ServerSettings.EncryptionModules, BackendModules = Serializable.ServerSettings.BackendModules, GenericModules = Serializable.ServerSettings.GenericModules, WebModules = Serializable.ServerSettings.WebModules, ConnectionModules = Serializable.ServerSettings.ConnectionModules, ServerModules = Serializable.ServerSettings.ServerModules, UsingAlternateUpdateURLs = Duplicati.Library.AutoUpdater.AutoUpdateSettings.UsesAlternateURLs, LogLevels = Enum.GetNames(typeof(Duplicati.Library.Logging.LogMessageType)), SuppressDonationMessages = Duplicati.Library.Main.Utility.SuppressDonationMessages, SpecialFolders = from n in SpecialFolders.Nodes select new { ID = n.id, Path = n.resolvedpath }, BrowserLocale = new { Code = browserlanguage.Name, EnglishName = browserlanguage.EnglishName, DisplayName = browserlanguage.NativeName }, SupportedLocales = Library.Localization.LocalizationService.SupportedCultures .Select(x => new { Code = x, EnglishName = new System.Globalization.CultureInfo(x).EnglishName, DisplayName = new System.Globalization.CultureInfo(x).NativeName } ), BrowserLocaleSupported = Library.Localization.LocalizationService.isCultureSupported(browserlanguage) }); }
public static IPwsObjectWrapper <Token_V1> GetNewToken() { return(RESTHandler <IPwsObjectWrapper <Token_V1> > .Invoke(() => Application.GetApplication().GetDefaultToken(), "Token")); }
public ActionResult Login(UserProfile objUser) { // Manage session and Context HttpServiceUriBuilder contextUri = new HttpServiceUriBuilder().SetServiceName(this.context.ServiceName); if (ModelState.IsValid) { ViewBag.Message = ""; ViewBag.RedirectURL = ""; bool newUserRegistration = false; bool userAllowedToLogin = false; if ((objUser.Password != null && objUser.Password.Length > 0)) { // First let deal to see if this a user registration if (objUser.FirstName != null) { newUserRegistration = true; Task <bool> result = RESTHandler.ExecuteFabricPOSTForEntity(typeof(UserProfile), Names.InsightDataServiceName, "api/entities/user/withIdentity/" + objUser.UserName, "user", objUser, this.context, this.httpClient, this.appLifetime.ApplicationStopping, ServiceEventSource.Current); if (result.Result) { userAllowedToLogin = true; } else { ViewBag.RedirectURL = contextUri.GetServiceNameSiteHomePath(); ViewBag.Message = "Error during new user registration - User already exist in the database"; } } if (!userAllowedToLogin && !newUserRegistration) { Task <object> userObject = RESTHandler.ExecuteFabricGETForEntity(typeof(UserProfile), Names.InsightDataServiceName, "api/entities/user/byIdentity/" + objUser.UserName, "user", this.context, this.httpClient, this.appLifetime.ApplicationStopping, ServiceEventSource.Current); if (userObject != null) { UserProfile userProfile = (UserProfile)userObject.Result; if (objUser.Password.Equals(userProfile.Password)) { userAllowedToLogin = true; } else { ViewBag.RedirectURL = contextUri.GetServiceNameSiteHomePath(); ViewBag.Message = "Invalid Username and/or Password"; } } else { ViewBag.RedirectURL = contextUri.GetServiceNameSiteHomePath(); ViewBag.Message = "Error checking user credentials"; } } if (userAllowedToLogin) { try { string redirectTo = HTTPHelper.StartSession(HttpContext, this, objUser, "User", "/api/devices", contextUri.GetServiceNameSiteHomePath()); //TODO : make the redirection configurable as part of insight application return(Redirect(redirectTo)); } catch (System.Exception ex) { ViewBag.RedirectURL = contextUri.GetServiceNameSiteHomePath(); ViewBag.Message = "Internal Error During User Login- Report to the System Administrator"; Console.WriteLine("On Login Session exception msg=[" + ex.Message + "]"); } } } else { ViewBag.RedirectURL = contextUri.GetServiceNameSiteHomePath(); ViewBag.Message = "Either username and/or password not provided"; } } if (!HTTPHelper.IsSessionExpired(HttpContext, this)) { HTTPHelper.EndSession(HttpContext, this); } return(View("Index", objUser)); }