directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1124978 - in /directory: apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/ apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/server/kerberos/shared/crypto/encryption/ apacheds/trunk/kerberos-c...
Date Thu, 19 May 2011 15:57:49 GMT
Author: elecharny
Date: Thu May 19 15:57:48 2011
New Revision: 1124978

URL: http://svn.apache.org/viewvc?rev=1124978&view=rev
Log:
o Fix for DIRSHARED-70
o Some few other related fixes in ADS and studio

Modified:
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/KerberosTime.java
    directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/server/kerberos/shared/crypto/encryption/CipherTextHandlerTest.java
    directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/server/kerberos/shared/keytab/KeytabTest.java
    directory/apacheds/trunk/protocol-ntp/src/main/java/org/apache/directory/server/ntp/messages/NtpTimeStamp.java
    directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/csn/Csn.java
    directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/csn/CsnTest.java
    directory/shared/trunk/util/src/main/java/org/apache/directory/shared/util/DateUtils.java
    directory/studio/trunk/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/LdifModificationLogger.java
    directory/studio/trunk/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/LdifSearchLogger.java

Modified: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/KerberosTime.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/KerberosTime.java?rev=1124978&r1=1124977&r2=1124978&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/KerberosTime.java
(original)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/KerberosTime.java
Thu May 19 15:57:48 2011
@@ -20,11 +20,11 @@
 package org.apache.directory.shared.kerberos;
 
 import java.text.ParseException;
-import java.text.SimpleDateFormat;
 import java.util.Calendar;
 import java.util.Date;
 import java.util.TimeZone;
 
+import org.apache.directory.shared.util.DateUtils;
 import org.apache.directory.shared.util.Strings;
 
 /**
@@ -36,10 +36,6 @@ import org.apache.directory.shared.util.
  */
 public class KerberosTime implements Comparable<KerberosTime>
 {
-
-    /** The format for a KerberosTime */
-    private static final SimpleDateFormat sdf = new SimpleDateFormat( "yyyyMMddHHmmss'Z'"
);
-    
     /** The UTC timeZone */
     private static final TimeZone UTC = TimeZone.getTimeZone( "UTC" );
     
@@ -61,12 +57,6 @@ public class KerberosTime implements Com
     /** The number of milliseconds in a week. */
     public static final int WEEK = MINUTE * 10080;
 
-    // Initialize the dateFormat with the UTC TZ
-    static
-    {
-        sdf.setTimeZone( UTC );
-    }
-
     
     /**
      * Creates a new instance of a KerberosTime object
@@ -128,9 +118,9 @@ public class KerberosTime implements Com
         Calendar calendar = Calendar.getInstance( UTC );
         calendar.setTimeInMillis( date );
         
-        synchronized ( sdf )
+        synchronized ( DateUtils.DATE_FORMAT )
         {
-            this.date = sdf.format( calendar.getTime() );
+            this.date = DateUtils.DATE_FORMAT.format( calendar.getTime() );
         }
         
         kerberosTime = (calendar.getTimeInMillis()/1000L)*1000L; // drop the ms
@@ -170,9 +160,9 @@ public class KerberosTime implements Com
     {
         Date date = null;
         
-        synchronized ( sdf )
+        synchronized ( DateUtils.DATE_FORMAT )
         {
-            date = sdf.parse( zuluTime );
+            date = DateUtils.DATE_FORMAT.parse( zuluTime );
         }
         
         return new KerberosTime( date );
@@ -185,9 +175,9 @@ public class KerberosTime implements Com
      */
     public void setDate( String date ) throws ParseException
     {
-        synchronized ( sdf )
+        synchronized ( DateUtils.DATE_FORMAT )
         {
-            kerberosTime = sdf.parse( date ).getTime();
+            kerberosTime = DateUtils.DATE_FORMAT.parse( date ).getTime();
         }
         
         convertInternal( kerberosTime );

Modified: directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/server/kerberos/shared/crypto/encryption/CipherTextHandlerTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/server/kerberos/shared/crypto/encryption/CipherTextHandlerTest.java?rev=1124978&r1=1124977&r2=1124978&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/server/kerberos/shared/crypto/encryption/CipherTextHandlerTest.java
(original)
+++ directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/server/kerberos/shared/crypto/encryption/CipherTextHandlerTest.java
Thu May 19 15:57:48 2011
@@ -24,15 +24,11 @@ import static org.junit.Assert.assertEqu
 import static org.junit.Assert.fail;
 
 import java.text.ParseException;
-import java.text.SimpleDateFormat;
 import java.util.Date;
-import java.util.TimeZone;
 
 import javax.security.auth.kerberos.KerberosKey;
 import javax.security.auth.kerberos.KerberosPrincipal;
 
-import com.mycila.junit.concurrent.Concurrency;
-import com.mycila.junit.concurrent.ConcurrentJunitRunner;
 import org.apache.directory.server.kerberos.protocol.KerberosDecoder;
 import org.apache.directory.shared.kerberos.KerberosTime;
 import org.apache.directory.shared.kerberos.codec.types.EncryptionType;
@@ -40,9 +36,13 @@ import org.apache.directory.shared.kerbe
 import org.apache.directory.shared.kerberos.components.EncryptionKey;
 import org.apache.directory.shared.kerberos.components.PaEncTsEnc;
 import org.apache.directory.shared.kerberos.exceptions.KerberosException;
+import org.apache.directory.shared.util.DateUtils;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
+import com.mycila.junit.concurrent.Concurrency;
+import com.mycila.junit.concurrent.ConcurrentJunitRunner;
+
 
 /**
  * Test case for sealing and unsealing Kerberos CipherText.
@@ -104,15 +104,6 @@ public class CipherTextHandlerTest
             ( byte ) 0x65, ( byte ) 0x92, ( byte ) 0xbd, ( byte ) 0xf5, ( byte ) 0x52, (
byte ) 0x9f, ( byte ) 0x94,
             ( byte ) 0x67, ( byte ) 0x10, ( byte ) 0xd2 };
 
-    private static final TimeZone UTC_TIME_ZONE = TimeZone.getTimeZone( "UTC" );
-
-    private static final SimpleDateFormat dateFormat = new SimpleDateFormat( "yyyyMMddHHmmss'Z'"
);
-
-    static
-    {
-        dateFormat.setTimeZone( UTC_TIME_ZONE );
-    }
-
 
     /**
      * Tests the lengths of the test vectors for encrypted timestamps for each
@@ -447,9 +438,10 @@ public class CipherTextHandlerTest
     protected PaEncTsEnc getEncryptedTimeStamp( String zuluTime, int microSeconds ) throws
ParseException
     {
         Date date = null;
-        synchronized ( dateFormat )
+        
+        synchronized ( DateUtils.DATE_FORMAT )
         {
-            date = dateFormat.parse( zuluTime );
+            date = DateUtils.DATE_FORMAT.parse( zuluTime );
         }
 
         KerberosTime timeStamp = new KerberosTime( date );

Modified: directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/server/kerberos/shared/keytab/KeytabTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/server/kerberos/shared/keytab/KeytabTest.java?rev=1124978&r1=1124977&r2=1124978&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/server/kerberos/shared/keytab/KeytabTest.java
(original)
+++ directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/server/kerberos/shared/keytab/KeytabTest.java
Thu May 19 15:57:48 2011
@@ -26,26 +26,26 @@ import static org.junit.Assert.fail;
 
 import java.security.InvalidKeyException;
 import java.text.ParseException;
-import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Date;
 import java.util.List;
 import java.util.Map;
-import java.util.TimeZone;
 
 import javax.crypto.spec.DESKeySpec;
 
-import com.mycila.junit.concurrent.Concurrency;
-import com.mycila.junit.concurrent.ConcurrentJunitRunner;
 import org.apache.directory.server.kerberos.shared.crypto.encryption.KerberosKeyFactory;
 import org.apache.directory.shared.kerberos.KerberosTime;
 import org.apache.directory.shared.kerberos.codec.types.EncryptionType;
 import org.apache.directory.shared.kerberos.components.EncryptionKey;
+import org.apache.directory.shared.util.DateUtils;
 import org.apache.mina.core.buffer.IoBuffer;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
+import com.mycila.junit.concurrent.Concurrency;
+import com.mycila.junit.concurrent.ConcurrentJunitRunner;
+
 
 /**
  * Tests 'keytab' formatted files.
@@ -82,15 +82,6 @@ public class KeytabTest
             ( byte ) 0x00, ( byte ) 0x08, ( byte ) 0x13, ( byte ) 0xD9, ( byte ) 0x19, (
byte ) 0x98, ( byte ) 0x23,
             ( byte ) 0x8F, ( byte ) 0x9E, ( byte ) 0x31 };
 
-    private static final TimeZone UTC_TIME_ZONE = TimeZone.getTimeZone( "UTC" );
-
-    private static final SimpleDateFormat dateFormat = new SimpleDateFormat( "yyyyMMddHHmmss'Z'"
);
-
-    static
-    {
-        dateFormat.setTimeZone( UTC_TIME_ZONE );
-    }
-
 
     /**
      * Read the first keytab test bytes and check for the presence of a valid DES key.
@@ -173,9 +164,10 @@ public class KeytabTest
 
         String zuluTime = "20070217235745Z";
         Date date = null;
-        synchronized ( dateFormat )
+        
+        synchronized ( DateUtils.DATE_FORMAT )
         {
-            date = dateFormat.parse( zuluTime );
+            date = DateUtils.DATE_FORMAT.parse( zuluTime );
         }
 
         KerberosTime timeStamp = new KerberosTime( date.getTime() );

Modified: directory/apacheds/trunk/protocol-ntp/src/main/java/org/apache/directory/server/ntp/messages/NtpTimeStamp.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ntp/src/main/java/org/apache/directory/server/ntp/messages/NtpTimeStamp.java?rev=1124978&r1=1124977&r2=1124978&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ntp/src/main/java/org/apache/directory/server/ntp/messages/NtpTimeStamp.java
(original)
+++ directory/apacheds/trunk/protocol-ntp/src/main/java/org/apache/directory/server/ntp/messages/NtpTimeStamp.java
Thu May 19 15:57:48 2011
@@ -24,7 +24,8 @@ package org.apache.directory.server.ntp.
 import java.nio.ByteBuffer;
 import java.text.SimpleDateFormat;
 import java.util.Date;
-import java.util.TimeZone;
+
+import org.apache.directory.shared.util.DateUtils;
 
 
 /**
@@ -43,12 +44,11 @@ public class NtpTimeStamp
      */
     private static final long NTP_EPOCH_DIFFERENCE = -2208988800000L;
 
-    private static final TimeZone UTC_TIME_ZONE = TimeZone.getTimeZone( "UTC" );
     private static final SimpleDateFormat dateFormat = new SimpleDateFormat( "yyyy-MM-dd
HH:mm:ss.SSS z" );
 
     static
     {
-        dateFormat.setTimeZone( UTC_TIME_ZONE );
+        dateFormat.setTimeZone( DateUtils.UTC_TIME_ZONE );
     }
 
     private long seconds = 0;

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/csn/Csn.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/csn/Csn.java?rev=1124978&r1=1124977&r2=1124978&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/csn/Csn.java
(original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/csn/Csn.java
Thu May 19 15:57:48 2011
@@ -26,6 +26,7 @@ import java.util.Date;
 
 import org.apache.directory.shared.i18n.I18n;
 import org.apache.directory.shared.util.Chars;
+import org.apache.directory.shared.util.DateUtils;
 import org.apache.directory.shared.util.Strings;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -80,6 +81,12 @@ public class Csn implements Comparable<C
     /** The Timestamp syntax. The last 'z' is _not_ the Time Zone */
     private static final SimpleDateFormat SDF = new SimpleDateFormat( "yyyyMMddHHmmss" );
     
+    // Initialize the dateFormat with the UTC TZ
+    static
+    {
+        SDF.setTimeZone( DateUtils.UTC_TIME_ZONE );
+    }
+    
     /** Padding used to format number with a fixed size */
     private static final String[] PADDING_6 = new String[] { "00000", "0000", "000", "00",
"0", "" };
 

Modified: directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/csn/CsnTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/csn/CsnTest.java?rev=1124978&r1=1124977&r2=1124978&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/csn/CsnTest.java
(original)
+++ directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/csn/CsnTest.java
Thu May 19 15:57:48 2011
@@ -20,20 +20,20 @@
 package org.apache.directory.shared.ldap.model.csn;
 
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
 import java.text.SimpleDateFormat;
 import java.util.Arrays;
 import java.util.Date;
 
-import com.mycila.junit.concurrent.Concurrency;
-import com.mycila.junit.concurrent.ConcurrentJunitRunner;
-import org.apache.directory.shared.ldap.model.csn.Csn;
-import org.apache.directory.shared.ldap.model.csn.InvalidCSNException;
+import org.apache.directory.shared.util.DateUtils;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import com.mycila.junit.concurrent.Concurrency;
+import com.mycila.junit.concurrent.ConcurrentJunitRunner;
 
 
 /**
@@ -46,21 +46,29 @@ import static org.junit.Assert.fail;
 @Concurrency()
 public class CsnTest
 {
-    private SimpleDateFormat sdf = new SimpleDateFormat( "yyyyMMddHHmmss.123456'Z'" );
+    private static final SimpleDateFormat SDF = new SimpleDateFormat( "yyyyMMddHHmmss.123456'Z'"
);
+    
+    static
+    {
+        SDF.setTimeZone( DateUtils.UTC_TIME_ZONE );
+    }
 
     @Test
     public void testCSN()
     {
-        long ts = System.currentTimeMillis();
-
-        Csn csn = new Csn( sdf.format( new Date( ts ) ) + "#123456#abc#654321" );
-
-        assertEquals( ts/1000, csn.getTimestamp()/1000 );
-        
-        // ALl the value are converted from hex to int
-        assertEquals( 1193046, csn.getChangeCount() );
-        assertEquals( 6636321, csn.getOperationNumber() );
-        assertEquals( 2748, csn.getReplicaId() );
+        synchronized ( SDF )
+        {
+            long ts = System.currentTimeMillis();
+    
+            Csn csn = new Csn( SDF.format( new Date( ts ) ) + "#123456#abc#654321" );
+    
+            assertEquals( ts/1000, csn.getTimestamp()/1000 );
+            
+            // ALl the value are converted from hex to int
+            assertEquals( 1193046, csn.getChangeCount() );
+            assertEquals( 6636321, csn.getOperationNumber() );
+            assertEquals( 2748, csn.getReplicaId() );
+        }
     }
 
 
@@ -99,7 +107,11 @@ public class CsnTest
     {
         try
         {
-            new Csn( sdf.format( new Date( System.currentTimeMillis() ) ) );
+            synchronized( SDF )
+            {
+                new Csn( SDF.format( new Date( System.currentTimeMillis() ) ) );
+            }
+            
             fail();
         }
         catch ( InvalidCSNException ice )

Modified: directory/shared/trunk/util/src/main/java/org/apache/directory/shared/util/DateUtils.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/util/src/main/java/org/apache/directory/shared/util/DateUtils.java?rev=1124978&r1=1124977&r2=1124978&view=diff
==============================================================================
--- directory/shared/trunk/util/src/main/java/org/apache/directory/shared/util/DateUtils.java
(original)
+++ directory/shared/trunk/util/src/main/java/org/apache/directory/shared/util/DateUtils.java
Thu May 19 15:57:48 2011
@@ -33,9 +33,11 @@ import java.util.TimeZone;
  */
 public final class DateUtils
 {
-    private static final TimeZone UTC_TIME_ZONE = TimeZone.getTimeZone( "GMT" );
+    /** Defines an UTC/GMT time zone */
+    public static final TimeZone UTC_TIME_ZONE = TimeZone.getTimeZone( "UTC" );
 
-    private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat( "yyyyMMddHHmmss'Z'"
);
+    /** Defines a default date format with a "yyyyMMddHHmmss'Z'" pattern */
+    public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat( "yyyyMMddHHmmss'Z'"
);
 
     static
     {

Modified: directory/studio/trunk/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/LdifModificationLogger.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/LdifModificationLogger.java?rev=1124978&r1=1124977&r2=1124978&view=diff
==============================================================================
--- directory/studio/trunk/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/LdifModificationLogger.java
(original)
+++ directory/studio/trunk/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/LdifModificationLogger.java
Thu May 19 15:57:48 2011
@@ -51,6 +51,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.model.message.Referral;
 import org.apache.directory.shared.ldap.model.name.Dn;
 import org.apache.directory.shared.ldap.model.name.Rdn;
+import org.apache.directory.shared.util.DateUtils;
 import org.apache.directory.studio.connection.core.Connection;
 import org.apache.directory.studio.connection.core.Connection.AliasDereferencingMethod;
 import org.apache.directory.studio.connection.core.ConnectionCoreConstants;
@@ -227,6 +228,7 @@ public class LdifModificationLogger impl
         {
             Logger logger = loggers.get( id );
             DateFormat df = new SimpleDateFormat( ConnectionCoreConstants.DATEFORMAT );
+            df.setTimeZone( DateUtils.UTC_TIME_ZONE );
 
             if ( ex != null )
             {

Modified: directory/studio/trunk/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/LdifSearchLogger.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/LdifSearchLogger.java?rev=1124978&r1=1124977&r2=1124978&view=diff
==============================================================================
--- directory/studio/trunk/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/LdifSearchLogger.java
(original)
+++ directory/studio/trunk/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/LdifSearchLogger.java
Thu May 19 15:57:48 2011
@@ -49,6 +49,7 @@ import javax.naming.ldap.Control;
 import org.apache.commons.lang.StringUtils;
 import org.apache.directory.shared.ldap.model.message.Referral;
 import org.apache.directory.shared.ldap.model.url.LdapUrl;
+import org.apache.directory.shared.util.DateUtils;
 import org.apache.directory.studio.connection.core.Connection;
 import org.apache.directory.studio.connection.core.Connection.AliasDereferencingMethod;
 import org.apache.directory.studio.connection.core.ConnectionCoreConstants;
@@ -217,6 +218,7 @@ public class LdifSearchLogger implements
         {
             Logger logger = loggers.get( id );
             DateFormat df = new SimpleDateFormat( ConnectionCoreConstants.DATEFORMAT );
+            df.setTimeZone( DateUtils.UTC_TIME_ZONE );
 
             if ( ex != null )
             {



Mime
View raw message