Java Code Examples for com.icegreen.greenmail.user.GreenMailUser#setPassword()
The following examples show how to use
com.icegreen.greenmail.user.GreenMailUser#setPassword() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GreenMailService.java From greenmail with Apache License 2.0 | 6 votes |
private void addMailUser(final String user) { // Parse ... int posColon = user.indexOf(':'); int posAt = user.indexOf('@'); String login = user.substring(0, posColon); String pwd = user.substring(posColon + 1, posAt); String domain = user.substring(posAt + 1); String email = login + '@' + domain; if (log.isDebugEnabled()) { // This is a test system, so we do not care about pwd in the log file. log.debug("Adding user " + login + ':' + pwd + '@' + domain); } GreenMailUser greenMailUser = managers.getUserManager().getUser(email); if (null == greenMailUser) { try { greenMailUser = managers.getUserManager().createUser(email, login, pwd); greenMailUser.setPassword(pwd); } catch (UserException e) { throw new RuntimeException(e); } } }
Example 2
Source File: GreenMailListener.java From greenmail with Apache License 2.0 | 5 votes |
@Override public void contextInitialized(final ServletContextEvent sce) { log.info("Initializing GreenMail"); managers = new Managers(); ServletContext ctx = sce.getServletContext(); configuration = ConfigurationFactory.create(extractParameters(ctx)); services = ServiceFactory.create(configuration, managers); for (Configuration.User user : configuration.getUsers()) { GreenMailUser greenMailUser = managers.getUserManager().getUser(user.email); if (null == greenMailUser) { try { greenMailUser = managers.getUserManager().createUser( user.email, user.login, user.password); greenMailUser.setPassword(user.password); } catch (UserException e) { throw new IllegalStateException(e); } } } for (Service s : services) { log.info("Starting GreenMail service: {}", s); s.startService(); } ContextHelper.initAttributes(ctx, managers, configuration); }
Example 3
Source File: GreenMail.java From greenmail with Apache License 2.0 | 5 votes |
@Override public GreenMailUser setUser(String email, String login, String password) { GreenMailUser user = managers.getUserManager().getUser(login); if (null == user) { try { user = managers.getUserManager().createUser(email, login, password); } catch (UserException e) { throw new RuntimeException(e); } } else { user.setPassword(password); } return user; }