Index: modeshape-jcr/src/main/java/org/modeshape/jcr/JcrRepository.java =================================================================== --- modeshape-jcr/src/main/java/org/modeshape/jcr/JcrRepository.java (revision 1803) +++ modeshape-jcr/src/main/java/org/modeshape/jcr/JcrRepository.java (working copy) @@ -310,7 +310,7 @@ public class JcrRepository implements Repository { /** * The default value for the {@link Option#ANONYMOUS_USER_ROLES} option is {@value} . */ - public static final String ANONYMOUS_USER_ROLES = "admin"; + public static final String ANONYMOUS_USER_ROLES = ModeShapeRoles.ADMIN; /** * The default value for the {@link Option#PROJECT_NODE_TYPES} option is {@value} . @@ -654,7 +654,7 @@ public class JcrRepository implements Repository { * Set up the anonymous role, if appropriate */ SecurityContext anonymousUserContext = null; - String rawAnonRoles = options != null ? options.get(Option.ANONYMOUS_USER_ROLES) : null; + String rawAnonRoles = this.options.get(Option.ANONYMOUS_USER_ROLES); if (rawAnonRoles != null) { final Set roles = new HashSet(); for (String role : rawAnonRoles.split("\\s*,\\s*")) { Index: modeshape-jcr/src/test/java/org/modeshape/jcr/AnonymousAccessTest.java =================================================================== --- modeshape-jcr/src/test/java/org/modeshape/jcr/AnonymousAccessTest.java (revision 1803) +++ modeshape-jcr/src/test/java/org/modeshape/jcr/AnonymousAccessTest.java (working copy) @@ -45,9 +45,8 @@ public class AnonymousAccessTest { public void beforeEach() throws Exception { JcrConfiguration config = new JcrConfiguration(); config.repositorySource("source").usingClass(InMemoryRepositorySource.class); - config.repository("repo") - .setSource("source") - .setOption(Option.ANONYMOUS_USER_ROLES, ModeShapeRoles.ADMIN) + config.repository("repo").setSource("source") + // .setOption(Option.ANONYMOUS_USER_ROLES, ModeShapeRoles.ADMIN) .setOption(Option.JAAS_LOGIN_CONFIG_NAME, "modeshape-jcr-non-existant"); // ensure no use of JAAS engine = config.build(); engine.start(); Index: modeshape-jcr/src/test/java/org/modeshape/jcr/JcrRepositoryTest.java =================================================================== --- modeshape-jcr/src/test/java/org/modeshape/jcr/JcrRepositoryTest.java (revision 1803) +++ modeshape-jcr/src/test/java/org/modeshape/jcr/JcrRepositoryTest.java (working copy) @@ -225,8 +225,16 @@ public class JcrRepositoryTest { } @Test( expected = javax.jcr.LoginException.class ) - public void shouldNotAllowLoginWithNoCredentials() throws Exception { + public void shouldNotAllowLoginWithNoCredentialsWhenAnonymousAuthenticationIsNotEnabled() throws Exception { // This would work iff this code was executing in a privileged block, but it's not + Map options = new HashMap(); + options.put(Option.ANONYMOUS_USER_ROLES, ""); // disable anonymous authentication + repository = new JcrRepository(context, connectionFactory, sourceName, new MockObservable(), null, descriptors, options); + repository.login(); + } + + @Test + public void shouldAllowLoginWithNoCredentialsWhenAnonymousAuthenticationIsEnabled() throws Exception { repository.login(); }