com.icegreen.greenmail.Managers Java Examples
The following examples show how to use
com.icegreen.greenmail.Managers.
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: InterruptableGreenMail.java From syncope with Apache License 2.0 | 6 votes |
@Override protected Map<String, AbstractServer> createServices(final ServerSetup[] config, final Managers mgr) { Map<String, AbstractServer> srvc = new HashMap<>(); for (ServerSetup setup : config) { if (srvc.containsKey(setup.getProtocol())) { throw new IllegalArgumentException("Server '" + setup.getProtocol() + "' was found at least twice in the array"); } final String protocol = setup.getProtocol(); if (protocol.startsWith(ServerSetup.PROTOCOL_SMTP)) { srvc.put(protocol, new InterruptableSmtpServer(setup, mgr)); } else if (protocol.startsWith(ServerSetup.PROTOCOL_POP3)) { srvc.put(protocol, new Pop3Server(setup, mgr)); } else if (protocol.startsWith(ServerSetup.PROTOCOL_IMAP)) { srvc.put(protocol, new ImapServer(setup, mgr)); } } return srvc; }
Example #2
Source File: GreenMail.java From greenmail with Apache License 2.0 | 6 votes |
/** * Create the required services according to the server setup * * @param config Service configuration * @return Services map */ protected Map<String, AbstractServer> createServices(ServerSetup[] config, Managers mgr) { Map<String, AbstractServer> srvc = new HashMap<>(); for (ServerSetup setup : config) { if (srvc.containsKey(setup.getProtocol())) { throw new IllegalArgumentException("Server '" + setup.getProtocol() + "' was found at least twice in the array"); } final String protocol = setup.getProtocol(); if (protocol.startsWith(ServerSetup.PROTOCOL_SMTP)) { srvc.put(protocol, new SmtpServer(setup, mgr)); } else if (protocol.startsWith(ServerSetup.PROTOCOL_POP3)) { srvc.put(protocol, new Pop3Server(setup, mgr)); } else if (protocol.startsWith(ServerSetup.PROTOCOL_IMAP)) { srvc.put(protocol, new ImapServer(setup, mgr)); } } return srvc; }
Example #3
Source File: GreenMail.java From greenmail with Apache License 2.0 | 5 votes |
@Override public synchronized void stop() { log.debug("Stopping GreenMail ..."); if (services != null) { for (Service service : services.values()) { log.debug("Stopping service {}", service); service.stopService(); } } managers = new Managers(); services = null; }
Example #4
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 #5
Source File: ServiceFactory.java From greenmail with Apache License 2.0 | 5 votes |
public static List<Service> create(final Configuration pConf, final Managers pManagers) { List<Configuration.ServiceConfiguration> seviceConfigs = pConf.getServiceConfigurations(); List<Service> services = new ArrayList<>(seviceConfigs.size()); for(Configuration.ServiceConfiguration serviceConf: seviceConfigs) { services.add(create(pConf, serviceConf, pManagers)); } return services; }
Example #6
Source File: AbstractServer.java From greenmail with Apache License 2.0 | 5 votes |
protected AbstractServer(ServerSetup setup, Managers managers) { this.setup = setup; String bindAddress = setup.getBindAddress(); if (null == bindAddress) { bindAddress = setup.getDefaultBindAddress(); } setName(setup.getProtocol() + ':' + bindAddress + ':' + setup.getPort()); try { bindTo = InetAddress.getByName(bindAddress); } catch (UnknownHostException e) { throw new RuntimeException("Failed to setup bind address for " + getName(), e); } this.managers = managers; }
Example #7
Source File: AlfrescoImapServer.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
public DefaultImapServer(ServerSetup setup, Managers managers, AtomicReference<Exception> serverOpeningExceptionRef) { super(setup, managers, serverOpeningExceptionRef); }
Example #8
Source File: GreenMailProxy.java From greenmail with Apache License 2.0 | 4 votes |
@Override public Managers getManagers() { return getGreenMail().getManagers(); }
Example #9
Source File: GreenMail.java From greenmail with Apache License 2.0 | 4 votes |
@Override public Managers getManagers() { return managers; }
Example #10
Source File: Pop3Server.java From greenmail with Apache License 2.0 | 4 votes |
public Pop3Server(ServerSetup setup, Managers managers) { super(setup, managers); }
Example #11
Source File: ImapServer.java From greenmail with Apache License 2.0 | 4 votes |
public ImapServer(ServerSetup setup, Managers managers) { super(setup, managers); }
Example #12
Source File: SmtpServer.java From greenmail with Apache License 2.0 | 4 votes |
public SmtpServer(ServerSetup setup, Managers managers) { super(setup, managers); }
Example #13
Source File: GreenMailListener.java From greenmail with Apache License 2.0 | 4 votes |
public Managers getManagers() { return managers; }
Example #14
Source File: ContextHelper.java From greenmail with Apache License 2.0 | 4 votes |
public static Managers getManagers(ServletContext ctx) { return (Managers) ctx.getAttribute(ATTRIBUTE_NAME_MANAGERS); }
Example #15
Source File: ContextHelper.java From greenmail with Apache License 2.0 | 4 votes |
public static void initAttributes(ServletContext ctx, Managers managers, Configuration configuration) { ctx.setAttribute(ATTRIBUTE_NAME_MANAGERS, managers); ctx.setAttribute(ATTRIBUTE_NAME_CONFIGURATION, configuration); }
Example #16
Source File: InterruptableSmtpServer.java From syncope with Apache License 2.0 | 4 votes |
public InterruptableSmtpServer(final ServerSetup setup, final Managers managers) { super(setup, managers); }
Example #17
Source File: AlfrescoImapServer.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
public SecureImapServer(ServerSetup setup, Managers managers, AtomicReference<Exception> serverOpeningExceptionRef) { super(setup, managers,serverOpeningExceptionRef); }
Example #18
Source File: GreenMailOperations.java From greenmail with Apache License 2.0 | 2 votes |
/** * @return Greenmail protocol managers */ Managers getManagers();