// POST: /Manage/RememberBrowser public ActionResult RememberBrowser() { var rememberBrowserIdentity = AuthentificationManager.CreateTwoFactorRememberBrowserIdentity(User.Identity.GetUSerId()); AuthenticationManager.SignIn(new AuthenticationProperties {IsPersistent= true}, rememberBrowserIdentity); return RedirectToAction("Index", "Manage"); }
public AuthForm() { InitializeComponent(); ChannelFactory<AuthentificationManager> dupFactory = null; dupFactory = new ChannelFactory<AuthentificationManager>( new NetTcpBinding(), new EndpointAddress("net.tcp://localhost:8999/AuthManager")); dupFactory.Open(); clientProxy = dupFactory.CreateChannel(); }
protected BaseEndpoint_For_UserDefinedCollections(AuthentificationManager AuthentificationManager, ILogger Logger) { this.ApiBaseUri = "https://papi.pepperi.com/v1.0/"; // Will be moved to Pepperi API this.IpaasBaseUri = "https://ipaas.pepperi.com/prod/api/"; // Will be moved to Pepperi API this.AuthentificationManager = AuthentificationManager; this.Logger = Logger; this.AuditLogs = new AuditLogsEndpoint(ApiBaseUri, AuthentificationManager.PepperiApiAuth, Logger); }
public static AuthentificationManager load(String path) { XmlSerializer deserializer = new XmlSerializer(typeof(AuthentificationManager)); StreamReader reader = new StreamReader(path); AuthentificationManager aut = (AuthentificationManager)deserializer.Deserialize(reader); reader.Close(); return(aut); }
public AuthForm() { InitializeComponent(); ChannelFactory <AuthentificationManager> dupFactory = null; dupFactory = new ChannelFactory <AuthentificationManager>( new NetTcpBinding(), new EndpointAddress("net.tcp://localhost:8999/AuthManager")); dupFactory.Open(); clientProxy = dupFactory.CreateChannel(); }
private void frmSample_Load(object sender, EventArgs e) { System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Ssl3 | System.Net.SecurityProtocolType.Tls12 | System.Net.SecurityProtocolType.Tls11 | System.Net.SecurityProtocolType.Tls; if (System.IO.File.Exists(AppDomain.CurrentDomain.BaseDirectory + "token.txt")) { txtToken.Text = System.IO.File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + "token.txt"); CompanyToken = txtToken.Text; auth = new Pepperi.SDK.PrivateAuthentication(DeveloperKey, CompanyToken); var authentificationManager = new AuthentificationManager(Logger, CompanyToken, DeveloperKey); client = new ApiClient(APIBaseAddress, auth, new PepperiLogger(), authentificationManager); } }
static void Main(string[] args) { Chatter Manuelle = new Chatter("Manuelle"), Léna = new Chatter("Léna"); TopicsManager tm = new TopicsManager(); tm.createTopic("Mon corps tout nu"); tm.createTopic("La pls, mon histoire"); Console.WriteLine("The openned topics are : "); foreach (String s in tm.topics.Keys) { Console.WriteLine(s); } Chatroom cr = tm.joinTopic("La pls, mon histoire"); cr.join(Manuelle); cr.join(Léna); cr.post("Coucou ma chérie, comment s'est passé ta journée ? Je veux tout savoir ;) <3 <3 <3", Manuelle); Console.ReadKey(); cr.post("J'ai passé le balai toute la journée et toi mon coeur ? :$ <3 <3", Léna); Console.ReadKey(); cr.post("Oh trop bien ! Moi j'ai passé l'aspirateur, j'ai retrouvé une chips derrière mon pc (encore) :@ ", Manuelle); Console.ReadKey(); cr.post("C'est encore tes connards de potes ! De toute façon je peux pas les blairer, surtout Théo ! Il est méchant mais le pire c'est qu'il a raison ! :(", Léna); Console.ReadKey(); cr.quit(Manuelle); cr.post("Oh non je suis toute seule ! Manu mon amour reviens moi ! Bon tant pis je vais allé voir un de ses potes comme j'ai l'habitude ! Je suis une coquine hihihi", Léna); Console.ReadLine(); AuthentificationManager test = new AuthentificationManager(); try { test.addUser("Manuelle", "Léna"); } catch (UserExistsException e) { e.DisplayLogReportShow(); } }
internal static ApiClient GetApiClient_ForPrivateApplication(string APIToken, ILogger Logger) { #region validate input if (APIToken == null || APIToken.Trim().Length == 0) { throw new PepperiException("Invalid argument. Api token can not be empty."); } #endregion string ApiBaseUri = Settings.ApiBaseUri; string PrivateApplication_ConsumerKey = Settings.PrivateApplication_ConsumerKey; var IAuthentication = new PrivateAuthentication(PrivateApplication_ConsumerKey, APIToken); var authentificationManager = new AuthentificationManager(Logger, APIToken, PrivateApplication_ConsumerKey); ApiClient ApiClient = new ApiClient(ApiBaseUri, IAuthentication, Logger, authentificationManager); return(ApiClient); }
private void btnConnect_Click(object sender, EventArgs e) { try { var token = PrivateAuthentication.GetAPITokenData(APIBaseAddress, DeveloperKey, txtEmail.Text, txtPassword.Text, Logger); if (token.APIToken == Guid.Empty.ToString()) { throw new Exception("user or passsword are incorrect."); } txtToken.Text = token.APIToken; System.IO.File.WriteAllText(AppDomain.CurrentDomain.BaseDirectory + "token.txt", token.APIToken); auth = new PrivateAuthentication(DeveloperKey, token.APIToken); var authentificationManager = new AuthentificationManager(Logger, token.APIToken, DeveloperKey); client = new ApiClient(APIBaseAddress, auth, Logger, authentificationManager); MessageBox.Show("Connected!"); } catch (Exception ex) { MessageBox.Show("Not Connected!. reason: " + ex.ToString()); } }
static void Main(string[] args) { ChannelFactory <AuthentificationManager> dupFactory = null; AuthentificationManager clientProxy = null; TextChatter _chatter = new TextChatter(); dupFactory = new ChannelFactory <AuthentificationManager>( new NetTcpBinding(), new EndpointAddress("net.tcp://localhost:8999/AuthManager")); dupFactory.Open(); clientProxy = dupFactory.CreateChannel(); int menu = 0; string username; while (menu == 0) { Console.WriteLine("Entrez votre username:"******" Entrez votre password:"******"1.Se connecter \n 2.s'inscrire"); switch (Console.ReadLine()) { case "1": if (clientProxy.login(username, password)) { joinTopicsManager(username); } break; case "2": clientProxy.addUser(username, password); break; } } }
/// <summary> /// Delete all the users in the database /// </summary> public void DeleteAllUsers() => AuthentificationManager.DeleteAllUsers();
private void Auth() { AuthentificationManager am = new AuthentificationManager(); TopicsManager tm = new TopicsManager(); try { while (true) { /* Vérification de la connexion avec le client */ if (!(clientSocket.Connected)) { ctThread.Abort(); } /* Nous avons créé chatLibrary.dll qui nous apporte les différents paquets utilisables par notre application*/ Packet packet = null; try { packet = Packet.Receive(ns); } catch (SerializationException e) { Console.WriteLine(e); } /* Packet de login */ if (packet is AuthPacket) { AuthPacket ap = (AuthPacket)packet; Console.Write("[AUTHENTIFICATION]User " + ap.login + " attempting to connect"); // flag contient le code d'erreur int flag = am.authentify(ap.login, ap.password); // packet de callback LoginPacket bp = new LoginPacket(flag); if (flag == 1) { /* User logged in */ Console.WriteLine(" SUCCESS"); User u = new User(ap.login, ap.password, ns); u.chatter = new Chatter(ap.login); ChatServer.addUser(u); Packet.Send(bp, ns); /* Displaying topics to user */ Console.Write("[SERVER]Sending topics : "); Console.Write("["); for (int i = 0; i < tm.getRooms().Count; ++i) { if (i == tm.getRooms().Count - 1) { Console.Write(tm.getRooms()[i]); } else { Console.Write(tm.getRooms()[i] + ", "); } } Console.WriteLine("]"); // Envoie des chatrooms disponibles TopicsPacket tp = new TopicsPacket(tm.getRooms()); Packet.Send(tp, ns); } else { Console.WriteLine("[AUTHENTIFICATION]Error, unable to connect the user " + ap.login + ", error code : " + flag); Packet.Send(bp, ns); this.Auth(); } } /* Paquet d'inscription d'un nouvel utilisateur */ if (packet is SubscribePacket) { SubscribePacket sb = (SubscribePacket)packet; SubscribeValidation sv = new SubscribeValidation(am.addUser(sb.login, sb.password)); if (sv.value) { Console.WriteLine("[REGISTER]User " + sb.login + " successfully created"); } else { Console.WriteLine("[REGISTER]Error during " + sb.login + " account creation"); } Packet.Send(sv, ns); } /* Paquet pour rejoindre une chatroom */ if (packet is JoinChatRoomPacket) { JoinChatRoomPacket jcp = (JoinChatRoomPacket)packet; if (tm.getRooms().Contains(jcp.chatRoom)) { bool flag = tm.joinTopic(jcp.chatRoom, ChatServer.getUser(jcp.user)); if (flag) { Console.WriteLine("[TOPICS]User " + jcp.user + " joined chatroom : " + jcp.chatRoom); } else { Console.WriteLine("[TOPICS]Cannont connect user to the chatroom, user : "******" is already in the chatroom : " + jcp.chatRoom); } Chatroom ct = (Chatroom)tm.getRoom(jcp.chatRoom); ListChatterPacket lcp = new ListChatterPacket(ct.getChatters(), jcp.chatRoom); Thread.Sleep(500); foreach (User u in ct.chatters) { Console.WriteLine("[TOPICS]Sending user list from " + jcp.chatRoom + " to user " + u.login); Packet.Send(lcp, u.ns); } } } /* Paquet pour créer une chatroom */ if (packet is CreateChatRoomPacket) { bool flag; CreateChatRoomValidationPacket ccvp; CreateChatRoomPacket ccp = (CreateChatRoomPacket)packet; if (!tm.topics.ContainsKey(ccp.chatRoom)) { flag = tm.createTopic(ccp.chatRoom); if (flag) { Console.WriteLine("[TOPICS]User " + ccp.user + " created chatroom : " + ccp.chatRoom); TopicsPacket tp = new TopicsPacket(tm.getRooms()); foreach (User u in ChatServer.chattingUsers) { Packet.Send(tp, u.ns); } } /* Broadcast la création de room avec affichage de message */ ccvp = new CreateChatRoomValidationPacket(flag, ccp.chatRoom); } else { flag = false; Console.WriteLine("[TOPICS]Chatroom creation failed, chatroom : " + ccp.chatRoom + " already exists"); ccvp = new CreateChatRoomValidationPacket(flag, ccp.chatRoom); } Packet.Send(ccvp, ns); } /* Paquet d'envoie de message */ if (packet is MessagePacket) { MessagePacket mp = (MessagePacket)packet; Console.WriteLine("[CHATROOM]Posting message : [" + mp.message + "] in chatroom :" + mp.chatroom + " by user : "******"[CHATROOM]User : "******" is leaving chatroom : " + lcrp.chatRoom); /* Il faut lock ici pour éviter un problème dans la liste des utilisateurs * Nous evitons ainsi d'envoyer un message à un utilisateur déjà déconnecté */ lock (thisLock) { cible.quit(ChatServer.getUser(lcrp.user)); Chatroom ct = (Chatroom)tm.getRoom(lcrp.chatRoom); ListChatterPacket lcp = new ListChatterPacket(ct.getChatters(), lcrp.chatRoom); Thread.Sleep(1000); foreach (User u in ct.chatters) { Console.WriteLine("[TOPICS]Sending user list from " + lcrp.chatRoom + " to user " + u.login); Packet.Send(lcp, u.ns); } } } /* Paquet de déconnexion d'un utilisateur */ if (packet is DisconnectPacket) { DisconnectPacket dp = (DisconnectPacket)packet; Thread.Sleep(200); User u = ChatServer.getUser(dp.user); u.ns.Close(); ChatServer.removeUser(u); this.clientSocket.Close(); Console.WriteLine("[SERVER]A user disconnected properly"); } } } catch (IOException e) { Console.WriteLine("[SERVER]A user crashed"); ctThread.Join(); } catch (NullReferenceException ex) { Console.WriteLine("[TOPICS]Impossible de retirer le client, celui-ci n'existe pas dans la chatroom"); Console.WriteLine(ex); } }
private List <string> connectedPseudos;// indique les personnes connecté #endregion public ServerTopicsManager(AuthentificationManager am) { this.am = am; connectedPseudos = new List <string>(); }
public AuthentificationController(AuthentificationManager authentificationManager, PasswordHasher passwordHasher, UserGateway userGateway) { _authentificationManager = authentificationManager; _passwordHasher = passwordHasher; _userGateway = userGateway; }
internal UserDefinedCollectionsEndpoint(AuthentificationManager AuthentificationManager, ILogger Logger) : base(AuthentificationManager, Logger) { }
protected void Page_Load(object sender, EventArgs e) { try { if (!string.IsNullOrEmpty(Request.Params.Get("action"))) { _action = Request.Params.Get("action"); } if (!string.IsNullOrEmpty(Request.Params.Get("uploaderId"))) { _uploaderId = Request.Params.Get("uploaderId"); } if (!string.IsNullOrEmpty(Request.Params.Get("temp"))) { float.TryParse(Request.Params.Get("temp"), out _temperature); } if (!string.IsNullOrEmpty(Request.Params.Get("hum"))) { float.TryParse(Request.Params.Get("hum"), out _humidity); } if (!string.IsNullOrEmpty(Request.Params.Get("apisecret"))) { _apisecret = Request.Params.Get("apisecret"); } if (string.IsNullOrEmpty(_action) || string.IsNullOrEmpty(_uploaderId) || string.IsNullOrEmpty(_apisecret) || _temperature == -100 || _humidity == -100) { return; } if (!AuthentificationManager.AuthenticateApi(_apisecret)) { return; } mongoManager = new MongoManager(); if (_action == "AddRecord") { List <BsonElement> elements = new List <BsonElement> { new BsonElement(Constants.Database.Fields.Humiture.Date, BsonValue.Create(DateTime.Now)), new BsonElement(Constants.Database.Fields.Humiture.Temperature, BsonValue.Create(_temperature)), new BsonElement(Constants.Database.Fields.Humiture.Humidity, BsonValue.Create(_humidity)) }; List <UploaderConfigItem> configItems = mongoManager.SelectFromCollection(new CollectionItem(Constants.Database.Settings), FilterBuilder.UploaderConfig.BuildFilter(_uploaderId)); if (configItems.Any()) { mongoManager.Insert(new BsonDocument(elements), new CollectionItem(configItems.FirstOrDefault().Position, Constants.Database.CollectionType.Humiture)); } else { LoggingManager.LogWaring("Cant find a Position for uploader with ID " + _uploaderId + ". Pleas add this Uploader to the Config. Value recieved is lost.", System.Reflection.MethodBase.GetCurrentMethod().Name); } return; } } catch (Exception ex) { LoggingManager.LogError(System.Reflection.MethodBase.GetCurrentMethod().Name, ex); } }
static void Main() { /* * Application.EnableVisualStyles(); * Application.SetCompatibleTextRenderingDefault(false); * Application.Run(new Form1()); */ AuthentificationManager am = new AuthentificationManager(); TopicsManager tm = new TopicsManager(); try { if (File.Exists(PATH)) { am = AuthentificationManager.load(PATH); } else { am = new AuthentificationManager(); } if (File.Exists(PATH_TOPICS)) { tm.topics = TopicsManager.load(PATH_TOPICS); } else { tm = new TopicsManager(); } } catch (IOException e) { Console.WriteLine(e.Message); } ChatServer.StartServer(); ChatServer.StartListening(); /*Chatter Manuelle = new Chatter("Manuelle"), Léna = new Chatter("Léna"); * tm.createTopic("Mon corps tout nu"); * tm.createTopic("La pls, mon histoire"); * Console.WriteLine("The openned topics are : "); * * * foreach (String s in tm.topics.Keys) * { * Console.WriteLine(s); * } * * Chatroom cr = tm.joinTopic("La pls, mon histoire"); * cr.join(Manuelle); * cr.join(Léna); * cr.post("Coucou ma chérie, comment s'est passé ta journée ? Je veux tout savoir ;) <3 <3 <3", Manuelle); * Console.ReadKey(); * cr.post("J'ai passé le balai toute la journée et toi mon coeur ? :$ <3 <3", Léna); * Console.ReadKey(); * cr.post("Oh trop bien ! Moi j'ai passé l'aspirateur, j'ai retrouvé une chips derrière mon pc (encore) :@ ", Manuelle); * Console.ReadKey(); * cr.post("C'est encore tes connards de potes ! De toute façon je peux pas les blairer, surtout Théo ! Il est méchant mais le pire c'est qu'il a raison ! :(", Léna); * Console.ReadKey(); * cr.quit(Manuelle); * cr.post("Oh non je suis toute seule ! Manu mon amour reviens moi ! Bon tant pis je vais allé voir un de ses potes comme j'ai l'habitude ! Je suis une coquine hihihi", Léna); * Console.ReadLine();*/ /* * test.checkRegistredUsers(); * * try * { * test.removeUser("Théo"); * } * catch (UserUnknowException e) * { * e.DisplayLogReportShow(); * } * * test.checkRegistredUsers(); * * try * { * test.authentify("Alexandre", "456"); * } * catch (WrongPasswordException e) * { * e.DisplayLogReportShow(); * } * catch (UserUnknowException e) * { * e.DisplayLogReportShow(); * } * * AuthentificationManager aut = null; * * if (File.Exists(PATH)) * { * aut = AuthentificationManager.load(PATH); * aut.checkRegistredUsers(); * } * else * { * aut = new AuthentificationManager(); * } * * * Console.ReadLine();*/ }
static void Main(string[] args) { Chatter Manuelle = new Chatter("Manuelle"), Léna = new Chatter("Léna"); TopicsManager tm = new TopicsManager(); tm.createTopic("Mon corps tout nu"); tm.createTopic("La pls, mon histoire"); Console.WriteLine("The openned topics are : "); foreach (String s in tm.topics.Keys) { Console.WriteLine(s); } Chatroom cr = tm.joinTopic("La pls, mon histoire"); cr.join(Manuelle); cr.join(Léna); cr.post("Coucou ma chérie, comment s'est passé ta journée ? Je veux tout savoir ;) <3 <3 <3", Manuelle); Console.ReadKey(); cr.post("J'ai passé le balai toute la journée et toi mon coeur ? :$ <3 <3", Léna); Console.ReadKey(); cr.post("Oh trop bien ! Moi j'ai passé l'aspirateur, j'ai retrouvé une chips derrière mon pc (encore) :@ ", Manuelle); Console.ReadKey(); cr.post("C'est encore tes connards de potes ! De toute façon je peux pas les blairer, surtout Théo ! Il est méchant mais le pire c'est qu'il a raison ! :(", Léna); Console.ReadKey(); cr.quit(Manuelle); cr.post("Oh non je suis toute seule ! Manu mon amour reviens moi ! Bon tant pis je vais allé voir un de ses potes comme j'ai l'habitude ! Je suis une coquine hihihi", Léna); Console.ReadLine(); /*AuthentificationManager test = new AuthentificationManager(); * * try * { * test.addUser("Manuelle", "Léna"); * test.addUser("Théo", "123"); * test.addUser("Alexandre", "456"); * * test.save("Test.xml"); * } * catch (UserExistsException e) * { * e.DisplayLogReportShow(); * } * catch (IOException e) * { * Console.WriteLine(e.Message); * } * Console.WriteLine(); * * * test.checkRegistredUsers(); * * try * { * test.removeUser("Théo"); * } * catch (UserUnknowException e) * { * e.DisplayLogReportShow(); * } * * test.checkRegistredUsers(); * * try * { * test.authentify("Alexandre", "456"); * } * catch(WrongPasswordException e) * { * e.DisplayLogReportShow(); * } * catch(UserUnknowException e) * { * e.DisplayLogReportShow(); * }*/ AuthentificationManager aut = null; if (File.Exists(PATH)) { aut = AuthentificationManager.load(PATH); aut.checkRegistredUsers(); } else { aut = new AuthentificationManager(); } Console.ReadLine(); }
/// <summary> /// Trie to authenticate with email and password /// </summary> /// <param name="Email">Email of the user</param> /// <param name="Password">Password of the user</param> /// <returns>true if the authentication succeed</returns> public bool Authenticate(string Email, string Password) => AuthentificationManager.Authenticate(Email, Password);
/// <summary> /// Add a new user (email and password) /// </summary> /// <param name="Email">Email of the user</param> /// <param name="Password">Password of the user</param> /// <returns>The number of line added in the database</returns> public Task <int> AddUser(string Email, string Password) => AuthentificationManager.AddUser(Email, Password);