public Models.Result AddThreeNumbers(int number1, int number2, int number3, int token) { Models.Result result = new Models.Result(); string status; //creating connection with the Authenticator to check if token is valid authenticateInterface = Models.AuthenticatorAccessInterface.remoteConnection(); //returns validity status status = authenticateInterface.validate(token); //token validated if (status.Equals("validated")) { //need to convert to string as string is the safest native data type for serialization string serviceAnswer = (number1 + number2 + number3).ToString(); result.Value = serviceAnswer; result.Reason = "Validated"; result.Status = "Value Returned"; } else if (status.Equals("not validated"))//invalid token { //will not be sending the result as not validated result.Value = null; result.Reason = "Authentication Error"; result.Status = "Denied"; } return(result); }
public Models.Result AddTwoNumbers(int number1, int number2, int token) { Models.Result result = new Models.Result(); string status; //calling connection and assign to the authenticator interface authenticateInterface = Models.AuthenticatorAccessInterface.remoteConnection(); status = authenticateInterface.validate(token); //if token is valid if (status.Equals("validated")) { //has to be in string format as it is the safest native data type for serialization and de-serialization string serviceAnswer = (number1 + number2).ToString(); result.Value = serviceAnswer; result.Reason = "Validated"; result.Status = "Returned"; } //invalid token else if (status.Equals("not validated")) { //valus is not returned as not validated result.Value = null; result.Reason = "Authentication Error"; result.Status = "Denied"; } return(result); }
public Models.ResultPrimeNumbers GeneratePrimeNumbersInRange(int number1, int number2, int token) { string status; Models.ResultPrimeNumbers result = new Models.ResultPrimeNumbers(); List <string> values; //create connection with the authenticator authenticateInterface = Models.AuthenticatorAccessInterface.remoteConnection(); status = authenticateInterface.validate(token); //token validated if (status.Equals("validated")) { //assigns the list of generated prime numbers in range(number1, number2) values = Models.PrimeNumbers.GeneratePrimeNumbers(number1, number2); result.Values = values; result.Reason = "Validated"; result.Status = "Returned"; } else if (status.Equals("not validated"))//invalid token { //not validated hence null Values result.Values = null; result.Reason = "Authentication Error"; result.Status = "Denied"; } return(result); }
public Models.ServiceDescriptionNStatusInterMed allServices(int token) { string status; Models.ServiceDescriptionNStatusInterMed serviceDescription = new Models.ServiceDescriptionNStatusInterMed(); //creating a connection with the Authenticator via static AuthenticatorAccessInterface.remoteConnection() authenticateInterface = Models.AuthenticatorAccessInterface.remoteConnection(); //fetch result provided by the authenticator status = authenticateInterface.validate(token); //If token funtion return result is "validated" will return all services if (status.Equals("validated")) { List <Models.ServiceDescriptionIntermed> services = new List <Models.ServiceDescriptionIntermed>(); //Read all text in appropriate json text file String allServicesJson = File.ReadAllText(SOA_Utilities.Constants.pathForServiceReg); //Deserialize all services in json string to List<Models.ServiceDescriptionIntermed> object services = JsonConvert.DeserializeObject <List <Models.ServiceDescriptionIntermed> >(allServicesJson); //assigning to object of return type serviceDescription.Services = services; serviceDescription.Status = "Access Guranteed!"; serviceDescription.Reason = "Validated"; return(serviceDescription); } //If token funtion return result is not validated return authentication error else if (status.Equals("not validated"))//invalid token { serviceDescription.Reason = "Authentication Error"; serviceDescription.Status = "Denied"; return(serviceDescription); } //If token funtion return result is not either "not validated" or "validated" means there is a internal code error //could be a business logic error in the in the authenticator class else { serviceDescription.Reason = "Logic Error"; serviceDescription.Reason = "Authentication return error !"; return(serviceDescription); } }