jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shivalika <destinee...@gmail.com>
Subject Setting Privileges
Date Thu, 08 Jul 2010 04:40:06 GMT

Hello users,

I have developed a login module called as SampleLoginModule & created its
.jar file. This file has been put into the repository & the path in
Repository.xml is changed.

Our this Login module works as:

1.admin logs in after being authenticated.
2.after login, the admin can create users.
The created users are written to a file Users.xml
As well as, i used the createUser method of UserManagerImpl -  it creates
users as JCR nodes.

public User createUser(String userID, String password) throws
RepositoryException

So far, working good!!

Now i want to add privileges for this particular created user at the time of
creation.

I did some R&D as :

public void access_control(Node testRootNode, PrincipalImpl principal)
throws UnsupportedRepositoryOperationException, RepositoryException {
        try {
            AccessControlPolicy acp = null;
            AccessControlManager acm = session.getAccessControlManager();
            System.out.println("1" + acm.toString());

            AccessControlPolicy[] it =
acm.getEffectivePolicies(testRootNode.getPath());
            System.out.println("2:::" + it.length);
            for (int i = 0; i < it.length; i++) {
                acp = it[i];
                System.out.println(acp.toString());
            }
            System.out.println("3" + it.toString());
            Privilege[] privileges = new
Privilege[]{acm.privilegeFromName(Privilege.JCR_WRITE)};
            System.out.println("3:::" + privileges.length);

            ((AccessControlList) acp).addAccessControlEntry(new
PrincipalImpl(session.getUserID()), privileges);
            System.out.println("4");
            acm.setPolicy(testRootNode.getPath(), acp);

            System.out.println("set");

        } catch (Exception re) {
            re.printStackTrace();
            System.out.println("Exception caught:" + re);
        }
    }

I get an exception as:
Exception caught:java.lang.ClassCastException:
org.apache.jackrabbit.core.security.authorization.NamedAccessControlPolicyImpl
cannot be cast to javax.jcr.security.AccessControlList

Moreover, the session is for the admin user, not the created user.

So, what i want is that as soon as the user is created by Admin, the
privileges are being set for this particular created user in question.

Any comments and suggestions would help greatly.

Thanks

shivalika.


-- 
View this message in context: http://jackrabbit.510166.n4.nabble.com/Setting-Privileges-tp2281799p2281799.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.

Mime
View raw message