package eu.dnetlib.enabling.aas.ctx;

import java.util.Map;

/**
 * SecurityContext management component responsible for searching, creating and deleting security contexts.
 * The only internal component allowed to access security contexts.
 * @author mhorst
 *
 */
public interface ISecurityContextContainer {
	
	public static final String SECCTX_TYPE_PROPERTY_KEY = "secCtxType";
	public static final String ATTRIBUTES_PROPERTY_KEY = "attributes";
	public static final String IDENTITIES_PROPERTY_KEY = "identities";
	public static final String OBLIGATIONS_PROPERTY_KEY = "obligations";
	

	/**
	 * Allows to get security contexts for given list of identifiers.
	 * @param ids
	 * @return SecurityContext[]
	 * @exception SecurityContextContainerException
	 */
	public SecurityContext[] queryContexts(String[] secCtxIds) throws SecurityContextContainerException;
	
	/**
	 * Creates new SecurityContext, caches it and returns it as a result.
	 * This operation involves creation of public and private keys pair if required for given resource.
	 * At the same time, the method should subscribe to the deletion and modification of the Resource 
	 * for which the Security Context has been created.
	 * @param resourceId
	 * @param properties
	 * @return
	 * @exception SecurityContextContainerException
	 */
	public SecurityContext createContext(String resourceId, Map<String,Object> properties) throws SecurityContextContainerException;
		
	/**
	 * Removes security context (also from cache). Returns the last recorded state.
	 * @param secCtxId
	 * @return SecurityContext
	 * @exception SecurityContextContainerException
	 */
	public SecurityContext deleteContext(String secCtxId) throws SecurityContextContainerException;
		
}
