Aller au contenu

CAS logo

Pulse C# Library

Foreword

Pulse C# library allows to verify identity of users using your .NET Application Windows Form. With this library, when a user is using a GUI, you can check at any moment if the current user is the legitimate one.

Compatibility / Requirements

  • This library is compatible for .NET Framework 4.8.
  • You can use it with computer architecture 32/64 bit.
  • Your .NET application must contain a Form interface and be connected to network.

Assembly used by the library

ID Version
Microsoft.CSharp 4.0.0.0
mscorlib 4.0.0.0
System 4.0.0.0
System.Core 4.0.0.0
System.Text.Json 6.0.0.0
System.Net.Http 4.2.0.0
System.Memory 4.0.1.2
System.Windows.Forms 4.0.0.0
System.Management 4.0.0.0
System.Drawing 4.0.0.0

Setup library in a project

  1. Download the library here

  2. Open your Visual Studio Project

  3. Click on Reference -> Add reference VS Add ref

  4. Install System.Memory assembly used by Pulse.

  5. Go to Browse section and and click the Browse button VS Add ref

  6. Select your pulse agent DLL neomia-pulse-agent-c-sharp.dll

  7. Enable the added DLL and click OK VS Add ref

  8. Go to your code and import the following namespace : neomia_pulse_agent_c_sharp

How to use the library ?

Remarks

All examples are programmed in Visual Basic but you can use any other langue compatible with .net framework.

The usage of the library is similar to pulse.js.

Standards library imports

1
2
3
Imports neomia_pulse_agent_c_sharp.api
Imports neomia_pulse_agent_c_sharp.exception.base
Imports neomia_pulse_agent_c_sharp.model

Prepare the Pulse API connection

Connect Pulse API with your API URL and API KEY.

1
PulseApi.Build("https://api.neomia.ai/pulse", "Df35yourkey2pimeqZ3OmsFdWXU63fm3zhWzuKc")

Check Pulse API Status

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
Dim pulseApi As PulseApi = PulseApi.GetInstance()

Try
    Dim status = pulseApi.Status()
    If status <> ApiStatus.Ok Then
        MsgBox("API connection error")
    End If
Catch ex As PulseException
    ex.Display()
End Try

Build Pulse Patterns

When your Form is ready you can start Pulse Recorder.

1
2
Dim pulseRec As PulseRec = PulseRec.GetInstance()
pulseRec.StartTracking()

After recording some key events you can generate a Pulse pattern.

1
2
Dim pulseRec As PulseRec = PulseRec.GetInstance()
Dim pattern = pulseRec.GetPattern()

After generating a valid pattern, please clean the recorder before building a new pattern.

1
2
Dim pulseRec As PulseRec = PulseRec.GetInstance()
pulseRec.ClearStack()

You can stop the recorder at any time.

1
2
Dim pulseRec As PulseRec = PulseRec.GetInstance()
pulseRec.StopTracking()

We recommend you to reset the recorder before closing the window.

1
2
Dim pulseRec As PulseRec = PulseRec.GetInstance()
pulseRec.Reset()

Track specifics fields

You can track specifics inputs if you add key in parameters of StartTracking and StopTracking. Each argument must be a Control added in a Windows Form.

1
2
Dim pulseRec As PulseRec = PulseRec.GetInstance()
pulseRec.StartTracking(input1, input2, input3)
1
2
Dim pulseRec As PulseRec = PulseRec.GetInstance()
pulseRec.StopTracking(input1, input2, input3)

Verify the pattern of a user

As the verify procedure can take a long time, the verify pattern process is executed in a background process.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
Dim pattern = As Pattern = pulseRec.GetPattern() 'Your pattern

Dim succesFunction = Function(authentication As Authentication, myUseful As Object)
'Do something
End Function
Dim failedFunction = Function(pulseException As PulseException, myUseful As Object)
'Do something
End Function

Dim pulseRec As PulseRec = PulseRec.GetInstance()

Dim myObj As Object = Nothing 'My custom object (same object as myUseful)

Dim pulseApi As PulseApi = PulseApi.GetInstance()

Dim task As Task = pulseApi.UserVerifyAsync("my.user@neomia.ai", pattern, True, myObj, succesFunction, failedFunction)

The verify method takes 6 arguments :

  1. userRef : the user reference.

  2. pattern : a Pulse pattern.

  3. enrollment : enrollment method (True if you allow user creation, otherwise False).

  4. payload : anything, can be null. An object transferred at the second parameter of success or failed fonction.

  5. onSuccess : the success function with two parameters : Authentication and your custom object. This function is called if the authentification process is successful.

  6. onFailure : the failed function with two parameters : PulseException and your custom object. This function is called if the authentification process has failled.

Authentication object

Authentication object generated by the verify procedure containing informations returned by Pulse API.

Example :

1
2
3
4
5
6
7
8
Dim authentication As Authentication = Nothing 'From success function

Dim action As Authentication.Action? = authentication.GetAction()

Dim rc As Authentication.RecommendedAction? = authentication.GetRecommendedAction()
Dim score As Double? = authentication.GetFinalScore()

Dim patternId As String = authentication.GetPatternTestId()

Reset Biometrics profile

To reset the biometrcis profile please use UserAction or UserActionAsync function with parameter PulseApi.Action.ResetBiometricProfil.

Example :

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
Dim succesFunction = Function(status As Boolean, myUseful As String)
    If status Then
        MsgBox("Reset")
    End If
End Function

Dim failedFunction = Function(pulseException As PulseException, myUseful As String)
    pulseException.Display()
End Function


Dim userRef As String = "g.laroyenne@systancia.com" 'My custom data in Pulse task

Dim pulseApi As PulseApi = PulseApi.GetInstance()

pulseApi.UserActionAsync(userRef, PulseApi.Action.ResetBiometricProfile, Nothing, userRef, succesFunction, failedFunction)

Add pattern as reference

You can add a pattern as reference if you own a pattern ID. Call UserAction or UserActionAsync function with PulseApi.Action.ResetBiometricProfil with action PulseApi.Action.LinkPatternId.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
Dim succesFunction = Function(status As Boolean, myUseful As String)
    If status Then
        MsgBox("Pattern added")
    End If
End Function

Dim failedFunction = Function(pulseException As PulseException, myUseful As String)
    pulseException.Display()
End Function

Dim userRef As String = "g.laroyenne@systancia.com" 'My custom data in Pulse task
Dim patternId As String = "507f191e810c19729de860ea" 'My pattern ID

Dim pulseApi As PulseApi = PulseApi.GetInstance()

pulseApi.UserActionAsync(userRef, PulseApi.Action.LinkPatternId, patternId, userRef, succesFunction, failedFunction)

Remove a user

You can remove a user from Pulse API with the function UserDelete or UserDeleteAsync.

Example :

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
Dim succesFunction = Function(status As Boolean, o As Object)
    If status Then
        MsgBox("Deleted")
    End If
End Function

Dim failedFunction = Function(pulseException As PulseException, o As Object)
    pulseException.Display()
End Function


Dim pulseApi As PulseApi = PulseApi.GetInstance()
pulseApi.UserDeleteAsync("g.laroyenne@systancia.com", succesFunction, failedFunction)

Quick Example

Here a simple exemple of a Pulse application in a Visual Basic Form login. You can see the sources in our Git Project

Example Interface