Package org.apache.webdav.lib

Examples of org.apache.webdav.lib.Ace


                             XMLPrinter.OPENING);

        Enumeration aceList = aces.elements();

        while (aceList.hasMoreElements()) {
            Ace ace = (Ace) aceList.nextElement();

            if (ace.isInherited() || ace.isProtected()) {
                // draft-ietf-webdav-acl-06
                // do not submit inherited and protected aces
                // continue with next ace
                continue;
            }

            printer.writeElement("D", null, "ace",
                                 XMLPrinter.OPENING);

            printer.writeElement("D", null, "principal",
                                 XMLPrinter.OPENING);

            boolean found = false;
            String principal = ace.getPrincipal();
            String[] types = {"all", "authenticated", "unauthenticated",
                              "property", "self"};
            for (int i = 0; i < types.length && !found; i++) {
                if (types[i].equals(principal)) {
                    found = true;
                    if ("property".equals(principal)) {
                        printer.writeElement("D", null, principal,
                                             XMLPrinter.OPENING);
                        PropertyName property = ace.getProperty();
                        String nsURI = property.getNamespaceURI();
                        if ("DAV:".equals(nsURI)) {
                            printer.writeElement("D", null,
                                                 property.getLocalName(),
                                                 XMLPrinter.NO_CONTENT);
                        } else {
                            printer.writeElement("Z", nsURI,
                                                 property.getLocalName(),
                                                 XMLPrinter.NO_CONTENT);
                        }
                        printer.writeElement("D", null, principal,
                                             XMLPrinter.CLOSING);
                    } else {
                        printer.writeElement("D", null, principal,
                                             XMLPrinter.NO_CONTENT);
                    }
                }
            }
            if (!found) {
                printer.writeElement("D", null, "href", XMLPrinter.OPENING);
                printer.writeText(principal);
                printer.writeElement("D", null, "href", XMLPrinter.CLOSING);
            }

            printer.writeElement("D", null, "principal",
                                 XMLPrinter.CLOSING);

            String positive = (ace.isNegative()) ? "deny" : "grant";

            printer.writeElement("D", null, positive,
                                 XMLPrinter.OPENING);

            Enumeration privilegeList = ace.enumeratePrivileges();
            while (privilegeList.hasMoreElements()) {
                Privilege privilege = (Privilege) privilegeList.nextElement();
                printer.writeElement("D", null, "privilege",
                                     XMLPrinter.OPENING);
                printer.writeElement(null,privilege.getNamespace(),privilege.getName(), XMLPrinter.NO_CONTENT);
                printer.writeElement("D", null, "privilege",
                                     XMLPrinter.CLOSING);
            }

            printer.writeElement("D", null, positive,
                                 XMLPrinter.CLOSING);

            if (ace.isInherited()) {
                printer.writeElement("D", null, "inherited",
                                     XMLPrinter.NO_CONTENT);
            }

            printer.writeElement("D", null, "ace",
View Full Code Here


            System.err.println("Error: unknown type of principal");
            System.err.println("element: " + element);
            return null;
        }

        Ace ace = new Ace(principal);

        child = DOMUtils.getFirstElement(element, "DAV:", "grant");
        if (child == null) {
            child = DOMUtils.getFirstElement(element, "DAV:", "deny");
            ace.setNegative(true);
         }
        if (child != null) {
            NodeList privilegeElements = child.getElementsByTagNameNS("DAV:", "privilege");
            for (int i = 0; i < privilegeElements.getLength(); i++) {
                Element privilegeElement = (Element) privilegeElements.item(i);
                NodeList privileges = privilegeElement.getElementsByTagName("*");
                for (int j=0 ; j<privileges.getLength() ; j++)
                {
                    Element privilege = (Element) privileges.item(j);
                    ace.addPrivilege(parsePrivilege(privilege));
                }
            }
        }

        child = DOMUtils.getFirstElement(element, "DAV:", "inherited");
        if (child != null) {
            href=DOMUtils.getFirstElement(child, "DAV:", "href");
            if (href!=null)
            {
                ace.setInherited(true);
                ace.setInheritedFrom(DOMUtils.getTextValue(href));
            }
            else
            {
                System.err.println("Error: mandatory element <href> is missing !");
                return null;
            }
        }

        child = DOMUtils.getFirstElement(element, "DAV:", "protected");
        if (child != null) {
            ace.setProtected(true);
        }

        return ace;

    }
View Full Code Here

            out.println();
            out.println("ACL from server");
            showAces(path, aces);
        }

        Ace ace=null;
        for (int i=0; i<aces.length && (ace==null); i++)
        {
            if ((aces[i].isNegative()==negative) && !aces[i].isProtected()
                && !aces[i].isInherited() && aces[i].getPrincipal().equals(principal))
            {
                if (debugLevel>5)
                    out.println("found ace");
                ace=aces[i];
            }
        }
        if (ace==null)
        {
            Ace[] oldAces=aces;
            aces=new Ace[oldAces.length+1];
            System.arraycopy(oldAces,0,aces,0,oldAces.length);
            ace=new Ace(principal, negative, false, false,null);
            aces[oldAces.length]=ace;
        }

        Privilege privilege=new Privilege(permission.getNamespaceURI(), permission.getLocalName(), null);
        ace.addPrivilege(privilege);

        if (debugLevel>5) {
            out.println();
            out.println("ACL with updated privileges");
            showAces(path, aces);
View Full Code Here

        out.println("ACL for " + path + ":");
        out.println("------------------------------------------------------------");
        for (int i=0; i<aces.length ; i++)
        {
            Ace ace=aces[i];
            out.println((!ace.isNegative()?"granted":"denied") +
                " to " + ace.getPrincipal() + " " +
                "   (" + (ace.isProtected()?"protected":"not protected") + ")" +
                "   (" + (ace.isInherited()? ("inherited from '" + ace.getInheritedFrom() + "'"): "not inherited") +")");

            Enumeration privileges=ace.enumeratePrivileges();
            while (privileges.hasMoreElements())
            {
                Privilege priv=(Privilege)privileges.nextElement();
                out.println("   " + priv.getNamespace() + priv.getName() + "   " + (priv.getParameter()==null?"":("("+priv.getParameter()+")")));
            }
View Full Code Here

            out.println();
            out.println("ACL from server");
            showAces(path, aces);
        }

        Ace ace=null;
        for (int i=0; i<aces.length && (ace==null); i++)
        {
            if ((aces[i].isNegative()==negative) && !aces[i].isProtected()
                && !aces[i].isInherited() && aces[i].getPrincipal().equals(principal))
            {
                if (debugLevel>5)
                    out.println("found ace");
                ace=aces[i];
            }
        }
        if (ace==null)
        {
            Ace[] oldAces=aces;
            aces=new Ace[oldAces.length+1];
            System.arraycopy(oldAces,0,aces,0,oldAces.length);
            ace=new Ace(principal, negative, false, false,null);
            aces[oldAces.length]=ace;
        }

        Privilege privilege=new Privilege(permission.getNamespaceURI(), permission.getLocalName(), null);
        ace.addPrivilege(privilege);

        if (debugLevel>5) {
            out.println();
            out.println("ACL with updated privileges");
            showAces(path, aces);
View Full Code Here

        out.println("ACL for " + path + ":");
        out.println("------------------------------------------------------------");
        for (int i=0; i<aces.length ; i++)
        {
            Ace ace=aces[i];
            out.println((!ace.isNegative()?"granted":"denied") +
                " to " + ace.getPrincipal() + " " +
                "   (" + (ace.isProtected()?"protected":"not protected") + ")" +
                "   (" + (ace.isInherited()? ("inherited from '" + ace.getInheritedFrom() + "'"): "not inherited") +")");

            Enumeration privileges=ace.enumeratePrivileges();
            while (privileges.hasMoreElements())
            {
                Privilege priv=(Privilege)privileges.nextElement();
                out.println("   " + priv.getNamespace() + priv.getName() + "   " + (priv.getParameter()==null?"":("("+priv.getParameter()+")")));
            }
View Full Code Here

            System.err.println("Error: unknown type of principal");
            System.err.println("element: " + element);
            return null;
        }

        Ace ace = new Ace(principal);

        child = DOMUtils.getFirstElement(element, "DAV:", "grant");
        if (child == null) {
            child = DOMUtils.getFirstElement(element, "DAV:", "deny");
            ace.setNegative(true);
         }
        if (child != null) {
            NodeList privilegeElements = child.getElementsByTagNameNS("DAV:", "privilege");
            for (int i = 0; i < privilegeElements.getLength(); i++) {
                Element privilegeElement = (Element) privilegeElements.item(i);
                NodeList privileges = privilegeElement.getElementsByTagName("*");
                for (int j=0 ; j<privileges.getLength() ; j++)
                {
                    Element privilege = (Element) privileges.item(j);
                    ace.addPrivilege(parsePrivilege(privilege));
                }
            }
        }

        child = DOMUtils.getFirstElement(element, "DAV:", "inherited");
        if (child != null) {
            href = DOMUtils.getFirstElement(child, "DAV:", "href");
            String shref = null;
            if (href != null)
            {
                shref = DOMUtils.getTextValue(href);
                if (!shref.equals(response.getHref())) {
                    ace.setInherited(true);
                    ace.setInheritedFrom(shref);
                }
            }
            else
            {
                System.err.println("Error: mandatory element <href> is missing !");
                return null;
            }
        }

        child = DOMUtils.getFirstElement(element, "DAV:", "protected");
        if (child != null) {
            ace.setProtected(true);
        }

        return ace;

    }
View Full Code Here

                             XMLPrinter.OPENING);

        Enumeration aceList = aces.elements();

        while (aceList.hasMoreElements()) {
            Ace ace = (Ace) aceList.nextElement();

            if (ace.isInherited() || ace.isProtected()) {
                // draft-ietf-webdav-acl-06
                // do not submit inherited and protected aces
                // continue with next ace
                continue;
            }

            printer.writeElement("D", null, "ace",
                                 XMLPrinter.OPENING);

            printer.writeElement("D", null, "principal",
                                 XMLPrinter.OPENING);

            boolean found = false;
            String principal = ace.getPrincipal();
            String[] types = {"all", "authenticated", "unauthenticated",
                              "property", "self"};
            for (int i = 0; i < types.length && !found; i++) {
                if (types[i].equals(principal)) {
                    found = true;
                    if ("property".equals(principal)) {
                        printer.writeElement("D", null, principal,
                                             XMLPrinter.OPENING);
                        PropertyName property = ace.getProperty();
                        String nsURI = property.getNamespaceURI();
                        if ("DAV:".equals(nsURI)) {
                            printer.writeElement("D", null,
                                                 property.getLocalName(),
                                                 XMLPrinter.NO_CONTENT);
                        } else {
                            printer.writeElement("Z", nsURI,
                                                 property.getLocalName(),
                                                 XMLPrinter.NO_CONTENT);
                        }
                        printer.writeElement("D", null, principal,
                                             XMLPrinter.CLOSING);
                    } else {
                        printer.writeElement("D", null, principal,
                                             XMLPrinter.NO_CONTENT);
                    }
                }
            }
            if (!found) {
                printer.writeElement("D", null, "href", XMLPrinter.OPENING);
                printer.writeText(principal);
                printer.writeElement("D", null, "href", XMLPrinter.CLOSING);
            }

            printer.writeElement("D", null, "principal",
                                 XMLPrinter.CLOSING);

            String positive = (ace.isNegative()) ? "deny" : "grant";

            printer.writeElement("D", null, positive,
                                 XMLPrinter.OPENING);

            Enumeration privilegeList = ace.enumeratePrivileges();
            while (privilegeList.hasMoreElements()) {
                Privilege privilege = (Privilege) privilegeList.nextElement();
                printer.writeElement("D", null, "privilege",
                                     XMLPrinter.OPENING);
                String nsURI = privilege.getNamespace();
View Full Code Here

                    System.out.println();
                    System.out.println("ACL from server");
        showAces(path, aces);
    }
   
    Ace ace=null;
    for (int i=0; i<aces.length && (ace==null); i++)
    {
      if ((aces[i].isNegative()==negative) && !aces[i].isProtected()
          && !aces[i].isInherited() && aces[i].getPrincipal().equals(principal))
      {
        if (debugLevel>5)
                                    //if (log.isDebugEnabled())
                                    System.out.println("found ace");
        ace=aces[i];
      }
    }
    if (ace==null)
    {
      Ace[] oldAces=aces;
      aces=new Ace[oldAces.length+1];
      System.arraycopy(oldAces,0,aces,0,oldAces.length);
      ace=new Ace(principal, negative, false, false,null);
      aces[oldAces.length]=ace;
    }
   
    Privilege privilege=new Privilege(namespace, permission, null);
    ace.addPrivilege(privilege);
   
    if (debugLevel>5) {
                    //if (log.isDebugEnabled()) {
                    System.out.println();
                    System.out.println("ACL with updated privileges");
View Full Code Here

  {
    System.out.println("ACL for " + path + ":");
    System.out.println("------------------------------------------------------------");
    for (int i=0; i<aces.length ; i++)
    {
      Ace ace=aces[i];
      System.out.println((!ace.isNegative()?"granted":"denied") +
        " to " + ace.getPrincipal() + " " +
        "   (" + (ace.isProtected()?"protected":"not protected") + ")" +
        "   (" + (ace.isInherited()? ("inherited from '" + ace.getInheritedFrom() + "'"): "not inherited") +")");
   
      Enumeration privileges=ace.enumeratePrivileges();
      while (privileges.hasMoreElements())
      {
        Privilege priv=(Privilege)privileges.nextElement();
        System.out.println("   " + priv.getNamespace() + priv.getName() + "   " + (priv.getParameter()==null?"":("("+priv.getParameter()+")")));
      }
View Full Code Here

TOP

Related Classes of org.apache.webdav.lib.Ace

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.