You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by co...@apache.org on 2017/07/27 15:47:48 UTC

syncope git commit: SYNCOPE-1174 - NPE in AccessTokenDataBinderImpl if no 'jwt.lifetime.minutes' schema is present

Repository: syncope
Updated Branches:
  refs/heads/master aa11ac9b4 -> 64ef5bf18


SYNCOPE-1174 - NPE in AccessTokenDataBinderImpl if no 'jwt.lifetime.minutes' schema is present


Project: http://git-wip-us.apache.org/repos/asf/syncope/repo
Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/64ef5bf1
Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/64ef5bf1
Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/64ef5bf1

Branch: refs/heads/master
Commit: 64ef5bf1800f699168f59fbd27be113c76cd0baa
Parents: aa11ac9
Author: Colm O hEigeartaigh <co...@apache.org>
Authored: Thu Jul 27 16:47:35 2017 +0100
Committer: Colm O hEigeartaigh <co...@apache.org>
Committed: Thu Jul 27 16:47:35 2017 +0100

----------------------------------------------------------------------
 .../java/data/AccessTokenDataBinderImpl.java             | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/syncope/blob/64ef5bf1/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/AccessTokenDataBinderImpl.java
----------------------------------------------------------------------
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/AccessTokenDataBinderImpl.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/AccessTokenDataBinderImpl.java
index 13a5b93..b415fb2 100644
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/AccessTokenDataBinderImpl.java
+++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/AccessTokenDataBinderImpl.java
@@ -38,6 +38,7 @@ import org.apache.syncope.core.persistence.api.dao.AccessTokenDAO;
 import org.apache.syncope.core.persistence.api.dao.ConfDAO;
 import org.apache.syncope.core.persistence.api.entity.AccessToken;
 import org.apache.syncope.core.persistence.api.entity.EntityFactory;
+import org.apache.syncope.core.persistence.api.entity.conf.CPlainAttr;
 import org.apache.syncope.core.provisioning.api.data.AccessTokenDataBinder;
 import org.apache.syncope.core.provisioning.api.serialization.POJOHelper;
 import org.apache.syncope.core.spring.BeanUtils;
@@ -124,9 +125,17 @@ public class AccessTokenDataBinderImpl implements AccessTokenDataBinder {
         }
 
         if (replaceExisting || body == null) {
+            int duration = 120;
+            CPlainAttr jwtLifetimeMins = confDAO.find("jwt.lifetime.minutes", "120");
+            if (jwtLifetimeMins != null) {
+                duration = jwtLifetimeMins.getValues().get(0).getLongValue().intValue();
+            } else {
+                LOG.warn("No schema found for 'jwt.lifetime.minutes'. Using default value of '120'");
+            }
+
             Triple<String, String, Date> created = generateJWT(
                     subject,
-                    confDAO.find("jwt.lifetime.minutes", "120").getValues().get(0).getLongValue().intValue(),
+                    duration,
                     claims);
 
             body = created.getMiddle();