Package org.apache.myfaces.extensions.cdi.jsf.api.config.view

Examples of org.apache.myfaces.extensions.cdi.jsf.api.config.view.ViewConfigDescriptor


        //we have to use it as current view if an AccessDecisionVoter uses the JSF API to check access to the view-id
        context.setViewRoot(result);

        try
        {
            ViewConfigDescriptor entry = ViewConfigCache.getViewConfigDescriptor(result.getViewId());

            if(entry != null)
            {
                lazyInit();

                AccessDecisionVoterContext voterContext =
                        CodiUtils.getContextualReferenceByClass(beanManager, AccessDecisionVoterContext.class, true);

                Class<? extends ViewConfig> errorView = null;

                if(entry instanceof EditableViewConfigDescriptor)
                {
                    errorView = ((EditableViewConfigDescriptor)entry).getErrorView();
                }

                invokeVoters(null /*TODO*/, this.beanManager, voterContext, entry.getAccessDecisionVoters(), errorView);
            }
        }
        catch (AccessDeniedException accessDeniedException)
        {
            Class<? extends ViewConfig> errorView =
View Full Code Here


        }
    }

    private void checkPermission(BeanManager beanManager, FacesContext facesContext)
    {
        ViewConfigDescriptor entry = ViewConfigCache.getViewConfigDescriptor(facesContext.getViewRoot().getViewId());

        if(entry == null)
        {
            return;
        }

        try
        {
            Class<? extends ViewConfig> errorView = null;

            AccessDecisionVoterContext voterContext =
                    CodiUtils.getContextualReferenceByClass(beanManager, AccessDecisionVoterContext.class, true);

            if(entry instanceof EditableViewConfigDescriptor)
            {
                errorView = ((EditableViewConfigDescriptor)entry).getErrorView();
            }
            invokeVoters(null, beanManager, voterContext, entry.getAccessDecisionVoters(), errorView);
        }
        catch (AccessDeniedException accessDeniedException)
        {
            tryToHandleSecurityViolation(accessDeniedException);
            facesContext.renderResponse();
View Full Code Here

    public void testSimpleInterfaceBasedConfigs()
    {
        viewConfigExtension.addPageDefinition(SimpleInterfaceBasedConfigs.Wizards.Registration.Step1.class);
        viewConfigExtension.addPageDefinition(SimpleInterfaceBasedConfigs.Wizards.Order.Step1.class);

        ViewConfigDescriptor registrationConfigEntry = ViewConfigCache.getViewConfigDescriptor(SimpleInterfaceBasedConfigs.Wizards.Registration.Step1.class);
        ViewConfigDescriptor orderConfigEntry = ViewConfigCache.getViewConfigDescriptor(SimpleInterfaceBasedConfigs.Wizards.Order.Step1.class);

        assertEquals(registrationConfigEntry.getViewId(),
                "/pages/wizards/registration/step1.xhtml");
        assertEquals(orderConfigEntry.getViewId(),
                "/pages/wizards/order/step1.xhtml");

        assertEquals(registrationConfigEntry.getNavigationMode(), Page.NavigationMode.DEFAULT);
        assertEquals(orderConfigEntry.getNavigationMode(), Page.NavigationMode.REDIRECT);

        assertTrue(registrationConfigEntry.getAccessDecisionVoters().size() == 0);
        assertEquals(orderConfigEntry.getAccessDecisionVoters().size(), 1);
        assertEquals(orderConfigEntry.getAccessDecisionVoters().iterator().next(), TestAccessDecisionVoter1.class);
    }
View Full Code Here

        assertEquals(ViewConfigCache.getViewConfigDescriptor(NavigationOverriding1.RedirectedPage1.class).getViewId(),
                                                       "/redirectedPage1.xhtml");
        assertEquals(ViewConfigCache.getViewConfigDescriptor(NavigationOverriding1.ForwardedPage1.class).getViewId(),
                                                       "/forwardedPage1.xhtml");

        ViewConfigDescriptor viewConfig =ViewConfigCache.getViewConfigDescriptor(NavigationOverriding1.RedirectedPage1.class);
        assertEquals(viewConfig.getNavigationMode(), NavigationMode.REDIRECT);

        viewConfig = ViewConfigCache.getViewConfigDescriptor(NavigationOverriding1.ForwardedPage1.class);

        assertEquals(viewConfig.getNavigationMode(), NavigationMode.FORWARD);
    }
View Full Code Here

        assertEquals(ViewConfigCache.getViewConfigDescriptor(NavigationOverriding2.RedirectedPage2.class).getViewId(),
                                                       "/redirectedPage2.xhtml");
        assertEquals(ViewConfigCache.getViewConfigDescriptor(NavigationOverriding2.ForwardedPage2.class).getViewId(),
                                                       "/forwardedPage2.xhtml");

        ViewConfigDescriptor viewConfig =ViewConfigCache.getViewConfigDescriptor(NavigationOverriding2.RedirectedPage2.class);
        assertEquals(viewConfig.getNavigationMode(), NavigationMode.REDIRECT);

        viewConfig = ViewConfigCache.getViewConfigDescriptor(NavigationOverriding2.ForwardedPage2.class);

        assertEquals(viewConfig.getNavigationMode(), NavigationMode.FORWARD);
    }
View Full Code Here

    public void testViewConfigWithAccessDecisionVoters()
    {
        viewConfigExtension.addPageDefinition(ViewConfigWithAccessDecisionVoters.Page1.class);
        viewConfigExtension.addPageDefinition(ViewConfigWithAccessDecisionVoters.Page2.class);

        ViewConfigDescriptor viewConfig = ViewConfigCache.getViewConfigDescriptor(ViewConfigWithAccessDecisionVoters.Page1.class);

        assertEquals(viewConfig.getAccessDecisionVoters().size(), 1);

        viewConfig = ViewConfigCache.getViewConfigDescriptor(ViewConfigWithAccessDecisionVoters.Page2.class);

        assertEquals(viewConfig.getAccessDecisionVoters().size(), 2);

        boolean voter2 = false;
        for(Class<? extends AccessDecisionVoter> accessDecisionVoter : viewConfig.getAccessDecisionVoters())
        {
            if(!voter2)
            {
                assertTrue(accessDecisionVoter.equals(TestAccessDecisionVoter2.class));
                voter2 = true;
View Full Code Here

    public void testViewConfigWithSecurityErrorPages()
    {
        viewConfigExtension.addPageDefinition(ViewConfigWithSecurityErrorPages.Page1.class);
        viewConfigExtension.addPageDefinition(ViewConfigWithSecurityErrorPages.Page2.class);

        ViewConfigDescriptor viewConfig = ViewConfigCache.getViewConfigDescriptor(ViewConfigWithSecurityErrorPages.Page1.class);

        assertEquals(((EditableViewConfigDescriptor)viewConfig).getErrorView(), SimpleView.class);

        viewConfig = ViewConfigCache.getViewConfigDescriptor(ViewConfigWithSecurityErrorPages.Page2.class);
        assertEquals(((EditableViewConfigDescriptor)viewConfig).getErrorView(), SimpleViewWithManualName.class);
View Full Code Here

    public void testViewConfigWithViewMetaData()
    {
        viewConfigExtension.addPageDefinition(ViewConfigWithViewMetaData.Page1.class);
        viewConfigExtension.addPageDefinition(ViewConfigWithViewMetaData.Page2.class);

        ViewConfigDescriptor viewConfig = ViewConfigCache.getViewConfigDescriptor(ViewConfigWithViewMetaData.Page1.class);

        assertEquals(viewConfig.getMetaData().size(), 2);

        viewConfig = ViewConfigCache.getViewConfigDescriptor(ViewConfigWithViewMetaData.Page2.class);
        assertEquals(viewConfig.getMetaData().size(), 3);
    }
View Full Code Here

    public void testViewConfigWithViewController()
    {
        viewConfigExtension.addPageDefinition(ViewConfigWithViewController.Page1.class);
        viewConfigExtension.addPageDefinition(ViewConfigWithViewController.Page2.class);

        ViewConfigDescriptor viewConfig = ViewConfigCache.getViewConfigDescriptor(ViewConfigWithViewController.Page1.class);

        List<PageBeanDescriptor> pageBeanDescriptors = viewConfig.getPageBeanDescriptors();
        assertEquals(pageBeanDescriptors.size(), 1);
        assertTrue(pageBeanDescriptors.iterator().next().getBeanClass().equals(TestPageBean2.class));

        viewConfig = ViewConfigCache.getViewConfigDescriptor(ViewConfigWithViewController.Page2.class);

        pageBeanDescriptors = viewConfig.getPageBeanDescriptors();
        assertEquals(pageBeanDescriptors.size(), 2);

        for(PageBeanDescriptor pageBeanDescriptor : pageBeanDescriptors)
        {
            assertTrue(pageBeanDescriptor.getBeanClass().equals(TestPageBean2.class) ||
View Full Code Here

            {
                String originalOutcome = outcome;

                outcome = outcome.substring(6);

                ViewConfigDescriptor entry = null;

                if(DefaultErrorView.class.getName().equals(originalOutcome))
                {
                    entry = ViewConfigCache.getDefaultErrorViewConfigDescriptor();
                }

                if(entry == null)
                {
                    Object loadedClass = tryToLoadClassForName(outcome);

                    if(loadedClass == null)
                    {
                        this.otherOutcomes.add(originalOutcome);
                    }
                    else if(ViewConfig.class.isAssignableFrom((Class)loadedClass))
                    {
                        //noinspection unchecked
                        entry = ViewConfigCache.getViewConfigDescriptor((Class<? extends ViewConfig>) loadedClass);
                    }
                }

                if(entry != null)
                {
                    return new NavigationCase("*",
                                              null,
                                              null,
                                              null,
                                              entry.getViewId(),
                                              null,
                                              Page.NavigationMode.REDIRECT.equals(entry.getNavigationMode()),
                                              false);
                }
            }
            return ((ConfigurableNavigationHandler) this.wrapped).getNavigationCase(context, action, outcome);
        }
View Full Code Here

TOP

Related Classes of org.apache.myfaces.extensions.cdi.jsf.api.config.view.ViewConfigDescriptor

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.