Logging in as guest
kevin.thorley May 5, 2010 10:37 AMI am trying to get a very simple demo of ModeShape up and running. I read the documentation on auth and understand that by default guest (anonymous) access is allowed. This is preferable to working with Jaas, at the moment. However I am unable to login to a new repository. Here is the code I am using (running against ModeShape 1.1.0-final):
JcrConfiguration config = new JcrConfiguration();
config.loadFrom(new File(args[0]));
engine = config.build();
System.out.println("Starting repository.");
engine.start();
JcrRepository repo = engine.getRepository("configrepo");
System.out.println(JcrRepository.Option.ANONYMOUS_USER_ROLES + ": " + repo.getOptions().get(JcrRepository.Option.ANONYMOUS_USER_ROLES));
Session session = repo.login();
This results in the following output:
Starting repository.
ANONYMOUS_USER_ROLES: admin
log4j:WARN No appenders could be found for logger (org.modeshape.graph.connector.RepositoryConnectionPool).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" javax.jcr.LoginException: login() can only be called successfully from within a java.security.PrivilegedAction or when the ANONYMOUS_USER_ROLES repository option is set
at org.modeshape.jcr.JcrRepository.login(JcrRepository.java:881)
at org.modeshape.jcr.JcrRepository.login(JcrRepository.java:829)
at com.dealer.configrepo.modeshape.examples.FirstRepository.main(FirstRepository.java:31)
As you can see, the ANONYMOUS_USER_ROLES seems to be set correctly, yet the login fails. I also tried logging in with guest credentials (using both "guest" and "anonymous" as usernames with an email address as a password in a SimpleCredentials object) but that resulted in a different exception:
Exception in thread "main" java.lang.SecurityException: Unable to locate a login configuration
at com.sun.security.auth.login.ConfigFile.<init>(ConfigFile.java:93)
I have to assume I'm just making a very basic mistake here, but I haven't been able to figure out what that is yet. Any suggestions?
Thanks,
Kevin