Hi all,

I have designed my own user-manage system,  which relates each user  to one
of serveral predefined jetspeed accounts.
But I don't know how to register the jetspeed account by programming when
the user submit it's username and password.

I found that it's possible to register by sending redirct url, just like
this:

public void processAction(ActionRequest request, ActionResponse response)
           throws PortletException, IOException {

       String username = request.getParameter(LoginConstants.USERNAME);
       String password = request.getParameter(LoginConstants.PASSWORD);

       // A hidden parameter in the submited form, indicating the
destination when redirecting
       String destLogin = request.getParameter(KEY_DEST_LOGIN);

       String loginUrl;

       //Making redirecting URL.

       String prefix = "http://localhost:8080/jetspeed";;
       if (destLogin != null && destLogin.length() > 0) {
           loginUrl = prefix + destLogin;
           loginUrl += "&" + LoginConstants.PASSWORD + "=" + password + "&"
                   + LoginConstants.USERNAME + "=" + username;
           response.sendRedirect(loginUrl);
       } else if (destLogout != null && destLogout.length() > 0) {
           loginUrl = prefix + destLogout;

       // Registering by sending redirect URL.

           response.sendRedirect(loginUrl);
       }


But I don't think it's a nice way to do register. Futher more,  by this way,
I can't set session information BEFORE and AFTER sendRedirect.

My desired way is like that:

public void processAction(ActionRequest request, ActionResponse response)
           throws PortletException, IOException {

      String username;
      String password;
      // get username and password from submited form
      //   ...
     //Using my own user admin
       LoginUser user = MyUserAdmin.getUserByNameAndPassword(username,
password);
    //    ....
    if ( user!=null)
    {
             // get jetspeed account associated with this user;
             String jetspeed_username = user.getJetspeedUsername();
             String jetspeed_password= user.getJetspeedPassword();

            // Do registeration by calling some API of jetspeed;
            // it's expected to register to the portal, but don't do any
redirection.
               //....<DON"T KNOW HOW TO DO>

            // Set my userinfo to the session and something else
            //   ....
    }

}

I think it's better, but I don't know how to do this.

Anyone would give me some help?
Thanks in advance.

Bob Song

Reply via email to