You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-user@portals.apache.org by Woody Sturges <WS...@bjc.org> on 2002/09/17 17:07:20 UTC

rundata.getACL() returns null for logged-in user with roles/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:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: rundata.getACL() returns null for logged-in user withroles/permissions

Posted by Mark Orciuch <ma...@ngsltd.com>.
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: mark_orciuch@ngsltd.com
web: http://www.ngsltd.com


> -----Original Message-----
> From: Woody Sturges [mailto:WSTURGES@bjc.org]
> Sent: Tuesday, September 17, 2002 10:07 AM
> To: jetspeed-user@jakarta.apache.org
> 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:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>