@Nullable public CConfiguration getCConf() { return (conf != null) ? CConfiguration.copy(conf) : null; }
/** * Prepares the resources that need to be localized to service containers. * * @param tempDir a temporary directory for creating files to be localized * @param hConf the hadoop configuration * @return a list of extra classpath that need to be added to each container. * @throws IOException if failed to prepare localize resources */ List<String> prepareLocalizeResource(Path tempDir, Configuration hConf) throws IOException { CConfiguration containerCConf = CConfiguration.copy(cConf); containerCConf.set(Constants.CFG_LOCAL_DATA_DIR, "data"); List<String> extraClassPath = new ArrayList<>(); prepareLogSaverResources(tempDir, containerCConf, runnableLocalizeResources.get(Constants.Service.LOGSAVER), extraClassPath); prepareHBaseDDLExecutorResources(tempDir, containerCConf); if (cConf.getBoolean(Constants.Explore.EXPLORE_ENABLED)) { prepareExploreResources(tempDir, hConf, runnableLocalizeResources.get(Constants.Service.EXPLORE_HTTP_USER_SERVICE), extraClassPath); } Path cConfPath = saveCConf(containerCConf, Files.createTempFile(tempDir, "cConf", ".xml")); Path hConfPath = saveHConf(hConf, Files.createTempFile(tempDir, "hConf", ".xml")); for (String service : ALL_SERVICES.keySet()) { Map<String, LocalizeResource> localizeResources = runnableLocalizeResources.get(service); localizeResources.put(CCONF_NAME, new LocalizeResource(cConfPath.toFile(), false)); localizeResources.put(HCONF_NAME, new LocalizeResource(hConfPath.toFile(), false)); } return extraClassPath; }
CConfiguration pipelineCConf = CConfiguration.copy(cConf); LogPipelineConfigurator configurator = new LogPipelineConfigurator(pipelineCConf); configurator.setContext(context);
@Test public void testAuthenticationDisabled() throws Exception { CConfiguration cConfCopy = CConfiguration.copy(CCONF); cConfCopy.setBoolean(Constants.Security.ENABLED, false); verifyDisabled(cConfCopy); }
CConfiguration pipelineCConf = CConfiguration.copy(cConf); LogPipelineConfigurator configurator = new LogPipelineConfigurator(pipelineCConf); configurator.setContext(context);
@Test public void testAuthorizationDisabled() throws Exception { CConfiguration cConfCopy = CConfiguration.copy(CCONF); cConfCopy.setBoolean(Constants.Security.Authorization.ENABLED, false); verifyDisabled(cConfCopy); }
@Test public void testAuthorizerExtension() throws IOException, ClassNotFoundException { Location externalAuthJar = createValidAuthExtensionJar(); CConfiguration cConfCopy = CConfiguration.copy(CCONF); cConfCopy.set(Constants.Security.Authorization.EXTENSION_JAR_PATH, externalAuthJar.toString()); // Create a temporary file. final File tempFile = TEMP_FOLDER.newFile("conf-file.xml"); cConfCopy.set(Constants.Security.Authorization.EXTENSION_EXTRA_CLASSPATH, tempFile.getParent()); try (AuthorizerInstantiator instantiator = new AuthorizerInstantiator(cConfCopy, AUTH_CONTEXT_FACTORY)) { // should be able to load the ExternalAuthorizer class via the AuthorizerInstantiatorService Authorizer externalAuthorizer1 = instantiator.get(); ClassLoader authorizerClassLoader = externalAuthorizer1.getClass().getClassLoader(); // should be able to load the ExternalAuthorizer class via the AuthorizerClassLoader authorizerClassLoader.loadClass(ValidExternalAuthorizer.class.getName()); Assert.assertNotNull(authorizerClassLoader.getResource("conf-file.xml")); } }
@Test public void testSystemUser() throws Exception { CConfiguration cConfCopy = CConfiguration.copy(CCONF); Principal systemUser = new Principal(UserGroupInformation.getCurrentUser().getShortUserName(), Principal.PrincipalType.USER); try (AuthorizerInstantiator authorizerInstantiator = new AuthorizerInstantiator(cConfCopy, AUTH_CONTEXT_FACTORY)) { Authorizer authorizer = authorizerInstantiator.get(); DefaultAuthorizationEnforcer authorizationEnforcer = new DefaultAuthorizationEnforcer(cConfCopy, authorizerInstantiator); NamespaceId ns1 = new NamespaceId("ns1"); authorizationEnforcer.enforce(NamespaceId.SYSTEM, systemUser, EnumSet.allOf(Action.class)); Assert.assertEquals(ImmutableSet.of(NamespaceId.SYSTEM), authorizationEnforcer.isVisible(ImmutableSet.of(ns1, NamespaceId.SYSTEM), systemUser)); } }
CConfiguration previewCConf = CConfiguration.copy(cConf); java.nio.file.Path previewDirPath = Paths.get(cConf.get(Constants.CFG_LOCAL_DATA_DIR), "preview").toAbsolutePath();
CConfiguration policyConf = CConfiguration.copy(cConf); String typeStr = args.get(RETRY_POLICY_TYPE); if (typeStr != null) {
CConfiguration policyConf = CConfiguration.copy(cConf); String typeStr = args.get(RETRY_POLICY_TYPE); if (typeStr != null) {
@Test public void testAuthorizerExtensionExtraClasspath() throws IOException, ClassNotFoundException { Location externalAuthJar = createValidAuthExtensionJar(); CConfiguration cConfCopy = CConfiguration.copy(CCONF); cConfCopy.set(Constants.Security.Authorization.EXTENSION_JAR_PATH, externalAuthJar.toString()); cConfCopy.set(Constants.Security.Authorization.EXTENSION_CONFIG_PREFIX + "config.path",
CConfiguration previewCConf = CConfiguration.copy(cConf); java.nio.file.Path previewDirPath = Paths.get(cConf.get(Constants.CFG_LOCAL_DATA_DIR), "preview").toAbsolutePath();
private Injector createInjector(int instanceId) { CConfiguration cConf = CConfiguration.copy(LeaderElectionMessagingServiceTest.cConf); cConf.setInt(Constants.MessagingSystem.CONTAINER_INSTANCE_ID, instanceId);
CConfiguration result = CConfiguration.copy(cConf);
CConfiguration result = CConfiguration.copy(cConf);
@Test public void testPropagationDisabled() throws Exception { CConfiguration cConfCopy = CConfiguration.copy(CCONF); try (AuthorizerInstantiator authorizerInstantiator = new AuthorizerInstantiator(cConfCopy, AUTH_CONTEXT_FACTORY)) { DefaultAuthorizationEnforcer authorizationEnforcer = new DefaultAuthorizationEnforcer(cConfCopy, authorizerInstantiator); authorizerInstantiator.get().grant(Authorizable.fromEntityId(NS), ALICE, ImmutableSet.of(Action.ADMIN)); authorizationEnforcer.enforce(NS, ALICE, Action.ADMIN); try { authorizationEnforcer.enforce(APP, ALICE, Action.ADMIN); Assert.fail("Alice should not have ADMIN privilege on the APP."); } catch (UnauthorizedException ignored) { // expected } } }
CConfiguration monitorCConf = CConfiguration.copy(cConf);
CConfiguration monitorCConf = CConfiguration.copy(cConf); monitorCConf.set(Constants.AppFabric.PROGRAM_STATUS_EVENT_TOPIC, "cdap-programStatus"); messagingService.createTopic(new TopicMetadata(NamespaceId.SYSTEM.topic("cdap-programStatus")));
CConfiguration monitorCConf = CConfiguration.copy(cConf); monitorCConf.set(Constants.AppFabric.PROGRAM_STATUS_EVENT_TOPIC, "cdap-programStatus"); messagingService.createTopic(new TopicMetadata(NamespaceId.SYSTEM.topic("cdap-programStatus")));