Author: bdelacretaz
Date: Wed Jan 9 08:24:31 2008
New Revision: 610436
URL: http://svn.apache.org/viewvc?rev=610436&view=rev
Log:
Throw MissingRepositoryException if no Repository available, to avoid NPEs
downstream
Modified:
incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/auth/SlingAuthenticator.java
Modified:
incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/auth/SlingAuthenticator.java
URL:
http://svn.apache.org/viewvc/incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/auth/SlingAuthenticator.java?rev=610436&r1=610435&r2=610436&view=diff
==============================================================================
---
incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/auth/SlingAuthenticator.java
(original)
+++
incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/auth/SlingAuthenticator.java
Wed Jan 9 08:24:31 2008
@@ -137,6 +137,13 @@
/** Whether access without credentials is allowed */
boolean anonymousAllowed;
+
+ /** A Repository is required to authenticate - this signals that it's
missing */
+ static class MissingRepositoryException extends RuntimeException {
+ MissingRepositoryException(String reason) {
+ super(reason);
+ }
+ }
/**
* The list of packages from the configuration file. This list is checked
@@ -343,7 +350,12 @@
// ---------- internal ----------------------------------------------------
private Repository getRepository() {
- return (Repository) repositoryTracker.getService();
+ final Repository repo = (Repository) repositoryTracker.getService();
+ if(repo == null) {
+ throw new MissingRepositoryException(
+ "No Repository available to " + getClass().getSimpleName()
+ ", cannot authenticate");
+ }
+ return repo;
}
private AuthenticationHandler[] getAuthenticationHandlers() {