use of org.aopalliance.intercept.MethodInvocation in project spring-security by spring-projects.
the class AbstractAclVoterTests method correctArgumentIsSelectedFromMultipleArgs.
@Test
public void correctArgumentIsSelectedFromMultipleArgs() throws Exception {
voter.setProcessDomainObjectClass(String.class);
MethodInvocation mi = MethodInvocationUtils.create(new TestClass(), "methodTakingAListAndAString", new ArrayList<Object>(), "The Argument");
assertThat(voter.getDomainObjectInstance(mi)).isEqualTo("The Argument");
}
use of org.aopalliance.intercept.MethodInvocation in project spring-security by spring-projects.
the class MethodInvocationUtilsTests method createFromClassReturnsMethodWithNoArgInfoForMethodWithNoArgs.
@Test
public void createFromClassReturnsMethodWithNoArgInfoForMethodWithNoArgs() {
new MethodInvocationUtils();
MethodInvocation mi = MethodInvocationUtils.createFromClass(String.class, "length");
assertThat(mi).isNotNull();
}
use of org.aopalliance.intercept.MethodInvocation in project spring-security by spring-projects.
the class MethodInvocationUtilsTests method createFromClassReturnsMethodIfArgInfoOmittedAndMethodNameIsUnique.
@Test
public void createFromClassReturnsMethodIfArgInfoOmittedAndMethodNameIsUnique() {
MethodInvocation mi = MethodInvocationUtils.createFromClass(BusinessServiceImpl.class, "methodReturningAnArray");
assertThat(mi).isNotNull();
}
use of org.aopalliance.intercept.MethodInvocation in project spring-security by spring-projects.
the class ContextPropagatingRemoteInvocationTests method getRemoteInvocation.
private ContextPropagatingRemoteInvocation getRemoteInvocation() throws Exception {
Class<TargetObject> clazz = TargetObject.class;
Method method = clazz.getMethod("makeLowerCase", new Class[] { String.class });
MethodInvocation mi = new SimpleMethodInvocation(new TargetObject(), method, "SOME_STRING");
ContextPropagatingRemoteInvocationFactory factory = new ContextPropagatingRemoteInvocationFactory();
return (ContextPropagatingRemoteInvocation) factory.createRemoteInvocation(mi);
}
use of org.aopalliance.intercept.MethodInvocation in project midpoint by Evolveum.
the class SecurityEnforcerImpl method decide.
/**
* Spring security method. It is practically applicable only for simple cases.
*/
@Override
public void decide(Authentication authentication, Object object, Collection<ConfigAttribute> configAttributes) throws AccessDeniedException, InsufficientAuthenticationException {
if (object instanceof MethodInvocation) {
MethodInvocation methodInvocation = (MethodInvocation) object;
// TODO
} else if (object instanceof FilterInvocation) {
FilterInvocation filterInvocation = (FilterInvocation) object;
// TODO
} else {
SecurityUtil.logSecurityDeny(object, ": Unknown type of secure object");
throw new IllegalArgumentException("Unknown type of secure object");
}
Object principalObject = authentication.getPrincipal();
if (!(principalObject instanceof MidPointPrincipal)) {
if (authentication.getPrincipal() instanceof String && "anonymousUser".equals(principalObject)) {
SecurityUtil.logSecurityDeny(object, ": Not logged in");
throw new InsufficientAuthenticationException("Not logged in.");
}
throw new IllegalArgumentException("Expected that spring security principal will be of type " + MidPointPrincipal.class.getName() + " but it was " + principalObject.getClass());
}
Collection<String> configActions = SecurityUtil.getActions(configAttributes);
for (String configAction : configActions) {
boolean isAuthorized;
try {
isAuthorized = isAuthorized(configAction, null, null, null, null, null);
} catch (SchemaException e) {
throw new SystemException(e.getMessage(), e);
}
if (isAuthorized) {
return;
}
}
SecurityUtil.logSecurityDeny(object, ": Not authorized", null, configActions);
// Better message is logged.
throw new AccessDeniedException("Not authorized");
}
Aggregations