Search in sources :

Example 1 with AuthorizationManager

use of org.camunda.bpm.engine.impl.persistence.entity.AuthorizationManager 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);
}
Also used : CommandContext(org.camunda.bpm.engine.impl.interceptor.CommandContext) Authentication(org.camunda.bpm.engine.impl.identity.Authentication) AuthorizationManager(org.camunda.bpm.engine.impl.persistence.entity.AuthorizationManager) DbEntityManager(org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager) ProcessEngineConfigurationImpl(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl) Before(org.junit.Before)

Example 2 with AuthorizationManager

use of org.camunda.bpm.engine.impl.persistence.entity.AuthorizationManager in project camunda-bpm-platform by camunda.

the class DeleteAuthorizationCmd method execute.

public Void execute(CommandContext commandContext) {
    final AuthorizationManager authorizationManager = commandContext.getAuthorizationManager();
    AuthorizationEntity authorization = (AuthorizationEntity) new AuthorizationQueryImpl().authorizationId(authorizationId).singleResult();
    ensureNotNull("Authorization for Id '" + authorizationId + "' does not exist", "authorization", authorization);
    authorizationManager.delete(authorization);
    return null;
}
Also used : AuthorizationQueryImpl(org.camunda.bpm.engine.impl.AuthorizationQueryImpl) AuthorizationEntity(org.camunda.bpm.engine.impl.persistence.entity.AuthorizationEntity) AuthorizationManager(org.camunda.bpm.engine.impl.persistence.entity.AuthorizationManager)

Aggregations

AuthorizationManager (org.camunda.bpm.engine.impl.persistence.entity.AuthorizationManager)2 AuthorizationQueryImpl (org.camunda.bpm.engine.impl.AuthorizationQueryImpl)1 ProcessEngineConfigurationImpl (org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)1 DbEntityManager (org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager)1 Authentication (org.camunda.bpm.engine.impl.identity.Authentication)1 CommandContext (org.camunda.bpm.engine.impl.interceptor.CommandContext)1 AuthorizationEntity (org.camunda.bpm.engine.impl.persistence.entity.AuthorizationEntity)1 Before (org.junit.Before)1