예제 #1
0
 /// <summary>
 /// Creating our auth controller
 /// </summary>
 /// <param name="helloWorldUser"></param>
 /// <param name="dataAccess"></param>
 /// <param name="dbConnectionSettings"></param>
 public AuthController(IHelloWorldParameters helloWorldParams,
                       IHelloWorldUser helloWorldUser,
                       IDataAccess <IDataParameterCollection> dataAccess,
                       IDatabaseConnectionSettings dbConnectionSettings)
 {
     this.DataAccess = dataAccess;
     this.DatabaseConnectionSettings = dbConnectionSettings;
     this.HelloWorldUser             = helloWorldUser;
 }
예제 #2
0
 /// <summary>
 /// Creating a new instance of the session handler
 /// </summary>
 /// <param name="dataAccess"></param>
 /// <param name="dbConnectionSettings"></param>
 /// <param name="helloWorldParams"></param>
 /// <param name="helloWorldUser"></param>
 public SessionHandler(IDataAccess <IDataParameterCollection> dataAccess,
                       IDatabaseConnectionSettings dbConnectionSettings,
                       IHelloWorldParameters helloWorldParams,
                       IHelloWorldUser helloWorldUser)
 {
     this.DataAccess = dataAccess;
     this.DatabaseConnectionSettings = dbConnectionSettings;
     this.HelloWorldParams           = helloWorldParams;
     this.HelloWorldUser             = helloWorldUser;
 }
 public HttpResponseMessage ReturnHelloWorld(IHelloWorldParameters parameters)
 {
     if (parameters.ApiId > 0) // ** Not actual auth implementation... more so representing api id check upon calls
     {                         // ** IRL would actually check if token is valid (not expired) with additonal checks and DB call
         this.HelloWorldLogic.PrintHelloWorld();
         return(this.Request.CreateResponse(HttpStatusCode.OK, this.HelloWorldLogic.GetHelloWorld()));
     }
     else
     {
         throw new Exception("Invalid token..");
     }
 }
예제 #4
0
        public HttpResponseMessage AuthenticateUser(IHelloWorldParameters parameters)
        {
            var session = new SessionHandler(this.DataAccess, this.DatabaseConnectionSettings, parameters, this.HelloWorldUser);

            session.Authenticate();

            if (session.HelloWorldUser.ErrorCode.Equals(HelloWorldErrors.NoError))
            {
                var token = session.Start();
                this.HelloWorldUser.ApiId = token.ApiID;

                // returning token if all is good
                return(this.Request.CreateResponse(HttpStatusCode.OK, token));
            }
            else
            {
                throw new Exception("Invalid credentials provided");
            }
        }
예제 #5
0
 /// <summary>
 /// Creating a new instance of HelloWorld -injecting dependencies
 /// </summary>
 public HelloWorld(StringWriter stringWriter,
                   IHelloWorldParameters printParameters)
 {
     this.StringMaker     = stringWriter;
     this.PrintParameters = printParameters;
 }
예제 #6
0
 public void Initialize()
 {
     this.HelloWorldParam = Substitute.For <IHelloWorldParameters>();
     this.HelloWorldLogic = new Core.HelloWorld(new StringWriter(), this.HelloWorldParam);
 }
 public HttpResponseMessage UpdateHelloWorld(IHelloWorldParameters parameters)
 {
     throw new NotImplementedException();
 }