You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ze...@apache.org on 2018/02/13 16:05:25 UTC

directory-kerby git commit: DIRKRB-688 Add time check in MySQL server plugin

Repository: directory-kerby
Updated Branches:
  refs/heads/trunk 268d2493e -> 2afba2e07


DIRKRB-688 Add time check in MySQL server plugin


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

Branch: refs/heads/trunk
Commit: 2afba2e070a7741d1532eb728131264c5c8cd0db
Parents: 268d249
Author: zenglinx <fr...@intel.com>
Authored: Wed Feb 14 00:04:50 2018 +0800
Committer: zenglinx <fr...@intel.com>
Committed: Wed Feb 14 00:04:50 2018 +0800

----------------------------------------------------------------------
 .../has/plugins/server/mysql/MySQLHasServerPlugin.java    | 10 ++++++++++
 1 file changed, 10 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/2afba2e0/has-project/has-plugins/src/main/java/org/apache/kerby/has/plugins/server/mysql/MySQLHasServerPlugin.java
----------------------------------------------------------------------
diff --git a/has-project/has-plugins/src/main/java/org/apache/kerby/has/plugins/server/mysql/MySQLHasServerPlugin.java b/has-project/has-plugins/src/main/java/org/apache/kerby/has/plugins/server/mysql/MySQLHasServerPlugin.java
index 7c58b21..982860e 100644
--- a/has-project/has-plugins/src/main/java/org/apache/kerby/has/plugins/server/mysql/MySQLHasServerPlugin.java
+++ b/has-project/has-plugins/src/main/java/org/apache/kerby/has/plugins/server/mysql/MySQLHasServerPlugin.java
@@ -29,6 +29,7 @@ import java.sql.Connection;
 import java.sql.SQLException;
 import java.sql.DriverManager;
 import java.sql.PreparedStatement;
+import java.util.Date;
 
 public class MySQLHasServerPlugin extends AbstractHasServerPlugin {
     private static final Logger LOG = LoggerFactory.getLogger(MySQLHasServerPlugin.class);
@@ -47,6 +48,15 @@ public class MySQLHasServerPlugin extends AbstractHasServerPlugin {
     @Override
     public void doAuthenticate(AuthToken userToken, AuthToken authToken)
         throws HasAuthenException {
+
+        // Check if the token is expired.
+        Date expiredTime = userToken.getExpiredTime();
+        Date now = new Date();
+        if (now.after(expiredTime)) {
+            LOG.error("Authentication failed: token is expired.");
+            throw new HasAuthenException("Authentication failed: token is expired.");
+        }
+
         String user = (String) userToken.getAttributes().get("user");
         String secret = (String) userToken.getAttributes().get("secret");