/// <summary> /// Abort the current authentication session at the authenticator service. /// Aborts the current authentication session at the authenticator. /// </summary> /// <param name="userName"> /// The user name of the client that wish to abort the session. /// Only the user name of the the client using this proxy can /// be passed. /// </param> /// <returns> /// True if the abortion was accepted, false otherwise. /// </returns> public bool Abort(string userName) { Contract.Requires(userName != null); this.socket.SendMessage( "abort", "userName=" + userName); this.currentServerResponse = this.socket.ReadMessage(); return this.currentServerResponse.Accepted; }
/// <summary> /// Processes the specified string representation of a /// http message. /// </summary> /// <param name="response"> /// The response containing a return value. /// </param> /// <returns> /// A string constituting the return values of the authentication /// server. /// </returns> private string GetReturnValueOf(Response response) { Contract.Requires(response.Accepted); // Extract return value int start = response.ReturnValue.IndexOf('=') + 1; int end = response.ReturnValue.Length; return response.ReturnValue.Substring(start, end - start); }
/// <summary> /// Submit user name and password to the authenticator service. /// Submits log-in request to the authentication-server. /// </summary> /// <param name="userName"> /// Client-submitted and encrypted user name. /// </param> /// <param name="password"> /// Client-submitted and encrypted user password. /// </param> /// <returns> /// True if the submitted combination of user name and /// user password was accepted by the server, false otherwise. /// </returns> public bool LogIn(string userName, string password) { Contract.Requires(userName != null); Contract.Requires(password != null); Console.WriteLine("Client initiates login-request to authenticator."); this.socket.SendMessage( "login", "userName="******"&" + "password="******"The log-in request at the authenticator was accepted: " + currentServerResponse.Accepted); return this.currentServerResponse.Accepted; }
/// <summary> /// Submits the specified keyValue from the client's /// key card to the authentication server. /// </summary> /// <param name="keyValue"> /// The encrypted key-value submitted by the user. /// </param> /// <param name="userName"> /// The encrypted user name of the user. /// </param> /// <returns> /// Returns true if the value of the submitted key is /// what the authentication server expected, false otherwise. /// </returns> public bool SubmitKey(string keyValue, string userName) { Contract.Requires(keyValue != null); Contract.Requires(userName != null); this.socket.SendMessage( "submitKey", "userName="******"&" + "keyValue=" + keyValue); this.currentServerResponse = this.socket.ReadMessage(); return this.currentServerResponse.Accepted; }
/// <summary> /// Create a new account at the authenticator service. /// Requests creation of new user account at the authentication /// service with the specified properties. /// </summary> /// <param name="userName"> /// The suggested user name. /// </param> /// <param name="password"> /// The suggested password. /// </param> /// <param name="cprNumber"> /// The CPR-number of the resident requesting a new account. /// </param> /// <returns> /// True if the creation was successful at the authenticator, /// false otherwise. /// </returns> public bool CreateUserAccount( string userName, string password, string cprNumber, string email) { Contract.Requires(userName != null); Contract.Requires(password != null); Contract.Requires(cprNumber != null); Contract.Requires(email != null); Console.WriteLine("Client initiates createUserAccount-request to authenticator."); this.socket.SendMessage( "createAccount", "username="******"&password="******"&cprnumber=" + cprNumber + "&email=" + email); this.currentServerResponse = this.socket.ReadMessage(); Console.WriteLine("The createUserAccount-request at the authenticator was accepted: " + currentServerResponse.Accepted); return this.currentServerResponse.Accepted; }