mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-10-15 15:02:20 +00:00
Merged HEAD-BUG-FIX (5.1/Cloud) to HEAD (5.1/Cloud)
108205: Merged 5.0.N (5.0.3) to HEAD-BUG-FIX (5.1/Cloud) 108186: Reverse merged 5.0.N (5.0.3) << Better solution found >> 106968: Merged DEV to 5.0.N (5.0.3) 106962: MNT-13706 : Admin console unusable after we set any busy port in Port Number Value for subsystem - Implemented fix for Transformations (JodConverter), FTP, SMTP and IMAP. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@108221 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -464,9 +464,6 @@
|
|||||||
<property name="persister">
|
<property name="persister">
|
||||||
<bean class="org.alfresco.config.AlfrescoPropertiesPersister"/>
|
<bean class="org.alfresco.config.AlfrescoPropertiesPersister"/>
|
||||||
</property>
|
</property>
|
||||||
<property name="loggableErrorEventMatcher">
|
|
||||||
<value>^.*ServerConfigurationBean.*$</value>
|
|
||||||
</property>
|
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="fileServerConfiguration" class="org.alfresco.repo.management.subsystems.SubsystemProxyFactory">
|
<bean id="fileServerConfiguration" class="org.alfresco.repo.management.subsystems.SubsystemProxyFactory">
|
||||||
@@ -513,9 +510,6 @@
|
|||||||
</entry>
|
</entry>
|
||||||
</map>
|
</map>
|
||||||
</property>
|
</property>
|
||||||
<property name="loggableErrorEventMatcher">
|
|
||||||
<value>^.*AlfrescoImapServer.*$</value>
|
|
||||||
</property>
|
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<!-- Outbound Email subsystem -->
|
<!-- Outbound Email subsystem -->
|
||||||
@@ -552,9 +546,6 @@
|
|||||||
<property name="autoStart">
|
<property name="autoStart">
|
||||||
<value>true</value>
|
<value>true</value>
|
||||||
</property>
|
</property>
|
||||||
<property name="loggableErrorEventMatcher">
|
|
||||||
<value>^.*EmailServer.*$</value>
|
|
||||||
</property>
|
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<!-- Subscription Service subsystem -->
|
<!-- Subscription Service subsystem -->
|
||||||
|
@@ -89,13 +89,6 @@ system.usage.err.limit_documents_exceeded=The allowable content limit of {0} has
|
|||||||
system.usage.err.limit_license_expiring=The Alfresco license will expire in {0} days.
|
system.usage.err.limit_license_expiring=The Alfresco license will expire in {0} days.
|
||||||
system.usage.err.limit_license_expired=The Alfresco license has expired.
|
system.usage.err.limit_license_expired=The Alfresco license has expired.
|
||||||
|
|
||||||
# Subsystems error messages
|
|
||||||
system.loggable_error_event.unspecified_error=Unspecified error.
|
|
||||||
system.jodconverter.err.failed_start=Unable to start JodConverter library. Cause: {0}.
|
|
||||||
system.imap.err.port_in_use=The port chosen for IMAP is already in use: {0}.
|
|
||||||
system.smtp.err.port_in_use=The port chosen for SMTP is already in use: {0}.
|
|
||||||
system.ftp.err.port_in_use=The port chosen for FTP is already in use: {0}.
|
|
||||||
|
|
||||||
# License
|
# License
|
||||||
system.license.msg.unknown=Unknown
|
system.license.msg.unknown=Unknown
|
||||||
system.license.msg.unlimited=Unlimited
|
system.license.msg.unlimited=Unlimited
|
||||||
|
@@ -1,414 +1,405 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||||
*
|
*
|
||||||
* This file is part of Alfresco
|
* This file is part of Alfresco
|
||||||
*
|
*
|
||||||
* Alfresco is free software: you can redistribute it and/or modify
|
* Alfresco is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Lesser General Public License as published by
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Alfresco is distributed in the hope that it will be useful,
|
* Alfresco is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU Lesser General Public License for more details.
|
* GNU Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package org.alfresco.email.server;
|
package org.alfresco.email.server;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
|
|
||||||
import org.alfresco.error.AlfrescoRuntimeException;
|
import org.alfresco.error.AlfrescoRuntimeException;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationComponent;
|
import org.alfresco.repo.security.authentication.AuthenticationComponent;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationException;
|
import org.alfresco.repo.security.authentication.AuthenticationException;
|
||||||
import org.alfresco.service.cmr.email.EmailMessageException;
|
import org.alfresco.service.cmr.email.EmailMessageException;
|
||||||
import org.alfresco.service.cmr.email.EmailService;
|
import org.alfresco.service.cmr.email.EmailService;
|
||||||
import org.alfresco.util.PortUtil;
|
import org.springframework.extensions.surf.util.AbstractLifecycleBean;
|
||||||
import org.springframework.extensions.surf.util.AbstractLifecycleBean;
|
import org.alfresco.util.PropertyCheck;
|
||||||
import org.alfresco.util.PropertyCheck;
|
import org.springframework.beans.BeansException;
|
||||||
import org.springframework.beans.BeansException;
|
import org.springframework.context.ApplicationEvent;
|
||||||
import org.springframework.context.ApplicationEvent;
|
import org.springframework.context.support.AbstractApplicationContext;
|
||||||
import org.springframework.context.support.AbstractApplicationContext;
|
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
|
||||||
|
/**
|
||||||
/**
|
* Base implementation of an email server.
|
||||||
* Base implementation of an email server.
|
* @since 2.2
|
||||||
* @since 2.2
|
*/
|
||||||
*/
|
public abstract class EmailServer extends AbstractLifecycleBean
|
||||||
public abstract class EmailServer extends AbstractLifecycleBean
|
{
|
||||||
{
|
private static final String ERR_SENDER_BLOCKED = "email.server.err.sender_blocked";
|
||||||
private static final String ERR_SENDER_BLOCKED = "email.server.err.sender_blocked";
|
|
||||||
private static final String SMTP_PORT_OCCUPIED_MESSAGE = "system.smtp.err.port_in_use";
|
private boolean enabled;
|
||||||
|
private String domain;
|
||||||
private boolean enabled;
|
private int port;
|
||||||
private String domain;
|
private int maxConnections;
|
||||||
private int port;
|
private Set<String> blockedSenders;
|
||||||
private int maxConnections;
|
private Set<String> allowedSenders;
|
||||||
private Set<String> blockedSenders;
|
private boolean hideTLS = false;
|
||||||
private Set<String> allowedSenders;
|
private boolean enableTLS = true;
|
||||||
private boolean hideTLS = false;
|
private boolean requireTLS = false;
|
||||||
private boolean enableTLS = true;
|
private boolean authenticate = false;
|
||||||
private boolean requireTLS = false;
|
|
||||||
private boolean authenticate = false;
|
|
||||||
|
|
||||||
private EmailService emailService;
|
private EmailService emailService;
|
||||||
private AuthenticationComponent authenticationComponent;
|
private AuthenticationComponent authenticationComponent;
|
||||||
|
|
||||||
protected EmailServer()
|
protected EmailServer()
|
||||||
{
|
{
|
||||||
this.enabled = false;
|
this.enabled = false;
|
||||||
this.port = 25;
|
this.port = 25;
|
||||||
this.domain = null;
|
this.domain = null;
|
||||||
this.maxConnections = 3;
|
this.maxConnections = 3;
|
||||||
this.blockedSenders = new HashSet<String>(23);
|
this.blockedSenders = new HashSet<String>(23);
|
||||||
this.allowedSenders = new HashSet<String>(23);
|
this.allowedSenders = new HashSet<String>(23);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param enabled Enable/disable server
|
* @param enabled Enable/disable server
|
||||||
*/
|
*/
|
||||||
public void setEnabled(boolean enabled)
|
public void setEnabled(boolean enabled)
|
||||||
{
|
{
|
||||||
this.enabled = enabled;
|
this.enabled = enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getDomain()
|
protected String getDomain()
|
||||||
{
|
{
|
||||||
return domain;
|
return domain;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDomain(String domain)
|
public void setDomain(String domain)
|
||||||
{
|
{
|
||||||
this.domain = domain;
|
this.domain = domain;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int getPort()
|
protected int getPort()
|
||||||
{
|
{
|
||||||
return port;
|
return port;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param port SMTP port (25 is default)
|
* @param port SMTP port (25 is default)
|
||||||
*/
|
*/
|
||||||
public void setPort(int port)
|
public void setPort(int port)
|
||||||
{
|
{
|
||||||
this.port = port;
|
this.port = port;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the maximum number of connection accepted by the server.
|
* Returns the maximum number of connection accepted by the server.
|
||||||
* @return the maximum number of connections
|
* @return the maximum number of connections
|
||||||
*/
|
*/
|
||||||
protected int getMaxConnections()
|
protected int getMaxConnections()
|
||||||
{
|
{
|
||||||
return maxConnections;
|
return maxConnections;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the maximum number of connection accepted by the server
|
* Sets the maximum number of connection accepted by the server
|
||||||
* @param maxConnections
|
* @param maxConnections
|
||||||
*/
|
*/
|
||||||
public void setMaxConnections(int maxConnections)
|
public void setMaxConnections(int maxConnections)
|
||||||
{
|
{
|
||||||
this.maxConnections = maxConnections;
|
this.maxConnections = maxConnections;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the blocked senders as a comma separated list. The entries will be trimmed of
|
* Set the blocked senders as a comma separated list. The entries will be trimmed of
|
||||||
* all whitespace.
|
* all whitespace.
|
||||||
*
|
*
|
||||||
* @param blockedSenders a comman separated list of blocked senders
|
* @param blockedSenders a comman separated list of blocked senders
|
||||||
*/
|
*/
|
||||||
public void setBlockedSenders(String blockedSenders)
|
public void setBlockedSenders(String blockedSenders)
|
||||||
{
|
{
|
||||||
StringTokenizer tokenizer = new StringTokenizer(blockedSenders, ",", false);
|
StringTokenizer tokenizer = new StringTokenizer(blockedSenders, ",", false);
|
||||||
while (tokenizer.hasMoreTokens())
|
while (tokenizer.hasMoreTokens())
|
||||||
{
|
{
|
||||||
String sender = tokenizer.nextToken().trim();
|
String sender = tokenizer.nextToken().trim();
|
||||||
this.blockedSenders.add(sender);
|
this.blockedSenders.add(sender);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param blockedSenders a list of senders that are not allowed to email in
|
* @param blockedSenders a list of senders that are not allowed to email in
|
||||||
*/
|
*/
|
||||||
public void setBlockedSendersList(List<String> blockedSenders)
|
public void setBlockedSendersList(List<String> blockedSenders)
|
||||||
{
|
{
|
||||||
this.blockedSenders.addAll(blockedSenders);
|
this.blockedSenders.addAll(blockedSenders);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the allowed senders as a comma separated list. The entries will be trimmed of
|
* Set the allowed senders as a comma separated list. The entries will be trimmed of
|
||||||
* all whitespace.
|
* all whitespace.
|
||||||
*
|
*
|
||||||
* @param allowedSenders a comman separated list of blocked senders
|
* @param allowedSenders a comman separated list of blocked senders
|
||||||
*/
|
*/
|
||||||
public void setAllowedSenders(String allowedSenders)
|
public void setAllowedSenders(String allowedSenders)
|
||||||
{
|
{
|
||||||
StringTokenizer tokenizer = new StringTokenizer(allowedSenders, ",", false);
|
StringTokenizer tokenizer = new StringTokenizer(allowedSenders, ",", false);
|
||||||
while (tokenizer.hasMoreTokens())
|
while (tokenizer.hasMoreTokens())
|
||||||
{
|
{
|
||||||
String sender = tokenizer.nextToken().trim();
|
String sender = tokenizer.nextToken().trim();
|
||||||
if (sender.length() == 0)
|
if (sender.length() == 0)
|
||||||
{
|
{
|
||||||
// Nothing
|
// Nothing
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
this.allowedSenders.add(sender);
|
this.allowedSenders.add(sender);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param allowedSenders a list of senders that are allowed to email in
|
* @param allowedSenders a list of senders that are allowed to email in
|
||||||
*/
|
*/
|
||||||
public void setAllowedSendersList(List<String> allowedSenders)
|
public void setAllowedSendersList(List<String> allowedSenders)
|
||||||
{
|
{
|
||||||
this.allowedSenders.addAll(allowedSenders);
|
this.allowedSenders.addAll(allowedSenders);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the service interface to interact with
|
* @return the service interface to interact with
|
||||||
*/
|
*/
|
||||||
protected EmailService getEmailService()
|
protected EmailService getEmailService()
|
||||||
{
|
{
|
||||||
return emailService;
|
return emailService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param emailService the service interface to interact with
|
* @param emailService the service interface to interact with
|
||||||
*/
|
*/
|
||||||
public void setEmailService(EmailService emailService)
|
public void setEmailService(EmailService emailService)
|
||||||
{
|
{
|
||||||
this.emailService = emailService;
|
this.emailService = emailService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filter incoming message by its sender e-mail address.
|
* Filter incoming message by its sender e-mail address.
|
||||||
*
|
*
|
||||||
* @param sender An e-mail address of sender
|
* @param sender An e-mail address of sender
|
||||||
* @throws EmailMessageException if the e-mail is rejected accordingly with blocked and allowed lists
|
* @throws EmailMessageException if the e-mail is rejected accordingly with blocked and allowed lists
|
||||||
*/
|
*/
|
||||||
protected void filterSender(String sender)
|
protected void filterSender(String sender)
|
||||||
{
|
{
|
||||||
// Check if the sender is in the blocked list
|
// Check if the sender is in the blocked list
|
||||||
for (String blockedSender : blockedSenders)
|
for (String blockedSender : blockedSenders)
|
||||||
{
|
{
|
||||||
if (sender.matches(blockedSender))
|
if (sender.matches(blockedSender))
|
||||||
{
|
{
|
||||||
throw new EmailMessageException(ERR_SENDER_BLOCKED, sender);
|
throw new EmailMessageException(ERR_SENDER_BLOCKED, sender);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there are any restrictions in the allowed list, then a positive match
|
// If there are any restrictions in the allowed list, then a positive match
|
||||||
// is absolutely required
|
// is absolutely required
|
||||||
if (!allowedSenders.isEmpty())
|
if (!allowedSenders.isEmpty())
|
||||||
{
|
{
|
||||||
boolean matched = false;
|
boolean matched = false;
|
||||||
for (String allowedSender : allowedSenders)
|
for (String allowedSender : allowedSenders)
|
||||||
{
|
{
|
||||||
if (sender.matches(allowedSender))
|
if (sender.matches(allowedSender))
|
||||||
{
|
{
|
||||||
matched = true;
|
matched = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!matched)
|
if (!matched)
|
||||||
{
|
{
|
||||||
throw new EmailMessageException(ERR_SENDER_BLOCKED, sender);
|
throw new EmailMessageException(ERR_SENDER_BLOCKED, sender);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method is called when server is starting up.
|
* Method is called when server is starting up.
|
||||||
*/
|
*/
|
||||||
public abstract void startup();
|
public abstract void startup();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method is called when server is shutting down.
|
* Method is called when server is shutting down.
|
||||||
*/
|
*/
|
||||||
public abstract void shutdown();
|
public abstract void shutdown();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void onBootstrap(ApplicationEvent event)
|
protected void onBootstrap(ApplicationEvent event)
|
||||||
{
|
{
|
||||||
if (!enabled)
|
if (!enabled)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Check properties
|
// Check properties
|
||||||
PropertyCheck.mandatory(this, "domain", domain);
|
PropertyCheck.mandatory(this, "domain", domain);
|
||||||
if (port <= 0 || port > 65535)
|
if (port <= 0 || port > 65535)
|
||||||
{
|
{
|
||||||
throw new AlfrescoRuntimeException("Property 'port' is incorrect");
|
throw new AlfrescoRuntimeException("Property 'port' is incorrect");
|
||||||
}
|
}
|
||||||
|
PropertyCheck.mandatory(this, "emailService", emailService);
|
||||||
// Check if port is occupied.
|
// Startup
|
||||||
if (!PortUtil.isPortFree(port))
|
startup();
|
||||||
{
|
}
|
||||||
throw new AlfrescoRuntimeException(SMTP_PORT_OCCUPIED_MESSAGE, new String[] { "" + port });
|
|
||||||
}
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
PropertyCheck.mandatory(this, "emailService", emailService);
|
*/
|
||||||
// Startup
|
@Override
|
||||||
startup();
|
protected void onShutdown(ApplicationEvent event)
|
||||||
}
|
{
|
||||||
|
if (enabled)
|
||||||
/**
|
{
|
||||||
* {@inheritDoc}
|
shutdown();
|
||||||
*/
|
}
|
||||||
@Override
|
}
|
||||||
protected void onShutdown(ApplicationEvent event)
|
|
||||||
{
|
private static volatile Boolean stop = false;
|
||||||
if (enabled)
|
|
||||||
{
|
public static void main(String[] args)
|
||||||
shutdown();
|
{
|
||||||
}
|
if (args.length == 0)
|
||||||
}
|
{
|
||||||
|
usage();
|
||||||
private static volatile Boolean stop = false;
|
return;
|
||||||
|
}
|
||||||
public static void main(String[] args)
|
AbstractApplicationContext context = null;
|
||||||
{
|
try
|
||||||
if (args.length == 0)
|
{
|
||||||
{
|
context = new ClassPathXmlApplicationContext(args);
|
||||||
usage();
|
} catch (BeansException e)
|
||||||
return;
|
{
|
||||||
}
|
System.err.println("Erro create context: " + e);
|
||||||
AbstractApplicationContext context = null;
|
usage();
|
||||||
try
|
return;
|
||||||
{
|
}
|
||||||
context = new ClassPathXmlApplicationContext(args);
|
|
||||||
} catch (BeansException e)
|
try
|
||||||
{
|
{
|
||||||
System.err.println("Erro create context: " + e);
|
if (!context.containsBean("emailServer"))
|
||||||
usage();
|
{
|
||||||
return;
|
usage();
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
try
|
|
||||||
{
|
Runtime.getRuntime().addShutdownHook(new Thread() {
|
||||||
if (!context.containsBean("emailServer"))
|
public void run()
|
||||||
{
|
{
|
||||||
usage();
|
stop = true;
|
||||||
return;
|
synchronized (stop)
|
||||||
}
|
{
|
||||||
|
stop.notifyAll();
|
||||||
Runtime.getRuntime().addShutdownHook(new Thread() {
|
}
|
||||||
public void run()
|
}
|
||||||
{
|
});
|
||||||
stop = true;
|
System.out.println("Use Ctrl-C to shutdown EmailServer");
|
||||||
synchronized (stop)
|
|
||||||
{
|
while (!stop)
|
||||||
stop.notifyAll();
|
{
|
||||||
}
|
synchronized (stop)
|
||||||
}
|
{
|
||||||
});
|
stop.wait();
|
||||||
System.out.println("Use Ctrl-C to shutdown EmailServer");
|
}
|
||||||
|
}
|
||||||
while (!stop)
|
}
|
||||||
{
|
catch (InterruptedException e)
|
||||||
synchronized (stop)
|
{
|
||||||
{
|
}
|
||||||
stop.wait();
|
finally
|
||||||
}
|
{
|
||||||
}
|
context.close();
|
||||||
}
|
}
|
||||||
catch (InterruptedException e)
|
|
||||||
{
|
}
|
||||||
}
|
|
||||||
finally
|
private static void usage()
|
||||||
{
|
{
|
||||||
context.close();
|
System.err.println("Use: EmailServer configLocation1, configLocation2, ...");
|
||||||
}
|
System.err.println("\t configLocation - spring xml configs with EmailServer related beans (emailServer, emailServerConfiguration, emailService)");
|
||||||
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
private static void usage()
|
* authenticate with a user/password
|
||||||
{
|
* @param userName
|
||||||
System.err.println("Use: EmailServer configLocation1, configLocation2, ...");
|
* @param password
|
||||||
System.err.println("\t configLocation - spring xml configs with EmailServer related beans (emailServer, emailServerConfiguration, emailService)");
|
* @return true - authenticated
|
||||||
}
|
*/
|
||||||
|
protected boolean authenticateUserNamePassword(String userName, char[] password)
|
||||||
/**
|
{
|
||||||
* authenticate with a user/password
|
try
|
||||||
* @param userName
|
{
|
||||||
* @param password
|
getAuthenticationComponent().authenticate(userName, password);
|
||||||
* @return true - authenticated
|
return true;
|
||||||
*/
|
}
|
||||||
protected boolean authenticateUserNamePassword(String userName, char[] password)
|
catch (AuthenticationException e)
|
||||||
{
|
{
|
||||||
try
|
return false;
|
||||||
{
|
}
|
||||||
getAuthenticationComponent().authenticate(userName, password);
|
}
|
||||||
return true;
|
|
||||||
}
|
/** Hide the TLS (Trusted Login Session) option
|
||||||
catch (AuthenticationException e)
|
*
|
||||||
{
|
* @param hideTLS
|
||||||
return false;
|
*/
|
||||||
}
|
public void setHideTLS(boolean hideTLS)
|
||||||
}
|
{
|
||||||
|
this.hideTLS = hideTLS;
|
||||||
/** Hide the TLS (Trusted Login Session) option
|
}
|
||||||
*
|
|
||||||
* @param hideTLS
|
public boolean isHideTLS()
|
||||||
*/
|
{
|
||||||
public void setHideTLS(boolean hideTLS)
|
return hideTLS;
|
||||||
{
|
}
|
||||||
this.hideTLS = hideTLS;
|
|
||||||
}
|
public void setEnableTLS(boolean enableTLS)
|
||||||
|
{
|
||||||
public boolean isHideTLS()
|
this.enableTLS = enableTLS;
|
||||||
{
|
}
|
||||||
return hideTLS;
|
|
||||||
}
|
public boolean isEnableTLS()
|
||||||
|
{
|
||||||
public void setEnableTLS(boolean enableTLS)
|
return enableTLS;
|
||||||
{
|
}
|
||||||
this.enableTLS = enableTLS;
|
|
||||||
}
|
public void setRequireTLS(boolean requireTLS)
|
||||||
|
{
|
||||||
public boolean isEnableTLS()
|
this.requireTLS = requireTLS;
|
||||||
{
|
}
|
||||||
return enableTLS;
|
|
||||||
}
|
public boolean isRequireTLS()
|
||||||
|
{
|
||||||
public void setRequireTLS(boolean requireTLS)
|
return requireTLS;
|
||||||
{
|
}
|
||||||
this.requireTLS = requireTLS;
|
|
||||||
}
|
public void setAuthenticate(boolean enableAuthentication)
|
||||||
|
{
|
||||||
public boolean isRequireTLS()
|
this.authenticate = enableAuthentication;
|
||||||
{
|
}
|
||||||
return requireTLS;
|
|
||||||
}
|
public boolean isAuthenticate()
|
||||||
|
{
|
||||||
public void setAuthenticate(boolean enableAuthentication)
|
return authenticate;
|
||||||
{
|
}
|
||||||
this.authenticate = enableAuthentication;
|
|
||||||
}
|
public void setAuthenticationComponent(AuthenticationComponent authenticationComponent)
|
||||||
|
{
|
||||||
public boolean isAuthenticate()
|
this.authenticationComponent = authenticationComponent;
|
||||||
{
|
}
|
||||||
return authenticate;
|
|
||||||
}
|
public AuthenticationComponent getAuthenticationComponent()
|
||||||
|
{
|
||||||
public void setAuthenticationComponent(AuthenticationComponent authenticationComponent)
|
return authenticationComponent;
|
||||||
{
|
}
|
||||||
this.authenticationComponent = authenticationComponent;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public AuthenticationComponent getAuthenticationComponent()
|
|
||||||
{
|
|
||||||
return authenticationComponent;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
@@ -83,11 +83,7 @@ import org.alfresco.jlan.util.Platform;
|
|||||||
import org.alfresco.jlan.util.StringList;
|
import org.alfresco.jlan.util.StringList;
|
||||||
import org.alfresco.jlan.util.X64;
|
import org.alfresco.jlan.util.X64;
|
||||||
import org.alfresco.repo.management.subsystems.ActivateableBean;
|
import org.alfresco.repo.management.subsystems.ActivateableBean;
|
||||||
import org.alfresco.repo.management.subsystems.LoggableErrorEvent;
|
|
||||||
import org.alfresco.util.PortUtil;
|
|
||||||
import org.springframework.beans.factory.DisposableBean;
|
import org.springframework.beans.factory.DisposableBean;
|
||||||
import org.springframework.context.ApplicationEventPublisher;
|
|
||||||
import org.springframework.context.ApplicationEventPublisherAware;
|
|
||||||
import org.springframework.extensions.config.element.GenericConfigElement;
|
import org.springframework.extensions.config.element.GenericConfigElement;
|
||||||
|
|
||||||
|
|
||||||
@@ -103,10 +99,8 @@ import org.springframework.extensions.config.element.GenericConfigElement;
|
|||||||
* @author dward
|
* @author dward
|
||||||
* @author mrogers
|
* @author mrogers
|
||||||
*/
|
*/
|
||||||
public class ServerConfigurationBean extends AbstractServerConfigurationBean implements DisposableBean, ApplicationEventPublisherAware
|
public class ServerConfigurationBean extends AbstractServerConfigurationBean implements DisposableBean
|
||||||
{
|
{
|
||||||
private static final String FTP_PORT_OCCUPIED_MESSAGE = "system.ftp.err.port_in_use";
|
|
||||||
|
|
||||||
private CIFSConfigBean cifsConfigBean;
|
private CIFSConfigBean cifsConfigBean;
|
||||||
private FTPConfigBean ftpConfigBean;
|
private FTPConfigBean ftpConfigBean;
|
||||||
private NFSConfigBean nfsConfigBean;
|
private NFSConfigBean nfsConfigBean;
|
||||||
@@ -116,8 +110,7 @@ public class ServerConfigurationBean extends AbstractServerConfigurationBean imp
|
|||||||
|
|
||||||
private ThreadRequestPool threadPool;
|
private ThreadRequestPool threadPool;
|
||||||
protected ClusterConfigBean clusterConfigBean;
|
protected ClusterConfigBean clusterConfigBean;
|
||||||
private ApplicationEventPublisher applicationEventPublisher;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default constructor
|
* Default constructor
|
||||||
*/
|
*/
|
||||||
@@ -1227,13 +1220,6 @@ public class ServerConfigurationBean extends AbstractServerConfigurationBean imp
|
|||||||
ftpConfig.setFTPPort(port);
|
ftpConfig.setFTPPort(port);
|
||||||
if (ftpConfig.getFTPPort() <= 0 || ftpConfig.getFTPPort() >= 65535)
|
if (ftpConfig.getFTPPort() <= 0 || ftpConfig.getFTPPort() >= 65535)
|
||||||
throw new AlfrescoRuntimeException("FTP server port out of valid range");
|
throw new AlfrescoRuntimeException("FTP server port out of valid range");
|
||||||
|
|
||||||
// Check if port is occupied.
|
|
||||||
if (!PortUtil.isPortFree(port))
|
|
||||||
{
|
|
||||||
applicationEventPublisher.publishEvent(new LoggableErrorEvent(this,
|
|
||||||
new AlfrescoRuntimeException(FTP_PORT_OCCUPIED_MESSAGE, new String[] { "" + port })));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -2382,10 +2368,4 @@ public class ServerConfigurationBean extends AbstractServerConfigurationBean imp
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher)
|
|
||||||
{
|
|
||||||
this.applicationEventPublisher = applicationEventPublisher;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -37,27 +37,12 @@ import com.icegreen.greenmail.util.ServerSetup;
|
|||||||
|
|
||||||
import javax.net.ssl.SSLServerSocketFactory;
|
import javax.net.ssl.SSLServerSocketFactory;
|
||||||
import javax.net.ssl.SSLServerSocket;
|
import javax.net.ssl.SSLServerSocket;
|
||||||
import org.alfresco.error.AlfrescoRuntimeException;
|
|
||||||
import org.alfresco.repo.management.subsystems.LoggableErrorEvent;
|
|
||||||
import org.alfresco.util.PortUtil;
|
|
||||||
import org.springframework.context.ApplicationEventPublisher;
|
|
||||||
import org.springframework.context.ApplicationEventPublisherAware;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Mike Shavnev
|
* @author Mike Shavnev
|
||||||
*/
|
*/
|
||||||
public class AlfrescoImapServer extends AbstractLifecycleBean implements ApplicationEventPublisherAware
|
public class AlfrescoImapServer extends AbstractLifecycleBean
|
||||||
{
|
{
|
||||||
private static final String IMAP_PORT_OCCUPIED_MESSAGE = "system.imap.err.port_in_use";
|
|
||||||
|
|
||||||
private ApplicationEventPublisher applicationEventPublisher;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher)
|
|
||||||
{
|
|
||||||
this.applicationEventPublisher = applicationEventPublisher;
|
|
||||||
}
|
|
||||||
|
|
||||||
private class SecureImapServer extends ImapServer
|
private class SecureImapServer extends ImapServer
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -265,13 +250,6 @@ public class AlfrescoImapServer extends AbstractLifecycleBean implements Applica
|
|||||||
|
|
||||||
if(isImapEnabled())
|
if(isImapEnabled())
|
||||||
{
|
{
|
||||||
// Check if port is occupied.
|
|
||||||
if (!PortUtil.isPortFree(port))
|
|
||||||
{
|
|
||||||
applicationEventPublisher.publishEvent(new LoggableErrorEvent(this,
|
|
||||||
new AlfrescoRuntimeException(IMAP_PORT_OCCUPIED_MESSAGE, new String[] { "" + port })));
|
|
||||||
}
|
|
||||||
|
|
||||||
AtomicReference<Exception> serverOpeningExceptionRef = new AtomicReference<Exception>();
|
AtomicReference<Exception> serverOpeningExceptionRef = new AtomicReference<Exception>();
|
||||||
serverImpl = new DefaultImapServer(new ServerSetup(port, host, ServerSetup.PROTOCOL_IMAP), imapManagers, serverOpeningExceptionRef);
|
serverImpl = new DefaultImapServer(new ServerSetup(port, host, ServerSetup.PROTOCOL_IMAP), imapManagers, serverOpeningExceptionRef);
|
||||||
serverImpl.startService(null);
|
serverImpl.startService(null);
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -1,59 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2005-2015 Alfresco Software Limited.
|
|
||||||
*
|
|
||||||
* This file is part of Alfresco
|
|
||||||
*
|
|
||||||
* Alfresco is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Lesser General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Alfresco is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
|
||||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package org.alfresco.repo.management.subsystems;
|
|
||||||
|
|
||||||
import org.alfresco.error.AlfrescoRuntimeException;
|
|
||||||
import org.springframework.context.ApplicationEvent;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Alfresco custom ApplicationEvent class used for publishing errors in subsystems.
|
|
||||||
*/
|
|
||||||
public class LoggableErrorEvent extends ApplicationEvent
|
|
||||||
{
|
|
||||||
private static final String UNSPECIFIED_ERROR_MESSAGE = "system.loggable_error_event.unspecified_error";
|
|
||||||
|
|
||||||
private AlfrescoRuntimeException exception;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new LoggableErrorEvent.
|
|
||||||
* @param source the component that published the event (never {@code null})
|
|
||||||
* @param exception the error to publish
|
|
||||||
*/
|
|
||||||
public LoggableErrorEvent(Object source, AlfrescoRuntimeException exception)
|
|
||||||
{
|
|
||||||
super(source);
|
|
||||||
this.exception = exception;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get this LoggableErrorEvent's exception.
|
|
||||||
* @return the stored exception if not null, otherwise a new RuntimeException
|
|
||||||
*/
|
|
||||||
public AlfrescoRuntimeException getException()
|
|
||||||
{
|
|
||||||
if (exception != null)
|
|
||||||
{
|
|
||||||
return exception;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return new AlfrescoRuntimeException(UNSPECIFIED_ERROR_MESSAGE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,71 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2005-2015 Alfresco Software Limited.
|
|
||||||
*
|
|
||||||
* This file is part of Alfresco
|
|
||||||
*
|
|
||||||
* Alfresco is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Lesser General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Alfresco is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
|
||||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package org.alfresco.util;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.ServerSocket;
|
|
||||||
import org.apache.commons.logging.Log;
|
|
||||||
import org.apache.commons.logging.LogFactory;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Alfresco port-related utility functions.
|
|
||||||
*/
|
|
||||||
public class PortUtil
|
|
||||||
{
|
|
||||||
private static Log logger = LogFactory.getLog(PortUtil.class);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if specified port is free.
|
|
||||||
* @param port port number to check
|
|
||||||
* @return true if port is free or false if it's already in use
|
|
||||||
*/
|
|
||||||
public static boolean isPortFree(int port)
|
|
||||||
{
|
|
||||||
boolean isFree = true;
|
|
||||||
ServerSocket serverSocket = null;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
serverSocket = new ServerSocket(port);
|
|
||||||
}
|
|
||||||
catch (IOException ioe)
|
|
||||||
{
|
|
||||||
isFree = false;
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
if (serverSocket != null)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
serverSocket.close();
|
|
||||||
}
|
|
||||||
catch (IOException ioe)
|
|
||||||
{
|
|
||||||
if (logger.isDebugEnabled())
|
|
||||||
{
|
|
||||||
logger.debug(ioe.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return isFree;
|
|
||||||
}
|
|
||||||
}
|
|
Reference in New Issue
Block a user