All Downloads are FREE. Search and download functionalities are using the official Maven repository.

br.com.jhonsapp.email.session.configurator.SenderConfigurator Maven / Gradle / Ivy

Go to download

Email Dispatcher is an open source project created by Jhonys Camacho and Jhonathan Camacho to facilitate the sending of emails.

There is a newer version: 1.0.3
Show newest version
package br.com.jhonsapp.email.session.configurator;

import java.io.Serializable;
import java.util.Properties;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.outjected.email.impl.SimpleMailConfig;

import br.com.jhonsapp.email.session.properties.UserProperties;
import br.com.jhonsapp.util.loader.PropertiesLoader;

/**
 * This class is used to configure and load email sender information.
 * 
 * @author Jhonathan Camacho
 *
 */
@Component
public class SenderConfigurator implements Serializable {

	/**
	 * Generated serial version id created at 08 July 2017.
	 */
	private static final long serialVersionUID = -8198436696559752388L;

	@Autowired
	private PropertiesLoader loader;
	private SimpleMailConfig sessionConfig;
	private Properties userProperties;

	public void configure(SimpleMailConfig sessionConfig) {

		this.sessionConfig = sessionConfig;

		userProperties = loader.getPropertiesFile(UserProperties.USER_PROPERTIES);
		verifyIfAllUserInformationValuesExist();
		setSenderInformationInSimpleMailConfig();
	}

	private void verifyIfAllUserInformationValuesExist() {

		loader.verifyIfValueExists(userProperties, UserProperties.typeKey);
		loader.verifyIfValueExists(userProperties, UserProperties.usernameKey);
		loader.verifyIfValueExists(userProperties, UserProperties.passwordKey);
	}

	private void setSenderInformationInSimpleMailConfig() {

		sessionConfig.setUsername(loader.getProperty(userProperties, UserProperties.usernameKey));
		sessionConfig.setPassword(loader.getProperty(userProperties, UserProperties.passwordKey));
	}
	
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy