Adapt the WPF Client to use the OTP Login from Web-Service

Adapt the MainWindow.xaml.cs code to be this:

using System;
using System.Windows;
using IdentityClient.ServiceReference1;

namespace IdentityClient
{

/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>

public partial class MainWindow : Window
{

public MainWindow()
{

InitializeComponent();

}

private async void button_Click(object sender, RoutedEventArgs e)
{

Guid aGuid;
int OTP; //for checking a OneTime Password
string TheMessage;
string aUser = “fred.flintstone@gmail.com”;
string aPwd = “Th1s1sMyP@ssw0rd”;
listBox.Items.Add(“Clicked”);
IdentityBrokerClient client = new IdentityBrokerClient();
listBox.Items.Add(“IdentityBrokerClient client = new IdentityBrokerClient();”);

// Test to add Fred
TheMessage = client.AddUserAsync(aUser, aPwd);
listBox.Items.Add(“client.AddUserAsync”);
listBox.Items.Add(TheMessage);
listBox.Items.Add(“——————“);

// Test to Get Fred his Guid
aGuid = await client.GetUserIdentifierAsync(aUser, aPwd);
listBox.Items.Add(“client.GetUserIdentifier”);
listBox.Items.Add(aGuid.ToString());

// Test to see if we can login Fred with his generated OTP
if (aGuid != Guid.Empty)
{

listBox.Items.Add(“——————“);
listBox.Items.Add(“Calculate OTP”);
OTP = OTPAuthenticator.OTPFromGuid(aGuid);
listBox.Items.Add(“OTP = “ + OTP.ToString());
TheMessage = await client.LogonUserWithOTPAsync(aUser, aPwd, OTP);
listBox.Items.Add(“client.LogonUserWithOTP”);
textBox.Text = TheMessage;

}

else
{

textBox.Text = “something is wrong”;

}

client.Close();

}

}

}

The test application creates a similar output like this:

IdentityClient_Run02

The OTP was generated and found to be valid by the WebService, so the Users sucessfully logged in 😉

Advertisements

Post a comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s