use of org.aspectj.lang.reflect.CodeSignature in project spring-security by spring-projects.
the class AspectJMethodSecurityInterceptorTests method setUp.
// ~ Methods
// ========================================================================================================
@Before
public final void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
SecurityContextHolder.clearContext();
token = new TestingAuthenticationToken("Test", "Password");
interceptor = new AspectJMethodSecurityInterceptor();
interceptor.setAccessDecisionManager(adm);
interceptor.setAuthenticationManager(authman);
interceptor.setSecurityMetadataSource(mds);
// Set up joinpoint information for the countLength method on TargetObject
// new MockJoinPoint(new
joinPoint = mock(ProceedingJoinPoint.class);
// TargetObject(), method);
Signature sig = mock(Signature.class);
when(sig.getDeclaringType()).thenReturn(TargetObject.class);
JoinPoint.StaticPart staticPart = mock(JoinPoint.StaticPart.class);
when(joinPoint.getSignature()).thenReturn(sig);
when(joinPoint.getStaticPart()).thenReturn(staticPart);
CodeSignature codeSig = mock(CodeSignature.class);
when(codeSig.getName()).thenReturn("countLength");
when(codeSig.getDeclaringType()).thenReturn(TargetObject.class);
when(codeSig.getParameterTypes()).thenReturn(new Class[] { String.class });
when(staticPart.getSignature()).thenReturn(codeSig);
when(mds.getAttributes(any(JoinPoint.class))).thenReturn(SecurityConfig.createList("ROLE_USER"));
when(authman.authenticate(token)).thenReturn(token);
}
use of org.aspectj.lang.reflect.CodeSignature in project AndroidDevMetrics by frogermcs.
the class Dagger2GraphAnalyzer method logAndExecute.
@Around("providesMethod() || injectConstructor()")
public Object logAndExecute(ProceedingJoinPoint joinPoint) throws Throwable {
long start = System.nanoTime();
Object result = joinPoint.proceed();
long stop = System.nanoTime();
long took = TimeUnit.NANOSECONDS.toMillis(stop - start);
if (!enabled) {
return result;
}
CodeSignature codeSignature = (CodeSignature) joinPoint.getSignature();
Class<?> cls = codeSignature.getDeclaringType();
if (codeSignature instanceof ConstructorSignature) {
InitManager.getInstance().addInitMetric(cls, joinPoint.getArgs(), took);
}
if (isMethodWithReturnType(codeSignature)) {
if (result != null) {
InitManager.getInstance().addInitMetric(result.getClass(), joinPoint.getArgs(), took);
}
}
return result;
}
use of org.aspectj.lang.reflect.CodeSignature in project hugo by JakeWharton.
the class Hugo method enterMethod.
private static void enterMethod(JoinPoint joinPoint) {
if (!enabled)
return;
CodeSignature codeSignature = (CodeSignature) joinPoint.getSignature();
Class<?> cls = codeSignature.getDeclaringType();
String methodName = codeSignature.getName();
String[] parameterNames = codeSignature.getParameterNames();
Object[] parameterValues = joinPoint.getArgs();
StringBuilder builder = new StringBuilder("⇢ ");
builder.append(methodName).append('(');
for (int i = 0; i < parameterValues.length; i++) {
if (i > 0) {
builder.append(", ");
}
builder.append(parameterNames[i]).append('=');
builder.append(Strings.toString(parameterValues[i]));
}
builder.append(')');
if (Looper.myLooper() != Looper.getMainLooper()) {
builder.append(" [Thread:\"").append(Thread.currentThread().getName()).append("\"]");
}
Log.v(asTag(cls), builder.toString());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
final String section = builder.toString().substring(2);
Trace.beginSection(section);
}
}
Aggregations