/// <summary> /// This is the click handler for the 'Authenticate' button. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void AuthenticateButton_Click(object sender, RoutedEventArgs args) { AuthenticateButton.IsEnabled = false; #if WINDOWS_PHONE_APP // For windows phone we just skip authentication because native WISPr is not supported. // Here you can implement custom authentication. authenticationContext.SkipAuthentication(); rootPage.NotifyUser("Authentication skipped", NotifyType.StatusMessage); #else HotspotCredentialsAuthenticationResult result = await authenticationContext.IssueCredentialsAsync( ConfigStore.UserName, ConfigStore.Password, ConfigStore.ExtraParameters, ConfigStore.MarkAsManualConnect); if (result.ResponseCode == HotspotAuthenticationResponseCode.LoginSucceeded) { rootPage.NotifyUser("Issuing credentials succeeded", NotifyType.StatusMessage); Uri logoffUrl = result.LogoffUrl; if (logoffUrl != null) { rootPage.NotifyUser("The logoff URL is: " + logoffUrl.OriginalString, NotifyType.StatusMessage); } } else { rootPage.NotifyUser("Issuing credentials failed", NotifyType.ErrorMessage); } #endif AuthenticateButton.IsEnabled = true; }
private void SkipButton_Click(object sender, RoutedEventArgs e) { // Here you can implement custom authentication. authenticationContext.SkipAuthentication(); rootPage.NotifyUser("Authentication skipped", NotifyType.StatusMessage); ClearAuthenticationToken(); }
/// <summary> /// This is the click handler for the 'Skip' button. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SkipButton_Click(object sender, RoutedEventArgs args) { try { authenticationContext.SkipAuthentication(); rootPage.NotifyUser("Authentication skipped", NotifyType.StatusMessage); } catch (Exception ex) { rootPage.NotifyUser(ex.ToString(), NotifyType.ErrorMessage); } ClearAuthenticationToken(); }
private async Task AuthenticateInBackgroundAsync() { // In case this handler performs more complex tasks, it may get canceled at runtime. // Check if task was canceled by now. if (_cancelRequested) { // In case the task handler takes too long to generate credentials and gets canceled, // the handler should terminate the authentication by aborting it Debug.WriteLine("Aborting authentication"); _context.AbortAuthentication(ConfigStore.MarkAsManualConnect); return; } if (ConfigStore.UseNativeWISPr) { // The most common way of handling an authentication attempt is by providing WISPr credentials // through the IssueCredentialsAsync API. // If the task doesn't take any actions for authentication failures, it can use the // IssueCredentials API to just provide credenstials. // Alternatively, an application could run its own business logic to authentication with the // hotspot. In this case it should call the SkipAuthentication API. Note that it should call // SkipAuthentication after it has authenticated to allow Windows to refresh the network connectivity // state instantly. Debug.WriteLine("Issuing credentials"); HotspotCredentialsAuthenticationResult result = await _context.IssueCredentialsAsync( ConfigStore.UserName, ConfigStore.Password, ConfigStore.ExtraParameters, ConfigStore.MarkAsManualConnect); if (result.ResponseCode == HotspotAuthenticationResponseCode.LoginSucceeded) { Debug.WriteLine("Issuing credentials succeeded"); Uri logoffUrl = result.LogoffUrl; if (logoffUrl != null) { Debug.WriteLine("The logoff URL is: " + logoffUrl.OriginalString); } } else { Debug.WriteLine("Issuing credentials failed"); } } else { //TODO: Please perform any authentication that is required by your particular scenario. // Check _cancelRequested periodically in case the task is canceled. // Finally call SkipAuthentication to indicate that we are not doing native WISPr authentication // This call also serves the purpose of indicating a successful authentication. _context.SkipAuthentication(); } }
/// <summary> /// This is the click handler for the 'Skip' button. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SkipButton_Click(object sender, RoutedEventArgs args) { authenticationContext.SkipAuthentication(); rootPage.NotifyUser("Authentication skipped", NotifyType.StatusMessage); ClearAuthenticationToken(); }