hi shivalika

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.

and the rest of the repository's security configuration?

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());

AccessControlManager#getEffectivePolicies is for display purpose
only -> see API

you should use
AccessControlManager#getApplicablePolicies or AccessControlManager#getPolicies to obtain policies that can
be modified and reapplied.

            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

see above. note however: whether or not an applicable policy
is an ACL or not depends on the AccessControlProvider specified
for the particular workspace.

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

? sorry can't follow you here.

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.

regards
angela

Reply via email to