Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
AgeAuthenticator.cs
1
using
Paiwise
;
2
using
System
;
3
using
System.Threading.Tasks;
4
using
Waher.Content
;
5
using
Waher.Runtime.Inventory
;
6
7
namespace
Waher.Service.IoTBroker.Legal.Identity.Age
8
{
12
public
class
AgeAuthenticator
:
IIdentityAuthenticatorService
13
{
17
public
AgeAuthenticator
()
18
{
19
}
20
24
public
Task
Start
()
25
{
26
return
Task.CompletedTask;
27
}
28
32
public
Task
Stop
()
33
{
34
return
Task.CompletedTask;
35
}
36
42
public
Grade
Supports
(
IIdentityApplication
Application)
43
{
44
PersonalInformation
PI = Application.PersonalInformation;
45
46
if
(PI.
BirthDate
.HasValue && PI.
AgeAbove
.HasValue)
47
return
Grade
.Perfect;
48
else
49
return
Grade
.NotAtAll;
50
}
51
56
public
Task
Validate
(
IIdentityApplication
Application)
57
{
58
try
59
{
60
PersonalInformation
PI = Application.PersonalInformation;
61
DateTime Now = DateTime.Now;
62
63
if
(!PI.
BirthDate
.HasValue || !PI.
AgeAbove
.HasValue)
64
return
Task.CompletedTask;
65
66
if
(PI.
BirthDate
.Value > Now)
67
{
68
Application.ClaimInvalid(
PersonalInformation
.
BirthDayTag
,
"Birth date is in the future."
,
"en"
,
"FutureBirthDate"
,
this
);
69
Application.ClaimInvalid(
PersonalInformation
.
BirthMonthTag
,
"Birth date is in the future."
,
"en"
,
"FutureBirthDate"
,
this
);
70
Application.ClaimInvalid(
PersonalInformation
.
BirthYearTag
,
"Birth date is in the future."
,
"en"
,
"FutureBirthDate"
,
this
);
71
return
Task.CompletedTask;
72
}
73
74
Duration
D =
Duration
.
GetDurationBetween
(PI.
BirthDate
.Value, Now);
75
76
if
(D.
Years
< PI.
AgeAbove
.Value)
77
{
78
Application.ClaimInvalid(
PersonalInformation
.
AgeAboveTag
,
"Age only above "
+ D.
Years
.ToString(),
"en"
,
"AgeNotReached"
,
this
);
79
return
Task.CompletedTask;
80
}
81
82
Application.ClaimValid(
PersonalInformation
.
AgeAboveTag
,
this
);
83
}
84
catch
(Exception ex)
85
{
86
Application.ReportError(ex.Message,
string
.Empty,
string
.Empty,
87
ValidationErrorType
.Service,
this
);
88
}
89
90
return
Task.CompletedTask;
91
}
92
}
93
}
Paiwise.PersonalInformation
Contains personal information found in a legal identity.
Definition:
PersonalInformation.cs:13
Paiwise.PersonalInformation.BirthDayTag
const string BirthDayTag
BDAY
Definition:
PersonalInformation.cs:87
Paiwise.PersonalInformation.BirthDate
DateTime? BirthDate
Birth date
Definition:
PersonalInformation.cs:373
Paiwise.PersonalInformation.AgeAboveTag
const string AgeAboveTag
AGEABOVE
Definition:
PersonalInformation.cs:102
Paiwise.PersonalInformation.AgeAbove
int? AgeAbove
Age above the stated number of years
Definition:
PersonalInformation.cs:357
Paiwise.PersonalInformation.BirthYearTag
const string BirthYearTag
BYEAR
Definition:
PersonalInformation.cs:97
Paiwise.PersonalInformation.BirthMonthTag
const string BirthMonthTag
BMONTH
Definition:
PersonalInformation.cs:92
Waher.Service.IoTBroker.Legal.Identity.Age.AgeAuthenticator
Validates identity applications that contain Birth Date and AGEABOVE property.
Definition:
AgeAuthenticator.cs:13
Waher.Service.IoTBroker.Legal.Identity.Age.AgeAuthenticator.Validate
Task Validate(IIdentityApplication Application)
Validates an identity application.
Definition:
AgeAuthenticator.cs:56
Waher.Service.IoTBroker.Legal.Identity.Age.AgeAuthenticator.Start
Task Start()
Starts the module.
Definition:
AgeAuthenticator.cs:24
Waher.Service.IoTBroker.Legal.Identity.Age.AgeAuthenticator.Supports
Grade Supports(IIdentityApplication Application)
Checks how well the authenticator supports the provided identity application.
Definition:
AgeAuthenticator.cs:42
Waher.Service.IoTBroker.Legal.Identity.Age.AgeAuthenticator.Stop
Task Stop()
Stops the module.
Definition:
AgeAuthenticator.cs:32
Waher.Service.IoTBroker.Legal.Identity.Age.AgeAuthenticator.AgeAuthenticator
AgeAuthenticator()
Validates identity applications that contain Birth Date and AGEABOVE property.
Definition:
AgeAuthenticator.cs:17
Paiwise.IIdentityApplication
Interface for identity applications.
Definition:
IIdentityApplication.cs:13
Paiwise.IIdentityAuthenticatorService
Interface for identity application authenticator services.
Definition:
IIdentityAuthenticatorService.cs:10
Paiwise
Definition:
BuyEDalerPaymentService.cs:14
Paiwise.ValidationErrorType
ValidationErrorType
Type of validation error.
Definition:
ValidationErrorType.cs:7
System
Definition:
Adapters.g.cs:58
Waher.Content
Definition:
Array.cs:6
Waher.Runtime.Inventory
Definition:
TypesLoader.cs:9
Waher.Runtime.Inventory.Grade
Grade
Grade enumeration
Definition:
Grade.cs:7
Waher.Service.IoTBroker.Legal.Identity.Age
Definition:
AgeAuthenticator.cs:8
Waher.Content.Duration
Represents a duration value, as defined by the xsd:duration data type: http://www....
Definition:
Duration.cs:14
Waher.Content.Duration.Years
int Years
Number of years.
Definition:
Duration.cs:131
Waher.Content.Duration.GetDurationBetween
static Duration GetDurationBetween(System.DateTime From, System.DateTime To)
Calculates the duration between two dates.
Definition:
Duration.cs:694
Waher.Service.IoTBroker
Legal
Identity
Age
AgeAuthenticator.cs
Generated by
1.9.5