Package javax.portlet

Examples of javax.portlet.PortletPreferences


     
      addUIFormInput(new UIFormStringInput(EMAIL_ADDRESS, EMAIL_ADDRESS, null).addValidator(MandatoryValidator.class).addValidator(
         EmailAddressValidator.class));
  
      PortletRequestContext pcontext = (PortletRequestContext)WebuiRequestContext.getCurrentInstance();
      PortletPreferences pref = pcontext.getRequest().getPreferences();
      boolean useCaptcha = Boolean.parseBoolean(pref.getValue(UIRegisterEditMode.USE_CAPTCHA,"true"));

      if (useCaptcha)
      {
         addUIFormInput(new UICaptcha(CAPTCHA, CAPTCHA, null).addValidator(MandatoryValidator.class).addValidator(CaptchaValidator.class));
         this.captchaInputAvailability = true;
View Full Code Here


   public static final String USE_CAPTCHA = "useCaptcha";
  
   public UIRegisterEditMode() throws Exception
   {
      PortletRequestContext pcontext = (PortletRequestContext)WebuiRequestContext.getCurrentInstance();
      PortletPreferences pref = pcontext.getRequest().getPreferences();
      boolean useCaptcha = Boolean.parseBoolean(pref.getValue(USE_CAPTCHA,"true"));
      addUIFormInput(new UIFormCheckBoxInput<Boolean>(USE_CAPTCHA, USE_CAPTCHA, useCaptcha).setValue(useCaptcha));
   }
View Full Code Here

      {
         // TODO Auto-generated method stub
         UIRegisterEditMode uiForm = event.getSource();
         boolean useCaptcha = uiForm.getUIFormCheckBoxInput(USE_CAPTCHA).isChecked();
         PortletRequestContext pcontext = (PortletRequestContext)WebuiRequestContext.getCurrentInstance();
         PortletPreferences pref = pcontext.getRequest().getPreferences();
         pref.setValue(USE_CAPTCHA, Boolean.toString(useCaptcha));
         pref.store();
        
         //Show/hide the captcha input in UIRegisterInputSet
         UIRegisterPortlet registerPortlet = uiForm.getParent();
         UIRegisterInputSet registerInputSet = registerPortlet.findFirstComponentOfType(UIRegisterInputSet.class);
        
View Full Code Here

      PortletRequestContext context = (PortletRequestContext)WebuiRequestContext.getCurrentInstance();

      UIDashboard dashboard = addChild(UIDashboard.class, null, null);
      addChild(UIDashboardEditForm.class, null, null);

      PortletPreferences pref = context.getRequest().getPreferences();
      String containerTemplate = pref.getValue("template", "three-columns");
      dashboard.setContainerTemplate(containerTemplate);

      String aggregatorId = pref.getValue("aggregatorId", "rssAggregator");
      dashboard.setAggregatorId(aggregatorId);
   }
View Full Code Here

{
   public UIPortalNavigationPortlet() throws Exception
   {
      PortletRequestContext context = (PortletRequestContext)WebuiRequestContext.getCurrentInstance();
      PortletRequest prequest = context.getRequest();
      PortletPreferences prefers = prequest.getPreferences();
      String template = prefers.getValue("template", "app:/groovy/portal/webui/component/UIPortalNavigation2.gtmpl");

      UIPortalNavigation2 portalNavigation = addChild(UIPortalNavigation2.class, "UIHorizontalNavigation", null);
      portalNavigation.setUseAjax(Boolean.valueOf(prefers.getValue("useAJAX", "true")));
      portalNavigation.setTemplate(template);
   }
View Full Code Here

   }

   public String getUrl()
   {
      PortletRequestContext pcontext = (PortletRequestContext)WebuiRequestContext.getCurrentInstance();
      PortletPreferences pref = pcontext.getRequest().getPreferences();
      String urlPref = pref.getValue("url", "http://www.google.com/ig/modules/horoscope.xml");
      if (urlPref.startsWith(LOCAL_STRING))
      {
         try
         {
            String gadgetName = urlPref.replaceFirst(LOCAL_STRING, "");
View Full Code Here

     * @return The value of the portlet preference, <code>null</code> if the
     *         preference is not defined.
     */
    public String getPortletPreference(String name) {
        PortletRequest request = getRequest();
        PortletPreferences preferences = request.getPreferences();

        return preferences.getValue(name, null);
    }
View Full Code Here

        Map<String, String> categoryKeywordsMap = retrieveCategoryKeywordsMap(categories, request);
        request.setAttribute("categoryKeywords", categoryKeywordsMap);
       
        request.setAttribute("layouts", LayoutBean.retrieveLayouts(request, decorationFactory));
        request.setAttribute("themes", ThemeBean.retrieveThemes(request, decorationFactory));
        PortletPreferences prefs = request.getPreferences();
        request.setAttribute("prefs", prefs.getMap());
       
        boolean hasEditAccess = false;
       
        try
        {
View Full Code Here

            return result ;
        }
       
        // System.out.println("SSOWebContentPortlet.doPreemptiveAuthentication...");
       
        PortletPreferences prefs = request.getPreferences();
        String type = getSingleSignOnAuthType(prefs);

        if (type.equalsIgnoreCase(SSO_TYPE_BASIC_PREEMPTIVE))
        {
            // Preemptive, basic authentication
            String userName = (String)request.getAttribute(SSO_REQUEST_ATTRIBUTE_USERNAME);
            if (userName == null) userName = "";
            String password = (String)request.getAttribute(SSO_REQUEST_ATTRIBUTE_PASSWORD);
            if (password == null) password = "";
           
            // System.out.println("...performing preemptive basic authentication with userName: "+userName+", and password: "+password);
            method.setDoAuthentication(true);
            method.getHostAuthState().setPreemptive();
            client.getState().setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(userName, password));
           
            // handled!
            return result ;
           
        }
        else if (type.startsWith(SSO_TYPE_FORM))
        {
            try
            {
                Boolean formAuth = (Boolean)PortletMessaging.receive(request, FORM_AUTH_STATE);
                if (formAuth != null)
                {
                    // already been here, done that
                    return (formAuth.booleanValue() ? result : null);
                }
                else
                {
                    // stop recursion, but assume failure, ...for now
                    PortletMessaging.publish(request, FORM_AUTH_STATE, Boolean.FALSE);
                }

                String formAction = prefs.getValue(SSO_TYPE_FORM_ACTION_URL, "");
                if (formAction == null || formAction.length() == 0)
                {
                    log.warn("sso.type specified as 'form', but no: "+SSO_TYPE_FORM_ACTION_URL+", action was specified - unable to preemptively authenticate by form.");
                    return null ;
                }
                String userNameField = prefs.getValue(SSO_TYPE_FORM_USERNAME_FIELD, "");
                if (userNameField == null || userNameField.length() == 0)
                {
                    log.warn("sso.type specified as 'form', but no: "+SSO_TYPE_FORM_USERNAME_FIELD+", username field was specified - unable to preemptively authenticate by form.");
                    return null ;
                }
                String passwordField = prefs.getValue(SSO_TYPE_FORM_PASSWORD_FIELD, "password");
                if (passwordField == null || passwordField.length() == 0)
                {
                    log.warn("sso.type specified as 'form', but no: "+SSO_TYPE_FORM_PASSWORD_FIELD+", password field was specified - unable to preemptively authenticate by form.");
                    return null ;
                }
               
                String userName = (String)request.getAttribute(SSO_REQUEST_ATTRIBUTE_USERNAME);
                if (userName == null) userName = "";
                String password = (String)request.getAttribute(SSO_REQUEST_ATTRIBUTE_PASSWORD);
                if (password == null) password = "";

                // get submit method
                int i = type.indexOf('.');
                boolean isPost = i > 0 ? type.substring(i+1).equalsIgnoreCase("post") : true ;    // default to post, since it is a form
           
                // get parameter map
                HashMap formParams = new HashMap();
                formParams.put(userNameField,new String[]{ userName });
                formParams.put(passwordField,new String[]{ password });
                String formArgs = prefs.getValue(SSO_TYPE_FORM_ACTION_ARGS, "");
                if (formArgs != null && formArgs.length() > 0)
                {
                    StringTokenizer iter = new StringTokenizer(formArgs, ";");
                    while (iter.hasMoreTokens())
                    {
                        String pair = iter.nextToken();
                        i = pair.indexOf('=') ;
                        if (i > 0)
                            formParams.put(pair.substring(0,i), new String[]{pair.substring(i+1)});
                    }
                }

                // resuse client - in case new cookies get set - but create a new method (for the formAction)
                String formMethod = (isPost) ? FORM_POST_METHOD : FORM_GET_METHOD;               
                method = getHttpMethod(client, getURLSource(formAction, formParams, request, response), formParams, formMethod, request);
                // System.out.println("...posting credentials");
                result = doHttpWebContent(client, method, 0, request, response) ;
                // System.out.println("Result of attempted authorization: "+success);
                PortletMessaging.publish(request, FORM_AUTH_STATE, Boolean.valueOf(result != null));
                return result ;
            }
            catch (Exception ex)
            {
                // bad
                log.error("Form-based authentication failed", ex);
            }
        }
        else if (type.equalsIgnoreCase(SSO_TYPE_URL) || type.equalsIgnoreCase(SSO_TYPE_URL_BASE64))
        {
            // set user name and password parameters in the HttpMethod
            String userNameParam = prefs.getValue(SSO_TYPE_URL_USERNAME_PARAM, "");
            if (userNameParam == null || userNameParam.length() == 0)
            {
                log.warn("sso.type specified as 'url', but no: "+SSO_TYPE_URL_USERNAME_PARAM+", username parameter was specified - unable to preemptively authenticate by URL.");
                return null ;
            }
            String passwordParam = prefs.getValue(SSO_TYPE_URL_PASSWORD_PARAM, "");
            if (passwordParam == null || passwordParam.length() == 0)
            {
                log.warn("sso.type specified as 'url', but no: "+SSO_TYPE_URL_PASSWORD_PARAM+", password parameter was specified - unable to preemptively authenticate by URL.");
                return null ;
            }
View Full Code Here

    }
   
    protected Map<String, String> retrieveCategoryKeywordsMap(List<String> categories, PortletRequest request) throws PortletException
    {
        Map<String, String> keywordsMap = new HashMap<String, String>();
        PortletPreferences prefs = request.getPreferences();
       
        for (String category : categories)
        {
            String keywords = prefs.getValue("Keywords:" + category, "");
            keywordsMap.put(category, keywords);
        }
       
        return keywordsMap;
    }
View Full Code Here

TOP

Related Classes of javax.portlet.PortletPreferences

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.