You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by pl...@apache.org on 2016/07/07 06:41:52 UTC

[07/27] directory-kerby git commit: NPE fixes

NPE fixes


Project: http://git-wip-us.apache.org/repos/asf/directory-kerby/repo
Commit: http://git-wip-us.apache.org/repos/asf/directory-kerby/commit/5e75bf59
Tree: http://git-wip-us.apache.org/repos/asf/directory-kerby/tree/5e75bf59
Diff: http://git-wip-us.apache.org/repos/asf/directory-kerby/diff/5e75bf59

Branch: refs/heads/kpasswd
Commit: 5e75bf59e378fc7c5c5c37e587c54fb4eb4b916e
Parents: 8518838
Author: Colm O hEigeartaigh <co...@apache.org>
Authored: Mon Jul 4 11:18:59 2016 +0100
Committer: Colm O hEigeartaigh <co...@apache.org>
Committed: Mon Jul 4 11:18:59 2016 +0100

----------------------------------------------------------------------
 .../test/jaas/TokenAuthLoginModule.java           | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/5e75bf59/kerby-kerb/integration-test/src/main/java/org/apache/kerby/kerberos/kerb/integration/test/jaas/TokenAuthLoginModule.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/integration-test/src/main/java/org/apache/kerby/kerberos/kerb/integration/test/jaas/TokenAuthLoginModule.java b/kerby-kerb/integration-test/src/main/java/org/apache/kerby/kerberos/kerb/integration/test/jaas/TokenAuthLoginModule.java
index cbeb01c..7eee5ba 100644
--- a/kerby-kerb/integration-test/src/main/java/org/apache/kerby/kerberos/kerb/integration/test/jaas/TokenAuthLoginModule.java
+++ b/kerby-kerb/integration-test/src/main/java/org/apache/kerby/kerberos/kerb/integration/test/jaas/TokenAuthLoginModule.java
@@ -102,9 +102,15 @@ public class TokenAuthLoginModule implements LoginModule {
         princName = (String) options.get(PRINCIPAL);
         tokenStr = (String) options.get(TOKEN);
         tokenCacheName = (String) options.get(TOKEN_CACHE);
-        armorCache = new File((String) options.get(ARMOR_CACHE));
-        cCache = new File((String) options.get(CREDENTIAL_CACHE));
-        signKeyFile = new File((String) options.get(SIGN_KEY_FILE));
+        if ((String) options.get(ARMOR_CACHE) != null) {
+            armorCache = new File((String) options.get(ARMOR_CACHE));
+        }
+        if ((String) options.get(CREDENTIAL_CACHE) != null) {
+            cCache = new File((String) options.get(CREDENTIAL_CACHE));
+        }
+        if ((String) options.get(SIGN_KEY_FILE) != null) {
+            signKeyFile = new File((String) options.get(SIGN_KEY_FILE));
+        }
     }
 
     /**
@@ -215,6 +221,10 @@ public class TokenAuthLoginModule implements LoginModule {
     }
 
     private void validateConfiguration() throws LoginException {
+        
+        if (armorCache == null) {
+            throw new LoginException("An armor cache must be specified via the armorCache configuration option");
+        }
 
         String error = "";
         if (tokenStr == null && tokenCacheName == null) {
@@ -244,7 +254,7 @@ public class TokenAuthLoginModule implements LoginModule {
         krbToken = new KrbToken(authToken, TokenFormat.JWT);
         TokenEncoder tokenEncoder = KrbRuntime.getTokenProvider().createTokenEncoder();
 
-        if (tokenEncoder instanceof JwtTokenEncoder) {
+        if (tokenEncoder instanceof JwtTokenEncoder && signKeyFile != null) {
             PrivateKey signKey = null;
             try {
                 FileInputStream fis = new FileInputStream(signKeyFile);