Package org.apache.lenya.ac

Examples of org.apache.lenya.ac.Policy


    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


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

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

                //                if (getLogger().isDebugEnabled()) {
                getLogger().debug("    Roles:       [" + roles.length + "]");
                //                }
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

        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

        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

            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

            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

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.