/** * Get an encrypted pseudonym for a user from the database. * @param user the User ID to get a encrypted pseudonym for. * @param sp the SP ID to get a encrypted pseudonym for. * @return The encrypted pseudonym for the specified user and SP, or null if no encrypted pseudonym was found in the database. */ public Pseudonym GetEncrypted(string user, string sp) { var pseudonyms = from ep in db.EncryptedPseudonyms where ep.user == user && ep.sp == sp select Pseudonym.Decode(ep.pseudonym); return(pseudonyms.FirstOrDefault()); }
/** * Get a polymorphic pseudonym for a user from the database. * @param user the User ID to get a polymorphic pseudonym for. * @return The polymorphic pseudonym for the specified user, or null if no polymorphic pseudonym was found in the database. */ public Pseudonym GetPolymorphic(string user) { var pseudonyms = from p in db.PolymorphicPseudonyms where p.user == user select Pseudonym.Decode(p.pseudonym); return(pseudonyms.FirstOrDefault()); }
/** * Get an encrypted pseudonym asynchronously. * @param pp The polymorphic pseudonym to get an encrypted pseudonym for. * @param sp The SP ID to get an encrypted pseudonym for. * @return A task that will result in the Encrypted Pseudonym. */ public async Task <Pseudonym> GetEPAsync(Pseudonym pp, string sp) { HttpClient client = new HttpClient(); HttpResponseMessage message = await client.GetAsync(string.Format(url, WebUtility.UrlEncode(pp.Encode()), WebUtility.UrlEncode(sp))); string epString = await message.Content.ReadAsStringAsync(); return(Pseudonym.Decode(epString)); }
/** * Execute the <code>randomize</code> query * @return 2D array <code>result</code> with <code>result[0][0]</code> being the encoded randomized pseudonym. */ public string[][] Randomize() { string[] oneResult = new string[1]; Pseudonym pseudonym = Pseudonym.Decode(parameters[0]); pseudonym = pseudonym.Randomize(); oneResult[0] = pseudonym.Encode(); return(new string[][] { oneResult }); }