This discussion is archived
2 Replies Latest reply: Sep 28, 2013 2:58 AM by Nitin Khare RSS

HasEffectivePrincipal in custom FormHandler

saminda konkaduwa Newbie
Currently Being Moderated

Hello Everyone,

 

I am using /atg/userprofiling/HasEffectivePrincipal in order to get the user roles.

I have created users and their roles in BCC.

I can use JSP pages to access this droplet in order to get user roles.

 

<dsp:droplet name="/atg/userprofiling/HasEffectivePrincipal">

            <dsp:param name="type" value="role" />

            <dsp:param name="id" value="/Wow/FullfillerAdmin" />

            <dsp:oparam name="output">

                    // The expected role

            </dsp:oparam>

            <dsp:oparam name="default">

                    // Not the expected role

            </dsp:oparam>

</dsp:droplet>

 

This is working fine. However i need to use this feature in my java class. It is a custom form handler.

 

Can anyone explain how to use this droplet in a custom form handler.

 

 

Thanks

saminda konkaduwa

  • 1. Re: HasEffectivePrincipal in custom FormHandler
    Nitin Khare Expert
    Currently Being Moderated

    You can refer to this post and the code snippet provided there and you should be able to do it from your custom component/form-handler.

     

    Re: Assigning user roles while creating user

  • 2. Re: HasEffectivePrincipal in custom FormHandler
    saminda konkaduwa Newbie
    Currently Being Moderated

    Thank you... You great.

     

    I am sharing my code to rest of other.

     

     

     

     

    ProfileTools prTools = getProfileTools();

    PropertyManager pmgr = prTools.getPropertyManager();

    String loginPropertyName = pmgr.getLoginPropertyName();

    String login = getStringValueProperty(loginPropertyName);

                   

    DirectoryPrincipal userPrincipal = userDirectory.findUserByLogin(login);

    if(userPrincipal!=null){

         User user = (User)userPrincipal;

         if(user!=null && user.getAssignedRoles()!=null){

               for (Object role : user.getAssignedRoles()) {

                       Role roleOfCurrentUser = (Role)role;   

                        if(roleOfCurrentUser!=null){

                                    // HERE I DID MY WORK

                         }else{

                                    setLoginSuccessURL("merchant_portal_login.jsp");

                         }                       

                }

         }else{

                setLoginSuccessURL("merchant_portal_login.jsp");

         }

    }else{

                 setLoginSuccessURL("merchant_portal_login.jsp");

    }

     

    saminda konkaduwa

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points