package pt.link.crypto;

import java.io.InputStream;
import java.util.Properties;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class UtilProperties {
	static Log log = LogFactory.getLog(UtilProperties.class);

	public static String getPropertyValue(String resourceName, String propertyName, Class clazz) throws RuntimeException {
		Properties properties = new Properties();
		
		InputStream inputStream =  clazz.getResourceAsStream("/"+resourceName);
		if(inputStream == null){
			log.error("resource not found");
			throw new RuntimeException("Error loading properties"  + "- resource not found");
		}
		try {
			properties.load(inputStream);
			return properties.getProperty(propertyName);
		} catch (Exception e) {
			log.error(e);
			throw new RuntimeException("Error loading properties" , e);
		}
	}

}
