@Requirement(reqId="DOI_CONFIG_010", reqName="Configuration du serveur central") public final class EmailSettings extends Object
Modifier and Type | Class and Description |
---|---|
private static class |
EmailSettings.EmailSettingsHolder |
Modifier and Type | Field and Description |
---|---|
private String |
authPwd
Password.
|
private String |
authUser
login.
|
private String |
contactAdmin
Contact admin uRL.
|
private boolean |
debug
debug.
|
private static boolean |
DEFAULT_DEBUG
Default debug : false.
|
private static org.apache.logging.log4j.Logger |
LOG
Logger.
|
private String |
smtpProtocol
SMTP protocol.
|
private String |
smtpUrl
SMTP URL.
|
private String |
tlsEnable
TLS.
|
Modifier | Constructor and Description |
---|---|
private |
EmailSettings()
Constructor
|
Modifier and Type | Method and Description |
---|---|
private org.restlet.representation.Representation |
createMailRepresentation(String subject,
String msg,
String to)
Creates the email representation.
|
String |
getAuthPwd()
Returns the decrypted password.
|
String |
getAuthUser()
Returns the decrypted login.
|
String |
getContactAdmin()
Returns the administrator's email.
|
static EmailSettings |
getInstance()
Access to unique INSTANCE of Settings
|
String |
getSmtpProtocol()
Returns the protocol.
|
String |
getSmtpURL()
Returns the protocol URL.
|
String |
getTlsEnable()
Returns True when TLS is enable otherwise False.
|
void |
init()
Init singleton.
|
private boolean |
isAuthenticate()
Returns true when sendmail neeed to be authenticated otherwide false.
|
private boolean |
isConfigureForSendingEmail()
Returns true when configuration may be enough to send an email.
|
boolean |
isDebug()
Returns the debug.
|
private boolean |
processMessage(String subject,
String message,
String receiverEmail)
Process the message.
|
private boolean |
sendMail(org.restlet.data.Protocol protocol,
org.restlet.Request request,
boolean startTls,
String subject,
String msg,
String to)
Sends an email only when
"Starter.CONTEXT_MODE" is set to PROD.
|
boolean |
sendMessage(String subject,
String msg)
Sends a message by email.
|
boolean |
sendMessage(String subject,
String msg,
String receiverEmail)
Sends a message by email to receiver.
|
void |
setDebug(boolean isEnabled)
Sets the debug.
|
private void |
setSmtpCredentials(org.restlet.Request request)
Sets the SMTP credential when the SMTP needs an authentication.
|
private static final boolean DEFAULT_DEBUG
private static final org.apache.logging.log4j.Logger LOG
private String smtpUrl
private String smtpProtocol
private String tlsEnable
private String authUser
private String authPwd
private String contactAdmin
private boolean debug
public static EmailSettings getInstance()
public void init()
public void setDebug(boolean isEnabled)
isEnabled
- True if debug is enabled otherwise Falsepublic boolean isDebug()
public boolean sendMessage(String subject, String msg)
subject
- Email's subjectmsg
- Email's messagepublic boolean sendMessage(String subject, String msg, String receiverEmail)
subject
- Email's subjectmsg
- Email's messagereceiverEmail
- receiverprivate boolean processMessage(String subject, String message, String receiverEmail) throws Exception
subject
- subject of the emailmessage
- messagereceiverEmail
- receiverException
- when an error happensprivate void setSmtpCredentials(org.restlet.Request request)
request
- requestprivate boolean isConfigureForSendingEmail()
private boolean isAuthenticate()
private org.restlet.representation.Representation createMailRepresentation(String subject, String msg, String to)
subject
- Email's subjectmsg
- Email's messageto
- receiverprivate boolean sendMail(org.restlet.data.Protocol protocol, org.restlet.Request request, boolean startTls, String subject, String msg, String to) throws Exception
protocol
- Protocol (SMTP or SMTPS)request
- requeststartTls
- startTlssubject
- Email's subjectmsg
- Email's messageto
- receiverException
- - if an error happens when stopping the requestpublic String getSmtpURL()
public String getSmtpProtocol()
public String getTlsEnable()
public String getAuthUser()
public String getAuthPwd()
public String getContactAdmin()
Copyright © 2017–2020 CNES. All rights reserved.