Examples of PolicyManager


Examples of gov.nasa.arc.mct.services.component.PolicyManager

       
        // Mock persistence provider, policy manager, and platform
        PlatformAccess access = new PlatformAccess();
        Platform mockPlatform = Mockito.mock(Platform.class);
        PersistenceProvider mockPersistenceProvider = Mockito.mock(PersistenceProvider.class);
        PolicyManager mockpoPolicyManager = Mockito.mock(PolicyManager.class);      
        CoreComponentRegistry mockComponentRegistry = Mockito.mock(CoreComponentRegistry.class);
        WindowManager mockWindowManager = Mockito.mock(WindowManager.class);
       
        access.setPlatform(mockPlatform);
        Mockito.when(mockPlatform.getPersistenceProvider()).thenReturn(mockPersistenceProvider);
        Mockito.when(mockPlatform.getPolicyManager()).thenReturn(mockPolicyManager);
        Mockito.when(mockPlatform.getComponentRegistry()).thenReturn(mockComponentRegistry);
        Mockito.when(mockPlatform.getWindowManager()).thenReturn(mockWindowManager);
        ExecutionResult mockResult = new ExecutionResult(new PolicyContext(), true, "");
        Mockito.when(mockpoPolicyManager.execute(Mockito.anyString(), Mockito.any(PolicyContext.class))).thenReturn(mockResult);
        Mockito.when(mockWindowManager.<Object>showInputDialog(
                Mockito.anyString(), Mockito.anyString(), Mockito.<Object[]>any(), Mockito.any(), Mockito.anyMap()))
                .thenAnswer(new Answer<Object>() {
                    @Override
                    public Object answer(InvocationOnMock invocation) throws Throwable {
View Full Code Here

Examples of gov.nasa.arc.mct.services.component.PolicyManager

       
        // Mock persistence provider, policy manager, and platform.
        PlatformAccess access = new PlatformAccess();
        Platform mockPlatform = Mockito.mock(Platform.class);
        PersistenceProvider mockPersistenceProvider = Mockito.mock(PersistenceProvider.class);
        PolicyManager mockpoPolicyManager = Mockito.mock(PolicyManager.class);      
        CoreComponentRegistry mockComponentRegistry = Mockito.mock(CoreComponentRegistry.class);
        WindowManager mockWindowManager = Mockito.mock(WindowManager.class);
       
        access.setPlatform(mockPlatform);
        Mockito.when(mockPlatform.getPersistenceProvider()).thenReturn(mockPersistenceProvider);
        Mockito.when(mockPlatform.getPolicyManager()).thenReturn(mockPolicyManager);       
        ExecutionResult mockResult = new ExecutionResult(new PolicyContext(), true, "");
        Mockito.when(mockpoPolicyManager.execute(Mockito.anyString(), Mockito.any(PolicyContext.class))).thenReturn(mockResult);
        Mockito.when(mockPlatform.getComponentRegistry()).thenReturn(mockComponentRegistry);
        Mockito.when(mockPlatform.getWindowManager()).thenReturn(mockWindowManager);
        Mockito.when(mockWindowManager.<Object>showInputDialog(
                Mockito.anyString(), Mockito.anyString(), Mockito.<Object[]>any(), Mockito.any(), Mockito.anyMap()))
                .thenAnswer(new Answer<Object>() {
View Full Code Here

Examples of gov.nasa.arc.mct.services.component.PolicyManager

public class MockPlatform implements Platform {
 
  @Override
  public PolicyManager getPolicyManager() {
    return new PolicyManager() {
     
      @Override
      public ExecutionResult execute(String categoryKey, PolicyContext context) {
        return new ExecutionResult(context, true, "");
      }
View Full Code Here

Examples of gov.nasa.arc.mct.services.component.PolicyManager

            private boolean canComponentBeContained() {
                PolicyContext context = new PolicyContext();
                context.setProperty(PolicyContext.PropertyName.SOURCE_COMPONENTS.getName(),Collections.singleton(referencedComponent));
                String policyCategoryKey = PolicyInfo.CategoryType.CAN_OBJECT_BE_CONTAINED_CATEGORY.getKey();
                Platform platform = PlatformAccess.getPlatform();
                PolicyManager policyManager = platform.getPolicyManager();
                ExecutionResult result = policyManager.execute(policyCategoryKey, context);
                return result.getStatus();
            }
           
            @Override
            protected Transferable createTransferable(JComponent c) {
View Full Code Here

Examples of org.apache.lenya.ac.PolicyManager

     */
    public Object getAttribute(String name, Configuration modeConf, Map objectModel)
            throws ConfigurationException {

        ServiceSelector serviceSelector = null;
        PolicyManager policyManager = null;
        AccessControllerResolver acResolver = null;
        AccreditableManager accreditableManager = null;

        // Get parameters
        final String[] attributes = name.split(":");

        if (attributes.length < 3) {
            throw new ConfigurationException("Invalid number of parameters: " + attributes.length
                    + ". Expected area, document-id, language.");
        }

        final String area = attributes[0];
        final String documentId = attributes[1];
        final String language = attributes[2];

        String value = null;
        try {
            PageEnvelope envelope = PageEnvelopeFactory.getInstance().getPageEnvelope(objectModel);
            Publication publication = envelope.getPublication();

            DocumentBuilder builder = publication.getDocumentBuilder();

            // Create canonical URL
            String canonicalUrl = builder
                    .buildCanonicalUrl(publication, area, documentId, language);

            if (getLogger().isDebugEnabled()) {
                getLogger().debug("Created canonicalURL: " + canonicalUrl);
            }

            // Get proxy for document
            serviceSelector = (ServiceSelector) this.manager.lookup(AccessControllerResolver.ROLE
                    + "Selector");
            acResolver = (AccessControllerResolver) serviceSelector
                    .select(AccessControllerResolver.DEFAULT_RESOLVER);

            AccessController accessController = acResolver.resolveAccessController(canonicalUrl);
            if (accessController instanceof DefaultAccessController) {
                DefaultAccessController defaultAccessController = (DefaultAccessController) accessController;
                accreditableManager = defaultAccessController.getAccreditableManager();
                Authorizer[] authorizers = defaultAccessController.getAuthorizers();
                for (int i = 0; i < authorizers.length; i++) {
                    if (authorizers[i] instanceof PolicyAuthorizer) {
                        PolicyAuthorizer policyAuthorizer = (PolicyAuthorizer) authorizers[i];
                        policyManager = policyAuthorizer.getPolicyManager();
                    }
                }
            }

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

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

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

View Full Code Here

Examples of org.apache.lenya.ac.PolicyManager

     * @throws AccessControlException when something went wrong.
     */
    public void testAccessController() throws AccessControlException {
       
        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

Examples of org.apache.lenya.ac.PolicyManager

            String type = policyManagerConfiguration.getAttribute(ATTRIBUTE_TYPE);
            try {
                policyManagerSelector =
                    (ServiceSelector) getServiceManager().lookup(PolicyManager.ROLE + "Selector");

                PolicyManager policyManager = (PolicyManager) policyManagerSelector.select(type);

                if (!(policyManager instanceof InheritingPolicyManager)) {
                    throw new AccessControlException(
                        "The "
                            + getClass().getName()
View Full Code Here

Examples of org.apache.lenya.ac.PolicyManager

            selector = (ServiceSelector) manager.lookup(AccessControllerResolver.ROLE + "Selector");
            acResolver = (AccessControllerResolver) selector
                    .select(AccessControllerResolver.DEFAULT_RESOLVER);
            accessController = acResolver.resolveAccessController(url);

            PolicyManager policyManager = accessController.getPolicyManager();
            Identity identity = workflowable.getSession().getIdentity();
            AccreditableManager accreditableMgr = accessController
            .getAccreditableManager();
            Policy policy = policyManager.getPolicy(accreditableMgr, url);
            RoleManager roleManager = accreditableMgr.getRoleManager();
           
            boolean complied = false;
           
            for (Iterator i = this.roleIds.iterator(); i.hasNext(); ) {
View Full Code Here

Examples of org.apache.lenya.ac.PolicyManager

                type = policyManagerConfiguration.getAttribute(this.ATTRIBUTE_TYPE);

                this.policyManagerSelector = (ServiceSelector) getServiceManager().lookup(
                        PolicyManager.ROLE + "Selector");

                PolicyManager _policyManager = (PolicyManager) this.policyManagerSelector
                        .select(type);

                if (!(_policyManager instanceof InheritingPolicyManager)) {
                    throw new AccessControlException("The " + getClass().getName()
                            + " can only be used with an "
View Full Code Here

Examples of org.apache.lenya.ac.PolicyManager

            AccreditableManager accreditableManager = controller.getAccreditableManager();
            UserManager userManager = accreditableManager.getUserManager();
            User[] users = userManager.getUsers();
            List usersWithRole = new ArrayList();
            PolicyManager policyManager = controller.getPolicyManager();

            Role roleObject = accreditableManager.getRoleManager().getRole(role);

            for (int i = 0; i < users.length; i++) {
                Identity identity = new Identity(logger);
                identity.addIdentifiable(users[i]);
                Role[] roles = policyManager.getGrantedRoles(accreditableManager, identity,
                        webappUrl);
                if (Arrays.asList(roles).contains(roleObject)) {
                    usersWithRole.add(users[i]);
                }
            }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.