use of org.camunda.bpm.engine.impl.identity.Authentication in project camunda-bpm-platform by camunda.
the class TaskAttachmentResourceImpl method isHistoryEnabled.
private boolean isHistoryEnabled() {
IdentityService identityService = engine.getIdentityService();
Authentication currentAuthentication = identityService.getCurrentAuthentication();
try {
identityService.clearAuthentication();
int historyLevel = engine.getManagementService().getHistoryLevel();
return historyLevel > ProcessEngineConfigurationImpl.HISTORYLEVEL_NONE;
} finally {
identityService.setAuthentication(currentAuthentication);
}
}
use of org.camunda.bpm.engine.impl.identity.Authentication 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.identity.Authentication in project camunda-bpm-platform by camunda.
the class AuthorizationManager method checkAuthorization.
public void checkAuthorization(List<PermissionCheck> permissionChecks) {
if (isAuthCheckExecuted()) {
Authentication currentAuthentication = getCurrentAuthentication();
String userId = currentAuthentication.getUserId();
boolean isAuthorized = isAuthorized(userId, currentAuthentication.getGroupIds(), permissionChecks);
if (!isAuthorized) {
List<MissingAuthorization> missingAuthorizations = new ArrayList<MissingAuthorization>();
for (PermissionCheck check : permissionChecks) {
missingAuthorizations.add(new MissingAuthorization(check.getPermission().getName(), check.getResource().resourceName(), check.getResourceId()));
}
throw new AuthorizationException(userId, missingAuthorizations);
}
}
}
use of org.camunda.bpm.engine.impl.identity.Authentication in project camunda-bpm-platform by camunda.
the class AuthorizationManager method checkCamundaAdmin.
// predefined authorization checks
/* MEMBER OF CAMUNDA_ADMIN */
/**
* Checks if the current authentication contains the group
* {@link Groups#CAMUNDA_ADMIN}. The check is ignored if the authorization is
* disabled or no authentication exists.
*
* @throws AuthorizationException
*/
public void checkCamundaAdmin() {
final Authentication currentAuthentication = getCurrentAuthentication();
CommandContext commandContext = Context.getCommandContext();
if (isAuthorizationEnabled() && commandContext.isAuthorizationCheckEnabled() && currentAuthentication != null && !isCamundaAdmin(currentAuthentication)) {
throw LOG.requiredCamundaAdminException();
}
}
use of org.camunda.bpm.engine.impl.identity.Authentication in project camunda-bpm-platform by camunda.
the class AuthorizationManager method checkAuthorization.
public void checkAuthorization(CompositePermissionCheck compositePermissionCheck) {
if (isAuthCheckExecuted()) {
Authentication currentAuthentication = getCurrentAuthentication();
String userId = currentAuthentication.getUserId();
boolean isAuthorized = isAuthorized(compositePermissionCheck);
if (!isAuthorized) {
List<MissingAuthorization> missingAuthorizations = new ArrayList<MissingAuthorization>();
for (PermissionCheck check : compositePermissionCheck.getAllPermissionChecks()) {
missingAuthorizations.add(new MissingAuthorization(check.getPermission().getName(), check.getResource().resourceName(), check.getResourceId()));
}
throw new AuthorizationException(userId, missingAuthorizations);
}
}
}
Aggregations