directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject [1/3] directory-kerby git commit: NPE fixes
Date Mon, 04 Jul 2016 11:53:46 GMT
Repository: directory-kerby
Updated Branches:
  refs/heads/trunk 85188383e -> 8b9b2f983


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/trunk
Commit: 5e75bf59e378fc7c5c5c37e587c54fb4eb4b916e
Parents: 8518838
Author: Colm O hEigeartaigh <coheigea@apache.org>
Authored: Mon Jul 4 11:18:59 2016 +0100
Committer: Colm O hEigeartaigh <coheigea@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);


Mime
View raw message