Package org.apache.lenya.ac

Examples of org.apache.lenya.ac.Policy


                            } 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

    public DefaultPolicy[] getPolicies(AccreditableManager controller, String url)
        throws AccessControlException {

        List policies = new ArrayList();

        Policy policy = buildURLPolicy(controller, url);
        policies.add(policy);

        String[] directories = url.split("/");
        url = "";
View Full Code Here

     * @throws PublicationException when something went wrong.
     */
    protected void rewriteLink(AttributesImpl newAttrs, Document targetDocument, String anchor)
            throws AccessControlException, PublicationException {
        String webappUrl = targetDocument.getCompleteURL();
        Policy policy = this.policyManager.getPolicy(this.accreditableManager, webappUrl);

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

        String rewrittenURL;
        if (proxy == null) {
            rewrittenURL = this.request.getContextPath() + webappUrl;
        } else {
            rewrittenURL = proxy.getURL(targetDocument);
        }
       
        if (anchor != null) {
            rewrittenURL += "#" + anchor;
        }

        if (getLogger().isDebugEnabled()) {
            getLogger().debug(this.indent + "SSL protection: [" + policy.isSSLProtected() + "]");
            getLogger().debug(this.indent + "Resolved proxy: [" + proxy + "]");
            getLogger().debug(this.indent + "Rewriting URL to: [" + rewrittenURL + "]");
        }

        setHrefAttribute(newAttrs, rewrittenURL);
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

        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

    public DefaultPolicy[] getPolicies(AccreditableManager controller, String url)
            throws AccessControlException {

        List policies = new ArrayList();

        Policy policy = buildURLPolicy(controller, url);
        policies.add(policy);

        String[] directories = url.split("/");
        url = "";
View Full Code Here

        Document document = publication.getDocumentBuilder().buildDocument(publication, url);

        File configDir = new File(publication.getDirectory(), FileItemManager.PATH);
        assertTrue(configDir.exists());

        Policy policy = getPolicyManager().getPolicy(getAccreditableManager(), url);

        DocumentType type = DocumentTypeBuilder.buildDocumentType(documentTypeName, publication);
        String workflowId = type.getWorkflowFileName();

        WorkflowFactory factory = WorkflowFactory.newInstance();

        String[] emptyRoles = {
        };
        Situation situation = factory.buildSituation(emptyRoles, "test", "127.0.0.1");

        WorkflowFactory.initHistory(document, workflowId, situation);

        for (int situationIndex = 0; situationIndex < situations.length; situationIndex++) {
            WorkflowInstance instance = null;
            instance = factory.buildInstance(document);
            assertNotNull(instance);

            System.out.println("Current state: " + instance.getCurrentState());

            Identity identity = new Identity();
            User user =
                getAccreditableManager().getUserManager().getUser(
                    situations[situationIndex].getUser());
            identity.addIdentifiable(user);

            Role[] roles = policy.getRoles(identity);
            System.out.print("Roles:");

            for (int roleIndex = 0; roleIndex < roles.length; roleIndex++) {
                System.out.print(" " + roles[roleIndex]);
            }
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.