Skip to content

Commit eb3acc3

Browse files
GutoVeroneziGutoVeronezi
andauthored
Externalize tls version and security protocols configuration on mail sending (#5119)
* Externalize configs to alert * Externalize configs to project Co-authored-by: GutoVeronezi <daniel@scclouds.com.br>
1 parent 1f8b34f commit eb3acc3

4 files changed

Lines changed: 27 additions & 2 deletions

File tree

engine/components-api/src/main/java/com/cloud/alert/AlertManager.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ public interface AlertManager extends Manager, AlertService {
3535
"Alert", "0.75", "Percentage (as a value between 0 and 1) of allocated storage utilization above which alerts will be sent about low storage available.", true,
3636
ConfigKey.Scope.Cluster, null);
3737

38+
public static final ConfigKey<Boolean> AlertSmtpUseStartTLS = new ConfigKey<Boolean>("Advanced", Boolean.class, "alert.smtp.useStartTLS", "false",
39+
"If set to true and if we enable security via alert.smtp.useAuth, this will enable StartTLS to secure the conection.", true);
40+
41+
public static final ConfigKey<String> AlertSmtpEnabledSecurityProtocols = new ConfigKey<String>("Advanced", String.class, "alert.smtp.enabledSecurityProtocols", "",
42+
"White-space separated security protocols; ex: \"TLSv1 TLSv1.1\". Supported protocols: SSLv2Hello, SSLv3, TLSv1, TLSv1.1 and TLSv1.2", true);
43+
3844
void clearAlert(AlertType alertType, long dataCenterId, long podId);
3945

4046
void recalculateCapacity();

server/src/main/java/com/cloud/alert/AlertManagerImpl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,8 @@ public String getConfigComponentName() {
759759

760760
@Override
761761
public ConfigKey<?>[] getConfigKeys() {
762-
return new ConfigKey<?>[] {CPUCapacityThreshold, MemoryCapacityThreshold, StorageAllocatedCapacityThreshold, StorageCapacityThreshold};
762+
return new ConfigKey<?>[] {CPUCapacityThreshold, MemoryCapacityThreshold, StorageAllocatedCapacityThreshold, StorageCapacityThreshold, AlertSmtpEnabledSecurityProtocols,
763+
AlertSmtpUseStartTLS};
763764
}
764765

765766
@Override

server/src/main/java/com/cloud/projects/ProjectManager.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,15 @@
1919
import java.util.List;
2020

2121
import com.cloud.user.Account;
22+
import org.apache.cloudstack.framework.config.ConfigKey;
2223

2324
public interface ProjectManager extends ProjectService {
25+
public static final ConfigKey<Boolean> ProjectSmtpUseStartTLS = new ConfigKey<Boolean>("Advanced", Boolean.class, "project.smtp.useStartTLS", "false",
26+
"If set to true and if we enable security via project.smtp.useAuth, this will enable StartTLS to secure the conection.", true);
27+
28+
public static final ConfigKey<String> ProjectSmtpEnabledSecurityProtocols = new ConfigKey<String>("Advanced", String.class, "project.smtp.enabledSecurityProtocols", "",
29+
"White-space separated security protocols; ex: \"TLSv1 TLSv1.1\". Supported protocols: SSLv2Hello, SSLv3, TLSv1, TLSv1.1 and TLSv1.2", true);
30+
2431
boolean canAccessProjectAccount(Account caller, long accountId);
2532

2633
boolean canModifyProjectAccount(Account caller, long accountId);

server/src/main/java/com/cloud/projects/ProjectManagerImpl.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,15 @@
8282
import com.cloud.utils.exception.CloudRuntimeException;
8383
import java.util.HashSet;
8484
import java.util.Set;
85+
import org.apache.cloudstack.framework.config.ConfigKey;
86+
import org.apache.cloudstack.framework.config.Configurable;
8587
import org.apache.cloudstack.utils.mailing.MailAddress;
8688
import org.apache.cloudstack.utils.mailing.SMTPMailProperties;
8789
import org.apache.cloudstack.utils.mailing.SMTPMailSender;
8890
import org.apache.commons.lang3.BooleanUtils;
8991

9092
@Component
91-
public class ProjectManagerImpl extends ManagerBase implements ProjectManager {
93+
public class ProjectManagerImpl extends ManagerBase implements ProjectManager, Configurable {
9294
public static final Logger s_logger = Logger.getLogger(ProjectManagerImpl.class);
9395

9496
@Inject
@@ -1366,4 +1368,13 @@ public boolean allowUserToCreateProject() {
13661368
return _allowUserToCreateProject;
13671369
}
13681370

1371+
@Override
1372+
public String getConfigComponentName() {
1373+
return ProjectManager.class.getSimpleName();
1374+
}
1375+
1376+
@Override
1377+
public ConfigKey<?>[] getConfigKeys() {
1378+
return new ConfigKey<?>[] {ProjectSmtpEnabledSecurityProtocols, ProjectSmtpUseStartTLS};
1379+
}
13691380
}

0 commit comments

Comments
 (0)