Search in sources :

Example 21 with Authentication

use of org.camunda.bpm.engine.impl.identity.Authentication in project camunda-bpm-platform by camunda.

the class MultiTenancyJobExecutorTest method hasAuthenticatedTenantId.

protected static DelegateExecutionAsserter hasAuthenticatedTenantId(final String expectedTenantId) {
    return new DelegateExecutionAsserter() {

        @Override
        public void doAssert(DelegateExecution execution) {
            IdentityService identityService = execution.getProcessEngineServices().getIdentityService();
            Authentication currentAuthentication = identityService.getCurrentAuthentication();
            assertThat(currentAuthentication, is(notNullValue()));
            assertThat(currentAuthentication.getTenantIds(), hasItem(expectedTenantId));
        }
    };
}
Also used : IdentityService(org.camunda.bpm.engine.IdentityService) Authentication(org.camunda.bpm.engine.impl.identity.Authentication) DelegateExecution(org.camunda.bpm.engine.delegate.DelegateExecution) DelegateExecutionAsserter(org.camunda.bpm.engine.test.api.delegate.AssertingJavaDelegate.DelegateExecutionAsserter)

Example 22 with Authentication

use of org.camunda.bpm.engine.impl.identity.Authentication in project camunda-bpm-platform by camunda.

the class MultiTenancyJobExecutorTest method hasNoAuthenticatedTenantId.

protected static DelegateExecutionAsserter hasNoAuthenticatedTenantId() {
    return new DelegateExecutionAsserter() {

        @Override
        public void doAssert(DelegateExecution execution) {
            IdentityService identityService = execution.getProcessEngineServices().getIdentityService();
            Authentication currentAuthentication = identityService.getCurrentAuthentication();
            assertThat(currentAuthentication, is(nullValue()));
        }
    };
}
Also used : IdentityService(org.camunda.bpm.engine.IdentityService) Authentication(org.camunda.bpm.engine.impl.identity.Authentication) DelegateExecution(org.camunda.bpm.engine.delegate.DelegateExecution) DelegateExecutionAsserter(org.camunda.bpm.engine.test.api.delegate.AssertingJavaDelegate.DelegateExecutionAsserter)

Example 23 with Authentication

use of org.camunda.bpm.engine.impl.identity.Authentication in project camunda-bpm-platform by camunda.

the class TenantManager method configureTenantCheck.

public void configureTenantCheck(TenantCheck tenantCheck) {
    if (isTenantCheckEnabled()) {
        Authentication currentAuthentication = getCurrentAuthentication();
        tenantCheck.setTenantCheckEnabled(true);
        tenantCheck.setAuthTenantIds(currentAuthentication.getTenantIds());
    } else {
        tenantCheck.setTenantCheckEnabled(false);
        tenantCheck.setAuthTenantIds(null);
    }
}
Also used : Authentication(org.camunda.bpm.engine.impl.identity.Authentication)

Example 24 with Authentication

use of org.camunda.bpm.engine.impl.identity.Authentication in project camunda-bpm-platform by camunda.

the class TenantManager method isAuthenticatedTenant.

public boolean isAuthenticatedTenant(String tenantId) {
    if (tenantId != null && isTenantCheckEnabled()) {
        Authentication currentAuthentication = getCurrentAuthentication();
        List<String> authenticatedTenantIds = currentAuthentication.getTenantIds();
        if (authenticatedTenantIds != null) {
            return authenticatedTenantIds.contains(tenantId);
        } else {
            return false;
        }
    } else {
        return true;
    }
}
Also used : Authentication(org.camunda.bpm.engine.impl.identity.Authentication)

Example 25 with Authentication

use of org.camunda.bpm.engine.impl.identity.Authentication in project camunda-bpm-platform by camunda.

the class IdentityServiceTest method testSetAuthenticatedUserGroupsAndTenants.

@Test
public void testSetAuthenticatedUserGroupsAndTenants() {
    List<String> groups = Arrays.asList("sales", "development");
    List<String> tenants = Arrays.asList("tenant1", "tenant2");
    identityService.setAuthentication("john", groups, tenants);
    Authentication currentAuthentication = identityService.getCurrentAuthentication();
    assertNotNull(currentAuthentication);
    assertEquals("john", currentAuthentication.getUserId());
    assertEquals(groups, currentAuthentication.getGroupIds());
    assertEquals(tenants, currentAuthentication.getTenantIds());
}
Also used : Authentication(org.camunda.bpm.engine.impl.identity.Authentication) Test(org.junit.Test)

Aggregations

Authentication (org.camunda.bpm.engine.impl.identity.Authentication)56 Test (org.junit.Test)29 Matchers.anyString (org.mockito.Matchers.anyString)22 ArrayList (java.util.ArrayList)9 IdentityService (org.camunda.bpm.engine.IdentityService)9 User (org.camunda.bpm.engine.identity.User)5 AuthorizationUtil (org.camunda.bpm.engine.rest.util.AuthorizationUtil)5 AuthorizationException (org.camunda.bpm.engine.AuthorizationException)4 Group (org.camunda.bpm.engine.identity.Group)4 GroupQuery (org.camunda.bpm.engine.identity.GroupQuery)4 UserQuery (org.camunda.bpm.engine.identity.UserQuery)4 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)3 CommandContext (org.camunda.bpm.engine.impl.interceptor.CommandContext)3 Parameters (org.junit.runners.Parameterized.Parameters)3 AuthorizationService (org.camunda.bpm.engine.AuthorizationService)2 Authorization (org.camunda.bpm.engine.authorization.Authorization)2 AuthorizationQuery (org.camunda.bpm.engine.authorization.AuthorizationQuery)2 MissingAuthorization (org.camunda.bpm.engine.authorization.MissingAuthorization)2 DelegateExecution (org.camunda.bpm.engine.delegate.DelegateExecution)2 ProcessEngineConfigurationImpl (org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)2