/// <summary> /// Cleans up when web browser form is closed. /// </summary> void _webBrowserForm_FormClosed(object sender, FormClosedEventArgs e) { if (!_wasAutoClosed) { if (this.Port.HasValue && this._server != null) { // clean up Authorisation Listener _server.Stop(); _server = null; } OnAuthoriseComplete(new AuthoriseCompleteEventArgs(AuthorisationResult.Denied, null)); } }
public void Initialize() { try { GalaxyInstance.Init(new InitParams("48767653913349277", "58be5c2e55d7f535cf8c4b6bbc09d185de90b152c8c42703cc13502465f0d04a")); authListener = new AuthListener(onGalaxyAuthSuccess, onGalaxyAuthFailure, onGalaxyAuthLost); stateChangeListener = new OperationalStateChangeListener(onGalaxyStateChange); GalaxyInstance.User().SignInGalaxy(requireOnline: true); active = true; ConnectionProgress++; } catch (Exception value) { Console.WriteLine(value); ConnectionFinished = true; } }
public RSA_KEYX_AuthListener(BusAttachment busAtt) { this.al = new AuthListener(busAtt); this.al.RequestCredentials += new AuthListenerRequestCredentialsAsyncHandler(this.RequestCreds); this.al.AuthenticationComplete += new AuthListenerAuthenticationCompleteHandler(this.AuthComplete); }
public QStatus EnablePeerSecurity(string authMechanisms, AuthListener listener, string keyStoreFileName, bool isShared) { return alljoyn_busattachment_enablepeersecurity(_busAttachment, authMechanisms, (listener == null ? IntPtr.Zero : listener.UnmanagedPtr), keyStoreFileName, (isShared ? 1 : 0)); }
/// <summary> /// Attempts authorise process by opening a web browser for the user. /// </summary> /// <param name="scopes">List of scopes required by the app for user to authorise.</param> /// <param name="state">Any state information to be pass back to the app on completion of authorisation.</param> public void AttemptAuthorise(List <string> scopes, string state) { if (_webBrowserForm != null) { Debug.WriteLine("Login in progress, must explicitly abort current login."); throw new ApplicationException("Login in progress, must explicitly abort current login."); } var url = String.Format("{0}?response_type=code&client_id={1}&scope={2}&redirect_uri={3}&state={4}", OAuthEnpoints.Auth, this.ClientId, string.Join(" ", scopes), this.RedirectUri, state); // a web browser that we can monitor and control var webBrowser = new WebBrowser() { AllowWebBrowserDrop = false, Dock = DockStyle.Fill, Name = "webBrowser", ScrollBarsEnabled = false, TabIndex = 0 }; webBrowser.DocumentText = @"<head></head><body></body>"; // fake a document so we can set cookies webBrowser.Document.Cookie = this.Cookie; // will save the user from having to login if valid session exists webBrowser.Url = new Uri(url); // need to do this last so it isnt overwritten if (this.Port.HasValue) { // if we have a port use it as the prefer method try { _server = new AuthListener(); _server.RequestComplete += Server_RequestComplete; _server.ListenTo(this.Port.Value); webBrowser.DocumentCompleted += WebBrowser_SaveCookies; } catch (Exception ex) { Debug.WriteLine("AuthListener failed to start giving the reason: {0}", ex.Message); // revert to monitoring web browser method webBrowser.DocumentCompleted += WebBrowser_DocumentCompleted; url = url.Replace(this.RedirectUri, Out_Of_Band_Uri); webBrowser.Url = new Uri(url); } } else { // this is a less secure method but unlikely to fail webBrowser.DocumentCompleted += WebBrowser_DocumentCompleted; } _wasAutoClosed = false; _webBrowserForm = new Form(); _webBrowserForm.WindowState = FormWindowState.Normal; _webBrowserForm.Controls.Add(webBrowser); _webBrowserForm.Size = new Size(800, 600); _webBrowserForm.Name = "Authorise App"; _webBrowserForm.Text = "Authorise an app"; _webBrowserForm.FormClosed += _webBrowserForm_FormClosed; Application.Run(_webBrowserForm); }
public QStatus EnablePeerSecurity(string authMechanisms, AuthListener listener, string keyStoreFileName, bool isShared) { return(alljoyn_busattachment_enablepeersecurity(_busAttachment, authMechanisms, (listener == null ? IntPtr.Zero : listener.UnmanagedPtr), keyStoreFileName, (isShared ? 1 : 0))); }
public void CreateUserWithEmailAndPassword(string email, string password, string userName, AuthListener authListener) { FirebaseAuth.Instance.CreateUserWithEmailAndPassword(email, password) .AddOnFailureListener(authListener) .AddOnSuccessListener(authListener); }
public void SignInWithEmailAndPassword(string email, string password, AuthListener authListener) { FirebaseAuth.Instance.SignInWithEmailAndPassword(email, password) .AddOnSuccessListener(authListener) .AddOnFailureListener(authListener); }