use of org.pentaho.platform.api.engine.IAuthorizationAction in project pentaho-platform by pentaho.
the class AuthorizationActionService method validateAuth.
public boolean validateAuth(String authAction) {
boolean isAllowed = false;
boolean validInput = false;
for (IAuthorizationAction a : getActionList()) {
if (a.getName().equals(authAction)) {
validInput = true;
break;
}
}
if (validInput) {
IAuthorizationPolicy policy = getPolicy();
isAllowed = policy.isAllowed(authAction);
}
return isAllowed;
}
use of org.pentaho.platform.api.engine.IAuthorizationAction in project pentaho-platform by pentaho.
the class AuthorizationActionServiceTest method testDoValidateAuth.
@Test
public void testDoValidateAuth() {
IAuthorizationPolicy policy = mock(IAuthorizationPolicy.class);
List<IAuthorizationAction> actions = new ArrayList();
actions.add(new AdministerSecurityAction());
doReturn(actions).when(authorizationActionService).getActionList();
doReturn(policy).when(authorizationActionService).getPolicy();
doReturn(true).when(policy).isAllowed("org.pentaho.security.administerSecurity");
boolean isAllowed = authorizationActionService.validateAuth("org.pentaho.security.administerSecurity");
assertEquals(isAllowed, true);
isAllowed = authorizationActionService.validateAuth("invalid-auth");
assertEquals(isAllowed, false);
}
Aggregations