protected boolean hasPermission(CoreSession session, DocumentModel doc, Set<String> permissions, boolean required) { for (String permission : permissions) { if ((required && !session.hasPermission(doc.getRef(), permission)) || (!required && session.hasPermission(doc.getRef(), permission))) { return false; } } return true; }
private boolean checkWritePerm(List<DocumentModel> selectedDocs) { for (DocumentModel documentModel : selectedDocs) { boolean canWrite = documentManager.hasPermission(documentModel.getRef(), SecurityConstants.WRITE_PROPERTIES); if (!canWrite) { return false; } } return true; }
private boolean checkPermissions(DocumentModel container, DocumentModel source, DocumentModel destination) throws NuxeoException { boolean status = true; if ( !documentManager.hasPermission(container.getRef(), SecurityConstants.WRITE) || !documentManager.hasPermission(source.getRef(), SecurityConstants.WRITE) || (null != destination && !documentManager.hasPermission(destination.getRef(), SecurityConstants.WRITE)) ) { status = false; } return status; }
@Override public boolean getCanAddSecurityRules() { return documentManager.hasPermission(currentDocument.getRef(), "WriteSecurity"); }
@Override public boolean canUntag(CoreSession session, String docId, String label) { return session.hasPermission(new IdRef(docId), SecurityConstants.WRITE); }
public boolean getDocumentExistsAndIsVisibleWithId(String id) { if (StringUtils.isEmpty(id)) { return false; } IdRef ref = new IdRef(id); return documentManager.exists(ref) && documentManager.hasPermission(ref, SecurityConstants.READ); }
public boolean getDocumentExistsAndIsVisibleWithPath(String path) { if (StringUtils.isEmpty(path)) { return false; } PathRef ref = new PathRef(path); return documentManager.exists(ref) && documentManager.hasPermission(ref, SecurityConstants.READ); }
/** * Checks if current user has given permission * on current document. * * @param permission * @return true if current user has given permission * on current document */ public boolean hasPermission(String permission){ DocumentModel currentDoc = navigationContext.getCurrentDocument(); return documentManager.hasPermission(currentDoc.getRef(), permission); }
@Override public boolean getWriteRight() { // TODO: WRITE is a high level compound permission (i.e. more like a // user profile), public methods of the Nuxeo framework should only // check atomic / specific permissions such as WRITE_PROPERTIES, // REMOVE, ADD_CHILDREN depending on the action to execute instead return documentManager.hasPermission(navigationContext.getCurrentDocument().getRef(), SecurityConstants.WRITE); }
/** * @return true if currentUser has all rights. */ public boolean hasAllRights(){ DocumentModel currentDoc = navigationContext.getCurrentDocument(); return documentManager.hasPermission(currentDoc.getRef(), SecurityConstants.EVERYTHING); }
@Override public boolean getCanRestore() { // TODO: should check for a specific RESTORE permission instead return documentManager.hasPermission(navigationContext.getCurrentDocument().getRef(), SecurityConstants.WRITE_VERSION); }
@Override public boolean folderAllowsDelete(DocumentModel folder) { return folder.getCoreSession().hasPermission(folder.getRef(), SecurityConstants.REMOVE_CHILDREN); }
public boolean getCanEdit() { if (documentsListsManager.isWorkingListEmpty(CURRENT_DOCUMENT_SELECTION)) { return false; } List<DocumentModel> docs = documentsListsManager.getWorkingList(CURRENT_DOCUMENT_SELECTION); for (DocumentModel doc : docs) { if (!documentManager.hasPermission(doc.getRef(), SecurityConstants.WRITE)) { return false; } } return true; }
@Override public boolean hasPermission(@WebParam(name = "sessionId") String sid, @WebParam(name = "uuid") String uuid, @WebParam(name = "permission") String permission) { WSRemotingSession rs = initSession(sid); CoreSession docMgr = rs.getDocumentManager(); DocumentModel doc = docMgr.getDocument(new IdRef(uuid)); if (doc == null) { throw new DocumentNotFoundException("No such document: " + uuid); } return docMgr.hasPermission(doc.getRef(), permission); }
public boolean canUnpublishProxy(DocumentModel proxy) throws NuxeoException { boolean status = false; // For local proxies only if (proxy != null && proxy.isProxy() && !proxy.hasFacet(ToutaticeNuxeoStudioConst.CST_FACET_REMOTE_PROXY)) { status = documentManager.hasPermission(proxy.getRef(), ToutaticeNuxeoStudioConst.CST_PERM_VALIDATE); } return status; }
@Override public boolean canValidateRoute(DocumentModel documentRoute, CoreSession coreSession) { if (!coreSession.hasChildren(documentRoute.getRef())) { // Cannot validate an empty route return false; } return coreSession.hasPermission(documentRoute.getRef(), SecurityConstants.EVERYTHING); }
public boolean check(Adaptable context) { CoreSession session = context.getAdapter(CoreSession.class); DocumentModel doc = context.getAdapter(DocumentModel.class); return session.hasPermission(doc.getRef(), perm); }
@Override public String lock(DocumentRef ref) { if (getSession().hasPermission(ref, SecurityConstants.WRITE_PROPERTIES)) { Lock lock = getSession().setLock(ref); return lock.getOwner(); } return ExistingResource.READONLY_TOKEN; }
public DocumentModel getOrCreate() { if (session.hasPermission(userWorkspace.getRef(), ADD_CHILDREN)) { run(); } else { runUnrestricted(); } return session.getDocument(userProfileDocRef); } }
public PublicationNode getToutaticeNodeByPath(String path) throws NuxeoException { DocumentRef docRef = new PathRef(path); if (coreSession.hasPermission(docRef, SecurityConstants.READ)) { return new ToutaticeCoreFolderPublicationNode(coreSession.getDocument(new PathRef(path)), getConfigName(), getSessionId(), factory); } else { return new VirtualCoreFolderPublicationNode(coreSession.getSessionId(), path, getConfigName(), sid, factory); } }