You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by kl...@apache.org on 2016/05/04 22:57:43 UTC
[43/63] [abbrv] incubator-geode git commit: GEODE-17: have a more
readable error message when authentication failed.
GEODE-17: have a more readable error message when authentication failed.
Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/53760ec8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/53760ec8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/53760ec8
Branch: refs/heads/feature/GEODE-1276
Commit: 53760ec866e22357b7d0acc9d612573ffd94d2ad
Parents: f04b669
Author: Jinmei Liao <ji...@pivotal.io>
Authored: Fri Apr 29 12:19:35 2016 -0700
Committer: Jinmei Liao <ji...@pivotal.io>
Committed: Fri Apr 29 12:19:35 2016 -0700
----------------------------------------------------------------------
.../internal/security/GeodeSecurityUtil.java | 2 ++
.../internal/security/shiro/CustomAuthRealm.java | 17 ++++++++---------
.../internal/security/JSONAuthorization.java | 4 +++-
.../com/gemstone/gemfire/util/test/TestUtil.java | 8 +-------
4 files changed, 14 insertions(+), 17 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/53760ec8/geode-core/src/main/java/com/gemstone/gemfire/internal/security/GeodeSecurityUtil.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/security/GeodeSecurityUtil.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/security/GeodeSecurityUtil.java
index 4fd92ed..1f1f4eb 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/security/GeodeSecurityUtil.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/security/GeodeSecurityUtil.java
@@ -53,6 +53,7 @@ public class GeodeSecurityUtil {
logger.info("Logging in "+username+"/"+password);
currentUser.login(token);
} catch (ShiroException e) {
+ logger.info(e.getMessage(), e);
throw new AuthenticationFailedException(e.getMessage(), e);
}
}
@@ -67,6 +68,7 @@ public class GeodeSecurityUtil {
currentUser.logout();
}
catch(ShiroException e){
+ logger.info(e.getMessage(), e);
throw new AuthenticationFailedException(e.getMessage(), e);
}
// clean out Shiro's thread local content
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/53760ec8/geode-core/src/main/java/com/gemstone/gemfire/internal/security/shiro/CustomAuthRealm.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/security/shiro/CustomAuthRealm.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/security/shiro/CustomAuthRealm.java
index afc3125..cb2b66b 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/security/shiro/CustomAuthRealm.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/security/shiro/CustomAuthRealm.java
@@ -36,7 +36,6 @@ import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
import com.gemstone.gemfire.internal.lang.StringUtils;
import com.gemstone.gemfire.management.internal.security.ResourceConstants;
import com.gemstone.gemfire.security.AccessControl;
-import com.gemstone.gemfire.security.AuthenticationFailedException;
import com.gemstone.gemfire.security.Authenticator;
import org.apache.logging.log4j.LogManager;
@@ -116,8 +115,8 @@ public class CustomAuthRealm extends AuthorizingRealm{
cachedAuthZCallback.put(principal, authzCallback);
return authzCallback;
} catch (Exception ex) {
- throw new AuthenticationFailedException(
- LocalizedStrings.HandShake_FAILED_TO_ACQUIRE_AUTHENTICATOR_OBJECT.toLocalizedString(), ex);
+ throw new AuthenticationException(
+ ex.toString(), ex);
}
}
} else {
@@ -131,25 +130,25 @@ public class CustomAuthRealm extends AuthorizingRealm{
cachedPostAuthZCallback.put(principal, postAuthzCallback);
return postAuthzCallback;
} catch (Exception ex) {
- throw new AuthenticationFailedException(
- LocalizedStrings.HandShake_FAILED_TO_ACQUIRE_AUTHENTICATOR_OBJECT.toLocalizedString(), ex);
+ throw new AuthenticationException(
+ ex.toString(), ex);
}
}
}
return null;
}
- private Authenticator getAuthenticator(Properties gfSecurityProperties) throws AuthenticationFailedException {
+ private Authenticator getAuthenticator(Properties gfSecurityProperties) throws AuthenticationException {
Authenticator auth;
try {
Method instanceGetter = ClassLoadUtil.methodFromName(this.authenticatorFactoryName);
auth = (Authenticator) instanceGetter.invoke(null, (Object[]) null);
} catch (Exception ex) {
- throw new AuthenticationFailedException(
- LocalizedStrings.HandShake_FAILED_TO_ACQUIRE_AUTHENTICATOR_OBJECT.toLocalizedString(), ex);
+ throw new AuthenticationException(
+ ex.toString(), ex);
}
if (auth == null) {
- throw new AuthenticationFailedException(
+ throw new AuthenticationException(
LocalizedStrings.HandShake_AUTHENTICATOR_INSTANCE_COULD_NOT_BE_OBTAINED.toLocalizedString());
}
auth.init(gfSecurityProperties);
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/53760ec8/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/JSONAuthorization.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/JSONAuthorization.java b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/JSONAuthorization.java
index 83f4876..9670822 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/JSONAuthorization.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/JSONAuthorization.java
@@ -64,7 +64,9 @@ public class JSONAuthorization implements AccessControl, Authenticator {
return new JSONAuthorization();
}
- public JSONAuthorization() {
+ public JSONAuthorization() throws IOException, JSONException {
+ // initialize with a default json file
+ setUpWithJsonFile("shiro-ini.json");
}
public JSONAuthorization(String jsonFileName) throws IOException, JSONException {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/53760ec8/geode-core/src/test/java/com/gemstone/gemfire/util/test/TestUtil.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/util/test/TestUtil.java b/geode-core/src/test/java/com/gemstone/gemfire/util/test/TestUtil.java
index 45369be..7d402d6 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/util/test/TestUtil.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/util/test/TestUtil.java
@@ -21,8 +21,6 @@ import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
-import junit.framework.AssertionFailedError;
-
import com.gemstone.gemfire.internal.FileUtil;
public class TestUtil {
@@ -42,7 +40,7 @@ public class TestUtil {
public static String getResourcePath(Class<?> clazz, String name) {
URL resource = clazz.getResource(name);
if(resource == null) {
- throw new AssertionFailedError("Could not find resource " + name);
+ throw new RuntimeException("Could not find resource " + name);
}
try {
String path = resource.toURI().getPath();
@@ -58,8 +56,4 @@ public class TestUtil {
throw new RuntimeException("Failed getting path to resource " + name, e);
}
}
-
- private TestUtil() {
-
- }
}