diff --git a/enterprise/security/src/main/java/org/neo4j/server/security/enterprise/auth/InternalFlatFileRealm.java b/enterprise/security/src/main/java/org/neo4j/server/security/enterprise/auth/InternalFlatFileRealm.java
index 783be7ae8a046..b831288cbd245 100644
--- a/enterprise/security/src/main/java/org/neo4j/server/security/enterprise/auth/InternalFlatFileRealm.java
+++ b/enterprise/security/src/main/java/org/neo4j/server/security/enterprise/auth/InternalFlatFileRealm.java
@@ -55,6 +55,7 @@
import org.neo4j.server.security.auth.UserRepository;
import org.neo4j.server.security.auth.exception.ConcurrentModificationException;
import org.neo4j.server.security.enterprise.auth.plugin.api.PredefinedRoles;
+import org.neo4j.server.security.enterprise.auth.plugin.spi.RealmLifecycle;
import static java.lang.String.format;
diff --git a/enterprise/security/src/main/java/org/neo4j/server/security/enterprise/auth/MultiRealmAuthManager.java b/enterprise/security/src/main/java/org/neo4j/server/security/enterprise/auth/MultiRealmAuthManager.java
index 5101cd14e190e..83ae1a8b89b78 100644
--- a/enterprise/security/src/main/java/org/neo4j/server/security/enterprise/auth/MultiRealmAuthManager.java
+++ b/enterprise/security/src/main/java/org/neo4j/server/security/enterprise/auth/MultiRealmAuthManager.java
@@ -44,6 +44,7 @@
import org.neo4j.kernel.api.security.exception.InvalidAuthTokenException;
import org.neo4j.kernel.enterprise.api.security.EnterpriseAuthSubject;
import org.neo4j.kernel.impl.enterprise.SecurityLog;
+import org.neo4j.server.security.enterprise.auth.plugin.spi.RealmLifecycle;
import static org.neo4j.helpers.Strings.escape;
diff --git a/enterprise/security/src/main/java/org/neo4j/server/security/enterprise/auth/plugin/PluginRealm.java b/enterprise/security/src/main/java/org/neo4j/server/security/enterprise/auth/plugin/PluginRealm.java
index bcef8503c59a2..ad6c494a8116f 100644
--- a/enterprise/security/src/main/java/org/neo4j/server/security/enterprise/auth/plugin/PluginRealm.java
+++ b/enterprise/security/src/main/java/org/neo4j/server/security/enterprise/auth/plugin/PluginRealm.java
@@ -29,12 +29,12 @@
import org.apache.shiro.subject.PrincipalCollection;
import org.neo4j.server.security.enterprise.auth.PredefinedRolesBuilder;
-import org.neo4j.server.security.enterprise.auth.RealmLifecycle;
import org.neo4j.server.security.enterprise.auth.ShiroAuthToken;
import org.neo4j.server.security.enterprise.auth.plugin.spi.AuthInfo;
import org.neo4j.server.security.enterprise.auth.plugin.spi.AuthPlugin;
import org.neo4j.server.security.enterprise.auth.plugin.spi.AuthenticationPlugin;
import org.neo4j.server.security.enterprise.auth.plugin.spi.AuthorizationPlugin;
+import org.neo4j.server.security.enterprise.auth.plugin.spi.RealmLifecycle;
public class PluginRealm extends AuthorizingRealm implements RealmLifecycle
{
@@ -85,27 +85,34 @@ protected AuthenticationInfo doGetAuthenticationInfo( AuthenticationToken token
{
if ( token instanceof ShiroAuthToken )
{
- if ( authPlugin != null )
+ try
{
- AuthInfo authInfo = authPlugin.getAuthInfo( ((ShiroAuthToken) token).getAuthTokenMap() );
- if ( authInfo != null )
+ if ( authPlugin != null )
{
- PluginAuthInfo pluginAuthInfo = PluginAuthInfo.create( authInfo, getName() );
+ AuthInfo authInfo = authPlugin.getAuthInfo( ((ShiroAuthToken) token).getAuthTokenMap() );
+ if ( authInfo != null )
+ {
+ PluginAuthInfo pluginAuthInfo = PluginAuthInfo.create( authInfo, getName() );
- cacheAuthorizationInfo( pluginAuthInfo );
+ cacheAuthorizationInfo( pluginAuthInfo );
- return pluginAuthInfo;
+ return pluginAuthInfo;
+ }
}
- }
- else if ( authenticationPlugin != null )
- {
- org.neo4j.server.security.enterprise.auth.plugin.spi.AuthenticationInfo authenticationInfo =
- authenticationPlugin.getAuthenticationInfo( ((ShiroAuthToken) token).getAuthTokenMap() );
- if ( authenticationInfo != null )
+ else if ( authenticationPlugin != null )
{
- return PluginAuthenticationInfo.create( authenticationInfo, getName() );
+ org.neo4j.server.security.enterprise.auth.plugin.spi.AuthenticationInfo authenticationInfo =
+ authenticationPlugin.getAuthenticationInfo( ((ShiroAuthToken) token).getAuthTokenMap() );
+ if ( authenticationInfo != null )
+ {
+ return PluginAuthenticationInfo.create( authenticationInfo, getName() );
+ }
}
}
+ catch ( org.neo4j.server.security.enterprise.auth.plugin.api.AuthenticationException e )
+ {
+ throw new AuthenticationException( e.getMessage(), e.getCause() );
+ }
}
return null;
}
diff --git a/enterprise/security/src/main/java/org/neo4j/server/security/enterprise/auth/RealmLifecycle.java b/enterprise/security/src/main/java/org/neo4j/server/security/enterprise/auth/plugin/api/AuthenticationException.java
similarity index 78%
rename from enterprise/security/src/main/java/org/neo4j/server/security/enterprise/auth/RealmLifecycle.java
rename to enterprise/security/src/main/java/org/neo4j/server/security/enterprise/auth/plugin/api/AuthenticationException.java
index 15c80dbe355e7..ca6ab29a0e369 100644
--- a/enterprise/security/src/main/java/org/neo4j/server/security/enterprise/auth/RealmLifecycle.java
+++ b/enterprise/security/src/main/java/org/neo4j/server/security/enterprise/auth/plugin/api/AuthenticationException.java
@@ -17,12 +17,8 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see .
*/
-package org.neo4j.server.security.enterprise.auth;
+package org.neo4j.server.security.enterprise.auth.plugin.api;
-public interface RealmLifecycle
+public class AuthenticationException extends Exception
{
- void initialize() throws Throwable;
- void start() throws Throwable;
- void stop() throws Throwable;
- void shutdown() throws Throwable;
}
diff --git a/enterprise/security/src/main/java/org/neo4j/server/security/enterprise/auth/plugin/spi/AuthPlugin.java b/enterprise/security/src/main/java/org/neo4j/server/security/enterprise/auth/plugin/spi/AuthPlugin.java
index 928bd4982fbb1..f6468a8b7bf5f 100644
--- a/enterprise/security/src/main/java/org/neo4j/server/security/enterprise/auth/plugin/spi/AuthPlugin.java
+++ b/enterprise/security/src/main/java/org/neo4j/server/security/enterprise/auth/plugin/spi/AuthPlugin.java
@@ -21,7 +21,7 @@
import java.util.Map;
-import org.neo4j.server.security.enterprise.auth.RealmLifecycle;
+import org.neo4j.server.security.enterprise.auth.plugin.api.AuthenticationException;
/**
* TODO
@@ -31,5 +31,5 @@ public interface AuthPlugin extends RealmLifecycle
/**
* TODO
*/
- AuthInfo getAuthInfo( Map authToken );
+ AuthInfo getAuthInfo( Map authToken ) throws AuthenticationException;
}
diff --git a/enterprise/security/src/main/java/org/neo4j/server/security/enterprise/auth/plugin/spi/AuthenticationPlugin.java b/enterprise/security/src/main/java/org/neo4j/server/security/enterprise/auth/plugin/spi/AuthenticationPlugin.java
index 40df9b5081c3a..d44ea017d3dca 100644
--- a/enterprise/security/src/main/java/org/neo4j/server/security/enterprise/auth/plugin/spi/AuthenticationPlugin.java
+++ b/enterprise/security/src/main/java/org/neo4j/server/security/enterprise/auth/plugin/spi/AuthenticationPlugin.java
@@ -21,8 +21,6 @@
import java.util.Map;
-import org.neo4j.server.security.enterprise.auth.RealmLifecycle;
-
/**
* TODO
*/
diff --git a/enterprise/security/src/main/java/org/neo4j/server/security/enterprise/auth/plugin/spi/AuthorizationPlugin.java b/enterprise/security/src/main/java/org/neo4j/server/security/enterprise/auth/plugin/spi/AuthorizationPlugin.java
index 199f1ae7e96a6..b1d26d83669a6 100644
--- a/enterprise/security/src/main/java/org/neo4j/server/security/enterprise/auth/plugin/spi/AuthorizationPlugin.java
+++ b/enterprise/security/src/main/java/org/neo4j/server/security/enterprise/auth/plugin/spi/AuthorizationPlugin.java
@@ -21,8 +21,6 @@
import java.util.Collection;
-import org.neo4j.server.security.enterprise.auth.RealmLifecycle;
-
/**
* TODO
*/
diff --git a/enterprise/security/src/main/java/org/neo4j/server/security/enterprise/auth/plugin/spi/RealmLifecycle.java b/enterprise/security/src/main/java/org/neo4j/server/security/enterprise/auth/plugin/spi/RealmLifecycle.java
new file mode 100644
index 0000000000000..cc05c2ef32e35
--- /dev/null
+++ b/enterprise/security/src/main/java/org/neo4j/server/security/enterprise/auth/plugin/spi/RealmLifecycle.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2002-2016 "Neo Technology,"
+ * Network Engine for Objects in Lund AB [http://neotechnology.com]
+ *
+ * This file is part of Neo4j.
+ *
+ * Neo4j is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+package org.neo4j.server.security.enterprise.auth.plugin.spi;
+
+public interface RealmLifecycle
+{
+ void initialize() throws Throwable;
+ void start() throws Throwable;
+ void stop() throws Throwable;
+ void shutdown() throws Throwable;
+
+ class Adapter implements RealmLifecycle
+ {
+ @Override
+ public void initialize() throws Throwable
+ {
+ }
+
+ @Override
+ public void start() throws Throwable
+ {
+ }
+
+ @Override
+ public void stop() throws Throwable
+ {
+ }
+
+ @Override
+ public void shutdown() throws Throwable
+ {
+ }
+ }
+}