use of org.camunda.bpm.engine.impl.db.AuthorizationCheck in project camunda-bpm-platform by camunda.
the class AuthorizationManager method configureQuery.
// authorization checks on queries ////////////////////////////////
public void configureQuery(ListQueryParameterObject query) {
AuthorizationCheck authCheck = query.getAuthCheck();
authCheck.getPermissionChecks().clear();
if (isAuthCheckExecuted()) {
Authentication currentAuthentication = getCurrentAuthentication();
authCheck.setAuthUserId(currentAuthentication.getUserId());
authCheck.setAuthGroupIds(currentAuthentication.getGroupIds());
enableQueryAuthCheck(authCheck);
} else {
authCheck.setAuthorizationCheckEnabled(false);
authCheck.setAuthUserId(null);
authCheck.setAuthGroupIds(null);
}
}
use of org.camunda.bpm.engine.impl.db.AuthorizationCheck in project camunda-bpm-platform by camunda.
the class AuthorizationManager method isAuthorized.
public boolean isAuthorized(String userId, List<String> groupIds, CompositePermissionCheck compositePermissionCheck) {
List<String> filteredGroupIds = filterAuthenticatedGroupIds(groupIds);
boolean isRevokeAuthorizationCheckEnabled = isRevokeAuthCheckEnabled(userId, groupIds);
AuthorizationCheck authCheck = new AuthorizationCheck(userId, filteredGroupIds, compositePermissionCheck, isRevokeAuthorizationCheckEnabled);
return getDbEntityManager().selectBoolean("isUserAuthorizedForResource", authCheck);
}
use of org.camunda.bpm.engine.impl.db.AuthorizationCheck in project camunda-bpm-platform by camunda.
the class AuthorizationCheckRevokesCfgTest method shouldCheckDbForCfgValueWithNoRevokes_auto.
@Test
public void shouldCheckDbForCfgValueWithNoRevokes_auto() {
final ListQueryParameterObject query = new ListQueryParameterObject();
final AuthorizationCheck authCheck = query.getAuthCheck();
final HashMap<String, Object> expectedQueryParams = new HashMap<String, Object>();
expectedQueryParams.put("userId", AUTHENTICATED_USER_ID);
expectedQueryParams.put("authGroupIds", AUTHENTICATED_GROUPS);
// given
when(mockedConfiguration.getAuthorizationCheckRevokes()).thenReturn(ProcessEngineConfiguration.AUTHORIZATION_CHECK_REVOKE_AUTO);
when(mockedEntityManager.selectBoolean(eq("selectRevokeAuthorization"), eq(expectedQueryParams))).thenReturn(false);
// if
authorizationManager.configureQuery(query);
// then
assertEquals(false, authCheck.isRevokeAuthorizationCheckEnabled());
verify(mockedEntityManager, times(1)).selectBoolean(eq("selectRevokeAuthorization"), eq(expectedQueryParams));
}
use of org.camunda.bpm.engine.impl.db.AuthorizationCheck in project camunda-bpm-platform by camunda.
the class AuthorizationCheckRevokesCfgTest method shouldCheckDbForCfgValue_auto.
@Test
public void shouldCheckDbForCfgValue_auto() {
final ListQueryParameterObject query = new ListQueryParameterObject();
final AuthorizationCheck authCheck = query.getAuthCheck();
final HashMap<String, Object> expectedQueryParams = new HashMap<String, Object>();
expectedQueryParams.put("userId", AUTHENTICATED_USER_ID);
expectedQueryParams.put("authGroupIds", AUTHENTICATED_GROUPS);
// given
when(mockedConfiguration.getAuthorizationCheckRevokes()).thenReturn(ProcessEngineConfiguration.AUTHORIZATION_CHECK_REVOKE_AUTO);
when(mockedEntityManager.selectBoolean(eq("selectRevokeAuthorization"), eq(expectedQueryParams))).thenReturn(true);
// if
authorizationManager.configureQuery(query);
// then
assertEquals(true, authCheck.isRevokeAuthorizationCheckEnabled());
verify(mockedEntityManager, times(1)).selectBoolean(eq("selectRevokeAuthorization"), eq(expectedQueryParams));
}
use of org.camunda.bpm.engine.impl.db.AuthorizationCheck in project camunda-bpm-platform by camunda.
the class AuthorizationCheckRevokesCfgTest method shouldCheckDbForCfgCaseInsensitive.
@Test
public void shouldCheckDbForCfgCaseInsensitive() {
final ListQueryParameterObject query = new ListQueryParameterObject();
final AuthorizationCheck authCheck = query.getAuthCheck();
final HashMap<String, Object> expectedQueryParams = new HashMap<String, Object>();
expectedQueryParams.put("userId", AUTHENTICATED_USER_ID);
expectedQueryParams.put("authGroupIds", AUTHENTICATED_GROUPS);
// given
when(mockedConfiguration.getAuthorizationCheckRevokes()).thenReturn("AuTo");
when(mockedEntityManager.selectBoolean(eq("selectRevokeAuthorization"), eq(expectedQueryParams))).thenReturn(true);
// if
authorizationManager.configureQuery(query);
// then
assertEquals(true, authCheck.isRevokeAuthorizationCheckEnabled());
verify(mockedEntityManager, times(1)).selectBoolean(eq("selectRevokeAuthorization"), eq(expectedQueryParams));
}
Aggregations