use of org.apache.zeppelin.notebook.NotebookAuthorization in project SSM by Intel-bigdata.
the class NotebookRepoSync method makePrivate.
private void makePrivate(String noteId, AuthenticationInfo subject) {
if (AuthenticationInfo.isAnonymous(subject)) {
LOG.info("User is anonymous, permissions are not set for pulled notes");
return;
}
NotebookAuthorization notebookAuthorization = NotebookAuthorization.getInstance();
Set<String> users = notebookAuthorization.getOwners(noteId);
users.add(subject.getUser());
notebookAuthorization.setOwners(noteId, users);
users = notebookAuthorization.getReaders(noteId);
users.add(subject.getUser());
notebookAuthorization.setReaders(noteId, users);
users = notebookAuthorization.getWriters(noteId);
users.add(subject.getUser());
notebookAuthorization.setWriters(noteId, users);
}
use of org.apache.zeppelin.notebook.NotebookAuthorization in project SSM by Intel-bigdata.
the class ZeppelinClient method relayToAllZeppelinHub.
private void relayToAllZeppelinHub(ZeppelinhubMessage hubMsg, String noteId) {
if (StringUtils.isBlank(noteId)) {
return;
}
NotebookAuthorization noteAuth = NotebookAuthorization.getInstance();
Map<String, String> userTokens = UserTokenContainer.getInstance().getAllUserTokens();
Client client = Client.getInstance();
Set<String> userAndRoles;
String token;
for (String user : userTokens.keySet()) {
userAndRoles = noteAuth.getRoles(user);
userAndRoles.add(user);
if (noteAuth.isReader(noteId, userAndRoles)) {
token = userTokens.get(user);
hubMsg.meta.put("token", token);
client.relayToZeppelinHub(hubMsg.serialize(), token);
}
}
}
use of org.apache.zeppelin.notebook.NotebookAuthorization in project zeppelin by apache.
the class NotebookRepoSync method makePrivate.
private void makePrivate(String noteId, AuthenticationInfo subject) {
if (AuthenticationInfo.isAnonymous(subject)) {
LOG.info("User is anonymous, permissions are not set for pulled notes");
return;
}
NotebookAuthorization notebookAuthorization = NotebookAuthorization.getInstance();
Set<String> users = notebookAuthorization.getOwners(noteId);
users.add(subject.getUser());
notebookAuthorization.setOwners(noteId, users);
users = notebookAuthorization.getReaders(noteId);
users.add(subject.getUser());
notebookAuthorization.setReaders(noteId, users);
users = notebookAuthorization.getWriters(noteId);
users.add(subject.getUser());
notebookAuthorization.setWriters(noteId, users);
}
use of org.apache.zeppelin.notebook.NotebookAuthorization in project zeppelin by apache.
the class NotebookServer method broadcastNoteListExcept.
private void broadcastNoteListExcept(List<Map<String, String>> notesInfo, AuthenticationInfo subject) {
Set<String> userAndRoles;
NotebookAuthorization authInfo = NotebookAuthorization.getInstance();
for (String user : userConnectedSockets.keySet()) {
if (subject.getUser().equals(user)) {
continue;
}
//reloaded already above; parameter - false
userAndRoles = authInfo.getRoles(user);
userAndRoles.add(user);
notesInfo = generateNotesInfo(false, new AuthenticationInfo(user), userAndRoles);
multicastToUser(user, new Message(OP.NOTES_INFO).put("notes", notesInfo));
}
}
use of org.apache.zeppelin.notebook.NotebookAuthorization in project SSM by Intel-bigdata.
the class NotebookRepoSync method sync.
/**
* Copies new/updated notes from source to destination storage
*
* @throws IOException
*/
void sync(int sourceRepoIndex, int destRepoIndex, AuthenticationInfo subject) throws IOException {
LOG.info("Sync started");
NotebookAuthorization auth = NotebookAuthorization.getInstance();
NotebookRepo srcRepo = getRepo(sourceRepoIndex);
NotebookRepo dstRepo = getRepo(destRepoIndex);
List<NoteInfo> allSrcNotes = srcRepo.list(subject);
List<NoteInfo> srcNotes = auth.filterByUser(allSrcNotes, subject);
List<NoteInfo> dstNotes = dstRepo.list(subject);
Map<String, List<String>> noteIds = notesCheckDiff(srcNotes, srcRepo, dstNotes, dstRepo, subject);
List<String> pushNoteIds = noteIds.get(pushKey);
List<String> pullNoteIds = noteIds.get(pullKey);
List<String> delDstNoteIds = noteIds.get(delDstKey);
if (!pushNoteIds.isEmpty()) {
LOG.info("Notes with the following IDs will be pushed");
for (String id : pushNoteIds) {
LOG.info("ID : " + id);
}
pushNotes(subject, pushNoteIds, srcRepo, dstRepo, false);
} else {
LOG.info("Nothing to push");
}
if (!pullNoteIds.isEmpty()) {
LOG.info("Notes with the following IDs will be pulled");
for (String id : pullNoteIds) {
LOG.info("ID : " + id);
}
pushNotes(subject, pullNoteIds, dstRepo, srcRepo, true);
} else {
LOG.info("Nothing to pull");
}
if (!delDstNoteIds.isEmpty()) {
LOG.info("Notes with the following IDs will be deleted from dest");
for (String id : delDstNoteIds) {
LOG.info("ID : " + id);
}
deleteNotes(subject, delDstNoteIds, dstRepo);
} else {
LOG.info("Nothing to delete from dest");
}
LOG.info("Sync ended");
}
Aggregations