directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From erodrig...@apache.org
Subject svn commit: r240277 - in /directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos: messages/value/KerberosTime.java service/MonitorRequest.java
Date Fri, 26 Aug 2005 16:27:49 GMT
Author: erodriguez
Date: Fri Aug 26 09:27:46 2005
New Revision: 240277

URL: http://svn.apache.org/viewcvs?rev=240277&view=rev
Log:
o  Added toString methods

Modified:
    directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/messages/value/KerberosTime.java
    directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/service/MonitorRequest.java

Modified: directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/messages/value/KerberosTime.java
URL: http://svn.apache.org/viewcvs/directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/messages/value/KerberosTime.java?rev=240277&r1=240276&r2=240277&view=diff
==============================================================================
--- directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/messages/value/KerberosTime.java
(original)
+++ directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/messages/value/KerberosTime.java
Fri Aug 26 09:27:46 2005
@@ -16,7 +16,9 @@
  */
 package org.apache.kerberos.messages.value;
 
+import java.text.SimpleDateFormat;
 import java.util.Date;
+import java.util.TimeZone;
 
 /**
  * Implementation of the time object for Kerberos
@@ -25,21 +27,29 @@
 {
     public static final KerberosTime INFINITY = new KerberosTime( Long.MAX_VALUE );
 
-    private long localTime;
+    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 );
+    }
+
+    private long kerberosTime;
 
     public KerberosTime()
     {
-        localTime = System.currentTimeMillis();
+        kerberosTime = System.currentTimeMillis();
     }
 
     public KerberosTime( long time )
     {
-        localTime = time;
+        kerberosTime = time;
     }
 
     public KerberosTime( Date time )
     {
-        localTime = time.getTime();
+        kerberosTime = time.getTime();
     }
 
     public int compareTo( Object o )
@@ -60,12 +70,12 @@
         final KerberosTime that = (KerberosTime) o;
 
         // primitive numbers follow this form
-        if ( this.localTime < that.localTime )
+        if ( this.kerberosTime < that.kerberosTime )
         {
             return BEFORE;
         }
 
-        if ( this.localTime > that.localTime )
+        if ( this.kerberosTime > that.kerberosTime )
         {
             return AFTER;
         }
@@ -75,36 +85,41 @@
 
     public long getTime()
     {
-        return localTime;
+        return kerberosTime;
     }
 
     public Date toDate()
     {
-        return new Date( localTime );
+        return new Date( kerberosTime );
     }
 
     public boolean isInClockSkew( long clockSkew )
     {
-        return Math.abs( localTime - System.currentTimeMillis() ) < clockSkew;
+        return Math.abs( kerberosTime - System.currentTimeMillis() ) < clockSkew;
     }
 
     public boolean greaterThan( KerberosTime time )
     {
-        return localTime > time.localTime;
+        return kerberosTime > time.kerberosTime;
     }
 
     public boolean lessThan( KerberosTime time )
     {
-        return localTime < time.localTime;
+        return kerberosTime < time.kerberosTime;
     }
 
     public boolean equals( KerberosTime time )
     {
-        return localTime == time.localTime;
+        return kerberosTime == time.kerberosTime;
     }
 
     public boolean isZero()
     {
-        return localTime == 0;
+        return kerberosTime == 0;
+    }
+
+    public String toString()
+    {
+        return dateFormat.format( new Date( kerberosTime ) );
     }
 }

Modified: directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/service/MonitorRequest.java
URL: http://svn.apache.org/viewcvs/directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/service/MonitorRequest.java?rev=240277&r1=240276&r2=240277&view=diff
==============================================================================
--- directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/service/MonitorRequest.java
(original)
+++ directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/service/MonitorRequest.java
Fri Aug 26 09:27:46 2005
@@ -20,6 +20,7 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.kerberos.chain.Context;
 import org.apache.kerberos.chain.impl.CommandBase;
+import org.apache.kerberos.crypto.encryption.EncryptionType;
 import org.apache.kerberos.messages.KdcRequest;
 
 public class MonitorRequest extends CommandBase
@@ -31,7 +32,7 @@
     {
         KdcContext kdcContext = (KdcContext) context;
         KdcRequest request = kdcContext.getRequest();
-        
+
         if ( log.isDebugEnabled() )
         {
             log.debug( "Responding to authentication request:"
@@ -39,7 +40,7 @@
                     + "\n\tserverPrincipal:       " + request.getServerPrincipal()
                     + "\n\tclientPrincipal:       " + request.getClientPrincipal()
                     + "\n\thostAddresses:         " + request.getAddresses()
-                    + "\n\tencryptionType:        " + request.getEType()
+                    + "\n\tencryptionType:        " + getEncryptionTypes( request )
                     + "\n\tfrom krb time:         " + request.getFrom()
                     + "\n\trealm krb time:        " + request.getRtime()
                     + "\n\tkdcOptions:            " + request.getKdcOptions()
@@ -49,7 +50,26 @@
                     + "\n\ttill:                  " + request.getTill()
                      );
         }
-        
+
         return CONTINUE_CHAIN;
+    }
+
+    public String getEncryptionTypes( KdcRequest request )
+    {
+        EncryptionType[] etypes = request.getEType();
+
+        StringBuffer sb = new StringBuffer();
+
+        for ( int ii = 0; ii < etypes.length; ii++ )
+        {
+            sb.append( etypes[ ii ].toString() );
+
+            if ( ii < etypes.length - 1 )
+            {
+                sb.append( ", " );
+            }
+        }
+
+        return sb.toString();
     }
 }



Mime
View raw message