use of org.camunda.bpm.engine.impl.identity.Authentication in project camunda-bpm-platform by camunda.
the class AuthorizationCheckRevokesCfgTest method setup.
@Before
public void setup() {
mockedCmdContext = mock(CommandContext.class);
mockedConfiguration = mock(ProcessEngineConfigurationImpl.class);
authorizationManager = spy(new AuthorizationManager());
mockedEntityManager = mock(DbEntityManager.class);
when(mockedCmdContext.getSession(eq(DbEntityManager.class))).thenReturn(mockedEntityManager);
when(authorizationManager.filterAuthenticatedGroupIds(eq(AUTHENTICATED_GROUPS))).thenReturn(AUTHENTICATED_GROUPS);
when(mockedCmdContext.getAuthentication()).thenReturn(new Authentication(AUTHENTICATED_USER_ID, AUTHENTICATED_GROUPS));
when(mockedCmdContext.isAuthorizationCheckEnabled()).thenReturn(true);
when(mockedConfiguration.isAuthorizationEnabled()).thenReturn(true);
Context.setCommandContext(mockedCmdContext);
Context.setProcessEngineConfiguration(mockedConfiguration);
}
use of org.camunda.bpm.engine.impl.identity.Authentication in project camunda-bpm-platform by camunda.
the class DefaultAuthorizationProvider method newDeployment.
// Deployment ///////////////////////////////////////////////
public AuthorizationEntity[] newDeployment(Deployment deployment) {
ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration();
IdentityService identityService = processEngineConfiguration.getIdentityService();
Authentication currentAuthentication = identityService.getCurrentAuthentication();
if (currentAuthentication != null && currentAuthentication.getUserId() != null) {
String userId = currentAuthentication.getUserId();
String deploymentId = deployment.getId();
AuthorizationEntity authorization = createGrantAuthorization(userId, null, DEPLOYMENT, deploymentId, READ, DELETE);
return new AuthorizationEntity[] { authorization };
}
return null;
}
use of org.camunda.bpm.engine.impl.identity.Authentication in project camunda-bpm-platform by camunda.
the class AuthorizationManager method checkAuthorization.
@Override
public void checkAuthorization(Permission permission, Resource resource, String resourceId) {
if (isAuthCheckExecuted()) {
Authentication currentAuthentication = getCurrentAuthentication();
boolean isAuthorized = isAuthorized(currentAuthentication.getUserId(), currentAuthentication.getGroupIds(), permission, resource, resourceId);
if (!isAuthorized) {
throw new AuthorizationException(currentAuthentication.getUserId(), permission.getName(), resource.resourceName(), resourceId);
}
}
}
use of org.camunda.bpm.engine.impl.identity.Authentication in project camunda-bpm-platform by camunda.
the class AuthorizationManager method isAuthCheckExecuted.
protected boolean isAuthCheckExecuted() {
Authentication currentAuthentication = getCurrentAuthentication();
CommandContext commandContext = Context.getCommandContext();
return isAuthorizationEnabled() && commandContext.isAuthorizationCheckEnabled() && currentAuthentication != null && currentAuthentication.getUserId() != null;
}
use of org.camunda.bpm.engine.impl.identity.Authentication in project camunda-bpm-platform by camunda.
the class AuthorizationTest method deleteDeployment.
protected void deleteDeployment(final String deploymentId, final boolean cascade) {
Authentication authentication = identityService.getCurrentAuthentication();
try {
identityService.clearAuthentication();
runWithoutAuthorization(new Callable<Void>() {
public Void call() throws Exception {
repositoryService.deleteDeployment(deploymentId, cascade);
return null;
}
});
} finally {
if (authentication != null) {
identityService.setAuthentication(authentication);
}
}
}
Aggregations