jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1404515 - in /jackrabbit/oak/trunk/oak-core/src: main/java/org/apache/jackrabbit/oak/security/authentication/token/TokenProviderImpl.java test/java/org/apache/jackrabbit/oak/security/authentication/token/TokenProviderImplTest.java
Date Thu, 01 Nov 2012 09:38:23 GMT
Author: angela
Date: Thu Nov  1 09:38:22 2012
New Revision: 1404515

URL: http://svn.apache.org/viewvc?rev=1404515&view=rev
Log:
 OAK-91 - Implement Authentication Support (WIP)

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authentication/token/TokenProviderImpl.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authentication/token/TokenProviderImplTest.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authentication/token/TokenProviderImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authentication/token/TokenProviderImpl.java?rev=1404515&r1=1404514&r2=1404515&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authentication/token/TokenProviderImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authentication/token/TokenProviderImpl.java
Thu Nov  1 09:38:22 2012
@@ -244,6 +244,11 @@ public class TokenProviderImpl implement
         if (tokenTree != null) {
             NodeUtil tokenNode = new NodeUtil(tokenTree);
             long expTime = getExpirationTime(tokenNode, 0);
+            if (tokenInfo.isExpired(loginTime)) {
+                log.debug("Attempt to reset an expired token.");
+                return false;
+            }
+
             if (expTime - loginTime <= tokenExpiration/2) {
                 long expirationTime = loginTime + tokenExpiration;
                 try {

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authentication/token/TokenProviderImplTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authentication/token/TokenProviderImplTest.java?rev=1404515&r1=1404514&r2=1404515&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authentication/token/TokenProviderImplTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authentication/token/TokenProviderImplTest.java
Thu Nov  1 09:38:22 2012
@@ -215,6 +215,15 @@ public class TokenProviderImplTest exten
     }
 
     @Test
+    public void testResetTokenExpirationExpiredToken() throws Exception {
+        TokenInfo info = tokenProvider.createToken(userId, Collections.<String, Object>emptyMap());
+
+        long expiredTime = new Date().getTime() + 7200000;
+        assertTrue(info.isExpired(expiredTime));
+        assertFalse(tokenProvider.resetTokenExpiration(info, expiredTime));
+    }
+
+    @Test
     public void testResetTokenExpiration() throws Exception {
         TokenInfo info = tokenProvider.createToken(userId, Collections.<String, Object>emptyMap());
 
@@ -223,11 +232,6 @@ public class TokenProviderImplTest exten
         long loginTime = new Date().getTime() + 3600000;
         assertFalse(info.isExpired(loginTime));
         assertTrue(tokenProvider.resetTokenExpiration(info, loginTime));
-
-        // TODO: check again if expired tokens should be resettable
-        long expiredTime = new Date().getTime() + 7200000;
-        assertTrue(info.isExpired(expiredTime));
-        assertTrue(tokenProvider.resetTokenExpiration(info, expiredTime));
     }
 
     //--------------------------------------------------------------------------



Mime
View raw message