use of org.apache.zeppelin.conf.ZeppelinConfiguration in project zeppelin by apache.
the class SecurityRestApi method ticket.
/**
* Get ticket
* Returns username & ticket
* for anonymous access, username is always anonymous.
* After getting this ticket, access through websockets become safe
*
* @return 200 response
*/
@GET
@Path("ticket")
@ZeppelinApi
public Response ticket() {
ZeppelinConfiguration conf = ZeppelinConfiguration.create();
String principal = SecurityUtils.getPrincipal();
HashSet<String> roles = SecurityUtils.getRoles();
JsonResponse response;
// ticket set to anonymous for anonymous user. Simplify testing.
String ticket;
if ("anonymous".equals(principal))
ticket = "anonymous";
else
ticket = TicketContainer.instance.getTicket(principal);
Map<String, String> data = new HashMap<>();
data.put("principal", principal);
data.put("roles", roles.toString());
data.put("ticket", ticket);
response = new JsonResponse(Response.Status.OK, "", data);
LOG.warn(response.toString());
return response.build();
}
use of org.apache.zeppelin.conf.ZeppelinConfiguration in project zeppelin by apache.
the class ZeppelinServer method main.
public static void main(String[] args) throws InterruptedException {
ZeppelinConfiguration conf = ZeppelinConfiguration.create();
conf.setProperty("args", args);
jettyWebServer = setupJettyServer(conf);
ContextHandlerCollection contexts = new ContextHandlerCollection();
jettyWebServer.setHandler(contexts);
// Web UI
final WebAppContext webApp = setupWebAppContext(contexts, conf);
// Create `ZeppelinServer` using reflection and setup REST Api
setupRestApiContextHandler(webApp, conf);
// Notebook server
setupNotebookServer(webApp, conf);
//Below is commented since zeppelin-docs module is removed.
//final WebAppContext webAppSwagg = setupWebAppSwagger(conf);
LOG.info("Starting zeppelin server");
try {
//Instantiates ZeppelinServer
jettyWebServer.start();
} catch (Exception e) {
LOG.error("Error while running jettyServer", e);
System.exit(-1);
}
LOG.info("Done, zeppelin server started");
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
LOG.info("Shutting down Zeppelin Server ... ");
try {
jettyWebServer.stop();
notebook.getInterpreterSettingManager().shutdown();
notebook.close();
Thread.sleep(3000);
} catch (Exception e) {
LOG.error("Error while stopping servlet container", e);
}
LOG.info("Bye");
}
});
// for graceful shutdown, input any key in console window
if (System.getenv("ZEPPELIN_IDENT_STRING") == null) {
try {
System.in.read();
} catch (IOException e) {
LOG.error("Exception in ZeppelinServer while main ", e);
}
System.exit(0);
}
jettyWebServer.join();
ZeppelinServer.notebook.getInterpreterSettingManager().close();
}
use of org.apache.zeppelin.conf.ZeppelinConfiguration in project zeppelin by apache.
the class NotebookServer method generateNotesInfo.
public List<Map<String, String>> generateNotesInfo(boolean needsReload, AuthenticationInfo subject, Set<String> userAndRoles) {
Notebook notebook = notebook();
ZeppelinConfiguration conf = notebook.getConf();
String homescreenNoteId = conf.getString(ConfVars.ZEPPELIN_NOTEBOOK_HOMESCREEN);
boolean hideHomeScreenNotebookFromList = conf.getBoolean(ConfVars.ZEPPELIN_NOTEBOOK_HOMESCREEN_HIDE);
if (needsReload) {
try {
notebook.reloadAllNotes(subject);
} catch (IOException e) {
LOG.error("Fail to reload notes from repository", e);
}
}
List<Note> notes = notebook.getAllNotes(userAndRoles);
List<Map<String, String>> notesInfo = new LinkedList<>();
for (Note note : notes) {
Map<String, String> info = new HashMap<>();
if (hideHomeScreenNotebookFromList && note.getId().equals(homescreenNoteId)) {
continue;
}
info.put("id", note.getId());
info.put("name", note.getName());
notesInfo.add(info);
}
return notesInfo;
}
use of org.apache.zeppelin.conf.ZeppelinConfiguration in project zeppelin by apache.
the class AuthenticationIT method startUp.
@BeforeClass
public static void startUp() {
if (!endToEndTestEnabled()) {
return;
}
try {
System.setProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_HOME.getVarName(), "../");
ZeppelinConfiguration conf = ZeppelinConfiguration.create();
shiroPath = conf.getRelativeDir(String.format("%s/shiro.ini", conf.getConfDir()));
File file = new File(shiroPath);
if (file.exists()) {
originalShiro = StringUtils.join(FileUtils.readLines(file, "UTF-8"), "\n");
}
FileUtils.write(file, authShiro, "UTF-8");
} catch (IOException e) {
LOG.error("Error in AuthenticationIT startUp::", e);
}
ZeppelinITUtils.restartZeppelin();
driver = WebDriverManager.getWebDriver();
}
use of org.apache.zeppelin.conf.ZeppelinConfiguration in project zeppelin by apache.
the class InstallInterpreter method main.
public static void main(String[] args) throws IOException {
if (args.length == 0) {
usage();
return;
}
ZeppelinConfiguration conf = ZeppelinConfiguration.create();
InstallInterpreter installer = new InstallInterpreter(new File(conf.getInterpreterListPath()), new File(conf.getInterpreterDir()), conf.getInterpreterLocalRepoPath());
String names = null;
String artifacts = null;
URL proxyUrl = null;
String proxyUser = null;
String proxyPassword = null;
boolean all = false;
for (int i = 0; i < args.length; i++) {
String arg = args[i].toLowerCase(Locale.US);
switch(arg) {
case "--list":
case "-l":
installer.list();
System.exit(0);
break;
case "--all":
case "-a":
all = true;
break;
case "--name":
case "-n":
names = args[++i];
break;
case "--artifact":
case "-t":
artifacts = args[++i];
break;
case "--version":
case "-v":
Util.getVersion();
break;
case "--proxy-url":
proxyUrl = new URL(args[++i]);
break;
case "--proxy-user":
proxyUser = args[++i];
break;
case "--proxy-password":
proxyPassword = args[++i];
break;
case "--help":
case "-h":
usage();
System.exit(0);
break;
default:
System.out.println("Unknown option " + arg);
}
}
if (proxyUrl != null) {
installer.setProxy(proxyUrl, proxyUser, proxyPassword);
}
if (all) {
installer.installAll();
System.exit(0);
}
if (names != null) {
if (artifacts != null) {
installer.install(names.split(","), artifacts.split(","));
} else {
installer.install(names.split(","));
}
}
}
Aggregations