sp.add(getSupportedPrivilege(child)); return new SupportedPrivilege(privilege, description, descriptionLanguage, isAbstract, sp.toArray(new SupportedPrivilege[sp.size()]));
private static void fillSupportedPrivilegeMap(List<SupportedPrivilege> sps, Map<Name, SupportedPrivilege> spMap, NameFactory nameFactory) throws NamespaceException, IllegalNameException { for (SupportedPrivilege sp : sps) { Privilege p = sp.getPrivilege(); Name privName = nameFactory.create(p.getNamespace().getURI(), p.getName()); spMap.put(privName, sp); List<SupportedPrivilege> agg = Arrays.asList(sp.getSupportedPrivileges()); if (!agg.isEmpty()) { fillSupportedPrivilegeMap(agg, spMap, nameFactory); } } }
SupportedPrivilege sp = spMap.get(privilegeName); Set<Name> aggrnames = null; SupportedPrivilege[] aggregates = sp.getSupportedPrivileges(); if (aggregates != null && aggregates.length > 0) { aggrnames = new HashSet<Name>(); for (SupportedPrivilege aggregate : aggregates) { Name aggregateName = nameFactory.create(aggregate.getPrivilege().getNamespace().getURI(), aggregate.getPrivilege().getName()); aggrnames.add(aggregateName); PrivilegeDefinition def = new PrivilegeDefinitionImpl(privilegeName, sp.isAbstract(), aggrnames); pDefs.add(def);
/** * @see XmlSerializable#toXml(Document) */ public Element toXml(Document document) { Element spElem = DomUtil.createElement(document, XML_SUPPORTED_PRIVILEGE, SecurityConstants.NAMESPACE); spElem.appendChild(privilege.toXml(document)); if (isAbstract) { DomUtil.addChildElement(spElem, XML_ABSTRACT, SecurityConstants.NAMESPACE); } if (description != null) { Element desc = DomUtil.addChildElement(spElem, XML_DESCRIPTION, SecurityConstants.NAMESPACE, description); if (descriptionLanguage != null) { DomUtil.setAttribute(desc, "lang", Namespace.XML_NAMESPACE, descriptionLanguage); } } if (supportedPrivileges != null) { for (SupportedPrivilege supportedPrivilege : supportedPrivileges) { spElem.appendChild(supportedPrivilege.toXml(document)); } } return spElem; }
private SupportedPrivilege createSupportedPrivilege(Privilege privilege) throws RepositoryException { String privilegeName = privilege.getName(); String localName = Text.getLocalName(privilegeName); String prefix = Text.getNamespacePrefix(privilegeName); Namespace ns = (prefix.isEmpty()) ? Namespace.EMPTY_NAMESPACE : Namespace.getNamespace(prefix, session.getNamespaceURI(prefix)); org.apache.jackrabbit.webdav.security.Privilege davPrivilege = org.apache.jackrabbit.webdav.security.Privilege.getPrivilege(localName, ns); SupportedPrivilege[] aggregates = (privilege.isAggregate()) ? getDeclaredAggregates(privilege) : null; SupportedPrivilege sp = new SupportedPrivilege(davPrivilege, null, null, privilege.isAbstract(), aggregates); if (!aggregated.contains(privilegeName)) { supportedPrivileges.put(privilegeName, sp); } return sp; }
public SupportedPrivilegeSetProperty(DavProperty<?> p) throws DavException { super(SecurityConstants.SUPPORTED_PRIVILEGE_SET, true); if (!SecurityConstants.SUPPORTED_PRIVILEGE_SET.equals(getName())) { throw new DavException(DavServletResponse.SC_BAD_REQUEST, "DAV:supported-privilege-set expected."); } List<SupportedPrivilege> supportedPrivs = new ArrayList<SupportedPrivilege>(); for (Object obj : Collections.singletonList(p.getValue())) { if (obj instanceof Element) { supportedPrivs.add(SupportedPrivilege.getSupportedPrivilege((Element) obj)); } else if (obj instanceof Collection) { for (Object entry : ((Collection<?>) obj)) { if (entry instanceof Element) { supportedPrivs.add(SupportedPrivilege.getSupportedPrivilege((Element) entry)); } } } } supportedPrivileges = supportedPrivs.toArray(new SupportedPrivilege[supportedPrivs.size()]); }
SupportedPrivilege sp = spMap.get(privilegeName); Set<Name> aggrnames = null; SupportedPrivilege[] aggregates = sp.getSupportedPrivileges(); if (aggregates != null && aggregates.length > 0) { aggrnames = new HashSet<Name>(); for (SupportedPrivilege aggregate : aggregates) { Name aggregateName = nameFactory.create(aggregate.getPrivilege().getNamespace().getURI(), aggregate.getPrivilege().getName()); aggrnames.add(aggregateName); PrivilegeDefinition def = new PrivilegeDefinitionImpl(privilegeName, sp.isAbstract(), aggrnames); pDefs.add(def);
/** * @see XmlSerializable#toXml(Document) */ public Element toXml(Document document) { Element spElem = DomUtil.createElement(document, XML_SUPPORTED_PRIVILEGE, SecurityConstants.NAMESPACE); spElem.appendChild(privilege.toXml(document)); if (isAbstract) { DomUtil.addChildElement(spElem, XML_ABSTRACT, SecurityConstants.NAMESPACE); } if (description != null) { Element desc = DomUtil.addChildElement(spElem, XML_DESCRIPTION, SecurityConstants.NAMESPACE, description); if (descriptionLanguage != null) { DomUtil.setAttribute(desc, "lang", Namespace.XML_NAMESPACE, descriptionLanguage); } } if (supportedPrivileges != null) { for (SupportedPrivilege supportedPrivilege : supportedPrivileges) { spElem.appendChild(supportedPrivilege.toXml(document)); } } return spElem; }
public SupportedPrivilegeSetProperty(DavProperty<?> p) throws DavException { super(SecurityConstants.SUPPORTED_PRIVILEGE_SET, true); if (!SecurityConstants.SUPPORTED_PRIVILEGE_SET.equals(getName())) { throw new DavException(DavServletResponse.SC_BAD_REQUEST, "DAV:supported-privilege-set expected."); } List<SupportedPrivilege> supportedPrivs = new ArrayList<SupportedPrivilege>(); for (Object obj : Collections.singletonList(p.getValue())) { if (obj instanceof Element) { supportedPrivs.add(SupportedPrivilege.getSupportedPrivilege((Element) obj)); } else if (obj instanceof Collection) { for (Object entry : ((Collection<?>) obj)) { if (entry instanceof Element) { supportedPrivs.add(SupportedPrivilege.getSupportedPrivilege((Element) entry)); } } } } supportedPrivileges = supportedPrivs.toArray(new SupportedPrivilege[supportedPrivs.size()]); }
sp.add(getSupportedPrivilege(child)); return new SupportedPrivilege(privilege, description, descriptionLanguage, isAbstract, sp.toArray(new SupportedPrivilege[sp.size()]));
/** * @see XmlSerializable#toXml(Document) */ public Element toXml(Document document) { Element spElem = DomUtil.createElement(document, XML_SUPPORTED_PRIVILEGE, SecurityConstants.NAMESPACE); spElem.appendChild(privilege.toXml(document)); if (isAbstract) { DomUtil.addChildElement(spElem, XML_ABSTRACT, SecurityConstants.NAMESPACE); } if (description != null) { Element desc = DomUtil.addChildElement(spElem, XML_DESCRIPTION, SecurityConstants.NAMESPACE, description); if (descriptionLanguage != null) { DomUtil.setAttribute(desc, "lang", Namespace.XML_NAMESPACE, descriptionLanguage); } } if (supportedPrivileges != null) { for (int i = 0; i < supportedPrivileges.length; i++) { spElem.appendChild(supportedPrivileges[i].toXml(document)); } } return spElem; } }
private static void fillSupportedPrivilegeMap(List<SupportedPrivilege> sps, Map<Name, SupportedPrivilege> spMap, NameFactory nameFactory) throws NamespaceException, IllegalNameException { for (SupportedPrivilege sp : sps) { Privilege p = sp.getPrivilege(); Name privName = nameFactory.create(p.getNamespace().getURI(), p.getName()); spMap.put(privName, sp); List<SupportedPrivilege> agg = Arrays.asList(sp.getSupportedPrivileges()); if (!agg.isEmpty()) { fillSupportedPrivilegeMap(agg, spMap, nameFactory); } } }