private bool TestBlackBoardConnection(ConnectionTestDTO test, out string info) { if (!TestDomainFormat(test, out info)) { return(false); } var session = test.enableProxyToolMode ? _blackboardClient.LoginToolAndCreateAClient( out info, test.domain.IsSSL(), test.domain, test.password) : _blackboardClient.LoginUserAndCreateAClient( out info, test.domain.IsSSL(), test.domain, test.login, test.password); bool success = session != null; if (session != null) { session.logout(); } return(success); }
private bool TestDomainFormat(ConnectionTestDTO test, out string error) { if (!test.domain.StartsWithProtocol()) { error = "Domain url should start with http:// or https://"; return(false); } if (test.domain.EndsWith("/")) { error = "Domain url should not end with '/'"; return(false); } Uri tmp; if (!Uri.TryCreate(test.domain, UriKind.Absolute, out tmp)) { error = "Invalid domain format"; return(false); } error = null; return(true); }
public ConnectionInfoDTO TestConnection(ConnectionTestDTO test) { bool success = false; string info = string.Empty; switch (test.type.ToLowerInvariant()) { case "ac": bool loginSameAsEmail; success = TestACConnection(test, out info, out loginSameAsEmail); break; case LmsProviderNames.AgilixBuzz: success = TestAgilixBuzzConnection(test, out info); break; case LmsProviderNames.Blackboard: success = TestBlackBoardConnection(test, out info); break; case LmsProviderNames.Moodle: var tupleResult = TestMoodleConnection(test).Result; success = tupleResult.result; info = tupleResult.info; break; case LmsProviderNames.Sakai: success = TestSakaiConnection(test, out info); break; case LmsProviderNames.Canvas: success = TestCanvasConnection(test, out info); break; case LmsProviderNames.Bridge: success = TestBridgeConnection(test, out info); break; case LmsProviderNames.Brightspace: success = TestBrightspaceConnection(test, out info); break; case LmsProviderNames.Schoology: success = TestSchoologyConnection(test, out info); break; case LmsProviderNames.Haiku: success = TestHaikuConnection(test, out info); break; } return(new ConnectionInfoDTO { status = success ? OkMessage : "Failed to connect", info = info }); }
private bool TestAgilixBuzzConnection(ConnectionTestDTO test, out string info) { if (!TestDomainFormat(test, out info)) { return(false); } bool result = Task.Run(async() => await _buzzClient.LoginAndCheckSessionAsync(test.domain.RemoveHttpProtocolAndTrailingSlash(), test.login, test.password)).Result; return(result); }
private bool TestHaikuConnection(ConnectionTestDTO test, out string info) { if (!TestDomainFormat(test, out info)) { return(false); } if (!Task.Run(() => _haikuClient.TestOauthAsync(test.domain, test.consumerKey, test.consumerSecret, test.token, test.tokenSecret)).Result) { info = "Can't connect."; return(false); } return(true); }
private async Task <(bool result, string info)> TestMoodleConnection(ConnectionTestDTO test) { string info; if (!TestDomainFormat(test, out info)) { return(false, info); } var tuple = await _moodleClient.LoginAndCheckSession( test.domain.IsSSL(), test.domain.RemoveHttpProtocolAndTrailingSlash(), test.login, test.password); return(tuple.result, info); }
private bool TestSchoologyConnection(ConnectionTestDTO test, out string info) { if (!TestDomainFormat(test, out info)) { return(false); } try { Task <dynamic> task = Task.Run <dynamic>(async() => await _schoologyClient.GetRestCall <dynamic>(test.login, test.password, "courses")); var courses = task.Result; return(courses != null); } catch (AggregateException ex) { _logger.Error("[TestSchoologyConnection]", ex); if (ex.InnerExceptions.First() is HttpRequestException reqEx) { info = reqEx.Message; } return(false); } }
public bool TestACConnection(ConnectionTestDTO test, out string info, out bool loginSameAsEmail) { if (test == null) { throw new ArgumentNullException(nameof(test)); } loginSameAsEmail = false; //sharedTemplatesFolderScoId = null; info = string.Empty; if (string.IsNullOrWhiteSpace(test.password)) { info = "Password is required"; return(false); } if (!TestDomainFormat(test, out info)) { return(false); } var provider = new AdobeConnectProvider(new ConnectionDetails(new Uri(test.domain))); var result = provider.Login(new UserCredentials(test.login, test.password)); if (!result.Success) { string error = FormatErrorFromAC(result); if (!string.IsNullOrWhiteSpace(error)) { info = error; } return(false); } CommonInfoResult commonInfo = provider.GetCommonInfo(); if (!commonInfo.Success) { _logger.ErrorFormat("GetPasswordPolicies.GetUserInfo. AC error. {0}.", commonInfo.Status.GetErrorInfo()); info = commonInfo.Status.GetErrorInfo(); return(false); } if (commonInfo.CommonInfo.AccountId.HasValue) { FieldCollectionResult fields = provider.GetAclFields(commonInfo.CommonInfo.AccountId.Value); if (!fields.Success) { _logger.ErrorFormat("GetPasswordPolicies.GetAclFields. AC error. {0}.", fields.Status.GetErrorInfo()); info = fields.Status.GetErrorInfo(); return(false); } //ScoContentCollectionResult sharedTemplates = provider.GetContentsByType("shared-meeting-templates"); //if (!sharedTemplates.Success) //{ // logger.ErrorFormat("GetPasswordPolicies.get shared-meeting-templates. AC error. {0}.", sharedTemplates.Status.GetErrorInfo()); // info = sharedTemplates.Status.GetErrorInfo(); // return false; //} //sharedTemplatesFolderScoId = sharedTemplates.ScoId; string setting = GetField(fields, "login-same-as-email"); loginSameAsEmail = string.IsNullOrEmpty(setting) || "YES".Equals(setting, StringComparison.OrdinalIgnoreCase); return(true); } _logger.Error("GetPasswordPolicies. Account is NULL. Check Adobe Connect account permissions. Admin account expected."); info = "Check Adobe Connect account permissions. Admin account expected."; return(false); }
private bool TestBrightspaceConnection(ConnectionTestDTO test, out string info) { info = "Not supported"; return(true); }
private bool TestCanvasConnection(ConnectionTestDTO test, out string info) { info = "Not supported"; return(true); }
private bool TestSakaiConnection(ConnectionTestDTO test, out string info) { info = "Not yet implemented"; return(true); }
public ConnectionInfoDTO TestConnection(ConnectionTestDTO test) { return(TestConnectionService.TestConnection(test)); }