private static OrderResponseType Authenticate(string ssn) { using (var client = new RpServicePortTypeClient()) { // RequirementType is optional // This will ensure only mobile BankID can be used // https://www.bankid.com/bankid-i-dina-tjanster/rp-info/guidelines RequirementType conditions = new RequirementType { condition = new[] { new ConditionType() { key = "certificatePolicies", value = new[] { "1.2.3.4.25" } // Mobile BankID } } }; // Set the parameters for the authentication AuthenticateRequestType authenticateRequestType = new AuthenticateRequestType() { personalNumber = ssn, requirementAlternatives = new[] { conditions } }; // ...authenticate return(client.Authenticate(authenticateRequestType)); } }
static void Main(string[] args) { try { using (var client = new BankIDService.RpServicePortTypeClient()) { // Century must be included Console.WriteLine("Enter your ssn, 10 or 12 digits (YY)YYMMDDNNNN"); string ssn = GetSsn(); // RequirementType is optional // This will ensure only mobile BankID can be used // https://www.bankid.com/bankid-i-dina-tjanster/rp-info/guidelines RequirementType conditions = new RequirementType { condition = new[] { new ConditionType() { key = "certificatePolicies", value = new[] {"1.2.3.4.25"} // Mobile BankID } } }; // Set the parameters for the authentication AuthenticateRequestType authenticateRequestType = new AuthenticateRequestType() { personalNumber = ssn, requirementAlternatives = new[] { conditions } }; // ...authenticate OrderResponseType response = client.Authenticate(authenticateRequestType); // Wait for the client to sign in do { Console.WriteLine("{0}Start the BankID application and sign in, press [ENTER] when done{0}", Environment.NewLine); } while (Console.ReadKey(true).Key != ConsoleKey.Enter); // ...collect the response CollectResponseType result = client.Collect(response.orderRef); do { Console.WriteLine("Hi {0}, please press [ESC] to exit", result.userInfo.givenName); } while (Console.ReadKey(true).Key != ConsoleKey.Escape); } } catch (Exception ex) { Console.WriteLine(ex.Message); Console.Read(); } }