use of gov.ca.cwds.security.permission.AbacPermission in project perry by ca-cwds.
the class DefaultStaticAuthorizer method authorize.
@Override
public void authorize(PerryAccount perryAccount, SimpleAuthorizationInfo authorizationInfo) {
Optional.ofNullable(perryAccount.getRoles()).ifPresent(authorizationInfo::addRoles);
authorizationInfo.addObjectPermission(new AbacPermission());
}
use of gov.ca.cwds.security.permission.AbacPermission in project perry by ca-cwds.
the class AbacMethodInterceptor method checkPermission.
@SuppressWarnings("unchecked")
private void checkPermission(String permission, Object arg) throws ScriptException {
AbacPermission abacPermission = new AbacPermission(permission);
String selector = abacPermission.getSecuredObject().toString();
int dotIndex = selector.indexOf('.');
String identifier;
if (dotIndex == -1) {
identifier = selector;
} else {
identifier = selector.substring(0, dotIndex);
}
ScriptContext scriptContext = new SimpleScriptContext();
scriptContext.setAttribute(identifier, arg, ScriptContext.ENGINE_SCOPE);
for (Object o : (Collection<Object>) scriptEngine.eval("[" + selector + "].flatten()", scriptContext)) {
abacPermission.setSecuredObject(o);
SecurityUtils.getSubject().checkPermission(abacPermission);
}
}
Aggregations