Package org.apache.lenya.ac

Examples of org.apache.lenya.ac.Policy


            int lastSlashIndex = getPolicyURL().lastIndexOf("/");
            if (lastSlashIndex != -1) {
                ancestorUrl = getPolicyURL().substring(0, lastSlashIndex);
            }

            Policy policy = getPolicyManager().getPolicy(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.
     */
    protected boolean isSSLProtected() throws ProcessingException {
        boolean ssl;
        try {
            Policy policy = getPolicyManager().getPolicy(getAccreditableManager(), getPolicyURL());
            ssl = policy.isSSLProtected();
        } catch (AccessControlException e) {
            throw new ProcessingException("Resolving policy failed: ", e);
        }
        return ssl;
    }
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

        File configDir = new File(publication.getDirectory(), "config" + File.separator + "ac"
                + File.separator + "passwd");
        assertTrue(configDir.exists());

        Policy policy = getPolicyManager().getPolicy(getAccreditableManager(), url);
       
        WorkflowResolver resolver = null;
        try {
            resolver = (WorkflowResolver) getManager().lookup(WorkflowResolver.ROLE);


            String[] emptyRoles = {};
            Situation situation = new CMSSituation(emptyRoles, "test", "127.0.0.1");

            WorkflowInstance instance = resolver.getWorkflowInstance(document);
            instance.getHistory().initialize(situation);

            for (int situationIndex = 0; situationIndex < situations.length; situationIndex++) {
                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

                        policyManager = policyAuthorizer.getPolicyManager();
                    }
                }
            }

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

            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

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

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

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

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

     */
    protected void rewriteLink(AttributesImpl newAttrs, Document targetDocument, String anchor)
            throws AccessControlException {

        String webappUrl = targetDocument.getCanonicalWebappURL();
        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

        Identity identity,
        Request request,
        String webappUrl)
        throws AccessControlException {

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

        boolean authorized = roles.length > 0;
        return authorized;
    }
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.