Package org.apache.lenya.ac

Examples of org.apache.lenya.ac.Policy


            String ancestorUrl = "";
            int lastSlashIndex = url.lastIndexOf("/");
            if (lastSlashIndex != -1) {
                ancestorUrl = url.substring(0, lastSlashIndex);
            }
            Policy policy =
                policyManager.getPolicy(accessController.getAccreditableManager(), ancestorUrl);
            ssl = policy.isSSLProtected();
        } catch (AccessControlException e) {
            throw new ProcessingException("Resolving policy failed: ", e);
        }
        return ssl;
    }
View Full Code Here


     * @throws ProcessingException when something went wrong.
     */
    public User[] getUsersWithRole(String roleId) throws ProcessingException {
        List users = new ArrayList();
        try {
            Policy policy =
                policyManager.getPolicy(accessController.getAccreditableManager(), getUrl());
            UserManager userManager = accessController.getAccreditableManager().getUserManager();
            User[] userArray = userManager.getUsers();
            for (int i = 0; i < userArray.length; i++) {
                Identity identity = new Identity();
                identity.addIdentifiable(userArray[i]);
                Role[] roles = policy.getRoles(identity);
                for (int roleIndex = 0; roleIndex < roles.length; roleIndex++) {
                    if (roles[roleIndex].getId().equals(roleId)) {
                        users.add(userArray[i]);
                    }
                }
View Full Code Here

                        policyManager = policyAuthorizer.getPolicyManager();
                    }
                }
            }

            Policy policy = policyManager.getPolicy(accreditableManager, canonicalUrl);

            Document doc = builder.buildDocument(publication, canonicalUrl);

            Proxy proxy = doc.getPublication().getProxy(doc, policy.isSSLProtected());

            if (proxy != null) {
                value = proxy.getURL(doc);
            } else {
                // Take server name and port from request.
View Full Code Here

            context = "";
        }

        String url = requestUri.substring(context.length());

        Policy policy = getPolicyManager().getPolicy(getAccreditableManager(), url);
        Role[] roles = policy.getRoles(identity);
        saveRoles(request, roles);

        boolean authorized = roles.length > 0;
        return authorized;
    }
View Full Code Here

                            } else {
                                // document is live
                                //if ssl, add prefix, if not, check for live mount point and apply if present
                                try {
                                    String url = urlPrefix + documentId;
                                    Policy policy = policyManager.getPolicy(accreditableManager, url);
                                    if (policy.isSSLProtected()) {
                                            log.debug(" live is SSL protected");
                                     // add prefix  
                                        newAttrs.setValue(
                                                i,
                                                sslPrefix + documentId + languageExtension + ".html");
                                    }
                                    else {
                                        // check for live mount point
                                        newAttrs.setValue(
                                        i,
                                        getNewHrefValue(languageExtension, documentId));
                                    }
                                   
                                    }
                                    catch (AccessControlException e) {
                                      throw new SAXException(e);
                                    }

                            }
                        } else {
                            /* authoring area
                             */
                            try {
                                String url = urlPrefix + documentId;
                                String finalurl;
                                Policy policy = policyManager.getPolicy(accreditableManager, url);
                                if (policy.isSSLProtected()) {
                                 // add prefix
                                        log.debug(" authoring is SSL protected");
                                        log.debug(" ssl prefix: " + sslPrefix);
                                        finalurl = sslPrefix + documentId + languageExtension + ".html";
                                        log.debug(" finalurl: " + finalurl);                                       
View Full Code Here

        String publicationId = url.substring(0, slashIndex);
        url = url.substring(publicationId.length());

        SourceResolver resolver = null;
        Policy policy = null;
        Source source = null;
        try {
            resolver = (SourceResolver) getManager().lookup(SourceResolver.ROLE);

            String policyUrl = publicationId + "/policies" + url + ".acml";
View Full Code Here

                getLogger().debug("    URL:         [" + urlPrefix + documentId + "]");
            }

            try {
                String url = urlPrefix + documentId;
                Policy policy = policyManager.getPolicy(accreditableManager, url);
                Role[] roles = policy.getRoles(identity);

                getLogger().debug("    Roles:       [" + roles.length + "]");

                if (roles.length == 0) {
                    getLogger().debug("    Adding attribute [protected='true']");
View Full Code Here

        DefaultAccessController controller = getAccessController();
        PolicyManager policyManager = controller.getPolicyManager();
        assertNotNull(policyManager);
       
        for (int i = 0; i < URLS.length; i++) {
            Policy policy = policyManager.getPolicy(controller.getAccreditableManager(), URLS[i]);
            assertNotNull(policy);
            assertTrue(policy.getRoles(getIdentity()).length > 0);
        }
    }
View Full Code Here

     * A test.
     * @throws AccessControlException when something went wrong.
     */
    public void testLoadPolicy() throws AccessControlException {
        String url = "/" + PublicationHelper.getPublication().getId() + URL;
        Policy policy = getPolicy(url);
        Role[] roles = policy.getRoles(getIdentity());
        System.out.print("Roles: ");

        for (int i = 0; i < roles.length; i++) {
            System.out.print(roles[i]);
        }
View Full Code Here

     * @param url The URL.
     * @return The policy.
     * @throws AccessControlException when something went wrong.
     */
    protected Policy getPolicy(String url) throws AccessControlException {
        Policy policy =
            getPolicyManager().getPolicy(getAccessController().getAccreditableManager(), url);

        return policy;
    }
View Full Code Here

TOP

Related Classes of org.apache.lenya.ac.Policy

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.