Search in sources :

Example 1 with AuthorizationBootstrapper

use of co.cask.cdap.security.authorization.AuthorizationBootstrapper in project cdap by caskdata.

the class AuthorizationBootstrapperTest method setup.

@BeforeClass
public static void setup() throws Exception {
    CConfiguration cConf = CConfiguration.create();
    cConf.set(Constants.CFG_LOCAL_DATA_DIR, TMP_FOLDER.newFolder().getAbsolutePath());
    cConf.setBoolean(Constants.Security.ENABLED, true);
    cConf.setBoolean(Constants.Security.KERBEROS_ENABLED, false);
    cConf.setBoolean(Constants.Security.Authorization.ENABLED, true);
    Location deploymentJar = AppJarHelper.createDeploymentJar(new LocalLocationFactory(TMP_FOLDER.newFolder()), InMemoryAuthorizer.class);
    cConf.set(Constants.Security.Authorization.EXTENSION_JAR_PATH, deploymentJar.toURI().getPath());
    // make Alice an admin user, so she can create namespaces
    cConf.set(Constants.Security.Authorization.ADMIN_USERS, ADMIN_USER.getName());
    instanceId = new InstanceId(cConf.get(Constants.INSTANCE_NAME));
    // setup a system artifact
    File systemArtifactsDir = TMP_FOLDER.newFolder();
    cConf.set(Constants.AppFabric.SYSTEM_ARTIFACTS_DIR, systemArtifactsDir.getAbsolutePath());
    createSystemArtifact(systemArtifactsDir);
    Injector injector = Guice.createInjector(new AppFabricTestModule(cConf));
    namespaceQueryAdmin = injector.getInstance(NamespaceQueryAdmin.class);
    namespaceAdmin = injector.getInstance(NamespaceAdmin.class);
    defaultNamespaceEnsurer = new DefaultNamespaceEnsurer(namespaceAdmin);
    discoveryServiceClient = injector.getInstance(DiscoveryServiceClient.class);
    txManager = injector.getInstance(TransactionManager.class);
    datasetService = injector.getInstance(DatasetService.class);
    systemArtifactLoader = injector.getInstance(SystemArtifactLoader.class);
    authorizationBootstrapper = injector.getInstance(AuthorizationBootstrapper.class);
    artifactRepository = injector.getInstance(ArtifactRepository.class);
    dsFramework = injector.getInstance(DatasetFramework.class);
    authorizationEnforcer = injector.getInstance(AuthorizationEnforcer.class);
}
Also used : DiscoveryServiceClient(org.apache.twill.discovery.DiscoveryServiceClient) InstanceId(co.cask.cdap.proto.id.InstanceId) NamespaceAdmin(co.cask.cdap.common.namespace.NamespaceAdmin) DatasetService(co.cask.cdap.data2.datafabric.dataset.service.DatasetService) ArtifactRepository(co.cask.cdap.internal.app.runtime.artifact.ArtifactRepository) AuthorizationEnforcer(co.cask.cdap.security.spi.authorization.AuthorizationEnforcer) DefaultNamespaceEnsurer(co.cask.cdap.internal.app.namespace.DefaultNamespaceEnsurer) CConfiguration(co.cask.cdap.common.conf.CConfiguration) DatasetFramework(co.cask.cdap.data2.dataset2.DatasetFramework) AuthorizationBootstrapper(co.cask.cdap.security.authorization.AuthorizationBootstrapper) Injector(com.google.inject.Injector) TransactionManager(org.apache.tephra.TransactionManager) SystemArtifactLoader(co.cask.cdap.internal.app.runtime.artifact.SystemArtifactLoader) NamespaceQueryAdmin(co.cask.cdap.common.namespace.NamespaceQueryAdmin) AppFabricTestModule(co.cask.cdap.internal.guice.AppFabricTestModule) LocalLocationFactory(org.apache.twill.filesystem.LocalLocationFactory) File(java.io.File) Location(org.apache.twill.filesystem.Location) BeforeClass(org.junit.BeforeClass)

Aggregations

CConfiguration (co.cask.cdap.common.conf.CConfiguration)1 NamespaceAdmin (co.cask.cdap.common.namespace.NamespaceAdmin)1 NamespaceQueryAdmin (co.cask.cdap.common.namespace.NamespaceQueryAdmin)1 DatasetService (co.cask.cdap.data2.datafabric.dataset.service.DatasetService)1 DatasetFramework (co.cask.cdap.data2.dataset2.DatasetFramework)1 DefaultNamespaceEnsurer (co.cask.cdap.internal.app.namespace.DefaultNamespaceEnsurer)1 ArtifactRepository (co.cask.cdap.internal.app.runtime.artifact.ArtifactRepository)1 SystemArtifactLoader (co.cask.cdap.internal.app.runtime.artifact.SystemArtifactLoader)1 AppFabricTestModule (co.cask.cdap.internal.guice.AppFabricTestModule)1 InstanceId (co.cask.cdap.proto.id.InstanceId)1 AuthorizationBootstrapper (co.cask.cdap.security.authorization.AuthorizationBootstrapper)1 AuthorizationEnforcer (co.cask.cdap.security.spi.authorization.AuthorizationEnforcer)1 Injector (com.google.inject.Injector)1 File (java.io.File)1 TransactionManager (org.apache.tephra.TransactionManager)1 DiscoveryServiceClient (org.apache.twill.discovery.DiscoveryServiceClient)1 LocalLocationFactory (org.apache.twill.filesystem.LocalLocationFactory)1 Location (org.apache.twill.filesystem.Location)1 BeforeClass (org.junit.BeforeClass)1