You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by AshokBS <as...@altimetrik.com> on 2014/03/04 11:08:30 UTC

How to create users using jackrabbit?

Hi, I have gone through many links and was not able to create users via
jackrabbit. Right now i am using jackrabbit-standalone-2.6.5.jar.

I have tried the below steps and was not able to create users until now ,
please help me what am i missing here:

Line1: Repository repository =
JcrUtils.getRepository("http://localhost:9090/server/"); 
Line2: Session session = repository.login(new SimpleCredentials("admin",
"admin".toCharArray()));
		
Line3: UserManager um = ((JackrabbitSession) session).getUserManager(); 
Line4: User user = um.createUser("john", "doe");

It throws an error at line no: 3.

The error is: java.lang.ClassCastException:
org.apache.jackrabbit.jcr2spi.SessionImpl cannot be cast to
org.apache.jackrabbit.api.JackrabbitSession at
com.sample.SampleJackrabbit.main(SampleJackrabbit.java:23)

Can someone provide me the steps i.e. best way to create user
programmatically? 





--
View this message in context: http://jackrabbit.510166.n4.nabble.com/How-to-create-users-using-jackrabbit-tp4660409.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.

AW: AW: How to create users using jackrabbit?

Posted by Malzer Ferdinand OSP sIT <Fe...@s-itsolutions.at>.
Hello,
We us a non-transient repository and use the following code to get create/access the repository:

            RepositoryConfig config = RepositoryConfig.install(new File(path));
            Repository repository = RepositoryImpl.create(config);

The path variable points to the directory where the repository.xml is stored.

regard


-----Ursprüngliche Nachricht-----
Von: AshokBS [mailto:asiddaiah@altimetrik.com] 
Gesendet: Mittwoch, 05. März 2014 07:08
An: users@jackrabbit.apache.org
Betreff: Re: AW: How to create users using jackrabbit? [phishing][bayes][heur]
Wichtigkeit: Niedrig

Hi Malzer,

Thanks for your response. I have seen some differences while doing this
activity of creating users.

Scenario1: I try to use TransientRepository and then login with admin
credentials and go ahead to create users, it is working fine. But the fact
is i am unable to login to the repository URL say something like:
http://localhost:9090/repository/default/

The code was something like this to create testuser:
Repository repository = new TransientRepository();
Session session = repository.login(new SimpleCredentials("admin",
"admin".toCharArray()));

final UserManager userManager = ((JackrabbitSession)
session).getUserManager();
final User user2 = userManager.createUser("testuser", "testuser");
session.save();

Why iam unable to login with testuser to the above URL? I mean where have we
mapping testuser to the above URL in this code.

Scenario2: I try to use JCRUtils API to get repository which is running and
try to login say something like this:
Repository repository =
JcrUtils.getRepository("http://localhost:9090/server");
Session session = repository.login(new SimpleCredentials("admin",
"admin".toCharArray()));
 UserManager um = ((JackrabbitSession) session).getUserManager();
User user = um.createUser("testuser", "testuser"); 

The above one will not allow me to create users as said earlier and give the
exception as: java.lang.ClassCastException:
org.apache.jackrabbit.jcr2spi.SessionImpl cannot be cast to
org.apache.jackrabbit.api.JackrabbitSession

Why is this happening? My queston is from scenario 1: where does the users
data reside and how to login to web browser to URL? Is it not possible to
use those created users for login?










--
View this message in context: http://jackrabbit.510166.n4.nabble.com/How-to-create-users-using-jackrabbit-tp4660409p4660417.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.

Re: AW: How to create users using jackrabbit?

Posted by AshokBS <as...@altimetrik.com>.
Hi Malzer,

Thanks for your response. I have seen some differences while doing this
activity of creating users.

Scenario1: I try to use TransientRepository and then login with admin
credentials and go ahead to create users, it is working fine. But the fact
is i am unable to login to the repository URL say something like:
http://localhost:9090/repository/default/

The code was something like this to create testuser:
Repository repository = new TransientRepository();
Session session = repository.login(new SimpleCredentials("admin",
"admin".toCharArray()));

final UserManager userManager = ((JackrabbitSession)
session).getUserManager();
final User user2 = userManager.createUser("testuser", "testuser");
session.save();

Why iam unable to login with testuser to the above URL? I mean where have we
mapping testuser to the above URL in this code.

Scenario2: I try to use JCRUtils API to get repository which is running and
try to login say something like this:
Repository repository =
JcrUtils.getRepository("http://localhost:9090/server");
Session session = repository.login(new SimpleCredentials("admin",
"admin".toCharArray()));
 UserManager um = ((JackrabbitSession) session).getUserManager();
User user = um.createUser("testuser", "testuser"); 

The above one will not allow me to create users as said earlier and give the
exception as: java.lang.ClassCastException:
org.apache.jackrabbit.jcr2spi.SessionImpl cannot be cast to
org.apache.jackrabbit.api.JackrabbitSession

Why is this happening? My queston is from scenario 1: where does the users
data reside and how to login to web browser to URL? Is it not possible to
use those created users for login?










--
View this message in context: http://jackrabbit.510166.n4.nabble.com/How-to-create-users-using-jackrabbit-tp4660409p4660417.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.

AW: How to create users using jackrabbit?

Posted by Malzer Ferdinand OSP sIT <Fe...@s-itsolutions.at>.
hello,

i use this code -sequence:

        Session session = null;
        try {
            //login to default workspace
            session = rep.login(new SimpleCredentials(userName,pwd));
            //retrieve user manager
            JackrabbitSession js = (JackrabbitSession) session;
            UserManager userMgr = js.getUserManager();

            //create the user
            org.apache.jackrabbit.api.security.user.User user = userMgr.createUser(UserId, password);
	...

regards.

	
-----Ursprüngliche Nachricht-----
Von: AshokBS [mailto:asiddaiah@altimetrik.com] 
Gesendet: Dienstag, 04. März 2014 11:09
An: users@jackrabbit.apache.org
Betreff: How to create users using jackrabbit? [phishing][bayes][heur]
Wichtigkeit: Niedrig

Hi, I have gone through many links and was not able to create users via
jackrabbit. Right now i am using jackrabbit-standalone-2.6.5.jar.

I have tried the below steps and was not able to create users until now ,
please help me what am i missing here:

Line1: Repository repository =
JcrUtils.getRepository("http://localhost:9090/server/"); 
Line2: Session session = repository.login(new SimpleCredentials("admin",
"admin".toCharArray()));
		
Line3: UserManager um = ((JackrabbitSession) session).getUserManager(); 
Line4: User user = um.createUser("john", "doe");

It throws an error at line no: 3.

The error is: java.lang.ClassCastException:
org.apache.jackrabbit.jcr2spi.SessionImpl cannot be cast to
org.apache.jackrabbit.api.JackrabbitSession at
com.sample.SampleJackrabbit.main(SampleJackrabbit.java:23)

Can someone provide me the steps i.e. best way to create user
programmatically? 





--
View this message in context: http://jackrabbit.510166.n4.nabble.com/How-to-create-users-using-jackrabbit-tp4660409.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.