public async Task<Session> Login (LoginOptions options, string [] scope, CancellationToken token) { List<AccountProvider> providers = GetProviderChain (options, scope).ToList (); options.TryReportProgress (LoginProgress.Authorizing); var providerExceptions = new List<Exception> (); // Try each provider in turn foreach (var pi in providers.Select ((p, i) => new { Provider = p, Index = i })) { bool isLast = (pi.Index == providers.Count - 1); AccountProvider provider = pi.Provider; token.ThrowIfCancellationRequested (); try { return await GetSession (provider, isLast, options, token); } catch (TaskCanceledException) { throw; } catch (Exception ex) { providerExceptions.Add (ex); } } // Neither provider worked throw new AggregateException ("Could not obtain session via either provider.", providerExceptions); }
async Task<Session> GetSession (AccountProvider provider, bool isLast, LoginOptions options, CancellationToken token) { if (!SessionManager.NetworkMonitor.IsNetworkAvailable) throw new OfflineException (); var account = await GetAccount (provider, !isLast, options); if (account == null) throw new Exception ("The user chose to skip this provider."); var service = provider.Service; var session = new Session (service, account); if (service.SupportsVerification) { // For services that support verification, do it now try { await service.VerifyAsync (account, token); } catch (TaskCanceledException) { throw; } catch (Exception ex) { throw new InvalidOperationException ("Account verification failed.", ex); } } return session; }
public override Task<ServiceUser> GetProfileAsync (CancellationToken token = default (CancellationToken), LoginOptions options = default (LoginOptions)) { return this.WithSession ( () => this.GetProfile (token), options, token ); }
public override Task ShareAsync (Item item, CancellationToken token = default (CancellationToken), LoginOptions options = default (LoginOptions)) { return this.WithSession ( () => this.Share (item, token), options, token ); }
public Task<Page<IEnumerable<ServiceUser>>> GetFriendsAsync (int itemsPerPage = 100, Page<IEnumerable<ServiceUser>> previous = null, CancellationToken token = default (CancellationToken), LoginOptions options = default (LoginOptions)) { return this.WithSession ( () => this.GetFriends (itemsPerPage, previous, token), options, token ); }
public Task<string> RemoveCommentAsync (string postId, LoginOptions options = default (LoginOptions), CancellationToken token = default (CancellationToken)) { return this.WithSession ( () => RemoveComment (postId, token), options, token ); }
public Task<string> AddCommentAsync (string threadId, string message, LoginOptions options = default (LoginOptions), CancellationToken token = default (CancellationToken)) { return this.WithSession ( () => AddComment (threadId, message, token), options, token ); }
public Task<Page<IEnumerable<ServiceUser>>> GetFriendsAsync (int count = 100, Page<IEnumerable<ServiceUser>> previous = null, CancellationToken token = default (CancellationToken), LoginOptions options = default (LoginOptions)) { return this.WithSession ( () => this.GetFriends (count, previous, token), options, token, new [] { "email" } ); }
public Task<FacebookLikeInfo> LikeAsync (string url, string objectId, CancellationToken token = default (CancellationToken), LoginOptions options = default (LoginOptions)) { return this.WithSession ( () => this.Like (url, objectId, token), options, token, new [] { "publish_actions" } ); }
public Task UnlikeAsync (string url, string likeId, CancellationToken token = default (CancellationToken), LoginOptions options = default (LoginOptions)) { return this.WithSession ( () => this.Unlike (url, likeId, token), options, token, new [] { "publish_actions" } ); }
public Task<Page<IEnumerable<ServiceUser>>> GetFriendsAsync (int itemsPerPage = 100, string orderBy = "best", Page<IEnumerable<ServiceUser>> previous = null, CancellationToken token = default (CancellationToken), LoginOptions options = default (LoginOptions)) { return this.WithSession ( () => this.GetPeople (itemsPerPage, orderBy, previous, token), options, token, new [] { PlusLoginScopeKey } ); }
public void LogInAsLastRegisteredUser(LoginOptions useLastGeneratedPassword) { var user = new User() { EmailAddress = UserGenerator.LastGeneratedUser.EmailAddress, Password = PasswordGenerator.LastGeneratedPassword }; LogIn(user); }
public static IAsyncOperation<Account> CreateNewAccount(LoginOptions loginOptions, string response) { InitEncryption(); SDK.Auth.AuthResponse authResponse = SDK.Auth.OAuth2.ParseFragment(response); return Task.Run(async () => { var account = await SDK.Auth.AccountManager.CreateNewAccount(loginOptions.ConvertToSDKLoginOptions(), authResponse); return Account.FromJson(SDK.Auth.Account.ToJson(account)); }).AsAsyncOperation(); }
public ClarizenUtils(string username, string password, int timeout) { ClarizenAPI = new Clarizen {EnableDecompression = true, Timeout = timeout}; var options = new LoginOptions { PartnerId = "", ApplicationId = "E000D035-3F63-4D51-87BA-737EE9B1487E" }; ClarizenAPI.Login(username, password, options); projectEntityDescription=new Dictionary<string, EntityDescription>(); }
public override Task<ServiceUser> GetProfileAsync (CancellationToken token = default (CancellationToken), LoginOptions options = default (LoginOptions)) { return this.WithSession ( () => this.GetProfile (token), options, token, new [] { UserinfoEmailScopeKey, PlusMeScopeKey } ); }
[Ignore("Disturbs local test runs")] // As it disturbs local test runs public void Login_CredentialsOkay_ShouldBeAuthenticated() { // Arrange var options = new LoginOptions { Caption = "Foretag login", DialogLocation = LoginOptions.Location.CenterToParent, Username = AdTestUser, Password = AdTestPassword }; // Act bool ok = AdfsLogin.Login(new AdfsOptions { IdpEndpoint = "https://dev-idp.vfltest.dk/adfs/ls/", Realm = "https://localhost.vfltest.dk/WindowsFormsApplWithWebLogin/" }, options); // Assert ok.Should().BeTrue(); AdfsLogin.IsAuthenticated().Should().BeTrue(); Assert.AreEqual(Thread.CurrentPrincipal.Identity.Name, "PROD\\CommonLoginCI"); }
public string GetToken(LoginOptions opts) { //string baseUrl = ClientConfig.GetValue<string>("BaseUrl"); string url = $"{opts.ServerUrl}/connect/token"; _loggerService.Debug($"Server url: {url}"); if (!_rawCmsService.Ping(url)) { _loggerService.Error("host not found."); return(string.Empty); } //create RestSharp client and POST request object RestClient client = new RestClient(url); RestRequest request = new RestRequest(Method.POST); //add GetToken() API method parameters request.Parameters.Clear(); request.AddParameter("grant_type", "password"); request.AddParameter("username", opts.Username); request.AddParameter("password", opts.Password); request.AddParameter("client_id", opts.ClientId); request.AddParameter("client_secret", opts.ClientSecret); request.AddParameter("scoope", "openid"); //make the API request and get the response IRestResponse response = client.Execute(request); TokenResponse res = Newtonsoft.Json.JsonConvert.DeserializeObject <TokenResponse>(response.Content); if (response.IsSuccessful) { _loggerService.Debug("Success response token"); return(res.access_token); } else { _loggerService.Warn("Unable to get valid token."); throw new ExceptionToken(res.error, res.error_description); } }
public async Task SignInAsync(ICredentials credentials) { try { IsInProgress = true; this.CurrentUser = await this.AuthContext.AcquireTokenAsync(credentials); var uiConfig = this.AuthContext.Parameters.ToWebUIConfiguration(); var env = CrossSettings.Current.GetValueOrDefault("environment", DefaultEnvironment); var options = new LoginOptions(new Uri(AppUri[env]), new Uri(AppUri[env] + "#/projects"), uiConfig); await this.Client.LoginAsync(this.CurrentUser.IdToken, options); } finally { IsInProgress = false; } Notify(); }
private string GetRedirectUri() { string absoluteApplicationPath = GetAbsoluteApplicationPath(); if (string.IsNullOrEmpty(absoluteApplicationPath) || absoluteApplicationPath[absoluteApplicationPath.Length - 1] != '/') { absoluteApplicationPath += "/"; } string redirectUri = absoluteApplicationPath + RequestCallback; var uriBuilder = new UriBuilder(redirectUri); if (UserLocationStorageType == UserLocationStorageType.RedirectUri) { var queryStringValues = Extensions.ParseQueryString(uriBuilder.Query); queryStringValues[ProviderParameter] = Name; queryStringValues[OptionsParameter] = LoginOptions.ToString("D"); if (MaintainUserLocation) { string returnUrl = HttpContext.Current.Request.RawUrl; if (!LoginOptions.HasFlag(AuthLoginOptions.StayOnCurrentPage) || !IsUrlLocalToHost(returnUrl)) { returnUrl = HttpContext.Current.Request.QueryString[UrlParameter]; } if (!IsUrlLocalToHost(returnUrl)) { returnUrl = HttpContext.Current.Request.QueryString[ReturnUrlParameter]; } if (!IsUrlLocalToHost(returnUrl)) { returnUrl = SuccessUrl; } queryStringValues[UrlParameter] = returnUrl; } uriBuilder.Query = Extensions.BuildQueryString(queryStringValues); } return(uriBuilder.Uri.AbsoluteUri); }
protected virtual async void GetProfileAndFriendsAsync(LoginOptions options) { TableView.Source = null; TableView.ReloadData(); try { var profile = await Service.GetProfileAsync(options : options); new UIAlertView("Profile", profile.ToString(), null, "OK").Show(); } catch (UriFormatException) { new UIAlertView("Specify your API keys", "Open Services.cs and specify your API keys for each provider.", null, "OK").Show(); return; } catch { Console.WriteLine("Couldn't retrieve profile for {0}. (Maybe we're logged out?)", Service); return; } GetNextFriendsAsync(options); }
/// <summary> /// Logs currently authenticated user out by deleting locally persisted credentials and invoking the server to revoke /// the user auth tokens /// </summary> /// <returns>true if server logout was successful</returns> public async Task <bool> Logout() { Account account = AccountManager.GetAccount(); if (account != null) { LoginOptions options = account.GetLoginOptions(); AccountManager.DeleteAccount(); OAuth2.ClearCookies(options); bool loggedOut = await OAuth2.RevokeAuthToken(options, account.RefreshToken); if (loggedOut) { GetRestClient(); } return(loggedOut); } GetRestClient(); return(await Task.Factory.StartNew(() => true)); }
public void Login(SignInOptions signInOptions) { var credential = new NetworkCredential(signInOptions.Username, signInOptions.Password, signInOptions.Domain); AuthenticationResult result = authenticationProvider.Authenticate(credential); if (result.Status == AuthenticationStatus.Failure) { throw new AuthenticationException(result.Status, Translation.Instance.Authentication_Failed); } if (result.Status == AuthenticationStatus.ServiceUnavailable) { throw new AuthenticationException(result.Status, Translation.Instance.Authentication_ServiceUnavailable); } var optionsFactory = new LoginOptionsFactory(settings, result.UserDetails, signInOptions); LoginOptions clientOptions = optionsFactory.CreateInstance(); client.Login(clientOptions); }
private IDictionary <string, object> DecodeExtendedPropertyMap(IDictionary <string, object> source) { var extendedPropertyMap = new Dictionary <string, object>(); foreach (var key in source.Keys) { var value = source[key]; if (value is SerializableLoginOptions) { var loginOptions = (SerializableLoginOptions)value; value = new LoginOptions(loginOptions.DataSourceExtension, loginOptions.CompositionContextName, loginOptions.UsesDistributedEntityService ? EntityServiceOption.UseDistributedService : EntityServiceOption.UseLocalService, loginOptions.ServiceKey); } extendedPropertyMap[key] = value; } return(extendedPropertyMap); }
public void prompt(Credentials credentials, string title, string reason, LoginOptions options) { AsyncDelegate d = delegate { View = ObjectFactory.GetInstance <IPasswordPromptView>(); View.Title = title; View.Reason = reason; View.OkButtonText = LocaleFactory.localizedString("Unlock Vault", "Cryptomator"); View.IconView = IconCache.Instance.IconForName(options.icon(), 64); View.SavePassword = false; View.ValidateInput += ValidateInputEventHandler; if (DialogResult.Cancel == View.ShowDialog(_browser.View)) { throw new LoginCanceledException(); } credentials.setPassword(View.InputText); credentials.setSaved(View.SavePassword); }; _browser.Invoke(d); }
/// <summary> /// Logs currently authenticated user out by deleting locally persisted credentials and invoking the server to revoke /// the user auth tokens /// </summary> /// <returns>true if server logout was successful</returns> public async Task <bool> LogoutAsync(CancellationToken cancellationToken = default(CancellationToken)) { Account account = AccountManager.GetAccount(); if (account != null) { LoginOptions options = account.GetLoginOptions(); AccountManager.DeleteAccount(); await AuthHelper.ClearCookiesAsync(options); bool loggedOut = await OAuth2.RevokeAuthTokenAsync(options, account.RefreshToken, cancellationToken); if (loggedOut) { GetRestClient(); } return(loggedOut); } GetRestClient(); return(true); }
async void GetRootFolder(LoginOptions options) { tableView.Source = null; tableView.ReloadData(); try { var profile = await Services.Dropbox.GetProfileAsync(options : options); new UIAlertView("Profile", profile.ToString(), null, "OK").Show(); } catch (UriFormatException) { new UIAlertView("Specify your API keys", "Open Services.cs and specify your API keys for each provider.", null, "OK").Show(); return; } catch { Console.WriteLine("Failed to retrieve Dropbox profile. (Maybe we're logged out?)"); return; } DropboxManager.Metadata metadata; try { metadata = await Services.Dropbox.GetMetadataAsync("/", includeContent : true, hash : null, options : options); } catch { Console.WriteLine("Failed to retrieve Dropbox metadata"); return; } if (tableView.Source == null) { var source = new MetadataSource(metadata.Contents) { Controller = new WeakReference(this) }; tableView.Source = source; } else { ((MetadataSource)tableView.Source).Add(metadata.Contents); } tableView.ReloadData(); }
public void LogIn(LoginOptions loginOptions) { var user = new User(); switch (loginOptions) { case LoginOptions.UseLastGeneratedPassword: user.EmailAddress = UserGenerator.LastGeneratedUser.EmailAddress; user.Password = PasswordGenerator.LastGeneratedPassword; break; case LoginOptions.PredefinedCredentials: user.EmailAddress = LoginPage.PredifinedUserName; user.Password = LoginPage.PredifinedPassword; break; default: throw new ArgumentOutOfRangeException(nameof(loginOptions), loginOptions, null); } LoginPage.LogIn(user); }
public void StartLoginFlow(LoginOptions loginOptions) { if (loginOptions == null || String.IsNullOrWhiteSpace(loginOptions.CallbackUrl) || String.IsNullOrWhiteSpace(loginOptions.LoginUrl)) { return; } try { var loginUri = new Uri(OAuth2.ComputeAuthorizationUrl(loginOptions)); var callbackUri = new Uri(loginOptions.CallbackUrl); WebAuthenticationBroker.AuthenticateAndContinue(loginUri, callbackUri, null, WebAuthenticationOptions.None); } catch (Exception ex) { PlatformAdapter.SendToCustomLogger("AccountPage.StartLoginFlow - Exception occured", LoggingLevel.Critical); PlatformAdapter.SendToCustomLogger(ex, LoggingLevel.Critical); PlatformAdapter.Resolve <IAuthHelper>().StartLoginFlow(); } }
public Credentials prompt(Host bookmark, string title, string reason, LoginOptions options) { Credentials credentials = new VaultCredentials().withSaved(options.save()); AsyncDelegate d = delegate { View = ObjectFactory.GetInstance<IPasswordPromptView>(); View.Title = title; View.Reason = reason; View.OkButtonText = LocaleFactory.localizedString("Continue", "Credentials"); View.IconView = IconCache.Instance.IconForName(options.icon(), 64); View.SavePassword = options.save(); View.ValidateInput += ValidateInputEventHandler; if (DialogResult.Cancel == View.ShowDialog(_browser.View)) { throw new LoginCanceledException(); } credentials.setPassword(View.InputText); credentials.setSaved(View.SavePassword); }; _browser.Invoke(d); return credentials; }
async Task<Account> GetAccount (AccountProvider provider, bool allowFallback, LoginOptions options) { List<Account> accounts; options.TryReportProgress (provider.ProgressWhileAuthenticating); try { // Now, let's get accounts for current provider. // For different services and login methods, this may launch Safari, show iOS 6 prompt or just query ACAccounts. accounts = (await provider.GetAccounts ()).ToList (); } finally { options.TryReportProgress (LoginProgress.Authorizing); } if (accounts.Count == 0) throw new InvalidOperationException ("No accounts found for this service."); if (accounts.Count == 1) return accounts [0]; // If there is more than a single account, present an interface to choose one. // If fallback is available, add it to the list of options with null value. var choiceUI = options.AccountChoiceProvider; if (choiceUI == null) throw new InvalidOperationException ("There is more than one account, but no accountChoiceProvider was specified."); // Add "Other" option that falls back to next provider if (allowFallback) accounts.Add (null); // Show chooser interface options.TryReportProgress (LoginProgress.PresentingAccountChoice); try { return await choiceUI.ChooseAsync (accounts, a => (a != null) ? a.Username : "******"); } finally { options.TryReportProgress (LoginProgress.Authorizing); } }
IEnumerable <AccountProvider> GetProviderChain(LoginOptions options, string[] scope) { foreach (var serviceFactory in _fallbackChain) { var service = serviceFactory(); var scoped = service as ISupportScope; if (scoped != null && scope != null) { scoped.Scopes = scope; } yield return(new AccountProvider(service, null)); if (options.AllowLoginUI && service.SupportsAuthentication) { if (options.Activity != null) { yield return(new AccountProvider(service, options.Activity)); } } } }
public Dictionary <string, string> GetFormContent() { var content = new Dictionary <string, string>() { { "login", Login }, { "passwd", Passwd }, { "PPFT", PPFT }, { "PPSX", PPSX }, { "SI", SI }, { "type", Type.ToString() }, { "NewUser", NewUser.ToString() }, { "LoginOptions", LoginOptions.ToString() } }; if (NeedsRemoteNGCParams) { content.Add("ps", Ps.ToString()); content.Add("psRNGCEntropy", PsRNGCEntropy); content.Add("psRNGCDefaultType", PsRNGCDefaultType.ToString()); } return(content); }
public static async Task TestSetup(TestContext context) { SFApplicationHelper.RegisterServices(); SDKServiceLocator.RegisterService <ILoggingService, Hybrid.Logging.Logger>(); var settings = new EncryptionSettings(new HmacSHA256KeyGenerator(HashAlgorithmNames.Sha256)); Encryptor.init(settings); var options = new LoginOptions(TestCredentials.LoginUrl, TestCredentials.ClientId, TestCallbackUrl, "mobile", TestScopes); var response = new AuthResponse { RefreshToken = TestCredentials.RefreshToken, AccessToken = TestAuthToken, InstanceUrl = TestCredentials.InstanceUrl, IdentityUrl = TestCredentials.IdentityUrl, Scopes = TestScopes, }; Account account = await AccountManager.CreateNewAccount(options, response); account.UserId = TestCredentials.UserId; account.UserName = TestCredentials.Username; await OAuth2.RefreshAuthTokenAsync(account); _smartStore = SmartStore.GetSmartStore(); _smartStore.ResetDatabase(); _syncManager = SyncManager.GetInstance(); _restClient = new RestClient(account.InstanceUrl, account.AccessToken, async(cancellationToken) => { account = AccountManager.GetAccount(); account = await OAuth2.RefreshAuthTokenAsync(account); return(account.AccessToken); } ); CreateAccountsSoup(); _idToNames = await CreateTestAccountsOnServer(CountTestAccounts); }
public static async Task TestSetup(TestContext context) { var settings = new EncryptionSettings(new HmacSHA256KeyGenerator()); Encryptor.init(settings); var options = new LoginOptions(TestCredentials.LoginUrl, TestCredentials.ClientId, TestCallbackUrl, "mobile", TestScopes); var response = new AuthResponse { RefreshToken = TestCredentials.RefreshToken, AccessToken = TestAuthToken, InstanceUrl = TestCredentials.InstanceUrl, IdentityUrl = TestCredentials.IdentityUrl, Scopes = TestScopes, }; Account account = await AccountManager.CreateNewAccount(options, response); account.UserId = TestCredentials.UserId; account.UserName = TestCredentials.Username; await OAuth2.RefreshAuthToken(account); _smartStore = SmartStore.GetGlobalSmartStore(); _smartStore.ResetDatabase(); _syncManager = SyncManager.GetInstance(); _restClient = new RestClient(account.InstanceUrl, account.AccessToken, async() => { account = AccountManager.GetAccount(); AuthResponse authResponse = await OAuth2.RefreshAuthTokenRequest(account.GetLoginOptions(), account.RefreshToken); account.AccessToken = authResponse.AccessToken; return(account.AccessToken); } ); CreateAccountsSoup(); _idToNames = await CreateTestAccountsOnServer(CountTestAccounts); }
private async Task <Account> SetupTestAccountAsync(string hashAlgorithmName) { var testScope = new[] { "scopeA", "scopeB" }; SFApplicationHelper.RegisterServices(); var settings = new EncryptionSettings(new HmacSHA256KeyGenerator(hashAlgorithmName)); Encryptor.init(settings); var options = new LoginOptions(SmartStore.Store.TestCredentials.LoginUrl, SmartStore.Store.TestCredentials.ClientId, TestCredentials.CallbackUrl, "mobile", testScope); var response = new AuthResponse { RefreshToken = SmartStore.Store.TestCredentials.RefreshToken, AccessToken = TestCredentials.AccessToken, InstanceUrl = SmartStore.Store.TestCredentials.InstanceUrl, IdentityUrl = SmartStore.Store.TestCredentials.IdentityUrl, Scopes = testScope, }; var account = await AccountManager.CreateNewAccount(options, response); account.UserId = SmartStore.Store.TestCredentials.UserId; account.UserName = SmartStore.Store.TestCredentials.Username; return(await Task.FromResult(account)); }
private async void DoAuthFlow(LoginOptions loginOptions) { loginOptions.DisplayType = LoginOptions.DefaultStoreDisplayType; var loginUri = new Uri(OAuth2.ComputeAuthorizationUrl(loginOptions)); var callbackUri = new Uri(loginOptions.CallbackUrl); OAuth2.ClearCookies(loginOptions); WebAuthenticationResult webAuthenticationResult; try { PlatformAdapter.SendToCustomLogger( "AccountPage.DoAuthFlow - calling WebAuthenticationBroker.AuthenticateAsync()", LoggingLevel.Verbose); if (loginOptions.UseTwoParamAuthAsyncMethod) { webAuthenticationResult = await WebAuthenticationBroker.AuthenticateAsync(loginOptions.BrokerOptions, loginUri); } else { webAuthenticationResult = await WebAuthenticationBroker.AuthenticateAsync(loginOptions.BrokerOptions, loginUri, callbackUri); } } // If a bad URI was passed in the user is shown an error message by the WebAuthenticationBroken, when user // taps back arrow we are then thrown a FileNotFoundException, but since user already saw error message we // should just swallow that exception catch (FileNotFoundException) { SetupAccountPage(); return; } catch (Exception ex) { PlatformAdapter.SendToCustomLogger("AccountPage.StartLoginFlow - Exception occured", LoggingLevel.Critical); PlatformAdapter.SendToCustomLogger(ex, LoggingLevel.Critical); DisplayErrorDialog(LocalizedStrings.GetString("generic_error")); SetupAccountPage(); return; } if (webAuthenticationResult.ResponseStatus == WebAuthenticationStatus.Success) { var responseUri = new Uri(webAuthenticationResult.ResponseData); if (!String.IsNullOrWhiteSpace(responseUri.Query) && responseUri.Query.IndexOf("error", StringComparison.CurrentCultureIgnoreCase) >= 0) { DisplayErrorDialog(LocalizedStrings.GetString("generic_authentication_error")); SetupAccountPage(); } else { try { AuthResponse authResponse = OAuth2.ParseFragment(responseUri.Fragment.Substring(1)); PlatformAdapter.SendToCustomLogger("AccountPage.DoAuthFlow - calling EndLoginFlow()", LoggingLevel.Verbose); await PlatformAdapter.Resolve <IAuthHelper>().EndLoginFlow(loginOptions, authResponse); } catch (Exception ex) { DisplayErrorDialog($"Login failed: { ex.Message }"); SetupAccountPage(); } } } else if (webAuthenticationResult.ResponseStatus == WebAuthenticationStatus.UserCancel) { SetupAccountPage(); } else { DisplayErrorDialog(LocalizedStrings.GetString("generic_error")); SetupAccountPage(); } }
public override Task ShareAsync (Item item, CancellationToken token = default (CancellationToken), LoginOptions options = default (LoginOptions)) { throw new NotImplementedException (); }
public override void PreExecute() { base.PreExecute(); /// login string username = Variables.ClarizenUserName; string password = Variables.ClarizenPassword; clarizenClient = new Clarizen(); clarizenClient.Timeout = 10 * 1000 * 60; //For debugging clarizenClient.EnableDecompression = true; //compress traffic //Currently pass null in last argument LoginOptions options = new LoginOptions(); //If you are an enterprise user, leave the partnerId empty. If you are a certified partner, please //place the partner id you received from Clarizen here: options.PartnerId = ""; options.ApplicationId = "ClarizenClient"; //Replace with a string representing your application LoginResult lr = clarizenClient.Login(username, password, options); userId = lr.UserId; }
public override Task<Page<IEnumerable<ServiceUser>>> GetFriendsAsync (Page<IEnumerable<ServiceUser>> previous = null, CancellationToken token = default (CancellationToken), LoginOptions options = default (LoginOptions)) { return GetFriendsAsync (100, previous, token, options); }
private BookmarkController(T view, Host host, LoginInputValidator validator, LoginOptions options) : base(validator) { _host = host; _validator = validator; _options = options; View = view; _ticklerReachability = new Timer(OnRechability, null, Timeout.Infinite, Timeout.Infinite); _ticklerFavicon = new Timer(OnFavicon, null, Timeout.Infinite, Timeout.Infinite); View.ToggleOptions += View_ToggleOptions; View.OptionsVisible = PreferencesFactory.get().getBoolean(ToggleProperty); //set default favicon View.Favicon = Images.Site.Size(16); InitProtocols(); InitPrivateKeys(); InitConnectModes(); InitEncodings(); InitTimezones(); InitTransferModes(); Update(); View.ChangedProtocolEvent += View_ChangedProtocolEvent; View.ChangedProtocolEvent += ReadPasswordFromKeychain; View.ChangedPortEvent += View_ChangedPortEvent; View.ChangedUsernameEvent += View_ChangedUsernameEvent; View.ChangedUsernameEvent += ReadPasswordFromKeychain; View.ChangedServerEvent += View_ChangedServerEvent; View.ChangedServerEvent += ReadPasswordFromKeychain; View.ChangedEncodingEvent += View_ChangedEncodingEvent; View.ChangedPathEvent += View_ChangedPathEvent; View.ChangedTimezoneEvent += View_ChangedTimezoneEvent; View.ChangedConnectModeEvent += View_ChangedConnectModeEvent; View.ChangedTransferEvent += View_ChangedTransferEvent; View.ChangedAnonymousCheckboxEvent += View_ChangedAnonymousCheckboxEvent; View.ChangedPrivateKeyEvent += View_ChangedPrivateKeyEvent; View.OpenPrivateKeyBrowserEvent += View_OpenPrivateKeyBrowserEvent; View.ChangedClientCertificateEvent += View_ChangedClientCertificateEvent; View.ChangedNicknameEvent += View_ChangedNicknameEvent; View.ChangedWebURLEvent += View_ChangedWebURLEvent; View.ChangedCommentEvent += View_ChangedCommentEvent; View.ChangedBrowserDownloadPathEvent += View_ChangedBrowserDownloadPathEvent; View.OpenDownloadFolderBrowserEvent += View_OpenDownloadFolderBrowserEvent; View.OpenDownloadFolderEvent += View_OpenDownloadFolderEvent; View.OpenUrl += View_OpenUrl; View.OpenWebUrl += View_OpenWebUrl; ProfileListObserver observer = Locator.Current.GetService <ProfileListObserver>(); profileObserver = Observable.FromEventPattern <EventHandler, EventArgs>( h => observer.ProfilesChanged += h, h => observer.ProfilesChanged -= h) .Subscribe(_ => { InitProtocols(); Update(); }); }
static void RunLoginUser(LoginOptions loginOptions) { Authentification.Login(loginOptions.UserName); }
public Credentials prompt(Host bookmark, String username, String title, String reason, LoginOptions options) { View = ObjectFactory.GetInstance <ILoginView>(); var credentials = new Credentials().withSaved(options.keychain()).withUsername(username); InitEventHandlers(bookmark, credentials, options); View.Title = LocaleFactory.localizedString(title, "Credentials"); View.Message = LocaleFactory.localizedString(reason, "Credentials"); View.Username = username; View.SavePasswordState = options.keychain(); View.DiskIcon = Images.Get(options.icon()).Size(64); InitPrivateKeys(); Update(credentials, options); AsyncDelegate d = delegate { if (DialogResult.Cancel == View.ShowDialog(_browser.View)) { throw new LoginCanceledException(); } }; _browser.Invoke(d); return(credentials); }
private bool View_ValidateInput(Host bookmark, Credentials credentials, LoginOptions options) { return(credentials.validate(bookmark.getProtocol(), options)); }
private void View_ChangedUsernameEvent(Host bookmark, Credentials credentials, LoginOptions options) { credentials.setUsername(Utils.SafeString(View.Username)); if (Utils.IsNotBlank(credentials.getUsername())) { String password = keychain.getPassword(bookmark.getProtocol().getScheme(), bookmark.getPort(), bookmark.getHostname(), credentials.getUsername()); if (Utils.IsNotBlank(password)) { View.Password = password; // Make sure password fetched from keychain and set in field is set in model credentials.setPassword(password); } } Update(credentials, options); }
public Login(string userName, string password, LoginOptions loginOptions) { UserName = userName; Password = password; LoginOptions = loginOptions; }
public override Task<Page<IEnumerable<ServiceUser>>> GetFriendsAsync (Page<IEnumerable<ServiceUser>> previous = null, CancellationToken token = default (CancellationToken), LoginOptions options = default (LoginOptions)) { throw new NotImplementedException (); }
protected BookmarkController(Host host, LoginInputValidator validator, LoginOptions options) : this(ObjectFactory.GetInstance <T>(), host, validator, options) { _bookmarkCollectionListener = new RemovedCollectionListener(this, host); }
private int RunLoginOptionsCode(LoginOptions opts) { bool Verbose = false; _loggerService.SetVerbose(Verbose); string token = string.Empty; opts.ServerUrl = _rawCmsService.FixUrl(opts.ServerUrl); try { token = _tokenService.GetToken(opts); _loggerService.Debug($"\n---- TOKEN ------\n{token}\n-----------------"); } catch (ExceptionToken e) { _loggerService.Error($"token error:"); _loggerService.Error($"\t{e.Code}, {e.Message}"); return(2); } catch (Exception e) { _loggerService.Error("token error", e); return(2); } if (string.IsNullOrEmpty(token)) { _loggerService.Warn("Unable to get token. check if data are correct and retry."); return(2); } string mydocpath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); string fileconfigname = _clientConfigService.GetValue <string>("ConfigFile"); fileconfigname = string.Format(fileconfigname, opts.Username); string filePath = System.IO.Path.Combine(mydocpath, fileconfigname); ConfigFile cf = new ConfigFile { Token = token, CreatedTime = DateTime.Now.ToShortDateString(), ServerUrl = opts.ServerUrl, User = opts.Username }; _configService.Save(filePath); var win = System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(OSPlatform.Windows); var lin = System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(OSPlatform.Linux); var osx = System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(OSPlatform.OSX); string SetEnv = "SET"; if (lin || osx) { SetEnv = "export"; } var os = System.Environment.OSVersion.Platform; _loggerService.Info($"os: {os.ToString()}"); _loggerService.Info($"set enviroinment configuration: (copy, paste and hit return in console):\n\n{SetEnv} RAWCMSCONFIG={filePath}\n"); return(0); }
IEnumerable<AccountProvider> GetProviderChain (LoginOptions options, string [] scope) { throw new NotImplementedException ("GetProviderChain is not implemented on this platform."); }
protected BookmarkController(Host host, LoginOptions options) : this(ObjectFactory.GetInstance <T>(), host, new LoginInputValidator(host, options), options) { }
IEnumerable<AccountProvider> GetProviderChain (LoginOptions options, string [] scope) { foreach (var serviceFactory in _fallbackChain) { var service = serviceFactory (); var scoped = service as ISupportScope; if (scoped != null && scope != null) scoped.Scopes = scope; var system = service as IOSService; if (system != null) system.AllowLoginUI = options.AllowLoginUI; yield return new AccountProvider (service, false); if (options.AllowLoginUI && service.SupportsAuthentication) { if (options.PresentAuthController != null) yield return new AccountProvider (service, options.PresentAuthController); else yield return new AccountProvider (service, true); } } }
public Response Post(string user, string password) { return(LoginOptions.Autenticar(user, password)); }
IEnumerable<AccountProvider> GetProviderChain (LoginOptions options, string[] scope) { foreach (var serviceFactory in _fallbackChain) { var service = serviceFactory (); var scoped = service as ISupportScope; if (scoped != null && scope != null) scoped.Scopes = scope; yield return new AccountProvider (service, options.Activity); if (options.AllowLoginUI && service.SupportsAuthentication) { if (options.Activity != null) yield return new AccountProvider (service, options.Activity); } } }