You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2012/01/24 11:49:30 UTC

svn commit: r1235200 - in /directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory: server/kerberos/shared/replay/ReplayCacheImpl.java shared/kerberos/KerberosTime.java

Author: elecharny
Date: Tue Jan 24 10:49:29 2012
New Revision: 1235200

URL: http://svn.apache.org/viewvc?rev=1235200&view=rev
Log:
o Made the KerberosTime serializable (fix for DIRKRB-81)
o Added some javadoc

Modified:
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/server/kerberos/shared/replay/ReplayCacheImpl.java
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/KerberosTime.java

Modified: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/server/kerberos/shared/replay/ReplayCacheImpl.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/server/kerberos/shared/replay/ReplayCacheImpl.java?rev=1235200&r1=1235199&r2=1235200&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/server/kerberos/shared/replay/ReplayCacheImpl.java (original)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/server/kerberos/shared/replay/ReplayCacheImpl.java Tue Jan 24 10:49:29 2012
@@ -6,16 +6,16 @@
  *  to you under the Apache License, Version 2.0 (the
  *  "License"); you may not use this file except in compliance
  *  with the License.  You may obtain a copy of the License at
- *  
+ * 
  *    http://www.apache.org/licenses/LICENSE-2.0
- *  
+ * 
  *  Unless required by applicable law or agreed to in writing,
  *  software distributed under the License is distributed on an
  *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  *  KIND, either express or implied.  See the License for the
  *  specific language governing permissions and limitations
- *  under the License. 
- *  
+ *  under the License.
+ * 
  */
 package org.apache.directory.server.kerberos.shared.replay;
 
@@ -63,19 +63,26 @@ public class ReplayCacheImpl implements 
     {
         private static final long serialVersionUID = 1L;
 
+        /** The server principal */
         private KerberosPrincipal serverPrincipal;
+        
+        /** The client principal */
         private KerberosPrincipal clientPrincipal;
+        
+        /** The client time */
         private KerberosTime clientTime;
+        
+        /** The client micro seconds */
         private int clientMicroSeconds;
 
 
         /**
          * Creates a new instance of ReplayCacheEntry.
          * 
-         * @param serverPrincipal 
-         * @param clientPrincipal 
-         * @param clientTime 
-         * @param clientMicroSeconds 
+         * @param serverPrincipal
+         * @param clientPrincipal
+         * @param clientTime
+         * @param clientMicroSeconds
          */
         public ReplayCacheEntry( KerberosPrincipal serverPrincipal, KerberosPrincipal clientPrincipal,
             KerberosTime clientTime, int clientMicroSeconds )

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=1235200&r1=1235199&r2=1235200&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 Tue Jan 24 10:49:29 2012
@@ -6,19 +6,23 @@
  *  to you under the Apache License, Version 2.0 (the
  *  "License"); you may not use this file except in compliance
  *  with the License.  You may obtain a copy of the License at
- *  
+ * 
  *    http://www.apache.org/licenses/LICENSE-2.0
- *  
+ * 
  *  Unless required by applicable law or agreed to in writing,
  *  software distributed under the License is distributed on an
  *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  *  KIND, either express or implied.  See the License for the
  *  specific language governing permissions and limitations
- *  under the License. 
- *  
+ *  under the License.
+ * 
  */
 package org.apache.directory.shared.kerberos;
 
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
 import java.text.ParseException;
 import java.util.Calendar;
 import java.util.Date;
@@ -28,14 +32,16 @@ import org.apache.directory.shared.util.
 import org.apache.directory.shared.util.Strings;
 
 /**
- * An specialization of the ASN.1 GeneralTime. The Kerberos time contains date and 
+ * An specialization of the ASN.1 GeneralTime. The Kerberos time contains date and
  * time up to the seconds, but with no fractional seconds. It's also always
  * expressed as UTC timeZone, thus the 'Z' at the end of its string representation.
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class KerberosTime implements Comparable<KerberosTime>
+public class KerberosTime implements Comparable<KerberosTime>, Serializable
 {
+    private static final long serialVersionUID = 1L;
+
     /** The UTC timeZone */
     private static final TimeZone UTC = TimeZone.getTimeZone( "UTC" );
     
@@ -248,7 +254,7 @@ public class KerberosTime implements Com
      * @param that the kerberos time against which the current kerberos time is compared
      * @return 0 if both times are equal,<br>
      *         -1 if current time is less than the given time and<br>
-     *         1 if the given time is greater than the current time 
+     *         1 if the given time is greater than the current time
      */
     public int compareTo( KerberosTime that )
     {
@@ -311,6 +317,34 @@ public class KerberosTime implements Com
     
     
     /**
+     * Write a serialized version of this instance.
+     */
+    private void writeObject( ObjectOutputStream out ) throws IOException
+    {
+        out.writeUTF( date );
+    }
+    
+    
+    /**
+     * Read a KerberosTime from a stream
+     */
+    private void readObject( ObjectInputStream in ) throws IOException, ClassNotFoundException
+    {
+        String date = in.readUTF();
+        
+        try
+        {
+            setDate( date );
+        }
+        catch ( ParseException pe )
+        {
+            kerberosTime = (System.currentTimeMillis()/1000L)*1000L; // drop the ms
+            convertInternal( kerberosTime );
+        }
+    }
+    
+    
+    /**
      * {@inheritDoc}
      */
     public String toString()