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

com.linkare.zas.aspectj.utils.BaseZas.aj Maven / Gradle / Ivy

package com.linkare.zas.aspectj.utils;

import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;

import org.aspectj.lang.annotation.SuppressAjWarnings;

import com.linkare.booleval.ExpressionParser;
import com.linkare.zas.config.AccessRequirementSpecificationMode;
import com.linkare.zas.config.Configuration;
import com.linkare.zas.metainfo.ZasBaseRequirement;

/**
 * 
 * @author Paulo Zenida - Linkare TI
 * 
 * @param 
 */
@SuppressAjWarnings("adviceDidNotMatch")
public abstract class BaseZas implements IEnableAspect, IWeavingContextAspect, IPrecedenceManagerAspect {

    private static Map externalRequirementsSpecification = new LinkedHashMap();

    /**
     * It registers the access control requirements loaded from an external source. This method is static-private so that it can be accessed only by classes in
     * the same package, namely by class ZasXmlFileRequirementProcessor.
     * 
     * @param requirements
     *            The external access control requirements that have been loaded.
     */
    static void registerExternalRequirements(final Map requirements) {
	externalRequirementsSpecification = requirements;
    }

    /**
     * @param protectedObject
     *            The protected object's signature.
     * @return Returns a new instance of ZasBaseRequirement if there is any requirement specified for the protected object
     *         protectedObject passed in as argument. It returns null otherwise.
     */
    protected static ZasBaseRequirement getExternalRequirement(final String protectedObject) {
	final Set keys = externalRequirementsSpecification.keySet();
	for (final String key : keys) {
	    if (ExpressionParser.areExpressionsEquivalent(key, protectedObject))
		return externalRequirementsSpecification.get(key);
	}
	return null;
    }

    /**
     * Since all aspects in Zás extend from BaseZas, this constructor loads all the access control policy, if the method
     * isFileReadingEnabled() returns true.
     * 
     * @see AccessRequirementSpecificationMode#isFileReadingEnabled()
     */
    protected BaseZas() {
	//	if (Configuration.getAccessRequirementSpecificationMode().isFileReadingEnabled()) {
	//	    ZasXmlFileRequirementProcessor.load(Configuration.getAccessControlRequirementsFilename());
	//	}
    }

    public static Configuration getConfiguration() {
	return Configuration.getInstance();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy