Examples of JetspeedRunData


Examples of org.apache.jetspeed.services.rundata.JetspeedRunData

    /**
     * @see PortalPersistenceService#getInstances(Portlet, RunData)
     */
    public List getInstances( RunData data) throws PortletException
    {
        JetspeedRunData jData = (JetspeedRunData) data;
        return getInstances(jData.getProfile());
    }
View Full Code Here

Examples of org.apache.jetspeed.services.rundata.JetspeedRunData

    * called when the password reminder button is pressed.
    * sends a user their password
    **/
    public void doReminder( RunData rundata ) throws Exception
    {
        JetspeedRunData data = (JetspeedRunData)rundata;

        try {
            String username = data.getParameters().getString("username", "");

            JetspeedUser user = null;

            try {
                user = JetspeedSecurity.getUser(username);
            } catch (JetspeedSecurityException ignored) {
            }

            if (user == null)
            {
                data.setScreenTemplate("LoginHelp");
                data.setMessage(CustomLocalization.getString("JLOGINUSER_PASSWORDREMINDER_INVALIDUSER", rundata));
                if (logger.isDebugEnabled())
                    logger.debug(CustomLocalization.getString("JLOGINUSER_PASSWORDREMINDER_INVALIDUSER", rundata));
                return;
            }

            user.setHasLoggedIn( Boolean.FALSE);
            data.setUser(user);
            DynamicURI url = new DynamicURI(data);

            //build body via template
            StringWriter email_body = new StringWriter();

            Context context = TurbineVelocity.getContext(data);
            context.put( "data", data );
            context.put( "user", user );
            context.put("userurl",url);
            context.put("config",new JetspeedResources());

            //determine the language to be used for the notification email
            String lang = (String)user.getPerm("language");
            String ctry = (String)user.getPerm("country");
            Locale loc = null;
            if (lang != null && ctry != null)
            {
                loc = new Locale(lang,ctry);
            }

            String templatePath = TemplateLocator.locateEmailTemplate(data, JetspeedResources.getString("password.reminder.template"), loc);

            SimpleEmail se = new SimpleEmail();

            context.put("email",se);

            TurbineVelocity.handleRequest(context, templatePath, email_body);

            se.setMsg(email_body.toString());

            Properties props = System.getProperties();
            String mailServerMachine = JetspeedResources.getString( "mail.server" );
            props.put("mail.host", mailServerMachine );
            props.put("mail.smtp.host", mailServerMachine);

            se.send();

            data.setMessage (CustomLocalization.getString("JLOGINUSER_PASSWORDREMINDER_SENT", rundata));
            logger.info( "Password for user " + user.getUserName() + " was sent to " + user.getEmail());
            logger.info(CustomLocalization.getString("JLOGINUSER_PASSWORDREMINDER_SENT", rundata));
            data.setScreenTemplate("Login");
        } catch ( Exception e ) {
            data.setScreenTemplate("LoginHelp");
            String errorTitle = CustomLocalization.getString("JLOGINUSER_PASSWORDREMINDER_ERROR", rundata) ;
            String errorMessage = errorTitle + e.toString();

            logger.warn( errorMessage, e );
            data.setMessage ( errorMessage );
        }
    }
View Full Code Here

Examples of org.apache.jetspeed.services.rundata.JetspeedRunData

    }


    public void doPerform( RunData rundata ) throws Exception
    {
        JetspeedRunData data = (JetspeedRunData)rundata;
       
        String username = data.getParameters().getString("username", "");
        String password = data.getParameters().getString("password", "");

        boolean newUserApproval = JetspeedResources.getBoolean("newuser.approval.enable", false);
        String secretkey = (String) data.getParameters().getString("secretkey", null);
        if ( secretkey != null )
        {

            // its the first logon - we are verifying the secretkey

            // handle the buttons on the ConfirmRegistration page
            String button1 = data.getParameters().getString ( "submit1", null );
            if ( button1 != null && button1.equalsIgnoreCase("Cancel") )
            {
                data.setScreenTemplate(TurbineTemplate.getDefaultScreen());
                return;
            }
           
            // check to make sure the user entered the right confirmation key
            // if not, then send them to the ConfirmRegistration screen           
            JetspeedUser user = JetspeedSecurity.getUser(username);

            if (user == null)
            {
                logger.warn("JLogin User: Unexpected condition : user is NULL");
                return;  
            }
            String confirm_value = user.getConfirmed();
            if ( ! secretkey.equals ( confirm_value ) && ! confirm_value.equals ( JetspeedResources.CONFIRM_VALUE ) )
            {
                if ( newUserApproval )
                {
                    data.setMessage(CustomLocalization.getString("JLOGINUSER_KEYNOTVALID", rundata));
                    data.setScreenTemplate("NewUserAwaitingAcceptance");
                    return;
                }
                else
                {
                  if ( user.getConfirmed().equals(JetspeedResources.CONFIRM_VALUE_REJECTED))
                  {
                    data.setMessage(CustomLocalization.getString("JLOGINUSER_KEYNOTVALID", rundata));
                    data.setScreenTemplate("NewUserRejected");
                    return;
                  }
                  else
                  {
                    data.setMessage(CustomLocalization.getString("JLOGINUSER_KEYNOTVALID", rundata));
                    data.setScreenTemplate("ConfirmRegistration");
                    return;
                  }
                }
            }
            
            user.setConfirmed( JetspeedResources.CONFIRM_VALUE );
            data.setMessage (CustomLocalization.getString("JLOGINUSER_WELCOME", rundata));
            JetspeedSecurity.saveUser(user);
        }
       
        JetspeedUser user = null;
        try
        {
            user = JetspeedSecurity.login(username, password);
            JetspeedSecurity.saveUser(user);
        }
        catch (LoginException e)
        {           
            data.setScreenTemplate(JetspeedResources.getString(TurbineConstants.TEMPLATE_LOGIN));
            String message = e.getMessage() != null ? e.getMessage() : e.toString();
            data.setMessage(message);
            data.setUser(JetspeedSecurity.getAnonymousUser());
            data.getUser().setHasLoggedIn(new Boolean (false) );           

            if (e instanceof FailedLoginException)
            {
                if (!disableCheck(data))
                {               
                    logger.info("JLoginUser: Credential Failure on login for user: " + username);
                    data.setMessage(CustomLocalization.getString("PASSWORDFORM_FAILED_MSG", rundata));
                }
            }
            else if (e instanceof AccountExpiredException)
            {
                logger.info("JLoginUser: Account Expired for user " + username);
            }
            else if (e instanceof CredentialExpiredException)
            {
                logger.info("JLoginUser: Credentials expired for user: " + username);
                data.setScreenTemplate(
                    JetspeedResources.getString(JetspeedResources.CHANGE_PASSWORD_TEMPLATE, "ChangePassword")
                    );
                data.setMessage(CustomLocalization.getString("PASSWORDFORM_EXPIRED_MSG", rundata));
                data.getParameters().setString("username", username);
            }

            return;
        }
        catch (Throwable other)
        {
            data.setScreenTemplate(JetspeedResources.getString(TurbineConstants.TEMPLATE_ERROR));
            String message = other.getMessage() != null ? other.getMessage() : other.toString();
            data.setMessage(message);
            data.setStackTrace(org.apache.turbine.util.StringUtils.stackTrace(other), other);
            JetspeedUser juser = new FakeJetspeedUser(JetspeedSecurity.getAnonymousUserName(), false);
            data.setUser(juser);
            return;
        }
        if (user.getDisabled())
        {
            data.setMessage(CustomLocalization.getString("JLOGINUSER_ACCOUNT_DISABLED", rundata));
            data.setScreenTemplate(JetspeedResources.getString("logon.disabled.form"));
            data.getUser().setHasLoggedIn(new Boolean (false) );
            data.setUser(JetspeedSecurity.getAnonymousUser());           
            return;
        }

        // check for being confirmed before allowing someone to finish logging in
        if ( data.getUser().hasLoggedIn())
        {
            if  (JetspeedSecurity.isDisableAccountCheckEnabled())
            {
                // dst: this needs some refactoring. I don't believe this api is necessary
                JetspeedSecurity.resetDisableAccountCheck(data.getParameters().getString("username", ""));
            }       

            String confirmed = data.getUser().getConfirmed();
            if (confirmed == null || !confirmed.equals(JetspeedResources.CONFIRM_VALUE ))
            {
                if (confirmed != null && confirmed.equals(JetspeedResources.CONFIRM_VALUE_REJECTED))
                {
                  data.setMessage(CustomLocalization.getString("JLOGINUSER_KEYNOTVALID", rundata));
                  data.setScreenTemplate("NewUserRejected");
                  data.getUser().setHasLoggedIn(new Boolean (false) );
                  return;
                }
                else
                {
                  data.setMessage(CustomLocalization.getString("JLOGINUSER_CONFIRMFIRST", rundata));
                  data.setScreenTemplate("ConfirmRegistration");
                  data.getUser().setHasLoggedIn(new Boolean (false) );
                  return;
                }
            }

            // user has logged in successfully at this point
 
            boolean automaticLogonEnabled = JetspeedResources.getBoolean("automatic.logon.enable", false);
            if (automaticLogonEnabled)
            {
              //Does the user want to use this facility?
              boolean userRequestsRememberMe = data.getParameters().getBoolean("rememberme",false);
              if (userRequestsRememberMe)
              {
                //save cookies on the users machine.
                int maxage = JetspeedResources.getInt("automatic.logon.cookie.maxage",-1);
                String comment = JetspeedResources.getString("automatic.logon.cookie.comment","");
                String domain = JetspeedResources.getString("automatic.logon.cookie.domain");
                String path = JetspeedResources.getString("automatic.logon.cookie.path","/");

                if (domain == null)
                {
                  String server = data.getServerName();
                  domain = "." + server;
                }

                String loginCookieValue = null;

                if ( JetspeedResources.getString("automatic.logon.cookie.generation","everylogon").equals("everylogon") )
                {
                  loginCookieValue = ""+Math.random();
                  data.getUser().setPerm("logincookie",loginCookieValue);
                  JetspeedSecurity.saveUser( data.getJetspeedUser() );
                }
                else
                {
                  loginCookieValue = (String)data.getUser().getPerm("logincookie");
                  if (loginCookieValue == null || loginCookieValue.length() == 0)
                  {
                    loginCookieValue = ""+Math.random();
                    data.getUser().setPerm("logincookie",loginCookieValue);
                    JetspeedSecurity.saveUser( data.getJetspeedUser() );
                  }
                }

                Cookie userName = new Cookie("username",data.getUser().getUserName());
                Cookie loginCookie = new Cookie("logincookie",loginCookieValue);

                userName.setMaxAge(maxage);
                userName.setComment(comment);
                userName.setDomain(domain);
                userName.setPath(path);

                loginCookie.setMaxAge(maxage);
                loginCookie.setComment(comment);
                loginCookie.setDomain(domain);
                loginCookie.setPath(path);

                data.getResponse().addCookie(userName);
                data.getResponse().addCookie(loginCookie);

              }
                   
            }
View Full Code Here

Examples of org.apache.jetspeed.services.rundata.JetspeedRunData

        try
        {

            if (null != data)
            {
                JetspeedRunData jdata = (JetspeedRunData) data;
                Profile profile = jdata.getProfile();

                if (null == profile)
                {
                    logger.warn("JetspeedTool: profile is null");
                    profile = Profiler.getProfile(jdata);
                    jdata.setProfile(profile);
                }

                Portlet source = findPortlet(data);
                if (source != null)
                {
                    jdata.setPortlet(source.getName());
                    info =
                        PortletFactory.getPortlet(name, "PortletInfoPortlet");
                    info.getPortletConfig().setPortletSkin(
                        source.getPortletConfig().getPortletSkin());
                    PortletControl control =
View Full Code Here

Examples of org.apache.jetspeed.services.rundata.JetspeedRunData

     */
    private static Portlet findPortlet(RunData rundata)
    {

        Portlet found = null;
        JetspeedRunData jdata = (JetspeedRunData) rundata;
        String peid = jdata.getJs_peid();
        if (peid != null)
        {
            Stack sets = new Stack();
            sets.push(jdata.getProfile().getRootSet());

            while ((found == null) && (sets.size() > 0))
            {
                PortletSet set = (PortletSet) sets.pop();

View Full Code Here

Examples of org.apache.jetspeed.services.rundata.JetspeedRunData

                    controlName == null
                        ? PortalToolkit.getControl((String) null)
                        : PortalToolkit.getControl(controlName);
                if (control != null)
                {
                    JetspeedRunData jdata = (JetspeedRunData) rundata;
                    // Use the profile's skin
                    p.getPortletConfig().setPortletSkin(
                        PortalToolkit.getSkin(
                            jdata
                                .getProfile()
                                .getDocument()
                                .getPortlets()
                                .getSkin()));
                    control.setPortlet(p);
View Full Code Here

Examples of org.apache.jetspeed.services.rundata.JetspeedRunData

                controlName == null
                    ? PortalToolkit.getControl((String) null)
                    : PortalToolkit.getControl(controlName);
            if (control != null)
            {
                JetspeedRunData jdata = (JetspeedRunData) rundata;
                // Use the profile's skin
                p.getPortletConfig().setPortletSkin(
                    PortalToolkit.getSkin(
                        jdata
                            .getProfile()
                            .getDocument()
                            .getPortlets()
                            .getSkin()));
                control.setPortlet(p);
View Full Code Here

Examples of org.apache.jetspeed.services.rundata.JetspeedRunData

*/
public class UpdateAccount extends Action
{
    public void doPerform( RunData rundata ) throws Exception
    {
        JetspeedRunData data = (JetspeedRunData)rundata;

        // check to make sure the user has logged in before accessing this screen
        if ( ! data.getUser().hasLoggedIn() )
        {
            data.setScreenTemplate( JetspeedResources.getString( "services.JspService.screen.error.NotLoggedIn", "Error" ) );
            return;
        }

        String cancelBtn = data.getParameters().getString( "CancelBtn" , "" );
        String username  = data.getParameters().getString( "username" , "" );
        String oldPassword  = JetspeedSecurity.convertPassword(data.getParameters().getString( "old_password" , "" ));
        String password  = JetspeedSecurity.convertPassword(data.getParameters().getString( "password" , "" ));
        String password2 = JetspeedSecurity.convertPassword(data.getParameters().getString( "password_confirm" , "" ));
        String firstname = data.getParameters().getString( "firstname", "" );
        String lastname  = data.getParameters().getString( "lastname" , "" );
        String email     = data.getParameters().getString( "email" , "" );
        boolean userRequestsRememberMe = data.getParameters().getBoolean( "rememberme" , false );

        // Save user input in case there is an error and
        // we have to go back to the EditAccount screen
        Hashtable screenData = new Hashtable();
        screenData.put( "username",  username );
        screenData.put( "firstname", firstname );
        screenData.put( "lastname",  lastname );
        screenData.put( "email",     email );
        data.getRequest().setAttribute( "ScreenDataEditAccount", screenData );

        // CANCEL BUTTON
        //
        // check to see if the Cancel button was pressed.
        // if so, return to the screen we were previously on
        // defined by nextscreen in the EditAccount screen
        if ( ! cancelBtn.equalsIgnoreCase( "" ) )           
        {
            return;
        }

        // PASSWORD
        //
        // if the fields are empty, then don't do anything to the passwords
        boolean changepass = false;
        if ( password.trim().length() > 0 && password2.trim().length() > 0 )
        {
            changepass = true;
        }
       
        if ( changepass == true && ! password.equals( password2 ) )
        {
            data.setMessage(CustomLocalization.getString("UPDATEACCOUNT_PWNOTMATCH", rundata));
            backToEditAccount( data, screenData );
            return;
        }
       
        if ( changepass == true && password.equals( oldPassword ) )
        {
            // old password = new passwod, so do not change.
            changepass = false;
        }

            // FIRSTNAME
        //
        // make sure the firstname exists
        if ( firstname.length() == 0 )
        {
            data.setMessage(CustomLocalization.getString("UPDATEACCOUNT_NOFIRSTNAME", rundata));
            backToEditAccount( data, screenData );
            return;
        }

        // LASTNAME
        //
        // make sure the lastname exists
        if ( lastname.length() == 0 )
        {
            data.setMessage(CustomLocalization.getString("UPDATEACCOUNT_NOLASTNAME", rundata));
            backToEditAccount( data, screenData );
            return;
        }

        // AUTOMATIC LOGIN
        //
        // if automatic login is enabled, then handle the remember me checkbox
        if ( JetspeedResources.getBoolean("automatic.logon.enable", false) )
        {
          if ( ! userRequestsRememberMe )
          {
            if ( data.getRequest().getCookies() != null &&
                 data.getCookies().getString("username") != null &&
                 data.getCookies().getString("logincookie") != null )
            {
              // remove cookies by re-adding them with zero MaxAge, which deletes them
              Cookie userName = new Cookie("username","");
              Cookie loginCookie = new Cookie("logincookie","");

              String comment = JetspeedResources.getString("automatic.logon.cookie.comment","");
              String domain = JetspeedResources.getString("automatic.logon.cookie.domain");
              String path = JetspeedResources.getString("automatic.logon.cookie.path","/");

              if (domain == null)
              {
                String server = data.getServerName();
                domain = "." + server;
              }

              userName.setMaxAge(0);
              userName.setComment(comment);
              userName.setDomain(domain);
              userName.setPath(path);

              loginCookie.setMaxAge(0);
              loginCookie.setComment(comment);
              loginCookie.setDomain(domain);
              loginCookie.setPath(path);

              data.getResponse().addCookie(userName);
              data.getResponse().addCookie(loginCookie);

              data.getCookies().remove("username");
              data.getCookies().remove("logincookie");
            }
          }
          else
          {
            if ( data.getRequest().getCookies() == null ||
                 !data.getCookies().getString("username","").equals(data.getUser().getUserName()) ||
                 !data.getCookies().getString("logincookie","").equals(data.getUser().getPerm("logincookie")) )
            {
              String loginCookieValue = (String)data.getUser().getPerm("logincookie");
              if (loginCookieValue == null || loginCookieValue.length() == 0)
              {
                loginCookieValue = ""+Math.random();
                data.getUser().setPerm("logincookie",loginCookieValue);
                JetspeedSecurity.saveUser( data.getJetspeedUser() );
              }

              Cookie userName = new Cookie("username",data.getUser().getUserName());
              Cookie loginCookie = new Cookie("logincookie",loginCookieValue);

              int maxage = JetspeedResources.getInt("automatic.logon.cookie.maxage",-1);
              String comment = JetspeedResources.getString("automatic.logon.cookie.comment","");
              String domain = JetspeedResources.getString("automatic.logon.cookie.domain");
              String path = JetspeedResources.getString("automatic.logon.cookie.path","/");

              if (domain == null)
              {
                String server = data.getServerName();
                domain = "." + server;
              }

              userName.setMaxAge(maxage);
              userName.setComment(comment);
              userName.setDomain(domain);
              userName.setPath(path);

              loginCookie.setMaxAge(maxage);
              loginCookie.setComment(comment);
              loginCookie.setDomain(domain);
              loginCookie.setPath(path);

              data.getResponse().addCookie(userName);
              data.getResponse().addCookie(loginCookie);

              data.getCookies().add("username",data.getUser().getUserName());
              data.getCookies().add("logincookie",loginCookieValue);
            }
          }
        }

        // EMAIL
        //
        // make sure the email exists
        if ( email.length() == 0 )
        {
            data.setMessage(CustomLocalization.getString("UPDATEACCOUNT_NOEMAIL", rundata));
            backToEditAccount( data, screenData );
            return;
        }

        boolean enableMail = JetspeedResources.getBoolean("newuser.confirm.enable", false);

        String currentEmail = (String) data.getUser().getEmail();
        if ( enableMail && ( currentEmail == null || ! currentEmail.equalsIgnoreCase(email) ) )
            {
                //Send confirmation email if different than current
                data.getUser().setEmail( email );
                data.getUser().setConfirmed( GenerateUniqueId.getIdentifier() );
                JetspeedSecurity.saveUser( data.getJetspeedUser() );
                ActionLoader.getInstance().exec(data, "SendConfirmationEmail");
                // add in the username to the parameters because ConfirmRegistration needs it
                data.getParameters().add("username", data.getUser().getUserName() );
                data.setMessage(CustomLocalization.getString("UPDATEACCOUNT_NEWEMAILCONFIRM", rundata));
                data.setScreenTemplate("ConfirmRegistration");
            }
        else
            {      
                JetspeedSecurity.saveUser( data.getJetspeedUser() );
            }
           
        // update currently logged in information that might have changed
        data.getUser().setFirstName( firstname );
        data.getUser().setLastName( lastname );
        data.getUser().setEmail( email );
        if ( changepass )
        {
            try
            {
              JetspeedSecurity.changePassword(data.getJetspeedUser(),oldPassword, password);
            } catch (JetspeedSecurityException e)
            {
                data.setMessage(e.getMessage());
                backToEditAccount( data, screenData );
                return;
            }
        }

        //allow sub-classes to update additional information
        updateUser(data);

        JetspeedSecurity.saveUser( data.getJetspeedUser() );
        data.setMessage (CustomLocalization.getString("UPDATEACCOUNT_DONE", rundata));
       
    }
View Full Code Here

Examples of org.apache.jetspeed.services.rundata.JetspeedRunData

        {
            rundata.setScreenTemplate("Ecs");
            return;
        }

         JetspeedRunData jdata = (JetspeedRunData)rundata;
         jdata.setJs_peid(peid);

        // retrieve the print friendly format action template
         String template = JetspeedResources.getString(ACTION_PRINT_TEMPLATE_KEY, DEFAULT_TEMPLATE);

        // redirect to the content template
View Full Code Here

Examples of org.apache.jetspeed.services.rundata.JetspeedRunData

                                HttpServletResponse res,
                                ServletConfig config)
        throws TurbineException, IllegalArgumentException
    {
        // let the super do the work
        JetspeedRunData r = (JetspeedRunData)super.getRunData(key, req, res, config);

        // store the rundata associated with this thread
        m_runDataStore.put(Thread.currentThread(), r);

        // associate this http session with this thread in the state manager
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.