From 3182908bae8d1deb413b87dc8e3ace3b1379cacc Mon Sep 17 00:00:00 2001
From: Nemanja Lukic <nemanja.lukic@forgerock.com>
Date: Mon, 11 Jun 2012 14:35:59 +0000
Subject: [PATCH] Fix for OPENDJ-511
---
opends/src/server/org/opends/server/plugins/SambaPasswordPlugin.java | 49 +++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 47 insertions(+), 2 deletions(-)
diff --git a/opends/src/server/org/opends/server/plugins/SambaPasswordPlugin.java b/opends/src/server/org/opends/server/plugins/SambaPasswordPlugin.java
index 739047d..1cb1d2a 100644
--- a/opends/src/server/org/opends/server/plugins/SambaPasswordPlugin.java
+++ b/opends/src/server/org/opends/server/plugins/SambaPasswordPlugin.java
@@ -22,7 +22,7 @@
* CDDL HEADER END
*
*
- * Copyright 2011 profiq s.r.o.
+ * Copyright 2011-2012 profiq s.r.o.
* Portions copyright 2011 ForgeRock AS.
*/
package org.opends.server.plugins;
@@ -449,6 +449,9 @@
// The name of the Samba account object class.
private static final String SAMBA_SAM_ACCOUNT_OC_NAME = "sambaSAMAccount";
+ // The name of the Samba last password change attribute.
+ private static final String SAMBA_PWD_LAST_SET_NAME = "sambaPwdLastSet";
+
/**
* Debug tracer object to log debugging information.
*/
@@ -464,6 +467,18 @@
*/
private static final String MAGIC_STR = "KGS!@#$%";
+ // Default timestamp provider implementation.
+ private static final TimeStampProvider DEFAULT_TIMESTAMP_PROVIDER =
+ new TimeStampProvider()
+ {
+ public long getCurrentTime()
+ {
+ return System.currentTimeMillis() / 1000L;
+ }
+ };
+
+ // Use the default implementation of the timestamp provider... by default.
+ private TimeStampProvider timeStampProvider = DEFAULT_TIMESTAMP_PROVIDER;
/**
@@ -980,6 +995,11 @@
modifications
.add(new Modification(ModificationType.REPLACE, attribute));
}
+ final Attribute pwdLastSet = Attributes.create(
+ SAMBA_PWD_LAST_SET_NAME,
+ String.valueOf(timeStampProvider.getCurrentTime()));
+ modifications
+ .add(new Modification(ModificationType.REPLACE, pwdLastSet));
}
catch (final Exception e)
{
@@ -1061,4 +1081,29 @@
}
}
-}
+
+ /**
+ * Timestamp provider interface. Intended primarily for testing purposes.
+ */
+ static interface TimeStampProvider
+ {
+ /**
+ * Generates a custom time stamp.
+ *
+ * @return A timestamp in UNIX format.
+ */
+ long getCurrentTime();
+ }
+
+ /**
+ * Use custom timestamp provider. Intended primarily for testing purposes.
+ *
+ * @param timeStampProvider Provider object that implements the
+ * TimeStampProvider intreface.
+ */
+ void setTimeStampProvider(TimeStampProvider timeStampProvider)
+ {
+ this.timeStampProvider = (timeStampProvider == null)
+ ? DEFAULT_TIMESTAMP_PROVIDER : timeStampProvider;
+ }
+}
\ No newline at end of file
--
Gitblit v1.10.0