public CurrentUserPrivilegeSetProperty asDavProperty() throws RepositoryException { List<Privilege> davPrivs = new ArrayList<Privilege>(); for (javax.jcr.security.Privilege privilege : session.getAccessControlManager().getPrivileges(absPath)) { String privilegeName = privilege.getName(); String prefix = Text.getNamespacePrefix(privilegeName); Namespace ns = (prefix.isEmpty()) ? Namespace.EMPTY_NAMESPACE : Namespace.getNamespace(prefix, session.getNamespaceURI(prefix)); davPrivs.add(Privilege.getPrivilege(Text.getLocalName(privilegeName), ns)); } return new CurrentUserPrivilegeSetProperty(davPrivs.toArray(new Privilege[davPrivs.size()])); } }
/** * Create a new <code>CurrentUserPrivilegeSetProperty</code> from a DavProperty * as obtained from a MultiStatusResponse. * * @param xmlDavProperty * @throws DavException */ public CurrentUserPrivilegeSetProperty(DavProperty xmlDavProperty) throws DavException { super(xmlDavProperty.getName(), true); if (!SecurityConstants.CURRENT_USER_PRIVILEGE_SET.equals(getName())) { throw new DavException(DavServletResponse.SC_BAD_REQUEST, "DAV:current-user-privilege-set expected."); } privileges = new HashSet(); // parse property value Object value = xmlDavProperty.getValue(); if (value != null) { if (value instanceof Element) { privileges.add(Privilege.getPrivilege((Element)value)); } else if (value instanceof Collection) { Iterator it = ((Collection)value).iterator(); while (it.hasNext()) { Object entry = it.next(); if (entry instanceof Element) { privileges.add(Privilege.getPrivilege((Element)entry)); } } } } }
return new Name[0]; } else { Collection<Privilege> privs = new CurrentUserPrivilegeSetProperty(p).getValue(); Set<Name> privNames = new HashSet<Name>(privs.size()); for (Privilege priv : privs) {
return new Name[0]; } else { Collection<Privilege> privs = new CurrentUserPrivilegeSetProperty(p).getValue(); Set<Name> privNames = new HashSet<Name>(privs.size()); for (Privilege priv : privs) {
CurrentUserPrivilegeSetProperty privSet = new CurrentUserPrivilegeSetProperty(p); Collection<Privilege> privileges = privSet.getValue();
/** * Create a new <code>CurrentUserPrivilegeSetProperty</code> from a DavProperty * as obtained from a MultiStatusResponse. * * @param xmlDavProperty * @throws DavException */ public CurrentUserPrivilegeSetProperty(DavProperty<?> xmlDavProperty) throws DavException { super(xmlDavProperty.getName(), true); if (!SecurityConstants.CURRENT_USER_PRIVILEGE_SET.equals(getName())) { throw new DavException(DavServletResponse.SC_BAD_REQUEST, "DAV:current-user-privilege-set expected."); } privileges = new HashSet<Privilege>(); // parse property value Object value = xmlDavProperty.getValue(); if (value != null) { if (value instanceof Element) { privileges.add(Privilege.getPrivilege((Element)value)); } else if (value instanceof Collection) { for (Object entry : ((Collection<?>) value)) { if (entry instanceof Element) { privileges.add(Privilege.getPrivilege((Element) entry)); } } } } }
private void addResponses(DavResourceLocator locator) { String repositoryPath = locator.getRepositoryPath(); MultiStatusResponse resp = new MultiStatusResponse(locator.getHref(false), null); List<Privilege> currentPrivs = new ArrayList<Privilege>(); for (Privilege priv : PRIVS) { try { if (getRepositorySession().hasPermission(repositoryPath, priv.getName())) { currentPrivs.add(priv); } } catch (RepositoryException e) { // ignore log.debug(e.toString()); } } resp.add(new CurrentUserPrivilegeSetProperty(currentPrivs.toArray(new Privilege[currentPrivs.size()]))); ms.addResponse(resp); }
CurrentUserPrivilegeSetProperty privSet = new CurrentUserPrivilegeSetProperty(p); Collection<Privilege> privileges = privSet.getValue();
/** * Create a new <code>CurrentUserPrivilegeSetProperty</code> from a DavProperty * as obtained from a MultiStatusResponse. * * @param xmlDavProperty * @throws DavException */ public CurrentUserPrivilegeSetProperty(DavProperty<?> xmlDavProperty) throws DavException { super(xmlDavProperty.getName(), true); if (!SecurityConstants.CURRENT_USER_PRIVILEGE_SET.equals(getName())) { throw new DavException(DavServletResponse.SC_BAD_REQUEST, "DAV:current-user-privilege-set expected."); } privileges = new HashSet<Privilege>(); // parse property value Object value = xmlDavProperty.getValue(); if (value != null) { if (value instanceof Element) { privileges.add(Privilege.getPrivilege((Element)value)); } else if (value instanceof Collection) { for (Object entry : ((Collection<?>) value)) { if (entry instanceof Element) { privileges.add(Privilege.getPrivilege((Element) entry)); } } } } }