com.linkare.zas.aspectj.Truster.aj Maven / Gradle / Ivy
package com.linkare.zas.aspectj;
import static com.linkare.zas.aspectj.SharedSecurityContext.*;
import org.aspectj.lang.annotation.SuppressAjWarnings;
import com.linkare.zas.annotation.Trusts;
import com.linkare.zas.api.IAOPMetaData;
import com.linkare.zas.api.TrusterAdvise;
import com.linkare.zas.api.ZasInitializer;
import com.linkare.zas.aspectj.accessinfo.AOPMetaData;
import com.linkare.zas.aspectj.utils.BaseZas;
/**
*
* @author Paulo Zenida - Linkare TI
*
*/
@SuppressWarnings("unchecked")
@SuppressAjWarnings("adviceDidNotMatch")
public abstract aspect Truster extends BaseZas {
@ZasInitializer
protected Truster() {
}
// Pointcuts
protected pointcut exceptionJoinPoints() :
within(Truster+) ||
within(Enforcer+) ||
within(Logger+) ||
within(StackOfSubjectsBuilder+) ||
within(InvokerController+) ||
within(ZasXmlFileRequirementProcessor);
@SuppressWarnings("unchecked")
@TrusterAdvise
@SuppressAjWarnings("adviceDidNotMatch")
after(final Trusts trusts) :
enabled() && !exceptionJoinPoints() && (call(@Trusts * *..*.*(..)) || call(@Trusts *..*.new(..))) && @annotation(trusts) && weavingContext() {
final IAOPMetaData aopMetaData = AOPMetaData.create(thisJoinPoint, thisEnclosingJoinPointStaticPart);
if (getCurrentJoinPointTrustResult() != null && getCurrentJoinPointTrustResult().getSignature().equals(aopMetaData.getJoinPoint().getSignature())) {
setCurrentJoinPointTrustResult(null);
}
}
@SuppressWarnings("unchecked")
@TrusterAdvise
@SuppressAjWarnings("adviceDidNotMatch")
before(final Trusts trusts) :
enabled() && !exceptionJoinPoints() && (call(@Trusts * *..*.*(..)) || call(@Trusts *..*.new(..))) && @annotation(trusts) && weavingContext() {
final IAOPMetaData aopMetaData = AOPMetaData.create(thisJoinPoint, thisEnclosingJoinPointStaticPart);
final Class extends Object> callerClass = aopMetaData.getEnclosingStaticPart().getSignature().getDeclaringType();
for (final Class clazz : trusts.value()) {
if (clazz == callerClass) {
setCurrentJoinPointTrustResult(buildCurrentJoinPointBooleanResult(aopMetaData.getJoinPoint().getSignature(), true));
return;
}
}
}
}