@Test public void testEmail() { try { Node node = new LocalNodeManager().launchNode(); UserAgentManager l = node.getUserManager(); UserAgentImpl a = UserAgentImpl.createUserAgent("pass"); a.unlock("pass"); a.setEmail("email@example.com"); node.storeAgent(a); assertEquals(a.getIdentifier(), l.getAgentIdByEmail("email@example.com")); UserAgentImpl b = UserAgentImpl.createUserAgent("pass"); b.unlock("pass"); b.setEmail("email@example.com"); try { node.storeAgent(b); fail("EmailAlreadyTakenException expected"); } catch (EmailAlreadyTakenException e) { } b.setEmail("EMAIL@example.com"); try { node.storeAgent(b); fail("EmailAlreadyTakenException expected"); } catch (EmailAlreadyTakenException e) { } b.setEmail("email2@example.com"); node.storeAgent(b); assertEquals(b.getIdentifier(), l.getAgentIdByEmail("email2@example.com")); b.setEmail("email3@example.com"); node.storeAgent(b); assertEquals(b.getIdentifier(), l.getAgentIdByEmail("email3@example.com")); assertEquals(b.getIdentifier(), l.getAgentIdByEmail("EMAIL3@example.com")); try { l.getAgentIdByEmail("fdewfue"); fail("AgentNotFoundException expected"); } catch (AgentNotFoundException e) { } } catch (Exception e) { e.printStackTrace(); } }
public String getAgentIdByEmail(String email) throws AgentNotFoundException, AgentOperationFailedException { try { EnvelopeVersion env = node.fetchEnvelope(PREFIX_USER_MAIL + email.toLowerCase()); return (String) env.getContent(); } catch (EnvelopeNotFoundException e) { throw new AgentNotFoundException("Email not found!", e); } catch (EnvelopeException | SerializationException | CryptoException e) { throw new AgentOperationFailedException("Could not read email from storage"); } }
UserAgentManager { public String getAgentIdByEmail(String email) throws AgentNotFoundException, AgentOperationFailedException { try { EnvelopeVersion env = node.fetchEnvelope(PREFIX_USER_MAIL + email.toLowerCase()); return (String) env.getContent(); } catch (EnvelopeNotFoundException e) { throw new AgentNotFoundException("Email not found!", e); } catch (EnvelopeException | SerializationException | CryptoException e) { throw new AgentOperationFailedException("Could not read email from storage"); } } }
UserAgentManager { public String getAgentIdByEmail(String email) throws AgentNotFoundException, AgentOperationFailedException { try { EnvelopeVersion env = node.fetchEnvelope(PREFIX_USER_MAIL + email.toLowerCase()); return (String) env.getContent(); } catch (EnvelopeNotFoundException e) { throw new AgentNotFoundException("Email not found!", e); } catch (EnvelopeException | SerializationException | CryptoException e) { throw new AgentOperationFailedException("Could not read email from storage"); } } UserAgentManager(Node node); }
UserAgentManager { public String getAgentIdByEmail(String email) throws AgentNotFoundException, AgentOperationFailedException { try { EnvelopeVersion env = node.fetchEnvelope(PREFIX_USER_MAIL + email.toLowerCase()); return (String) env.getContent(); } catch (EnvelopeNotFoundException e) { throw new AgentNotFoundException("Email not found!", e); } catch (EnvelopeException | SerializationException | CryptoException e) { throw new AgentOperationFailedException("Could not read email from storage"); } } UserAgentManager(Node node); void registerUserAgent(UserAgent agent); void registerOIDCSub(UserAgentImpl agent, String sub); String getAgentId(String prefixedIdentifier); String getAgentIdByLogin(String name); String getAgentIdByEmail(String email); String getAgentIdByOIDCSub(String sub); }
UserAgentManager { public String getAgentIdByEmail(String email) throws AgentNotFoundException, AgentOperationFailedException { try { EnvelopeVersion env = node.fetchEnvelope(PREFIX_USER_MAIL + email.toLowerCase()); return (String) env.getContent(); } catch (EnvelopeNotFoundException e) { throw new AgentNotFoundException("Email not found!", e); } catch (EnvelopeException | SerializationException | CryptoException e) { throw new AgentOperationFailedException("Could not read email from storage"); } } UserAgentManager(Node node); void registerUserAgent(UserAgent agent); void registerOIDCSub(UserAgentImpl agent, String sub); String getAgentId(String prefixedIdentifier); String getAgentIdByLogin(String name); String getAgentIdByEmail(String email); String getAgentIdByOIDCSub(String sub);  }