use of com.opensymphony.xwork2.config.entities.ActionConfig in project dhis2-core by dhis2.
the class XWorkSecurityInterceptor method intercept.
@Override
public String intercept(ActionInvocation invocation) throws Exception {
ActionConfig actionConfig = invocation.getProxy().getConfig();
definitionSourceTag.set(requiredAuthoritiesProvider.createSecurityMetadataSource(actionConfig));
InterceptorStatusToken token = beforeInvocation(actionConfig);
addActionAccessResolver(invocation);
Object result = null;
try {
result = invocation.invoke();
} finally {
result = afterInvocation(token, result);
definitionSourceTag.remove();
}
if (result != null) {
return result.toString();
}
return null;
}
use of com.opensymphony.xwork2.config.entities.ActionConfig in project dhis2-core by dhis2.
the class ActionAccessVoter method vote.
@Override
public int vote(Authentication authentication, Object object, Collection<ConfigAttribute> attributes) {
if (!supports(object.getClass())) {
LOG.debug("ACCESS_ABSTAIN [" + object.toString() + "]: Class not supported.");
return ACCESS_ABSTAIN;
}
ActionConfig actionConfig = (ActionConfig) object;
Collection<ConfigAttribute> requiredAuthorities = StrutsAuthorityUtils.getConfigAttributes(actionConfig, requiredAuthoritiesKey);
Collection<ConfigAttribute> anyAuthorities = StrutsAuthorityUtils.getConfigAttributes(actionConfig, anyAuthoritiesKey);
int allStatus = allAuthorities(authentication, object, requiredAuthorities);
if (allStatus == ACCESS_DENIED) {
return ACCESS_DENIED;
}
int anyStatus = anyAuthority(authentication, object, anyAuthorities);
if (anyStatus == ACCESS_DENIED) {
return ACCESS_DENIED;
}
if (allStatus == ACCESS_GRANTED || anyStatus == ACCESS_GRANTED) {
return ACCESS_GRANTED;
}
return ACCESS_ABSTAIN;
}
Aggregations