directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From erodrig...@apache.org
Subject svn commit: r126636 - in incubator/directory: asn1/trunk/der/src/java/org/apache/asn1/der changepw/trunk/core/src/java/org/apache/changepw/io kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder
Date Thu, 27 Jan 2005 18:47:51 GMT
Author: erodriguez
Date: Thu Jan 27 10:47:49 2005
New Revision: 126636

URL: http://svn.apache.org/viewcvs?view=rev&rev=126636
Log:
Better input stream encapsulation.
Modified:
   incubator/directory/asn1/trunk/der/src/java/org/apache/asn1/der/ASN1InputStream.java
   incubator/directory/asn1/trunk/der/src/java/org/apache/asn1/der/DERApplicationSpecific.java
   incubator/directory/changepw/trunk/core/src/java/org/apache/changepw/io/ChangePasswordDataDecoder.java
   incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/ApplicationRequestDecoder.java
   incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/AuthenticatorDecoder.java
   incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/AuthorizationDataDecoder.java
   incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/EncKrbPrivPartDecoder.java
   incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/EncTicketPartDecoder.java
   incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/KdcRequestDecoder.java
   incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/KerberosMessageDecoder.java
   incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/PrivateMessageDecoder.java

Modified: incubator/directory/asn1/trunk/der/src/java/org/apache/asn1/der/ASN1InputStream.java
Url: http://svn.apache.org/viewcvs/incubator/directory/asn1/trunk/der/src/java/org/apache/asn1/der/ASN1InputStream.java?view=diff&rev=126636&p1=incubator/directory/asn1/trunk/der/src/java/org/apache/asn1/der/ASN1InputStream.java&r1=126635&p2=incubator/directory/asn1/trunk/der/src/java/org/apache/asn1/der/ASN1InputStream.java&r2=126636
==============================================================================
--- incubator/directory/asn1/trunk/der/src/java/org/apache/asn1/der/ASN1InputStream.java	(original)
+++ incubator/directory/asn1/trunk/der/src/java/org/apache/asn1/der/ASN1InputStream.java	Thu
Jan 27 10:47:49 2005
@@ -23,6 +23,7 @@
 import java.io.FilterInputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.nio.ByteBuffer;
 import java.util.Vector;
 
 /**
@@ -48,9 +49,9 @@
                                         }
                                     };
 
-    public ASN1InputStream( InputStream is )
+    public ASN1InputStream( ByteBuffer in )
     {
-        super( is );
+        super( newInputStream( in ) );
     }
 
     public ASN1InputStream( byte[] input )
@@ -58,6 +59,32 @@
         super( new ByteArrayInputStream( input ) );
     }
     
+    private static InputStream newInputStream( final ByteBuffer buf )
+    {
+        return new InputStream()
+		{
+            public synchronized int read() throws IOException
+			{
+                if ( !buf.hasRemaining() )
+                {
+                    return -1;
+                }
+                
+                int result = buf.get() & 0x000000FF;
+                
+                return result;
+            }
+    
+            public synchronized int read( byte[] bytes, int off, int len ) throws IOException
+			{
+                // Read only what's left
+                len = Math.min( len, buf.remaining() );
+                buf.get( bytes, off, len );
+                return len;
+            }
+        };
+    }
+    
     protected int readLength()
         throws IOException
     {
@@ -145,8 +172,7 @@
         case DERObject.NULL:
             return new DERNull();   
         case DERObject.SEQUENCE | DERObject.CONSTRUCTED:
-            ByteArrayInputStream bais = new ByteArrayInputStream( bytes );
-            ASN1InputStream      ais  = new ASN1InputStream( bytes );
+            ASN1InputStream ais = new ASN1InputStream( bytes );
             
             DERSequence sequence = new DERSequence();
 
@@ -160,8 +186,7 @@
 
             return sequence;
         case DERObject.SET | DERObject.CONSTRUCTED:
-            bais = new ByteArrayInputStream( bytes );
-            ais = new ASN1InputStream( bais );
+            ais = new ASN1InputStream( bytes );
             DERSet set = new DERSet();
 
             obj = ais.readObject();
@@ -250,8 +275,7 @@
                     return new DERTaggedObject( false, tagNo, new DEROctetString( bytes )
);
                 }
 
-                bais = new ByteArrayInputStream( bytes );
-                ais = new ASN1InputStream( bais );
+                ais = new ASN1InputStream( bytes );
 
                 DEREncodable encodable = ais.readObject();
 

Modified: incubator/directory/asn1/trunk/der/src/java/org/apache/asn1/der/DERApplicationSpecific.java
Url: http://svn.apache.org/viewcvs/incubator/directory/asn1/trunk/der/src/java/org/apache/asn1/der/DERApplicationSpecific.java?view=diff&rev=126636&p1=incubator/directory/asn1/trunk/der/src/java/org/apache/asn1/der/DERApplicationSpecific.java&r1=126635&p2=incubator/directory/asn1/trunk/der/src/java/org/apache/asn1/der/DERApplicationSpecific.java&r2=126636
==============================================================================
--- incubator/directory/asn1/trunk/der/src/java/org/apache/asn1/der/DERApplicationSpecific.java
(original)
+++ incubator/directory/asn1/trunk/der/src/java/org/apache/asn1/der/DERApplicationSpecific.java
Thu Jan 27 10:47:49 2005
@@ -17,7 +17,6 @@
 
 package org.apache.asn1.der;
 
-import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 
@@ -61,7 +60,7 @@
     public DEREncodable getObject() 
         throws IOException 
     {
-        return new ASN1InputStream( new ByteArrayInputStream( getOctets() ) ).readObject();
+        return new ASN1InputStream( getOctets() ).readObject();
     }
     
     public void encode( ASN1OutputStream out ) throws IOException

Modified: incubator/directory/changepw/trunk/core/src/java/org/apache/changepw/io/ChangePasswordDataDecoder.java
Url: http://svn.apache.org/viewcvs/incubator/directory/changepw/trunk/core/src/java/org/apache/changepw/io/ChangePasswordDataDecoder.java?view=diff&rev=126636&p1=incubator/directory/changepw/trunk/core/src/java/org/apache/changepw/io/ChangePasswordDataDecoder.java&r1=126635&p2=incubator/directory/changepw/trunk/core/src/java/org/apache/changepw/io/ChangePasswordDataDecoder.java&r2=126636
==============================================================================
--- incubator/directory/changepw/trunk/core/src/java/org/apache/changepw/io/ChangePasswordDataDecoder.java
(original)
+++ incubator/directory/changepw/trunk/core/src/java/org/apache/changepw/io/ChangePasswordDataDecoder.java
Thu Jan 27 10:47:49 2005
@@ -17,7 +17,6 @@
 
 package org.apache.changepw.io;
 
-import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.util.Enumeration;
 
@@ -37,8 +36,7 @@
 	public ChangePasswordData decodeChangePasswordData( byte[] encodedChangePasswdData )
 		throws IOException
 	{
-		ByteArrayInputStream bais = new ByteArrayInputStream( encodedChangePasswdData );
-		ASN1InputStream ais = new ASN1InputStream( bais );
+		ASN1InputStream ais = new ASN1InputStream( encodedChangePasswdData );
 		
 		DERSequence sequence = (DERSequence) ais.readObject();
 		

Modified: incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/ApplicationRequestDecoder.java
Url: http://svn.apache.org/viewcvs/incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/ApplicationRequestDecoder.java?view=diff&rev=126636&p1=incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/ApplicationRequestDecoder.java&r1=126635&p2=incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/ApplicationRequestDecoder.java&r2=126636
==============================================================================
--- incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/ApplicationRequestDecoder.java
(original)
+++ incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/ApplicationRequestDecoder.java
Thu Jan 27 10:47:49 2005
@@ -17,7 +17,6 @@
 
 package org.apache.kerberos.io.decoder;
 
-import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.util.Enumeration;
 
@@ -33,17 +32,17 @@
 import org.apache.kerberos.messages.value.ApOptions;
 
 
-public class ApplicationRequestDecoder extends KerberosMessageDecoder {
-	
-	public ApplicationRequest decode(byte[] encodedAuthHeader) throws IOException {
-		
-		ByteArrayInputStream bais = new ByteArrayInputStream(encodedAuthHeader);
-		ASN1InputStream ais = new ASN1InputStream(bais);
+public class ApplicationRequestDecoder extends KerberosMessageDecoder
+{
+	public ApplicationRequest decode( byte[] encodedAuthHeader ) throws IOException
+	{
+		ASN1InputStream ais = new ASN1InputStream( encodedAuthHeader );
 
 		DERApplicationSpecific app = (DERApplicationSpecific) ais.readObject();
 		
 		DERSequence apreq = (DERSequence) app.getObject();
-		return decodeApplicationRequestSequence(apreq);
+		
+		return decodeApplicationRequestSequence( apreq );
 	}
 	
 	/*
@@ -56,18 +55,20 @@
         authenticator[4]              EncryptedData
         }
     */
-	private ApplicationRequest decodeApplicationRequestSequence(DERSequence sequence) throws
IOException {
-		
+	private ApplicationRequest decodeApplicationRequestSequence( DERSequence sequence ) throws
IOException
+	{
 		ApplicationRequest authHeader = new ApplicationRequest();
 		
-		for (Enumeration e = sequence.getObjects(); e.hasMoreElements();) {
+		for ( Enumeration e = sequence.getObjects(); e.hasMoreElements(); )
+		{
 			DERTaggedObject object = ((DERTaggedObject) e.nextElement());
 			int tag = object.getTagNo();
 			DEREncodable derObject = object.getObject();
-			switch (tag) {
+			
+			switch ( tag ) {
 				case 0:
 					DERInteger tag0 = (DERInteger) derObject;
-					authHeader.setProtocolVersionNumber(tag0.intValue());
+					authHeader.setProtocolVersionNumber( tag0.intValue() );
 					break;
 				case 1:
 					DERInteger tag1 = (DERInteger) derObject;
@@ -79,14 +80,14 @@
 					break;
 				case 3:
 					DERApplicationSpecific tag3 = (DERApplicationSpecific)derObject;
-					authHeader.setTicket(decodeTicket(tag3));
+					authHeader.setTicket( decodeTicket( tag3 ) );
 					break;
 				case 4:
 					DERSequence tag4 = (DERSequence)derObject;
-					authHeader.setEncPart(decodeEncryptedData(tag4));
+					authHeader.setEncPart( decodeEncryptedData( tag4 ) );
 					break;
 			    default:
-			    	System.out.println(derObject);
+			    	System.out.println( derObject );
 			    	break;
 			}
 		}

Modified: incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/AuthenticatorDecoder.java
Url: http://svn.apache.org/viewcvs/incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/AuthenticatorDecoder.java?view=diff&rev=126636&p1=incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/AuthenticatorDecoder.java&r1=126635&p2=incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/AuthenticatorDecoder.java&r2=126636
==============================================================================
--- incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/AuthenticatorDecoder.java
(original)
+++ incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/AuthenticatorDecoder.java
Thu Jan 27 10:47:49 2005
@@ -17,7 +17,6 @@
 
 package org.apache.kerberos.io.decoder;
 
-import java.io.ByteArrayInputStream;
 import java.io.IOException;
 
 import org.apache.asn1.der.ASN1InputStream;
@@ -25,18 +24,18 @@
 import org.apache.asn1.der.DERSequence;
 import org.apache.kerberos.messages.components.Authenticator;
 
-public class AuthenticatorDecoder extends KerberosMessageDecoder {
-	
-	public Authenticator decode(byte[] encodedAuthenticator) throws IOException {
-		
-		ByteArrayInputStream bais = new ByteArrayInputStream(encodedAuthenticator);
-		ASN1InputStream ais = new ASN1InputStream(bais);
+
+public class AuthenticatorDecoder extends KerberosMessageDecoder
+{
+	public Authenticator decode( byte[] encodedAuthenticator ) throws IOException
+	{
+		ASN1InputStream ais = new ASN1InputStream( encodedAuthenticator );
 		
 		DERApplicationSpecific app = (DERApplicationSpecific) ais.readObject();
 		
 		DERSequence sequence = (DERSequence) app.getObject();
 		
-		return decodeAuthenticator(sequence);
+		return decodeAuthenticator( sequence );
 	}
 }
 

Modified: incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/AuthorizationDataDecoder.java
Url: http://svn.apache.org/viewcvs/incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/AuthorizationDataDecoder.java?view=diff&rev=126636&p1=incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/AuthorizationDataDecoder.java&r1=126635&p2=incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/AuthorizationDataDecoder.java&r2=126636
==============================================================================
--- incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/AuthorizationDataDecoder.java
(original)
+++ incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/AuthorizationDataDecoder.java
Thu Jan 27 10:47:49 2005
@@ -17,23 +17,22 @@
 
 package org.apache.kerberos.io.decoder;
 
-import java.io.ByteArrayInputStream;
 import java.io.IOException;
 
 import org.apache.asn1.der.ASN1InputStream;
 import org.apache.asn1.der.DERSequence;
 import org.apache.kerberos.messages.value.AuthorizationData;
 
-public class AuthorizationDataDecoder extends KerberosMessageDecoder {
-	
-	public AuthorizationData decode(byte[] encodedAuthData) throws IOException {
-		
-		ByteArrayInputStream bais = new ByteArrayInputStream(encodedAuthData);
-		ASN1InputStream ais = new ASN1InputStream(bais);
+
+public class AuthorizationDataDecoder extends KerberosMessageDecoder
+{
+	public AuthorizationData decode( byte[] encodedAuthData ) throws IOException
+	{
+		ASN1InputStream ais = new ASN1InputStream( encodedAuthData );
 
 		DERSequence sequence = (DERSequence) ais.readObject();
 		
-		return decodeAuthorizationData(sequence);
+		return decodeAuthorizationData( sequence );
 	}
 }
 

Modified: incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/EncKrbPrivPartDecoder.java
Url: http://svn.apache.org/viewcvs/incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/EncKrbPrivPartDecoder.java?view=diff&rev=126636&p1=incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/EncKrbPrivPartDecoder.java&r1=126635&p2=incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/EncKrbPrivPartDecoder.java&r2=126636
==============================================================================
--- incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/EncKrbPrivPartDecoder.java
(original)
+++ incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/EncKrbPrivPartDecoder.java
Thu Jan 27 10:47:49 2005
@@ -17,7 +17,6 @@
 
 package org.apache.kerberos.io.decoder;
 
-import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.util.Enumeration;
 
@@ -32,55 +31,57 @@
 import org.apache.kerberos.messages.components.EncKrbPrivPart;
 import org.apache.kerberos.messages.components.EncKrbPrivPartModifier;
 
-public class EncKrbPrivPartDecoder extends KerberosMessageDecoder {
-	
-	public EncKrbPrivPart decode(byte[] encodedPrivatePart) throws IOException {
-		
-		ByteArrayInputStream bais = new ByteArrayInputStream(encodedPrivatePart);
-		ASN1InputStream ais = new ASN1InputStream(bais);
+
+public class EncKrbPrivPartDecoder extends KerberosMessageDecoder
+{
+	public EncKrbPrivPart decode( byte[] encodedPrivatePart ) throws IOException
+	{
+		ASN1InputStream ais = new ASN1InputStream( encodedPrivatePart );
 
 		DERApplicationSpecific app = (DERApplicationSpecific) ais.readObject();
 		
 		DERSequence privatePart = (DERSequence) app.getObject();
 		
-		return decodePrivatePartSequence(privatePart);
+		return decodePrivatePartSequence( privatePart );
 	}
 	
-	private EncKrbPrivPart decodePrivatePartSequence(DERSequence sequence) {
-		
+	private EncKrbPrivPart decodePrivatePartSequence( DERSequence sequence )
+	{
 		EncKrbPrivPartModifier modifier = new EncKrbPrivPartModifier();
 		
-		for (Enumeration e = sequence.getObjects(); e.hasMoreElements();) {
-			DERTaggedObject object = ((DERTaggedObject) e.nextElement());
+		for ( Enumeration e = sequence.getObjects(); e.hasMoreElements(); )
+		{
+			DERTaggedObject object = (DERTaggedObject) e.nextElement();
 			int tag = object.getTagNo();
 			DEREncodable derObject = object.getObject();
-			switch (tag) {
+			
+			switch ( tag ) {
 				case 0:
 					DEROctetString tag0 = (DEROctetString) derObject;
-					modifier.setUserData(tag0.getOctets());
+					modifier.setUserData( tag0.getOctets() );
 					break;
 				case 1:
 					DERGeneralizedTime tag1 = (DERGeneralizedTime) derObject;
-					modifier.setTimestamp(decodeKerberosTime(tag1));
+					modifier.setTimestamp( decodeKerberosTime( tag1 ) );
 					break;
 				case 2:
 					DERInteger tag2 = (DERInteger)derObject;
-					modifier.setMicroSecond(new Integer(tag2.intValue()));
+					modifier.setMicroSecond( new Integer( tag2.intValue() ) );
 					break;
 				case 3:
 					DERInteger tag3 = (DERInteger)derObject;
-					modifier.setSequenceNumber(new Integer(tag3.intValue()));
+					modifier.setSequenceNumber( new Integer( tag3.intValue() ) );
 					break;
 				case 4:
 					DERSequence tag4 = (DERSequence)derObject;
-					modifier.setSenderAddress(decodeHostAddress(tag4));
+					modifier.setSenderAddress( decodeHostAddress( tag4 ) );
 					break;
 				case 5:
 					DERSequence tag5 = (DERSequence)derObject;
-					modifier.setRecipientAddress(decodeHostAddress(tag5));
+					modifier.setRecipientAddress( decodeHostAddress( tag5 ) );
 					break;
 			    default:
-			    	System.out.println(derObject);
+			    	System.out.println( derObject );
 			    	break;
 			}
 		}

Modified: incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/EncTicketPartDecoder.java
Url: http://svn.apache.org/viewcvs/incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/EncTicketPartDecoder.java?view=diff&rev=126636&p1=incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/EncTicketPartDecoder.java&r1=126635&p2=incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/EncTicketPartDecoder.java&r2=126636
==============================================================================
--- incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/EncTicketPartDecoder.java
(original)
+++ incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/EncTicketPartDecoder.java
Thu Jan 27 10:47:49 2005
@@ -17,7 +17,6 @@
 
 package org.apache.kerberos.io.decoder;
 
-import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.util.Enumeration;
 
@@ -33,19 +32,18 @@
 import org.apache.kerberos.messages.components.EncTicketPartModifier;
 import org.apache.kerberos.messages.value.TicketFlags;
 
-public class EncTicketPartDecoder extends KerberosMessageDecoder {
-	
-	public EncTicketPart decode(byte[] encodedTicket) throws IOException {
-		
-		ByteArrayInputStream bais = new ByteArrayInputStream(encodedTicket);
-		ASN1InputStream ais = new ASN1InputStream(bais);
+
+public class EncTicketPartDecoder extends KerberosMessageDecoder
+{
+	public EncTicketPart decode( byte[] encodedTicket ) throws IOException
+	{
+		ASN1InputStream ais = new ASN1InputStream( encodedTicket );
 		
 		DERApplicationSpecific app = (DERApplicationSpecific) ais.readObject();
 		
 		DERSequence sequence = (DERSequence) app.getObject();
 		
-		return decodeEncTicketPartSequence(sequence);
-		
+		return decodeEncTicketPartSequence( sequence );
 	}
 	
 	/*
@@ -63,61 +61,62 @@
 	                      caddr[9]             HostAddresses OPTIONAL,
 	                      authorization-data[10]   AuthorizationData OPTIONAL
 	}*/
-	private EncTicketPart decodeEncTicketPartSequence(DERSequence sequence) {
+	private EncTicketPart decodeEncTicketPartSequence( DERSequence sequence ) {
 		
 		EncTicketPartModifier modifier = new EncTicketPartModifier();
 		
-		for (Enumeration e = sequence.getObjects(); e.hasMoreElements();) {
-			DERTaggedObject object = ((DERTaggedObject) e.nextElement());
+		for ( Enumeration e = sequence.getObjects(); e.hasMoreElements(); ) {
+			DERTaggedObject object = (DERTaggedObject) e.nextElement();
 			int tag = object.getTagNo();
 			DEREncodable derObject = object.getObject();
-			switch (tag) {
+			
+			switch ( tag ) {
 				case 0:
 					DERBitString tag0 = (DERBitString)derObject;
-					modifier.setFlags(new TicketFlags(tag0.getOctets()));
+					modifier.setFlags( new TicketFlags( tag0.getOctets() ) );
 					break;
 				case 1:
 					DERSequence tag1 = (DERSequence) derObject;
-					modifier.setSessionKey(decodeEncryptionKey(tag1));
+					modifier.setSessionKey( decodeEncryptionKey( tag1 ) );
 					break;
 				case 2:
 					DERGeneralString tag2 = (DERGeneralString)derObject;
-					modifier.setClientRealm(tag2.getString());
+					modifier.setClientRealm( tag2.getString() );
 					break;
 				case 3:
 					DERSequence tag3 = (DERSequence)derObject;
-					modifier.setClientName(decodePrincipalName(tag3));
+					modifier.setClientName( decodePrincipalName( tag3 ) );
 					break;
 				case 4:
 					DERSequence tag4 = (DERSequence)derObject;
-					modifier.setTransitedEncoding(decodeTransitedEncoding(tag4));
+					modifier.setTransitedEncoding( decodeTransitedEncoding( tag4 ) );
 					break;
 				case 5:
 					DERGeneralizedTime tag5 = (DERGeneralizedTime)derObject;
-					modifier.setAuthTime(decodeKerberosTime(tag5));
+					modifier.setAuthTime( decodeKerberosTime( tag5 ) );
 					break;
 				case 6:
 					DERGeneralizedTime tag6 = (DERGeneralizedTime)derObject;
-					modifier.setStartTime(decodeKerberosTime(tag6));
+					modifier.setStartTime( decodeKerberosTime( tag6 ) );
 					break;
 				case 7:
 					DERGeneralizedTime tag7 = (DERGeneralizedTime)derObject;
-					modifier.setEndTime(decodeKerberosTime(tag7));
+					modifier.setEndTime( decodeKerberosTime( tag7 ) );
 					break;
 				case 8:
 					DERGeneralizedTime tag8 = (DERGeneralizedTime)derObject;
-					modifier.setRenewTill(decodeKerberosTime(tag8));
+					modifier.setRenewTill( decodeKerberosTime( tag8 ) );
 					break;
 				case 9:
 					DERSequence tag9 = (DERSequence)derObject;
-					modifier.setClientAddresses(decodeHostAddresses(tag9));
+					modifier.setClientAddresses( decodeHostAddresses( tag9 ) );
 					break;
 				case 10:
 					DERSequence tag10 = (DERSequence)derObject;
-					modifier.setAuthorizationData(decodeAuthorizationData(tag10));
+					modifier.setAuthorizationData( decodeAuthorizationData( tag10 ) );
 					break;
 			    default:
-			    	System.out.println(derObject);
+			    	System.out.println( derObject );
 			    	break;
 			}
 		}

Modified: incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/KdcRequestDecoder.java
Url: http://svn.apache.org/viewcvs/incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/KdcRequestDecoder.java?view=diff&rev=126636&p1=incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/KdcRequestDecoder.java&r1=126635&p2=incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/KdcRequestDecoder.java&r2=126636
==============================================================================
--- incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/KdcRequestDecoder.java
(original)
+++ incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/KdcRequestDecoder.java
Thu Jan 27 10:47:49 2005
@@ -46,7 +46,7 @@
 {
 	public KdcRequest decode( ByteBuffer in ) throws IOException
 	{
-		ASN1InputStream ais = new ASN1InputStream( newInputStream( in ) );
+		ASN1InputStream ais = new ASN1InputStream( in );
 		
 		DERApplicationSpecific app = (DERApplicationSpecific) ais.readObject();
 		
@@ -77,6 +77,7 @@
 			DERTaggedObject object = ((DERTaggedObject) e.nextElement());
 			int tag = object.getTagNo();
 			DEREncodable derObject = object.getObject();
+			
 			switch (tag) {
 				case 1:
 					DERInteger tag1 = (DERInteger)derObject;
@@ -131,6 +132,7 @@
 			DERTaggedObject object = ((DERTaggedObject) e.nextElement());
 			int tag = object.getTagNo();
 			DEREncodable derObject = object.getObject();
+			
 			switch (tag) {
 				case 1:
 					DERInteger padataType = (DERInteger) derObject;
@@ -176,6 +178,7 @@
 			DERTaggedObject object = ((DERTaggedObject) e.nextElement());
 			int tag = object.getTagNo();
 			DEREncodable derObject = object.getObject();
+			
 			switch (tag) {
 				case 0:
 					DERBitString kdcOptions = (DERBitString)derObject;

Modified: incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/KerberosMessageDecoder.java
Url: http://svn.apache.org/viewcvs/incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/KerberosMessageDecoder.java?view=diff&rev=126636&p1=incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/KerberosMessageDecoder.java&r1=126635&p2=incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/KerberosMessageDecoder.java&r2=126636
==============================================================================
--- incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/KerberosMessageDecoder.java
(original)
+++ incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/KerberosMessageDecoder.java
Thu Jan 27 10:47:49 2005
@@ -18,8 +18,6 @@
 package org.apache.kerberos.io.decoder;
 
 import java.io.IOException;
-import java.io.InputStream;
-import java.nio.ByteBuffer;
 import java.text.ParseException;
 import java.util.Date;
 import java.util.Enumeration;
@@ -60,32 +58,6 @@
 
 public abstract class KerberosMessageDecoder
 {
-    public InputStream newInputStream( final ByteBuffer buf )
-    {
-        return new InputStream()
-		{
-            public synchronized int read() throws IOException
-			{
-                if ( !buf.hasRemaining() )
-                {
-                    return -1;
-                }
-                
-                int result = buf.get() & 0x000000FF;
-                
-                return result;
-            }
-    
-            public synchronized int read( byte[] bytes, int off, int len ) throws IOException
-			{
-                // Read only what's left
-                len = Math.min( len, buf.remaining() );
-                buf.get( bytes, off, len );
-                return len;
-            }
-        };
-    }
-	
 	/*
 	Ticket ::=                    [APPLICATION 1] SEQUENCE {
         tkt-vno[0]                   INTEGER,
@@ -103,6 +75,7 @@
 			DERTaggedObject object = ((DERTaggedObject) e.nextElement());
 			int tag = object.getTagNo();
 			DEREncodable derObject = object.getObject();
+			
 			switch (tag) {
 				case 0:
 					DERInteger tag0 = (DERInteger)derObject;
@@ -142,6 +115,7 @@
 			DERTaggedObject object = ((DERTaggedObject) e.nextElement());
 			int tag = object.getTagNo();
 			DEREncodable derObject = object.getObject();
+			
 			switch (tag) {
 				case 0:
 					DERInteger etype = (DERInteger)derObject;
@@ -176,6 +150,7 @@
 			DERTaggedObject object = ((DERTaggedObject) e.nextElement());
 			int tag = object.getTagNo();
 			DEREncodable derObject = object.getObject();
+			
 			switch (tag) {
 				case 0:
 					DERInteger nameType = (DERInteger)derObject;
@@ -245,6 +220,7 @@
 			DERTaggedObject object = ((DERTaggedObject) e.nextElement());
 			int tag = object.getTagNo();
 			DEREncodable derObject = object.getObject();
+			
 			switch (tag) {
 				case 0:
 					DERInteger addressType = (DERInteger)derObject;
@@ -294,6 +270,7 @@
 			DERTaggedObject object = ((DERTaggedObject) e.nextElement());
 			int tag = object.getTagNo();
 			DEREncodable derObject = object.getObject();
+			
 			switch (tag) {
 				case 0:
 					DERInteger tag0 = (DERInteger)derObject;
@@ -324,6 +301,7 @@
 			DERTaggedObject object = ((DERTaggedObject) e.nextElement());
 			int tag = object.getTagNo();
 			DEREncodable derObject = object.getObject();
+			
 			switch (tag) {
 				case 0:
 					DERInteger tag0 = (DERInteger)derObject;
@@ -370,6 +348,7 @@
 			DERTaggedObject object = ((DERTaggedObject) e.nextElement());
 			int tag = object.getTagNo();
 			DEREncodable derObject = object.getObject();
+			
 			switch (tag) {
 				case 0:
 					DERInteger tag0 = (DERInteger)derObject;
@@ -399,6 +378,7 @@
 			DERTaggedObject object = ((DERTaggedObject) e.nextElement());
 			int tag = object.getTagNo();
 			DEREncodable derObject = object.getObject();
+			
 			switch (tag) {
 				case 0:
 					DERInteger tag0 = (DERInteger) derObject;
@@ -443,6 +423,7 @@
 			DERTaggedObject object = ((DERTaggedObject) e.nextElement());
 			int tag = object.getTagNo();
 			DEREncodable derObject = object.getObject();
+			
 			switch (tag) {
 				case 0:
 					DERInteger tag0 = (DERInteger)derObject;
@@ -483,6 +464,7 @@
 			DERTaggedObject object = ((DERTaggedObject) e.nextElement());
 			int tag = object.getTagNo();
 			DEREncodable derObject = object.getObject();
+			
 			switch (tag) {
 				case 0:
 					DERInteger tag0 = (DERInteger)derObject;

Modified: incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/PrivateMessageDecoder.java
Url: http://svn.apache.org/viewcvs/incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/PrivateMessageDecoder.java?view=diff&rev=126636&p1=incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/PrivateMessageDecoder.java&r1=126635&p2=incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/PrivateMessageDecoder.java&r2=126636
==============================================================================
--- incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/PrivateMessageDecoder.java
(original)
+++ incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io/decoder/PrivateMessageDecoder.java
Thu Jan 27 10:47:49 2005
@@ -17,7 +17,6 @@
 
 package org.apache.kerberos.io.decoder;
 
-import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.util.Enumeration;
 
@@ -30,45 +29,49 @@
 import org.apache.kerberos.messages.MessageType;
 import org.apache.kerberos.messages.application.PrivateMessage;
 
-public class PrivateMessageDecoder extends KerberosMessageDecoder {
-	
-	public PrivateMessage decode(byte[] encodedPrivateMessage) throws IOException {
-		
-		ByteArrayInputStream bais = new ByteArrayInputStream(encodedPrivateMessage);
-		ASN1InputStream ais = new ASN1InputStream(bais);
+
+public class PrivateMessageDecoder extends KerberosMessageDecoder
+{
+	public PrivateMessage decode( byte[] encodedPrivateMessage ) throws IOException
+	{
+		ASN1InputStream ais = new ASN1InputStream( encodedPrivateMessage );
 
 		DERApplicationSpecific app = (DERApplicationSpecific) ais.readObject();
 		
 		DERSequence privateMessage = (DERSequence) app.getObject();
-		return decodePrivateMessageSequence(privateMessage);
+		
+		return decodePrivateMessageSequence( privateMessage );
 	}
 	
-	private PrivateMessage decodePrivateMessageSequence(DERSequence sequence) {
-		
+	private PrivateMessage decodePrivateMessageSequence(DERSequence sequence)
+	{
 		PrivateMessage message = new PrivateMessage();
 		
-		for (Enumeration e = sequence.getObjects(); e.hasMoreElements();) {
-			DERTaggedObject object = ((DERTaggedObject) e.nextElement());
+		for ( Enumeration e = sequence.getObjects(); e.hasMoreElements(); )
+		{
+			DERTaggedObject object = (DERTaggedObject) e.nextElement();
 			int tag = object.getTagNo();
 			DEREncodable derObject = object.getObject();
-			switch (tag) {
+			
+			switch ( tag ) {
 				case 0:
 					DERInteger tag0 = (DERInteger) derObject;
-					message.setProtocolVersionNumber(tag0.intValue());
+					message.setProtocolVersionNumber( tag0.intValue() );
 					break;
 				case 1:
 					DERInteger tag1 = (DERInteger) derObject;
-					message.setMessageType(MessageType.getTypeByOrdinal(tag1.intValue()));
+					message.setMessageType( MessageType.getTypeByOrdinal( tag1.intValue() ) );
 					break;
 				case 3:
 					DERSequence tag3 = (DERSequence)derObject;
-					message.setEncryptedPart(decodeEncryptedData(tag3));
+					message.setEncryptedPart( decodeEncryptedData( tag3 ) );
 					break;
 			    default:
-			    	System.out.println(derObject);
+			    	System.out.println( derObject );
 			    	break;
 			}
 		}
+		
 		return message;
 	}
 }

Mime
View raw message