use of org.apache.atlas.AtlasClient in project incubator-atlas by apache.
the class HiveMetaStoreBridge method main.
public static void main(String[] args) throws AtlasHookException {
try {
Configuration atlasConf = ApplicationProperties.get();
String[] atlasEndpoint = atlasConf.getStringArray(ATLAS_ENDPOINT);
if (atlasEndpoint == null || atlasEndpoint.length == 0) {
atlasEndpoint = new String[] { DEFAULT_DGI_URL };
}
AtlasClient atlasClient;
if (!AuthenticationUtil.isKerberosAuthenticationEnabled()) {
String[] basicAuthUsernamePassword = AuthenticationUtil.getBasicAuthenticationInput();
atlasClient = new AtlasClient(atlasEndpoint, basicAuthUsernamePassword);
} else {
UserGroupInformation ugi = UserGroupInformation.getCurrentUser();
atlasClient = new AtlasClient(ugi, ugi.getShortUserName(), atlasEndpoint);
}
Options options = new Options();
CommandLineParser parser = new BasicParser();
CommandLine cmd = parser.parse(options, args);
boolean failOnError = false;
if (cmd.hasOption("failOnError")) {
failOnError = true;
}
HiveMetaStoreBridge hiveMetaStoreBridge = new HiveMetaStoreBridge(atlasConf, new HiveConf(), atlasClient);
hiveMetaStoreBridge.importHiveMetadata(failOnError);
} catch (Exception e) {
throw new AtlasHookException("HiveMetaStoreBridge.main() failed.", e);
}
}
use of org.apache.atlas.AtlasClient in project incubator-atlas by apache.
the class StormAtlasHookIT method setUp.
@BeforeClass
public void setUp() throws Exception {
// start a local storm cluster
stormCluster = StormTestUtil.createLocalStormCluster();
LOG.info("Created a storm local cluster");
Configuration configuration = ApplicationProperties.get();
if (!AuthenticationUtil.isKerberosAuthenticationEnabled()) {
atlasClient = new AtlasClient(configuration.getStringArray(HiveMetaStoreBridge.ATLAS_ENDPOINT), new String[] { "admin", "admin" });
} else {
atlasClient = new AtlasClient(configuration.getStringArray(HiveMetaStoreBridge.ATLAS_ENDPOINT));
}
}
use of org.apache.atlas.AtlasClient in project incubator-atlas by apache.
the class SSLTest method setUp.
@BeforeClass
public void setUp() throws Exception {
jksPath = new Path(Files.createTempDirectory("tempproviders").toString(), "test.jks");
providerUrl = JavaKeyStoreProvider.SCHEME_NAME + "://file/" + jksPath.toUri();
setupCredentials();
final PropertiesConfiguration configuration = getSSLConfiguration(providerUrl);
String persistDir = writeConfiguration(configuration);
persistSSLClientConfiguration(configuration);
originalConf = System.getProperty("atlas.conf");
System.setProperty("atlas.conf", persistDir);
originalHomeDir = System.getProperty("atlas.home");
System.setProperty("atlas.home", TestUtils.getTargetDirectory());
atlasClient = new AtlasClient(configuration, new String[] { DGI_URL }, new String[] { "admin", "admin" });
secureEmbeddedServer = new TestSecureEmbeddedServer(21443, getWarPath()) {
@Override
public org.apache.commons.configuration.Configuration getConfiguration() {
return configuration;
}
};
secureEmbeddedServer.getServer().start();
}
use of org.apache.atlas.AtlasClient in project incubator-atlas by apache.
the class SSLAndKerberosTest method setUp.
@BeforeClass
public void setUp() throws Exception {
jksPath = new Path(Files.createTempDirectory("tempproviders").toString(), "test.jks");
providerUrl = JavaKeyStoreProvider.SCHEME_NAME + "://file/" + jksPath.toUri();
String persistDir = TestUtils.getTempDirectory();
setupKDCAndPrincipals();
setupCredentials();
// client will actually only leverage subset of these properties
final PropertiesConfiguration configuration = getSSLConfiguration(providerUrl);
persistSSLClientConfiguration(configuration);
TestUtils.writeConfiguration(configuration, persistDir + File.separator + ApplicationProperties.APPLICATION_PROPERTIES);
String confLocation = System.getProperty("atlas.conf");
URL url;
if (confLocation == null) {
url = SSLAndKerberosTest.class.getResource("/" + ApplicationProperties.APPLICATION_PROPERTIES);
} else {
url = new File(confLocation, ApplicationProperties.APPLICATION_PROPERTIES).toURI().toURL();
}
configuration.load(url);
configuration.setProperty(TLS_ENABLED, true);
configuration.setProperty("atlas.authentication.method.kerberos", "true");
configuration.setProperty("atlas.authentication.keytab", userKeytabFile.getAbsolutePath());
configuration.setProperty("atlas.authentication.principal", "dgi/localhost@" + kdc.getRealm());
configuration.setProperty("atlas.authentication.method.file", "false");
configuration.setProperty("atlas.authentication.method.kerberos", "true");
configuration.setProperty("atlas.authentication.method.kerberos.principal", "HTTP/localhost@" + kdc.getRealm());
configuration.setProperty("atlas.authentication.method.kerberos.keytab", httpKeytabFile.getAbsolutePath());
configuration.setProperty("atlas.authentication.method.kerberos.name.rules", "RULE:[1:$1@$0](.*@EXAMPLE.COM)s/@.*//\nDEFAULT");
configuration.setProperty("atlas.authentication.method.file", "true");
configuration.setProperty("atlas.authentication.method.file.filename", persistDir + "/users-credentials");
configuration.setProperty("atlas.auth.policy.file", persistDir + "/policy-store.txt");
TestUtils.writeConfiguration(configuration, persistDir + File.separator + "atlas-application.properties");
setupUserCredential(persistDir);
setUpPolicyStore(persistDir);
subject = loginTestUser();
UserGroupInformation.loginUserFromSubject(subject);
UserGroupInformation proxyUser = UserGroupInformation.createProxyUser("testUser", UserGroupInformation.getLoginUser());
// save original setting
originalConf = System.getProperty("atlas.conf");
System.setProperty("atlas.conf", persistDir);
originalHomeDir = System.getProperty("atlas.home");
System.setProperty("atlas.home", TestUtils.getTargetDirectory());
dgiCLient = proxyUser.doAs(new PrivilegedExceptionAction<AtlasClient>() {
@Override
public AtlasClient run() throws Exception {
return new AtlasClient(configuration, DGI_URL);
}
});
secureEmbeddedServer = new TestSecureEmbeddedServer(21443, getWarPath()) {
@Override
public PropertiesConfiguration getConfiguration() {
return configuration;
}
};
secureEmbeddedServer.getServer().start();
}
use of org.apache.atlas.AtlasClient in project incubator-atlas by apache.
the class EntityJerseyResourceIT method testRequestUser.
@Test
public void testRequestUser() throws Exception {
Referenceable entity = new Referenceable(DATABASE_TYPE_BUILTIN);
String dbName = randomString();
entity.set("name", dbName);
entity.set(QUALIFIED_NAME, dbName);
entity.set("clusterName", randomString());
entity.set("description", randomString());
entity.set(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, dbName);
entity.set("owner", "user1");
entity.set("clusterName", "cl1");
entity.set("parameters", Collections.EMPTY_MAP);
entity.set("location", "/tmp");
String user = "admin";
AtlasClient localClient = null;
if (!AuthenticationUtil.isKerberosAuthenticationEnabled()) {
localClient = new AtlasClient(atlasUrls, new String[] { "admin", "admin" });
} else {
localClient = new AtlasClient(atlasUrls);
}
String entityId = localClient.createEntity(entity).get(0);
List<EntityAuditEvent> events = atlasClientV1.getEntityAuditEvents(entityId, (short) 10);
assertEquals(events.size(), 1);
assertEquals(events.get(0).getUser(), user);
}
Aggregations