Examples of CarbonUIDefinitions


Examples of org.wso2.carbon.ui.deployment.beans.CarbonUIDefinitions

        HashMap<String, String> httpUrlsToBeByPassed = new HashMap<String, String>();
        Context defaultContext = null;
        if (bundle != null) {
            ServiceReference reference = bundle.getBundleContext().getServiceReference(
                    CarbonUIDefinitions.class.getName());
            CarbonUIDefinitions carbonUIDefinitions;
            if (reference != null) {
                carbonUIDefinitions = (CarbonUIDefinitions) bundle.getBundleContext().getService(
                        reference);
                if (carbonUIDefinitions != null) {
                    httpUrlsToBeByPassed = carbonUIDefinitions.getHttpUrls();
                    if (carbonUIDefinitions.getContexts().containsKey("default-context")) {
                        defaultContext = carbonUIDefinitions.getContexts().get("default-context");
                    }

                }
            }
        }

        if (requestedURI.equals(context) || requestedURI.equals(context + "/")) {
            if (defaultContext != null && !"".equals(defaultContext.getContextName())
                    && !"null".equals(defaultContext.getContextName())) {
                String adminConsoleURL = CarbonUIUtil.getAdminConsoleURL(request);
                int index = adminConsoleURL.lastIndexOf("carbon");
                String defaultContextUrl = adminConsoleURL.substring(0, index)
                        + defaultContext.getContextName() + "/";
                response.sendRedirect(defaultContextUrl);
            } else {
                response.sendRedirect("carbon");
            }
            return false;
        }
        // when war is deployed on top of an existing app server we cannot use
        // root context
        // for deployment. Hence a new context is added.
        // Now url changes from eg: carbon/admin/index.jsp to
        // wso2/carbon/admin/index.jsp
        // In this case before doing anything, we need to remove web app context
        // (eg: wso2) .
        String tmp = requestedURI;
        String customWarContext = "";
        if (requestedURI.startsWith("/carbon") && !(requestedURI.startsWith("/carbon/carbon/"))) {
            // one can name the folder as 'carbon'
            requestedURI = tmp;
        } else if (requestedURI.indexOf("filedownload") == -1
                && requestedURI.indexOf("fileupload") == -1) {
            // replace first context
            String tmp1 = tmp.replaceFirst("/", "");
            int end = tmp1.indexOf("/");
            if (end > -1) {
                customWarContext = tmp1.substring(0, end);
                // one can rename the war file as 'registry'.
                // This will conflict with our internal 'registry' context
                if (!(requestedURI.startsWith("/registry/registry/"))
                        && !(requestedURI.startsWith("/registry/carbon/"))
                        && (customWarContext.equals("registry")
                        || customWarContext.equals("gadgets") || customWarContext
                        .equals("social"))) {
                    requestedURI = tmp;
                } else {
                    requestedURI = tmp.substring(end + 1);
                }
            }
        }

        // Disabling http access to admin console
        // user guide documents should be allowed to access via http protocol
        if (!request.isSecure() && !(requestedURI.endsWith(".html"))) {

            // by passing items required for try-it & IDE plugins
            if (requestedURI.endsWith(".css") || requestedURI.endsWith(".gif")
                    || requestedURI.endsWith(".GIF") || requestedURI.endsWith(".jpg")
                    || requestedURI.endsWith(".JPG") || requestedURI.endsWith(".png")
                    || requestedURI.endsWith(".PNG") || requestedURI.endsWith(".xsl")
                    || requestedURI.endsWith(".xslt") || requestedURI.endsWith(".js")
                    || requestedURI.endsWith(".ico") || requestedURI.endsWith("/filedownload")
                    || requestedURI.endsWith("/fileupload")
                    || requestedURI.indexOf("/fileupload/") > -1
                    || requestedURI.indexOf("admin/jsp/WSRequestXSSproxy_ajaxprocessor.jsp") > -1
                    || requestedURI.indexOf("registry/atom") > -1
                    || requestedURI.indexOf("registry/tags") > -1
                    || requestedURI.indexOf("gadgets/") > -1
                    || requestedURI.indexOf("registry/resource") > -1) {
                return true;
            }

            String resourceURI = requestedURI.replaceFirst("/carbon/", "../");

            // bypassing the pages which are specified as bypass https
            if (httpUrlsToBeByPassed.containsKey(resourceURI)) {
                if (!authenticated) {
                    try {
                        Cookie[] cookies = request.getCookies();
                        if (cookies != null) {
                            for (Cookie cookie : cookies) {
                                if (cookie.getName().equals(CarbonConstants.REMEMBER_ME_COOKE_NAME)) {
                                    if (getAuthenticator(request).reAuthenticateOnSessionExpire(request)) {
                                        String cookieValue = cookie.getValue();
                                        CarbonUIAuthenticationUtil.onSuccessAdminLogin(request,
                                                getUserNameFromCookie(cookieValue));
                                    }
                                }
                            }
                        }
                    } catch (Exception e) {
                        log.error(e.getMessage(), e);
                        throw new IOException(e.getMessage(), e);
                    }
                }
                return true;
            }

            String adminConsoleURL = CarbonUIUtil.getAdminConsoleURL(request);
            if (adminConsoleURL != null) {
                if (log.isTraceEnabled()) {
                    log.trace("Request came to admin console via http.Forwarding to : "
                            + adminConsoleURL);
                }
                response.sendRedirect(adminConsoleURL);
                return false;
            }
        }

        String resourceURI = requestedURI.replaceFirst("/carbon/", "../");

        if (log.isDebugEnabled()) {
            log.debug("CarbonSecuredHttpContext -> handleSecurity() requestURI:" + requestedURI
                    + " id:" + sessionId + " resourceURI:" + resourceURI);
        }

        // retrieve urls that should be by-passed from security check
        HashMap<String, String> urlsToBeByPassed = new HashMap<String, String>();
        if (bundle != null) {
            ServiceReference reference = bundle.getBundleContext().getServiceReference(
                    CarbonUIDefinitions.class.getName());
            CarbonUIDefinitions carbonUIDefinitions;
            if (reference != null) {
                carbonUIDefinitions = (CarbonUIDefinitions) bundle.getBundleContext().getService(
                        reference);
                if (carbonUIDefinitions != null) {
                    urlsToBeByPassed = carbonUIDefinitions.getUnauthenticatedUrls();
                    /*
                     * if(log.isDebugEnabled()){ Iterator<String> itr =
                     * urlsToBeByPassed.keySet().iterator();
                     * while(itr.hasNext()){
                     * log.debug("Should bypass url : "+itr.next()); } }
View Full Code Here

Examples of org.wso2.carbon.ui.deployment.beans.CarbonUIDefinitions

                    CarbonUIUtil.getAdminConsoleURL(serverConfiguration.getFirstProperty("WebContextRoot"));

            //Retrieving available contexts
            Context defaultContext = null;
            ServiceReference reference = ctxt.getBundleContext().getServiceReference(CarbonUIDefinitions.class.getName());
            CarbonUIDefinitions carbonUIDefinitions = null;
            if (reference != null) {
                carbonUIDefinitions =
                        (CarbonUIDefinitions) ctxt.getBundleContext().getService(reference);
                if (carbonUIDefinitions != null) {
                    if (carbonUIDefinitions.getContexts().containsKey("default-context")) {
                        defaultContext = carbonUIDefinitions.getContexts().get("default-context");
                    }

                }
            }
View Full Code Here

Examples of org.wso2.carbon.ui.deployment.beans.CarbonUIDefinitions

        ConfigurationContext configContext =
                getConfigurationContextService().getClientConfigContext();

        ServerConfiguration serverConfig = getServerConfiguration();

        CarbonUIDefinitions carbonUIDefinitions = new CarbonUIDefinitions();
        context.registerService(CarbonUIDefinitions.class.getName(), carbonUIDefinitions, null);

        // create a CustomUIDefinitions object and set it as a osgi service. UIBundleDeployer can access this
        // service and populate it with custom UI definitions of the deployed UI bundle, if available.
        CustomUIDefenitions customUIDefenitions = new CustomUIDefenitions();
View Full Code Here

Examples of org.wso2.carbon.ui.deployment.beans.CarbonUIDefinitions

                setDefaultMenus(loggedInUserName, isSuperTenant, userPermission, request);
            }
           
        String filtered = (String)request.getSession().getAttribute(MenuAdminClient.USER_MENU_ITEMS_FILTERED);
        if("false".equals(filtered)){
          CarbonUIDefinitions o = new CarbonUIDefinitions();
          Menu[] filteredMenus = o.getMenuDefinitions(loggedInUserName, isSuperTenant, userPermission, request, menus);
          menus = null;
          menus = filteredMenus;
          request.getSession().setAttribute(USER_MENU_ITEMS,menus);
        }
        if(menus != null){
View Full Code Here

Examples of org.wso2.carbon.ui.deployment.beans.CarbonUIDefinitions

                                 ArrayList<String> userPermission,
                                 HttpServletRequest request) {
        BundleContext bundleContext = CarbonUIUtil.getBundleContext();
        if (bundleContext != null) {
            ServiceReference reference = bundleContext.getServiceReference(CarbonUIDefinitions.class.getName());
            CarbonUIDefinitions carbonUIDefinitions;
            if (reference != null) {
                carbonUIDefinitions = (CarbonUIDefinitions) bundleContext.getService(reference);
                menus = carbonUIDefinitions.getMenuDefinitions(loggedInUserName,
                            isSuperTenant, userPermission,request);
                if (menus != null) {
                  if (log.isDebugEnabled()) {
                        log.debug("Found exiting menu items in OSGI context");
                    }
View Full Code Here

Examples of org.wso2.carbon.ui.deployment.beans.CarbonUIDefinitions

        Component component = ComponentBuilder.build(bundle, bundleContext);
        if (component == null) {
            return;
        } else {
            ServiceReference reference = bundleContext.getServiceReference(CarbonUIDefinitions.class.getName());
            CarbonUIDefinitions carbonUIDefinitions = null;
            if (reference != null) {
                carbonUIDefinitions = (CarbonUIDefinitions) bundleContext.getService(reference);
            }
            if (carbonUIDefinitions != null) {
                if (log.isDebugEnabled()) {
                    log.debug("Found carbonUIDefinitions in OSGi context");
                }
                carbonUIDefinitions.setMenuDefinitions(component.getMenus(), action);
                carbonUIDefinitions.setServletDefinitions(component.getServlets(), action);
                carbonUIDefinitions.addUnauthenticatedUrls(component.getUnauthenticatedUrlList());
                carbonUIDefinitions.addSkipTilesUrls(component.getSkipTilesUrlList());
                carbonUIDefinitions.addHttpUrls(component.getSkipHttpsUrlList());
                carbonUIDefinitions.addContexts(component.getContextsList());
            } else {
                if (log.isDebugEnabled()) {
                    log.debug("CarbonUIDefinitions is NULL. Registering new...");
                }
                carbonUIDefinitions = new CarbonUIDefinitions();
                carbonUIDefinitions.setMenuDefinitions(component.getMenus(), action);
                carbonUIDefinitions.setServletDefinitions(component.getServlets(), action);
                carbonUIDefinitions.addUnauthenticatedUrls(component.getUnauthenticatedUrlList());
                carbonUIDefinitions.addSkipTilesUrls(component.getSkipTilesUrlList());
                carbonUIDefinitions.addHttpUrls(component.getSkipHttpsUrlList());
                carbonUIDefinitions.addContexts(component.getContextsList());
                bundleContext.registerService(CarbonUIDefinitions.class.getName(), carbonUIDefinitions, null);
            }
        }

        //processing servlet definitions
View Full Code Here

Examples of org.wso2.carbon.ui.deployment.beans.CarbonUIDefinitions

    private void populatehttpUrlsToBeByPassed() {
        if (bundle != null && httpUrlsToBeByPassed.isEmpty() && defaultContext == null) {
            @SuppressWarnings("rawtypes")
            ServiceReference reference = bundle.getBundleContext().getServiceReference(
                    CarbonUIDefinitions.class.getName());
            CarbonUIDefinitions carbonUIDefinitions;
            if (reference != null) {
                carbonUIDefinitions = (CarbonUIDefinitions) bundle.getBundleContext().getService(
                        reference);
                if (carbonUIDefinitions != null) {
                    httpUrlsToBeByPassed = carbonUIDefinitions.getHttpUrls();
                    if (carbonUIDefinitions.getContexts().containsKey("default-context")) {
                        defaultContext = carbonUIDefinitions.getContexts().get("default-context");
                    }

                }
            }
        }
View Full Code Here

Examples of org.wso2.carbon.ui.deployment.beans.CarbonUIDefinitions

        Component component = ComponentBuilder.build(bundle, bundleContext);
        if (component == null) {
            return;
        } else {
            ServiceReference reference = bundleContext.getServiceReference(CarbonUIDefinitions.class.getName());
            CarbonUIDefinitions carbonUIDefinitions = null;
            if (reference != null) {
                carbonUIDefinitions = (CarbonUIDefinitions) bundleContext.getService(reference);
            }
            if (carbonUIDefinitions != null) {
                if (log.isDebugEnabled()) {
                    log.debug("Found carbonUIDefinitions in OSGi context");
                }
                if (CarbonConstants.ADD_UI_COMPONENT.equals(action)) {
                    if (log.isDebugEnabled()) {
                        log.debug("Adding UI component using existing Carbon Definition");
                    }
                    ArrayList<Menu> menusToAdd = new ArrayList<Menu>();
          for (Menu menu : component.getMenus()) {
           
            // Prevent adding the menu if it is defined to be hidden.
            if (!(hideMenuIds.contains(menu.getId()))) {
              menusToAdd.add(menu);
            }
          }
          if(menusToAdd.size() > 0) {
            Menu[] menus = new Menu[menusToAdd.size()];
            menus = menusToAdd.toArray(menus);
            carbonUIDefinitions.addMenuItems(menus);
          }

                    carbonUIDefinitions.addServletItems(component.getServlets());
                    carbonUIDefinitions.addUnauthenticatedUrls(component.getUnauthenticatedUrlList());
                    carbonUIDefinitions.addSkipTilesUrls(component.getSkipTilesUrlList());
                    carbonUIDefinitions.addHttpUrls(component.getSkipHttpsUrlList());
                    carbonUIDefinitions.addContexts(component.getContextsList());
                } else if (CarbonConstants.REMOVE_UI_COMPONENT.equals(action)) {
                    if (log.isDebugEnabled()) {
                        log.debug("Removing UI component using existing carbon definition");
                    }
                    carbonUIDefinitions.removeMenuItems(component.getMenus());
                    carbonUIDefinitions.removeServletItems(component.getServlets());
                    carbonUIDefinitions.removeUnauthenticatedUrls(component.getUnauthenticatedUrlList());
                    carbonUIDefinitions.removeSkipTilesUrls(component.getSkipTilesUrlList());
                    carbonUIDefinitions.removeHttpUrls(component.getSkipHttpsUrlList());
                    carbonUIDefinitions.removeContexts(component.getContextsList());
                }
            } else {
                if (log.isDebugEnabled()) {
                    log.debug("CarbonUIDefinitions is NULL. Registering new...");
                }
                carbonUIDefinitions = new CarbonUIDefinitions();
                carbonUIDefinitions.addMenuItems(component.getMenus());
                carbonUIDefinitions.addServletItems(component.getServlets());
                carbonUIDefinitions.addUnauthenticatedUrls(component.getUnauthenticatedUrlList());
                carbonUIDefinitions.addSkipTilesUrls(component.getSkipTilesUrlList());
                carbonUIDefinitions.addHttpUrls(component.getSkipHttpsUrlList());
                carbonUIDefinitions.addContexts(component.getContextsList());
                bundleContext.registerService(CarbonUIDefinitions.class.getName(), carbonUIDefinitions, null);
            }
        }
        //processing servlet definitions
        processServletDefinitions(component,action);
View Full Code Here

Examples of org.wso2.carbon.ui.deployment.beans.CarbonUIDefinitions

        HashMap<String, String> urlsToBeByPassed = new HashMap<String, String>();
        if (bundle != null) {
            ServiceReference reference = bundle.getBundleContext()
                    .getServiceReference(CarbonUIDefinitions.class.getName());
            CarbonUIDefinitions carbonUIDefinitions = null;
            if (reference != null) {
                carbonUIDefinitions =
                        (CarbonUIDefinitions) bundle.getBundleContext().getService(reference);
                if (carbonUIDefinitions != null) {
                    urlsToBeByPassed = carbonUIDefinitions.getSkipTilesUrls();
                }
            }
        }

        //if the current uri is marked to be by-passed, let it pass through
View Full Code Here

Examples of org.wso2.carbon.ui.deployment.beans.CarbonUIDefinitions

                setDefaultMenus(loggedInUserName, isSuperTenant, userPermission, request);
            }
           
        String filtered = (String)request.getSession().getAttribute(MenuAdminClient.USER_MENU_ITEMS_FILTERED);
        if("false".equals(filtered)){
          CarbonUIDefinitions o = new CarbonUIDefinitions();
          Menu[] filteredMenus = o.getMenuDefinitions(loggedInUserName, isSuperTenant, userPermission, request, menus);
          menus = filteredMenus;
          request.getSession().setAttribute(USER_MENU_ITEMS,menus);
        }
        if(menus != null){
          if(log.isDebugEnabled()){
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.