package in.gov.digilocker.uidai.web.properties;

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

import org.springframework.stereotype.Service;

@Service
public class DigilockerProperties {
	private String apiKeyDateFormat;
	private boolean exceptionEnabled;
	private boolean msgqueueEnabled;
	private boolean allResponseCaptured;
	private boolean isResponseCapturedUsingList;
	private String aadhaarList;
	
	private String digilockerCertPath;
	private String digilockerCertPassword;
	private String digilockerCertAlias;
	
	private boolean proxy;
	private String proxyPort;
	private String proxyHost;
	
	
	public DigilockerProperties() {
		Properties prop = new Properties();
	    try {
	      InputStream input = getClass().getClassLoader().getResourceAsStream("digilocker-api.properties");
	      prop.load(input);
	    }catch (Exception e) {
	      throw new RuntimeException(e.getMessage());
	    }
	    this.apiKeyDateFormat = prop.getProperty("digilocker.client.key.format");
	    
	    this.exceptionEnabled = (prop.getProperty("digilocker.is.exception.enabled") != null ? Boolean.parseBoolean(prop.getProperty("digilocker.is.exception.enabled").trim()) : false);	    
	    
	    this.msgqueueEnabled = (prop.getProperty("digilocker.is.msgqueue.enabled") != null ?  Boolean.parseBoolean(prop.getProperty("digilocker.is.msgqueue.enabled").trim()) : false);
	    
	    this.allResponseCaptured = (prop.getProperty("digilocker.all.response.is.captured") != null ? Boolean.parseBoolean(prop.getProperty("digilocker.all.response.is.captured").trim()) : false);	    
	    
	    this.isResponseCapturedUsingList = (prop.getProperty("digilocker.response.is.captured.using.list") != null ? Boolean.parseBoolean(prop.getProperty("digilocker.response.is.captured.using.list").trim()) : false);
	    
	    this.digilockerCertPath= prop.getProperty("digilocker.p12.file.path");
	    this.digilockerCertPassword= prop.getProperty("digilocker.p12.file.password");
	    this.digilockerCertAlias= prop.getProperty("digilocker.p12.file.alias");
	    this.proxy = (prop.getProperty("digilocker.api.is.proxy") != null ? Boolean.valueOf(prop.getProperty("digilocker.api.is.proxy")).booleanValue() : false);
	    this.proxyHost = prop.getProperty("digilocker.api.proxy.host");
	    this.proxyPort = prop.getProperty("digilocker.api.proxy.port");
	    
	    this.aadhaarList= prop.getProperty("digilocker.aadhaar.list");	    
	}


	public String getApiKeyDateFormat() {
		return apiKeyDateFormat;
	}


	public void setApiKeyDateFormat(String apiKeyDateFormat) {
		this.apiKeyDateFormat = apiKeyDateFormat;
	}


	public boolean isExceptionEnabled() {
		return exceptionEnabled;
	}


	public void setExceptionEnabled(boolean exceptionEnabled) {
		this.exceptionEnabled = exceptionEnabled;
	}


	public boolean isMsgqueueEnabled() {
		return msgqueueEnabled;
	}


	public void setMsgqueueEnabled(boolean msgqueueEnabled) {
		this.msgqueueEnabled = msgqueueEnabled;
	}


	public boolean isAllResponseCaptured() {
		return allResponseCaptured;
	}


	public void setAllResponseCaptured(boolean allResponseCaptured) {
		this.allResponseCaptured = allResponseCaptured;
	}


	public boolean isResponseCapturedUsingList() {
		return isResponseCapturedUsingList;
	}


	public void setResponseCapturedUsingList(boolean isResponseCapturedUsingList) {
		this.isResponseCapturedUsingList = isResponseCapturedUsingList;
	}


	public String getAadhaarList() {
		return aadhaarList;
	}


	public void setAadhaarList(String aadhaarList) {
		this.aadhaarList = aadhaarList;
	}


	public String getDigilockerCertPath() {
		return digilockerCertPath;
	}


	public void setDigilockerCertPath(String digilockerCertPath) {
		this.digilockerCertPath = digilockerCertPath;
	}


	public String getDigilockerCertPassword() {
		return digilockerCertPassword;
	}


	public void setDigilockerCertPassword(String digilockerCertPassword) {
		this.digilockerCertPassword = digilockerCertPassword;
	}


	public String getDigilockerCertAlias() {
		return digilockerCertAlias;
	}


	public void setDigilockerCertAlias(String digilockerCertAlias) {
		this.digilockerCertAlias = digilockerCertAlias;
	}


	public boolean isProxy() {
		return proxy;
	}


	public void setProxy(boolean proxy) {
		this.proxy = proxy;
	}


	public String getProxyPort() {
		return proxyPort;
	}


	public void setProxyPort(String proxyPort) {
		this.proxyPort = proxyPort;
	}


	public String getProxyHost() {
		return proxyHost;
	}


	public void setProxyHost(String proxyHost) {
		this.proxyHost = proxyHost;
	}
	

	
	
}
