Woody,

I think that I ran into this before and I still don't know why rundata's ACL
is null. Feel free to submit this as a bug (perhaps then it will get looked
at). Here's some code to get user permissions:

    Hashtable permSet = new Hashtable(); // use whatever container you like
here
    Iterator roles =
JetspeedSecurity.getRoles(data.getUser().getUserName());
    while (roles.hasNext()) {
        Iterator perms =
JetspeedSecurity.getPermissions(((Role)roles.next()).getName());
        while (perms.hasNext()) {
            try {
                String perm = ((Permission)perms.next()).getName();
                if (!permSet.containsKey(perm)) {
                    permSet.put(perm, "");
                }
            } catch (Exception e1) {
            }
        }
    }

In the end, permSet will contain unique set of user permission names. Hope
this helps.

Best regards,

Mark C. Orciuch
Next Generation Solutions, Ltd.
e-Mail: [EMAIL PROTECTED]
web: http://www.ngsltd.com


> -----Original Message-----
> From: Woody Sturges [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, September 17, 2002 10:07 AM
> To: [EMAIL PROTECTED]
> Subject: rundata.getACL() returns null for logged-in user
> withroles/permissions
>
>
> Hi all, I'm having a problem getting an AccessControlList from within a
> VelocityPortletAction.  I'm using the passed RunData object to grab the
> ACL, but it returns null.  The getUser() works, and the current user has
> roles and permissions (they can run the portlet, which is secured with a
> role).  Here's my code:
>
>     public void doSend(RunData data, Context context)
>     {
>       try {
>               String userName = data.getUser().getUserName();
>               PermissionSet permissions = null;
>               AccessControlList acl = data.getACL();
>               if (acl == null) {
>                       System.out.println("ACL is NULL!");
>               } else {
>                       permissions = data.getACL().getPermissions();
>               }
>
>               System.out.println("userName: " + userName + ",
> permissions: " + permissions);
>
>       } catch (Exception e) {
>               e.printStackTrace();
>               context.put("message", e.getMessage());
>       }
>     }
>
> The above prints:
> [9/17/02 9:18:20:734 CDT] 50795bb5 SystemOut     U ACL is NULL!
> [9/17/02 9:18:20:734 CDT] 50795bb5 SystemOut     U userName: wsturges,
> permissions: null
>
> Can anyone offer any suggestions?  Thanks in advance,
> Woody
>
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to