![JAR search and dependency download from the Maven repository](/logo.png)
com.linkare.zas.aspectj.InvokerController.aj Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of zas-impl Show documentation
Show all versions of zas-impl Show documentation
The AspectJ based implementation of the Zas project. This is the new version of the implementation of Zas which, initially, started as a M.Sc. thesis project by Paulo Zenida at ISCTE.
The newest version!
package com.linkare.zas.aspectj;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import com.linkare.zas.annotation.AllowedInvokers;
import com.linkare.zas.api.IAOPMetaData;
import com.linkare.zas.api.ZasInitializer;
import com.linkare.zas.aspectj.accessinfo.AOPMetaData;
import com.linkare.zas.aspectj.accessinfo.ConstructorSignature;
import com.linkare.zas.aspectj.accessinfo.MethodSignature;
import com.linkare.zas.aspectj.utils.BaseZas;
import com.linkare.zas.aspectj.utils.ZasUtils;
import com.linkare.zas.config.Configuration;
/**
*
* @author Paulo Zenida - Linkare TI
*
* @param
*/
public abstract aspect InvokerController extends BaseZas {
@ZasInitializer
protected InvokerController() {
}
// Pointcuts
private pointcut exceptionJoinPoints() : within(InvokerController+) || within(Enforcer+) || within(Truster+);
/**
* This pointcut controls whether this aspect's behavior should be enabled or not. Its implementation depends on the AspectJ language being active, as
* defined in BaseZas
, and the method isInvokerControlEnabled()
method returning true.
*/
public pointcut enabled() : BaseZas.enabled() && if(Configuration.isInvokerControlEnabled());
public pointcut allowedInvokers(final AllowedInvokers allowedInvokers) :
(call(@AllowedInvokers * *..*.*(..)) || call(@AllowedInvokers *..*.new(..))) && @annotation(allowedInvokers) && weavingContext();
after(final AllowedInvokers allowedInvokers) : allowedInvokers(allowedInvokers) {
final IAOPMetaData aopMetaData = AOPMetaData.create(thisJoinPoint, thisEnclosingJoinPointStaticPart);
if (SharedSecurityContext.getCurrentJoinPointAllowedInvokersResult() != null
&& SharedSecurityContext.getCurrentJoinPointAllowedInvokersResult().getSignature().equals(aopMetaData.getJoinPoint().getSignature())) {
SharedSecurityContext.setCurrentJoinPointAllowedInvokersResult(null);
}
}
before(final AllowedInvokers allowedInvokers) : allowedInvokers(allowedInvokers) {
final IAOPMetaData aopMetaData = AOPMetaData.create(thisJoinPoint, thisEnclosingJoinPointStaticPart);
String callerSignature = null;
if (aopMetaData.getEnclosingStaticPart().getKind().isMethod()) {
final Method method = ((MethodSignature) aopMetaData.getEnclosingStaticPart().getSignature()).getMethod();
callerSignature = ZasUtils.discardReturnTypeFromSignature(method.toString());
} else {
final Constructor extends Object> constructor = ((ConstructorSignature) aopMetaData.getEnclosingStaticPart().getSignature()).getConstructor();
callerSignature = ZasUtils.discardReturnTypeFromSignature(constructor.toString());
}
for (final String method : allowedInvokers.value()) {
if (method.equals(callerSignature)) {
SharedSecurityContext.setCurrentJoinPointAllowedInvokersResult(SharedSecurityContext.buildCurrentJoinPointBooleanResult(aopMetaData.getJoinPoint()
.getSignature(),
true));
return;
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy