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

com.safelayer.rap.config.PkiConnectorConfig Maven / Gradle / Ivy

Go to download

The PKI Connector RESTAPI is a library that helps developing new PKI Connectors for TrustedX

The newest version!
package com.safelayer.rap.config;

import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;

public class PkiConnectorConfig {
	private Map parameters = new HashMap<>();
	
	private static boolean isInitialized = false;
	private static PkiConnectorConfig pkiConnectorConfig;

	public String getParameter(String key) {
		return parameters.get(key);
	}

	public static synchronized void initialize(ServletContextEvent sce) throws Exception {
		ServletContext context = sce.getServletContext();
		Enumeration parametersNameList = context.getInitParameterNames();
		if (parametersNameList == null ||  !parametersNameList.hasMoreElements())
			throw new NoStandaloneConfigExcepcion();
		
		pkiConnectorConfig = new PkiConnectorConfig();

		while (parametersNameList.hasMoreElements()) {
			String parameterName = (String) parametersNameList.nextElement();
			String parameterValue = context.getInitParameter(parameterName).toString();
			pkiConnectorConfig.parameters.put(parameterName, parameterValue);
		}
		isInitialized = true;
	}

	public static PkiConnectorConfig getInstance() throws Exception {
		if (!isInitialized)
			throw new Exception("Pki Connector configuration not initialized");
		return pkiConnectorConfig;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy