// TODO: !!! WWW section!!! public virtual bool HasLmsDomain(string domainToCheck) { var domains = new List <string>(); if (!string.IsNullOrEmpty(LmsDomain)) { domains.Add(CleanDomain(LmsDomain)); } if ((LmsProviderId == (int)LmsProviderEnum.Blackboard) && EnableProxyToolMode.GetValueOrDefault()) { domains.AddRange(AdditionalLmsDomains.Select(x => x.RemoveHttpProtocolAndTrailingSlash())); } // NOTE: sakai sends :8080 in our environment- check other LMS //index = input.IndexOf(":"); //if (index > 0) // input = input.Substring(0, index); return(domains.Any(s => s.Equals(domainToCheck, StringComparison.OrdinalIgnoreCase))); }
/// <param name="preferUserSettings">when true - means that user tokens/parameters will be used instead of license(admin) /// to retrieve information from API</param> public virtual Dictionary <string, object> GetLMSSettings(dynamic settings, LmsUserParameters userParameters = null, bool preferUserSettings = false) { Dictionary <string, object> result = new Dictionary <string, object>(); switch (LmsProviderId) { case (int)LmsProviderEnum.Canvas: // LmsLicenseSettingNames.CanvasOAuthId, // LmsLicenseSettingNames.CanvasOAuthKey result.Add(LmsLicenseSettingNames.LicenseKey, ConsumerKey); result.Add(LmsLicenseSettingNames.LmsDomain, LmsDomain); if (userParameters != null) { result.Add(LmsUserSettingNames.Token, preferUserSettings ? userParameters.LmsUser.Token : AdminUser?.Token); result.Add(LmsUserSettingNames.CourseId, userParameters.Course); } else { result.Add(LmsUserSettingNames.Token, AdminUser?.Token); } //result.Add(LmsUserSettingNames.RefreshToken, session.RefreshToken); break; case (int)LmsProviderEnum.AgilixBuzz: result.Add(LmsLicenseSettingNames.BuzzAdminUsername, AdminUser?.Username); result.Add(LmsLicenseSettingNames.BuzzAdminPassword, AdminUser?.Password); result.Add(LmsLicenseSettingNames.LicenseKey, ConsumerKey); result.Add(LmsLicenseSettingNames.LmsDomain, LmsDomain); break; case (int)LmsProviderEnum.Schoology: result.Add(LmsLicenseSettingNames.SchoologyConsumerKey, GetSetting <string>(LmsLicenseSettingNames.SchoologyConsumerKey)); result.Add(LmsLicenseSettingNames.SchoologyConsumerSecret, GetSetting <string>(LmsLicenseSettingNames.SchoologyConsumerSecret)); result.Add(LmsLicenseSettingNames.LicenseKey, ConsumerKey); result.Add(LmsLicenseSettingNames.LmsDomain, LmsDomain); break; case (int)LmsProviderEnum.Blackboard: var enableProxy = EnableProxyToolMode.GetValueOrDefault(); result.Add(LmsLicenseSettingNames.UseSSL, UseSSL.GetValueOrDefault()); result.Add(LmsLicenseSettingNames.BlackBoardEnableProxyToolMode, enableProxy); if (enableProxy) { string defaultToolRegistrationPassword = settings?.InitialBBPassword; string toolPassword = string.IsNullOrWhiteSpace(ProxyToolSharedPassword) ? defaultToolRegistrationPassword : ProxyToolSharedPassword; result.Add(LmsLicenseSettingNames.BlackBoardProxyToolPassword, toolPassword); } else { result.Add(LmsLicenseSettingNames.AdminUsername, AdminUser?.Username); result.Add(LmsLicenseSettingNames.AdminPassword, AdminUser?.Password); } result.Add(LmsLicenseSettingNames.LicenseKey, ConsumerKey); result.Add(LmsLicenseSettingNames.LmsDomain, LmsDomain); //result.Add(LmsLicenseSettingNames.BlackBoardUseSSL, true); if (userParameters != null) { result.Add(LmsUserSettingNames.Token, userParameters.Wstoken); //todo: separate setting? result.Add(LmsUserSettingNames.CourseId, userParameters.Course); result.Add(LmsUserSettingNames.CourseName, userParameters.CourseName); } break; case (int)LmsProviderEnum.Bridge: result.Add(LmsLicenseSettingNames.LmsDomain, LmsDomain); result.Add(LmsLicenseSettingNames.BridgeApiTokenKey, GetSetting <string>(LmsLicenseSettingNames.BridgeApiTokenKey)); result.Add(LmsLicenseSettingNames.BridgeApiTokenSecret, GetSetting <string>(LmsLicenseSettingNames.BridgeApiTokenSecret)); break; case (int)LmsProviderEnum.Brightspace: result.Add(LmsUserSettingNames.Token, AdminUser?.Token); result.Add(LmsLicenseSettingNames.LmsDomain, LmsDomain); result.Add(LmsLicenseSettingNames.LicenseKey, ConsumerKey); result.Add(LmsLicenseSettingNames.LicenseId, Id); var keys = GetApiKeys(this, (string)settings.BrightspaceAppId, (string)settings.BrightspaceAppKey); result.Add(LmsLicenseSettingNames.BrigthSpaceAppId, keys.Key); result.Add(LmsLicenseSettingNames.BrigthSpaceAppKey, keys.Value); result.Add(LmsLicenseSettingNames.BrightSpaceAllowAdminAdditionToCourse, true); break; case (int)LmsProviderEnum.Moodle: result.Add(LmsLicenseSettingNames.MoodleCoreServiceToken, GetSetting <string>(LmsLicenseSettingNames.MoodleCoreServiceToken)); result.Add(LmsLicenseSettingNames.MoodleQuizServiceToken, GetSetting <string>(LmsLicenseSettingNames.MoodleQuizServiceToken)); result.Add(LmsLicenseSettingNames.UseSSL, UseSSL.GetValueOrDefault()); result.Add(LmsLicenseSettingNames.LmsDomain, LmsDomain); result.Add(LmsLicenseSettingNames.LicenseKey, ConsumerKey); if (AdminUser != null) { result.Add(LmsLicenseSettingNames.AdminUsername, AdminUser.Username); result.Add(LmsLicenseSettingNames.AdminPassword, AdminUser.Password); } if (userParameters != null) { result.Add(LmsUserSettingNames.CourseId, userParameters.Course); result.Add(LmsUserSettingNames.SessionId, userParameters.Id); } break; case (int)LmsProviderEnum.Haiku: result.Add(LmsLicenseSettingNames.HaikuConsumerKey, GetSetting <string>(LmsLicenseSettingNames.HaikuConsumerKey)); result.Add(LmsLicenseSettingNames.HaikuConsumerSecret, GetSetting <string>(LmsLicenseSettingNames.HaikuConsumerSecret)); result.Add(LmsLicenseSettingNames.HaikuToken, GetSetting <string>(LmsLicenseSettingNames.HaikuToken)); result.Add(LmsLicenseSettingNames.HaikuTokenSecret, GetSetting <string>(LmsLicenseSettingNames.HaikuTokenSecret)); result.Add(LmsLicenseSettingNames.UseSSL, UseSSL.GetValueOrDefault()); result.Add(LmsLicenseSettingNames.LmsDomain, LmsDomain); result.Add(LmsLicenseSettingNames.LicenseKey, ConsumerKey); break; case (int)LmsProviderEnum.Sakai: result.Add(LmsLicenseSettingNames.LicenseKey, ConsumerKey); result.Add(LmsLicenseSettingNames.LicenseSecret, SharedSecret); result.Add(LmsLicenseSettingNames.LanguageId, LanguageId); result.Add(LmsLicenseSettingNames.UseSSL, UseSSL.GetValueOrDefault()); result.Add(LmsLicenseSettingNames.LmsDomain, LmsDomain); if (AdminUser != null) { result.Add(LmsLicenseSettingNames.AdminUsername, AdminUser.Username); result.Add(LmsLicenseSettingNames.AdminPassword, AdminUser.Password); } if (userParameters != null) { result.Add(LmsUserSettingNames.CourseId, userParameters.Course); result.Add(LmsUserSettingNames.CourseName, userParameters.CourseName); result.Add(LmsUserSettingNames.SessionId, userParameters.Id); result.Add(LmsUserSettingNames.UserId, userParameters.LmsUser.UserId); result.Add(LmsUserSettingNames.Username, userParameters.LmsUser.Username); } break; default: throw new NotImplementedException($"LmsProviderId {LmsProviderId} is not implemented."); } return(result); }