Package javax.portlet

Examples of javax.portlet.PortletException


           
            ContentFragment fragment = page.getFragmentById(fragmentId);
           
            if (fragment == null)
            {
                throw new PortletException("Cannot find fragment: " + fragmentId);
            }

            String roles = request.getParameter("roles");
            String groups = request.getParameter("groups");
            String users = request.getParameter("users");
            String permissions = request.getParameter("permissions");
           
            SecurityConstraints constraints = new TransientSecurityConstraints(fragment.getSecurityConstraints());
           
            List<SecurityConstraint> constraintList = null;
           
            if (constraints != null)
            {
                constraintList = constraints.getSecurityConstraints();
               
                if (constraintList != null)
                {
                    for (Iterator it = constraintList.iterator(); it.hasNext(); )
                    {
                        SecurityConstraint constraint = (SecurityConstraint) it.next();
                       
                        String [] removeRoleArray = StringUtils.split(roles, DELIMITERS);
                        String [] removeGroupArray = StringUtils.split(groups, DELIMITERS);
                        String [] removeUserArray = StringUtils.split(users, DELIMITERS);
                       
                        List<String> roleList = constraint.getRoles();
                        List<String> groupList = constraint.getGroups();
                        List<String> userList = constraint.getUsers();
                       
                        if (hasEqualItems(removeRoleArray, roleList) &&
                            hasEqualItems(removeGroupArray, groupList) &&
                            hasEqualItems(removeUserArray, userList))
                        {
                            it.remove();
                            break;
                        }
                    }
                }
            }
           
            if (constraints != null && constraintList != null)
            {
                constraints.setSecurityConstraints(constraintList);
            }
           
            pageLayoutComponent.updateSecurityConstraints(fragment, constraints);
        }
        catch (Exception e)
        {
            throw new PortletException("Failed to remove security constraint.", e);
        }
    }
View Full Code Here


           
            ContentFragment fragment = page.getFragmentById(fragmentId);
           
            if (fragment == null)
            {
                throw new PortletException("Cannot find fragment: " + fragmentId);
            }
           
            String [] securityConstraintRefs = request.getParameterValues("securityConstraintRef");
           
            SecurityConstraints constraints = new TransientSecurityConstraints(fragment.getSecurityConstraints());
           
            Set<String> constraintRefSet = new HashSet<String>();
           
            if (securityConstraintRefs != null)
            {
                for (int i = 0; i < securityConstraintRefs.length; i++)
                {
                    if (!"".equals(securityConstraintRefs[i]))
                    {
                        constraintRefSet.add(securityConstraintRefs[i]);
                    }
                }
            }
           
            constraints.setSecurityConstraintsRefs(constraintRefSet.isEmpty() ? null : new ArrayList<String>(constraintRefSet));
           
            pageLayoutComponent.updateSecurityConstraints(fragment, constraints);
        }
        catch (Exception e)
        {
            throw new PortletException("Failed to remove security constraint.", e);
        }
    }
View Full Code Here

    {
        super.init(config);
        userManager = (UserManager)getPortletContext().getAttribute(CommonPortletServices.CPS_USER_MANAGER_COMPONENT);
        if (null == userManager)
        {
            throw new PortletException("Failed to find the User Manager on portlet initialization");
        }
    }
View Full Code Here

        super.init(config);
        groupManager = (GroupManager)
            getPortletContext().getAttribute(CommonPortletServices.CPS_GROUP_MANAGER_COMPONENT);
        if (null == groupManager)
        {
            throw new PortletException("Failed to find the User Manager on portlet initialization");
        }
    }
View Full Code Here

        super.init(config);
        PortletContext context = getPortletContext();
        statistics = (PortalStatistics) context
                .getAttribute(CommonPortletServices.CPS_PORTAL_STATISTICS);
        if (statistics == null)
                throw new PortletException(
                        "Could not get instance of portal statistics component");
    }
View Full Code Here

        super.init(config);
        userManager = (UserManager)
            getPortletContext().getAttribute(CommonPortletServices.CPS_USER_MANAGER_COMPONENT);
        if (null == userManager)
        {
            throw new PortletException("Failed to find the User Manager on portlet initialization");
        }
    }
View Full Code Here

        super.init(config);
        roleManager = (RoleManager)
            getPortletContext().getAttribute(CommonPortletServices.CPS_GROUP_MANAGER_COMPONENT);
        if (null == roleManager)
        {
            throw new PortletException("Failed to find the User Manager on portlet initialization");
        }
    }
View Full Code Here

    {  
        this.portletConfig = portletConfig;
        pageManager = (PageManager) getPortletContext().getAttribute(CommonPortletServices.CPS_PAGE_MANAGER_COMPONENT);       
        if (null == pageManager)
        {
            PortletException pe = new PortletException("Failed to find the Page Manager on portlet initialization");
            throw new RuntimeException(pe);
        }

        rm = (RoleManager) getPortletContext().getAttribute(CommonPortletServices.CPS_ROLE_MANAGER_COMPONENT);
        if (rm == null)
View Full Code Here

            } else if (RESTART_ACTION.equals(action)) {
                configurationManager.restartConfiguration(configId);
                messageStatus = "Restarted application<br /><br />";
            } else {
                messageStatus = "Invalid value for changeState: " + action + "<br /><br />";
                throw new PortletException("Invalid value for changeState: " + action);
            }
        } catch (NoSuchConfigException e) {
            // ignore this for now
            messageStatus = "Configuration not found<br /><br />";
            throw new PortletException("Configuration not found", e);
        } catch (LifecycleException e) {
            // todo we have a much more detailed report now
            messageStatus = "Lifecycle operation failed<br /><br />";
            throw new PortletException("Exception", e);
        } catch (Exception e) {
            messageStatus = "Encountered an unhandled exception<br /><br />";
            throw new PortletException("Exception", e);
        }
    }
View Full Code Here

                            }
                        }
                        if(keys != null && keys.length == 1) {
                            setProperty(secure, "keyAlias", keys[0]);
                        } else {
                            throw new PortletException("Cannot handle keystores with anything but 1 unlocked private key");
                        }
                    } catch (KeystoreException e) {
                        throw new PortletException(e);
                    }
                    String trustStore = actionRequest.getParameter("unlockTrustStore");
                    // "" is a valid trustStore value, which means the parameter should be cleared
                    setProperty(secure, "trustStore", isValid(trustStore) ? trustStore : null);
                } else if (server.equals(WEB_SERVER_TOMCAT)) {
                    if(isValid(truststoreType)) {setProperty(secure, "truststoreType", truststoreType);}
                    if(isValid(truststoreFile)) {setProperty(secure, "truststoreFileName", truststoreFile);}
                    if(isValid(truststorePass)) {setProperty(secure, "truststorePassword", truststorePass);}
                } else {
                    //todo:   Handle "should not occur" condition
                }
            }
            // Start the connector
            try {
                ((GeronimoManagedBean)connector).startRecursive();
            } catch (Exception e) {
                log.error("Unable to start connector", e); //todo: get into rendered page somehow?
            }
            actionResponse.setRenderParameter("mode", "list");
        } else if(mode.equals("save")) { // User just submitted the form to update a connector
            // Get submitted values
            //todo: lots of validation
            String host = actionRequest.getParameter("host");
            int port = Integer.parseInt(actionRequest.getParameter("port"));
            int maxThreads = Integer.parseInt(actionRequest.getParameter("maxThreads"));
            Integer minThreads = getInteger(actionRequest, "minThreads");
            String connectorURI = actionRequest.getParameter("connectorURI");
            // Identify and update the connector
            WebConnector connector = PortletManager.getWebConnector(actionRequest, new AbstractName(URI.create(connectorURI)));
            if(connector != null) {
                connector.setHost(host);
                connector.setPort(port);
                connector.setMaxThreads(maxThreads);
                if(server.equals(WEB_SERVER_JETTY)) {
                    if(minThreads != null) {
                        setProperty(connector,"minThreads",minThreads);
                    }
                    else if (server.equals(WEB_SERVER_TOMCAT)) {
                        //todo:   Any Tomcat specific processing?
                    }
                    else {
                        //todo:   Handle "should not occur" condition
                    }
                }
                if(connector instanceof SecureConnector) {
                    String keystoreType = actionRequest.getParameter("keystoreType");
                    String keystoreFile = actionRequest.getParameter("keystoreFile");
                    String privateKeyPass = actionRequest.getParameter("privateKeyPassword");
                    String keystorePass = actionRequest.getParameter("keystorePassword");
                    String secureProtocol = actionRequest.getParameter("secureProtocol");
                    String algorithm = actionRequest.getParameter("algorithm");
                    String truststoreType = actionRequest.getParameter("truststoreType");
                    String truststoreFile = actionRequest.getParameter("truststoreFile");
                    String truststorePass = actionRequest.getParameter("truststorePassword");
                    boolean clientAuth = isValid(actionRequest.getParameter("clientAuth"));
                    SecureConnector secure = (SecureConnector) connector;
                    if(isValid(keystoreType)) {secure.setKeystoreType(keystoreType);}
                    if(isValid(keystoreFile)) {secure.setKeystoreFileName(keystoreFile);}
                    if(isValid(keystorePass)) {secure.setKeystorePassword(keystorePass);}
                    if(isValid(secureProtocol)) {secure.setSecureProtocol(secureProtocol);}
                    if(isValid(algorithm)) {secure.setAlgorithm(algorithm);}
                    secure.setClientAuthRequired(clientAuth);
                    if(server.equals(WEB_SERVER_JETTY)) {
                        if(isValid(privateKeyPass)) {setProperty(secure, "keyPassword", privateKeyPass);}
                        String keyStore = actionRequest.getParameter("unlockKeyStore");
                        String trustStore = actionRequest.getParameter("unlockTrustStore");
                        setProperty(secure, "keyStore", keyStore);
                        try {
                            KeystoreInstance[] keystores = PortletManager.getCurrentServer(actionRequest).getKeystoreManager().getKeystores();

                            String[] keys = null;
                            for (int i = 0; i < keystores.length; i++) {
                                KeystoreInstance keystore = keystores[i];
                                if(keystore.getKeystoreName().equals(keyStore)) {
                                    keys = keystore.getUnlockedKeys(null);
                                }
                            }
                            if(keys != null && keys.length == 1) {
                                setProperty(secure, "keyAlias", keys[0]);
                            } else {
                                throw new PortletException("Cannot handle keystores with anything but 1 unlocked private key");
                            }
                        } catch (KeystoreException e) {
                            throw new PortletException(e);
                        }
                        // "" is a valid trustStore value, which means the parameter should be cleared
                        setProperty(secure, "trustStore", isValid(trustStore) ? trustStore : null);
                    }
                    else if (server.equals(WEB_SERVER_TOMCAT)) {
View Full Code Here

TOP

Related Classes of javax.portlet.PortletException

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.