[jboss-cvs] JBossAS SVN: r70966 - in projects/security/security-negotiation/trunk/jboss-negotiation/src: main/com/darranl/tomcat/gss and 10 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Mar 18 17:24:45 EDT 2008


Author: darran.lofthouse at jboss.com
Date: 2008-03-18 17:24:45 -0400 (Tue, 18 Mar 2008)
New Revision: 70966

Added:
   projects/security/security-negotiation/trunk/jboss-negotiation/src/main/org/jboss/security/negotiation/spnego/encoding/
   projects/security/security-negotiation/trunk/jboss-negotiation/src/main/org/jboss/security/negotiation/spnego/encoding/DebugHelper.java
   projects/security/security-negotiation/trunk/jboss-negotiation/src/main/org/jboss/security/negotiation/spnego/encoding/NegTokenDecoder.java
   projects/security/security-negotiation/trunk/jboss-negotiation/src/main/org/jboss/security/negotiation/spnego/encoding/NegTokenEncoder.java
   projects/security/security-negotiation/trunk/jboss-negotiation/src/main/org/jboss/security/negotiation/spnego/encoding/NegTokenInit.java
   projects/security/security-negotiation/trunk/jboss-negotiation/src/main/org/jboss/security/negotiation/spnego/encoding/NegTokenInitDecoder.java
   projects/security/security-negotiation/trunk/jboss-negotiation/src/main/org/jboss/security/negotiation/spnego/encoding/NegTokenTarg.java
   projects/security/security-negotiation/trunk/jboss-negotiation/src/main/org/jboss/security/negotiation/spnego/encoding/NegTokenTargDecoder.java
   projects/security/security-negotiation/trunk/jboss-negotiation/src/main/org/jboss/security/negotiation/spnego/encoding/NegTokenTargEncoder.java
   projects/security/security-negotiation/trunk/jboss-negotiation/src/tests/org/
   projects/security/security-negotiation/trunk/jboss-negotiation/src/tests/org/jboss/
   projects/security/security-negotiation/trunk/jboss-negotiation/src/tests/org/jboss/security/
   projects/security/security-negotiation/trunk/jboss-negotiation/src/tests/org/jboss/security/negotiation/
   projects/security/security-negotiation/trunk/jboss-negotiation/src/tests/org/jboss/security/negotiation/spnego/
   projects/security/security-negotiation/trunk/jboss-negotiation/src/tests/org/jboss/security/negotiation/spnego/encoding/
   projects/security/security-negotiation/trunk/jboss-negotiation/src/tests/org/jboss/security/negotiation/spnego/encoding/NegTokenEncoderTest.java
   projects/security/security-negotiation/trunk/jboss-negotiation/src/tests/org/jboss/security/negotiation/spnego/encoding/NegTokenInitDecoderTest.java
   projects/security/security-negotiation/trunk/jboss-negotiation/src/tests/org/jboss/security/negotiation/spnego/encoding/NegTokenTargEncoderTest.java
Removed:
   projects/security/security-negotiation/trunk/jboss-negotiation/src/main/com/darranl/spnego/
Modified:
   projects/security/security-negotiation/trunk/jboss-negotiation/src/main/com/darranl/tomcat/gss/SPNEGOValve.java
   projects/security/security-negotiation/trunk/jboss-negotiation/src/main/org/jboss/security/negotiation/MessageTrace.java
   projects/security/security-negotiation/trunk/jboss-negotiation/src/main/org/jboss/security/negotiation/spnego/SPNEGOLoginModule.java
Log:
[SECURITY-65] Package restructureing.

Modified: projects/security/security-negotiation/trunk/jboss-negotiation/src/main/com/darranl/tomcat/gss/SPNEGOValve.java
===================================================================
--- projects/security/security-negotiation/trunk/jboss-negotiation/src/main/com/darranl/tomcat/gss/SPNEGOValve.java	2008-03-18 21:05:26 UTC (rev 70965)
+++ projects/security/security-negotiation/trunk/jboss-negotiation/src/main/com/darranl/tomcat/gss/SPNEGOValve.java	2008-03-18 21:24:45 UTC (rev 70966)
@@ -38,14 +38,13 @@
 import org.ietf.jgss.GSSException;
 import org.ietf.jgss.GSSManager;
 import org.ietf.jgss.Oid;
+import org.jboss.security.negotiation.spnego.encoding.DebugHelper;
+import org.jboss.security.negotiation.spnego.encoding.NegTokenInit;
+import org.jboss.security.negotiation.spnego.encoding.NegTokenInitDecoder;
+import org.jboss.security.negotiation.spnego.encoding.NegTokenTarg;
+import org.jboss.security.negotiation.spnego.encoding.NegTokenTargDecoder;
+import org.jboss.security.negotiation.spnego.encoding.NegTokenTargEncoder;
 
-import com.darranl.spnego.DebugHelper;
-import com.darranl.spnego.NegTokenInit;
-import com.darranl.spnego.NegTokenInitDecoder;
-import com.darranl.spnego.NegTokenTarg;
-import com.darranl.spnego.NegTokenTargDecoder;
-import com.darranl.spnego.NegTokenTargEncoder;
-
 /**
  * A SPNEGOValve for Kerberos authentication for web
  * applications.
@@ -338,5 +337,4 @@
       }
    }
 
-
 }

Modified: projects/security/security-negotiation/trunk/jboss-negotiation/src/main/org/jboss/security/negotiation/MessageTrace.java
===================================================================
--- projects/security/security-negotiation/trunk/jboss-negotiation/src/main/org/jboss/security/negotiation/MessageTrace.java	2008-03-18 21:05:26 UTC (rev 70965)
+++ projects/security/security-negotiation/trunk/jboss-negotiation/src/main/org/jboss/security/negotiation/MessageTrace.java	2008-03-18 21:24:45 UTC (rev 70966)
@@ -23,9 +23,8 @@
 package org.jboss.security.negotiation;
 
 import org.jboss.logging.Logger;
+import org.jboss.security.negotiation.spnego.encoding.DebugHelper;
 
-import com.darranl.spnego.DebugHelper;
-
 /**
  * Handle message tracing hierarchy.
  * 

Modified: projects/security/security-negotiation/trunk/jboss-negotiation/src/main/org/jboss/security/negotiation/spnego/SPNEGOLoginModule.java
===================================================================
--- projects/security/security-negotiation/trunk/jboss-negotiation/src/main/org/jboss/security/negotiation/spnego/SPNEGOLoginModule.java	2008-03-18 21:05:26 UTC (rev 70965)
+++ projects/security/security-negotiation/trunk/jboss-negotiation/src/main/org/jboss/security/negotiation/spnego/SPNEGOLoginModule.java	2008-03-18 21:24:45 UTC (rev 70966)
@@ -44,13 +44,12 @@
 import org.jboss.security.SimpleGroup;
 import org.jboss.security.auth.spi.AbstractServerLoginModule;
 import org.jboss.security.negotiation.MessageTrace;
+import org.jboss.security.negotiation.spnego.encoding.NegTokenInit;
+import org.jboss.security.negotiation.spnego.encoding.NegTokenInitDecoder;
+import org.jboss.security.negotiation.spnego.encoding.NegTokenTarg;
+import org.jboss.security.negotiation.spnego.encoding.NegTokenTargDecoder;
+import org.jboss.security.negotiation.spnego.encoding.NegTokenTargEncoder;
 
-import com.darranl.spnego.NegTokenInit;
-import com.darranl.spnego.NegTokenInitDecoder;
-import com.darranl.spnego.NegTokenTarg;
-import com.darranl.spnego.NegTokenTargDecoder;
-import com.darranl.spnego.NegTokenTargEncoder;
-
 /**
  * Login module to work in conjunction with SPNEGOAuthenticator to handle the 
  * authentication requirements. 

Copied: projects/security/security-negotiation/trunk/jboss-negotiation/src/main/org/jboss/security/negotiation/spnego/encoding/DebugHelper.java (from rev 70965, projects/security/security-negotiation/trunk/jboss-negotiation/src/main/com/darranl/spnego/DebugHelper.java)
===================================================================
--- projects/security/security-negotiation/trunk/jboss-negotiation/src/main/org/jboss/security/negotiation/spnego/encoding/DebugHelper.java	                        (rev 0)
+++ projects/security/security-negotiation/trunk/jboss-negotiation/src/main/org/jboss/security/negotiation/spnego/encoding/DebugHelper.java	2008-03-18 21:24:45 UTC (rev 70966)
@@ -0,0 +1,46 @@
+/*
+ * Copyright © 2008  Red Hat Middleware, LLC. or third-party contributors as indicated 
+ * by the @author tags or express copyright attribution statements applied by the 
+ * authors. All third-party contributions are distributed under license by Red Hat 
+ * Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify, copy, 
+ * or redistribute it subject to the terms and conditions of the GNU Lesser General 
+ * Public License, v. 2.1. This program is distributed in the hope that it will be 
+ * useful, but WITHOUT A WARRANTY; without even the implied warranty of MERCHANTABILITY 
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for 
+ * more details. You should have received a copy of the GNU Lesser General Public License, 
+ * v.2.1 along with this distribution; if not, write to the Free Software Foundation, Inc., 
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.jboss.security.negotiation.spnego.encoding;
+
+import org.apache.commons.codec.binary.Hex;
+
+/**
+ * Utility class to assist debugging.
+ * 
+ * @author <a href="darranlofthouse at hotmail.com">Darran Lofthouse</a>
+ */
+public class DebugHelper
+{
+
+   public static String convertToHex(final byte[] message)
+   {
+      StringBuffer sb = new StringBuffer(message.length * 5);
+      char[] hex = Hex.encodeHex(message);
+
+      for (int i = 0; i < hex.length; i++)
+      {
+         if (i % 2 == 0)
+         {
+            sb.append(" 0x");
+         }
+
+         sb.append(hex[i]);
+      }
+
+      return sb.toString();
+   }
+}

Copied: projects/security/security-negotiation/trunk/jboss-negotiation/src/main/org/jboss/security/negotiation/spnego/encoding/NegTokenDecoder.java (from rev 70965, projects/security/security-negotiation/trunk/jboss-negotiation/src/main/com/darranl/spnego/NegTokenDecoder.java)
===================================================================
--- projects/security/security-negotiation/trunk/jboss-negotiation/src/main/org/jboss/security/negotiation/spnego/encoding/NegTokenDecoder.java	                        (rev 0)
+++ projects/security/security-negotiation/trunk/jboss-negotiation/src/main/org/jboss/security/negotiation/spnego/encoding/NegTokenDecoder.java	2008-03-18 21:24:45 UTC (rev 70966)
@@ -0,0 +1,67 @@
+/*
+ * Copyright © 2008  Red Hat Middleware, LLC. or third-party contributors as indicated 
+ * by the @author tags or express copyright attribution statements applied by the 
+ * authors. All third-party contributions are distributed under license by Red Hat 
+ * Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify, copy, 
+ * or redistribute it subject to the terms and conditions of the GNU Lesser General 
+ * Public License, v. 2.1. This program is distributed in the hope that it will be 
+ * useful, but WITHOUT A WARRANTY; without even the implied warranty of MERCHANTABILITY 
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for 
+ * more details. You should have received a copy of the GNU Lesser General Public License, 
+ * v.2.1 along with this distribution; if not, write to the Free Software Foundation, Inc., 
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.jboss.security.negotiation.spnego.encoding;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * NegToken Decoder.
+ * 
+ * @author <a href="darranlofthouse at hotmail.com">Darran Lofthouse</a>
+ */
+public class NegTokenDecoder
+{
+
+   public static int readLength(final InputStream is) throws IOException
+   {
+      byte first = (byte) is.read();
+      byte masked = (byte) (first & (byte) 128);
+   
+      if (masked == 0)
+      {
+         return first;
+      }
+   
+      int lengthLength = first & (byte) 127;
+   
+      byte[] lengthBytes = new byte[lengthLength];
+      is.read(lengthBytes);
+   
+      int length = 0;
+      for (int i = 0; i < lengthLength; i++)
+      {
+         int currentPos = lengthLength - i - 1;
+         int currentLength = lengthBytes[currentPos];
+   
+         if (currentLength < 0)
+         {
+            currentLength += 256;
+         }
+   
+         if (i > 0)
+         {
+            currentLength = currentLength * (int) (Math.pow(2, 8 * i));
+         }
+   
+         length += currentLength;
+      }
+   
+      return length;
+   }
+
+}

Copied: projects/security/security-negotiation/trunk/jboss-negotiation/src/main/org/jboss/security/negotiation/spnego/encoding/NegTokenEncoder.java (from rev 70965, projects/security/security-negotiation/trunk/jboss-negotiation/src/main/com/darranl/spnego/NegTokenEncoder.java)
===================================================================
--- projects/security/security-negotiation/trunk/jboss-negotiation/src/main/org/jboss/security/negotiation/spnego/encoding/NegTokenEncoder.java	                        (rev 0)
+++ projects/security/security-negotiation/trunk/jboss-negotiation/src/main/org/jboss/security/negotiation/spnego/encoding/NegTokenEncoder.java	2008-03-18 21:24:45 UTC (rev 70966)
@@ -0,0 +1,82 @@
+/*
+ * Copyright © 2008  Red Hat Middleware, LLC. or third-party contributors as indicated 
+ * by the @author tags or express copyright attribution statements applied by the 
+ * authors. All third-party contributions are distributed under license by Red Hat 
+ * Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify, copy, 
+ * or redistribute it subject to the terms and conditions of the GNU Lesser General 
+ * Public License, v. 2.1. This program is distributed in the hope that it will be 
+ * useful, but WITHOUT A WARRANTY; without even the implied warranty of MERCHANTABILITY 
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for 
+ * more details. You should have received a copy of the GNU Lesser General Public License, 
+ * v.2.1 along with this distribution; if not, write to the Free Software Foundation, Inc., 
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.jboss.security.negotiation.spnego.encoding;
+
+/**
+ * Neg Token Encoder.
+ * 
+ * @author <a href="darranlofthouse at hotmail.com">Darran Lofthouse</a>
+ */
+public class NegTokenEncoder
+{
+
+   private static int bitsRequired(int x)
+   {
+      return (int) (Math.log(x) / Math.log(2)) + 1;
+   }
+
+   public static byte[] createTypeLength(final byte type, final int length)
+   {
+      byte[] token;
+
+      int bitsRequired = bitsRequired(length);
+
+      if (bitsRequired <= 7)
+      {
+         token = new byte[2];
+         token[1] = (byte) length;
+      }
+      else
+      {
+         int bytesRequired = bitsRequired / 8;
+         if (bitsRequired % 8 != 0)
+         {
+            bytesRequired++;
+         }
+
+         token = new byte[bytesRequired + 2];
+
+         token[1] = (byte) (bytesRequired | 0x80);
+
+         int lengthLeft = length;
+
+         for (int i = 0; i < bytesRequired; i++)
+         {
+            int pos = bytesRequired - i - 1;
+            if (pos == 0)
+            {
+               token[i + 2] = (byte) lengthLeft;
+            }
+            else
+            {
+               int pow = pos * 8;
+               int multiplier = (int) Math.pow(2, pow);
+               int byteValue = lengthLeft / multiplier;
+
+               token[i + 2] = (byte) byteValue;
+
+               lengthLeft -= byteValue * multiplier;
+            }
+
+         }
+      }
+
+      token[0] = type;
+
+      return token;
+   }
+}

Copied: projects/security/security-negotiation/trunk/jboss-negotiation/src/main/org/jboss/security/negotiation/spnego/encoding/NegTokenInit.java (from rev 70965, projects/security/security-negotiation/trunk/jboss-negotiation/src/main/com/darranl/spnego/NegTokenInit.java)
===================================================================
--- projects/security/security-negotiation/trunk/jboss-negotiation/src/main/org/jboss/security/negotiation/spnego/encoding/NegTokenInit.java	                        (rev 0)
+++ projects/security/security-negotiation/trunk/jboss-negotiation/src/main/org/jboss/security/negotiation/spnego/encoding/NegTokenInit.java	2008-03-18 21:24:45 UTC (rev 70966)
@@ -0,0 +1,93 @@
+/*
+ * Copyright © 2008  Red Hat Middleware, LLC. or third-party contributors as indicated 
+ * by the @author tags or express copyright attribution statements applied by the 
+ * authors. All third-party contributions are distributed under license by Red Hat 
+ * Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify, copy, 
+ * or redistribute it subject to the terms and conditions of the GNU Lesser General 
+ * Public License, v. 2.1. This program is distributed in the hope that it will be 
+ * useful, but WITHOUT A WARRANTY; without even the implied warranty of MERCHANTABILITY 
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for 
+ * more details. You should have received a copy of the GNU Lesser General Public License, 
+ * v.2.1 along with this distribution; if not, write to the Free Software Foundation, Inc., 
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.jboss.security.negotiation.spnego.encoding;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.ietf.jgss.Oid;
+
+/**
+ * Representation of NegTokenInit.
+ * 
+ * @author <a href="darranlofthouse at hotmail.com">Darran Lofthouse</a>
+ */
+public class NegTokenInit
+{
+
+   private Oid messageOid;
+
+   private final List mechTypes = new LinkedList();
+
+   private byte[] reqFlags;
+
+   private byte[] mechToken;
+
+   private byte[] mechListMIC;
+
+   public Oid getMessageOid()
+   {
+      return messageOid;
+   }
+
+   public void setMessageOid(final Oid messageOid)
+   {
+      this.messageOid = messageOid;
+   }
+
+   public List getMechTypes()
+   {
+      return mechTypes;
+   }
+
+   public void addMechType(final Oid mechType)
+   {
+      mechTypes.add(mechType);
+   }
+
+   public byte[] getMechToken()
+   {
+      return mechToken;
+   }
+
+   
+   public byte[] getReqFlags()
+   {
+      return reqFlags;
+   }
+
+   public void setReqFlags(byte[] reqFlags)
+   {
+      this.reqFlags = reqFlags;
+   }
+
+   public void setMechToken(byte[] mechToken)
+   {
+      this.mechToken = mechToken;
+   }
+
+   public byte[] getMechListMIC()
+   {
+      return mechListMIC;
+   }
+
+   public void setMechListMIC(byte[] mechListMIC)
+   {
+      this.mechListMIC = mechListMIC;
+   }
+
+}

Copied: projects/security/security-negotiation/trunk/jboss-negotiation/src/main/org/jboss/security/negotiation/spnego/encoding/NegTokenInitDecoder.java (from rev 70965, projects/security/security-negotiation/trunk/jboss-negotiation/src/main/com/darranl/spnego/NegTokenInitDecoder.java)
===================================================================
--- projects/security/security-negotiation/trunk/jboss-negotiation/src/main/org/jboss/security/negotiation/spnego/encoding/NegTokenInitDecoder.java	                        (rev 0)
+++ projects/security/security-negotiation/trunk/jboss-negotiation/src/main/org/jboss/security/negotiation/spnego/encoding/NegTokenInitDecoder.java	2008-03-18 21:24:45 UTC (rev 70966)
@@ -0,0 +1,140 @@
+/*
+ * Copyright © 2008  Red Hat Middleware, LLC. or third-party contributors as indicated 
+ * by the @author tags or express copyright attribution statements applied by the 
+ * authors. All third-party contributions are distributed under license by Red Hat 
+ * Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify, copy, 
+ * or redistribute it subject to the terms and conditions of the GNU Lesser General 
+ * Public License, v. 2.1. This program is distributed in the hope that it will be 
+ * useful, but WITHOUT A WARRANTY; without even the implied warranty of MERCHANTABILITY 
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for 
+ * more details. You should have received a copy of the GNU Lesser General Public License, 
+ * v.2.1 along with this distribution; if not, write to the Free Software Foundation, Inc., 
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.jboss.security.negotiation.spnego.encoding;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.ietf.jgss.GSSException;
+import org.ietf.jgss.Oid;
+
+/**
+ * NegTokenInit Decoder.
+ * 
+ * @author <a href="darranlofthouse at hotmail.com">Darran Lofthouse</a>
+ */
+public class NegTokenInitDecoder extends NegTokenDecoder
+{
+
+   protected static void decodeRequestFlags(final InputStream is, final NegTokenInit negTokenInit) throws IOException
+   {
+      int length = NegTokenDecoder.readLength(is);
+      byte[] reqFlags = new byte[length];
+      is.read(reqFlags);
+
+      negTokenInit.setReqFlags(reqFlags);
+   }
+
+   protected static void decodeMechTypes(final InputStream is, final NegTokenInit negTokenInit) throws IOException,
+         GSSException
+   {
+      int length = NegTokenDecoder.readLength(is);
+      byte sequenceType = (byte) is.read();
+      int sequenceLength = NegTokenDecoder.readLength(is);
+
+      int leftAfter = is.available() - sequenceLength;
+
+      while (is.available() > leftAfter)
+      {
+         negTokenInit.addMechType(new Oid(is));
+      }
+   }
+
+   protected static void decodeMechToken(final InputStream is, final NegTokenInit negTokenInit) throws IOException
+   {
+      int length = NegTokenDecoder.readLength(is);
+
+      byte type = (byte) is.read();
+      int tokenLength = readLength(is);
+
+      byte[] mechToken = new byte[tokenLength];
+      is.read(mechToken);
+
+      negTokenInit.setMechToken(mechToken);
+   }
+
+   protected static void decodeMechListMIC(final InputStream is, final NegTokenInit negTokenInit) throws IOException
+   {
+      int length = NegTokenDecoder.readLength(is);
+      byte[] mechListMIC = new byte[length];
+      is.read(mechListMIC);
+
+      negTokenInit.setMechListMIC(mechListMIC);
+   }
+
+   protected static void decodeNegTokenInitSequence(final InputStream is, final NegTokenInit negTokenInit)
+         throws IOException, GSSException
+   {
+      byte type = (byte) is.read();
+      int sequenceLength = NegTokenDecoder.readLength(is);
+
+      int leftAfter = is.available() - sequenceLength;
+
+      while (is.available() > leftAfter)
+      {
+         byte sequenceType = (byte) is.read();
+
+         switch (sequenceType)
+         {
+            case (byte) 0xa0 :
+               decodeMechTypes(is, negTokenInit);
+               break;
+            case (byte) 0xa1 :
+               decodeRequestFlags(is, negTokenInit);
+               break;
+            case (byte) 0xa2 :
+               decodeMechToken(is, negTokenInit);
+               break;
+            case (byte) 0xa3 :
+               decodeMechListMIC(is, negTokenInit);
+               break;
+            default :
+               throw new IOException("Unexpected message type");
+         }
+      }
+
+   }
+
+   /**
+    *  Decode the SPNEGO message contained witin the byte[] and return a
+    *  NegTokenInit object.
+    * 
+    * @param token - The SPNEGO message contained 
+    * with a byte[]
+    * @return The decoded NegTokenInit
+    * @throws IOException 
+    * @throws GSSException 
+    */
+   public static NegTokenInit decode(final byte[] token) throws IOException, GSSException
+   {
+      NegTokenInit negTokenInit = new NegTokenInit();
+      ByteArrayInputStream bais = new ByteArrayInputStream(token);
+      byte firstByte = (byte) bais.read();
+
+      int totalLength = NegTokenDecoder.readLength(bais);
+
+      negTokenInit.setMessageOid(new Oid(bais));
+
+      int tokenType = bais.read();
+      int remainingLength = NegTokenDecoder.readLength(bais);
+
+      decodeNegTokenInitSequence(bais, negTokenInit);
+
+      return negTokenInit;
+   }
+}

Copied: projects/security/security-negotiation/trunk/jboss-negotiation/src/main/org/jboss/security/negotiation/spnego/encoding/NegTokenTarg.java (from rev 70965, projects/security/security-negotiation/trunk/jboss-negotiation/src/main/com/darranl/spnego/NegTokenTarg.java)
===================================================================
--- projects/security/security-negotiation/trunk/jboss-negotiation/src/main/org/jboss/security/negotiation/spnego/encoding/NegTokenTarg.java	                        (rev 0)
+++ projects/security/security-negotiation/trunk/jboss-negotiation/src/main/org/jboss/security/negotiation/spnego/encoding/NegTokenTarg.java	2008-03-18 21:24:45 UTC (rev 70966)
@@ -0,0 +1,82 @@
+/*
+ * Copyright © 2008  Red Hat Middleware, LLC. or third-party contributors as indicated 
+ * by the @author tags or express copyright attribution statements applied by the 
+ * authors. All third-party contributions are distributed under license by Red Hat 
+ * Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify, copy, 
+ * or redistribute it subject to the terms and conditions of the GNU Lesser General 
+ * Public License, v. 2.1. This program is distributed in the hope that it will be 
+ * useful, but WITHOUT A WARRANTY; without even the implied warranty of MERCHANTABILITY 
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for 
+ * more details. You should have received a copy of the GNU Lesser General Public License, 
+ * v.2.1 along with this distribution; if not, write to the Free Software Foundation, Inc., 
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.jboss.security.negotiation.spnego.encoding;
+
+import org.ietf.jgss.Oid;
+
+/**
+ * Representation of NegTokenTarg.
+ * 
+ * @author <a href="darranlofthouse at hotmail.com">Darran Lofthouse</a>
+ */
+public class NegTokenTarg
+{
+   public static final Integer ACCEPT_COMPLETED = new Integer(1);
+
+   public static final Integer ACCEPT_INCOMPLETE = new Integer(2);
+
+   public static final Integer REJECTED = new Integer(3);
+
+   private Integer negResult = null;
+
+   private Oid supportedMech = null;
+
+   private byte[] responseToken = null;
+
+   private byte[] mechListMIC = null;
+
+   public Integer getNegResult()
+   {
+      return negResult;
+   }
+
+   public void setNegResult(Integer negResult)
+   {
+      this.negResult = negResult;
+   }
+
+   public Oid getSupportedMech()
+   {
+      return supportedMech;
+   }
+
+   public void setSupportedMech(Oid supportedMech)
+   {
+      this.supportedMech = supportedMech;
+   }
+
+   public byte[] getResponseToken()
+   {
+      return responseToken;
+   }
+
+   public void setResponseToken(byte[] responseToken)
+   {
+      this.responseToken = responseToken;
+   }
+
+   public byte[] getMechListMIC()
+   {
+      return mechListMIC;
+   }
+
+   public void setMechListMIC(byte[] mechListMIC)
+   {
+      this.mechListMIC = mechListMIC;
+   }
+
+}

Copied: projects/security/security-negotiation/trunk/jboss-negotiation/src/main/org/jboss/security/negotiation/spnego/encoding/NegTokenTargDecoder.java (from rev 70965, projects/security/security-negotiation/trunk/jboss-negotiation/src/main/com/darranl/spnego/NegTokenTargDecoder.java)
===================================================================
--- projects/security/security-negotiation/trunk/jboss-negotiation/src/main/org/jboss/security/negotiation/spnego/encoding/NegTokenTargDecoder.java	                        (rev 0)
+++ projects/security/security-negotiation/trunk/jboss-negotiation/src/main/org/jboss/security/negotiation/spnego/encoding/NegTokenTargDecoder.java	2008-03-18 21:24:45 UTC (rev 70966)
@@ -0,0 +1,133 @@
+/*
+ * Copyright © 2008  Red Hat Middleware, LLC. or third-party contributors as indicated 
+ * by the @author tags or express copyright attribution statements applied by the 
+ * authors. All third-party contributions are distributed under license by Red Hat 
+ * Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify, copy, 
+ * or redistribute it subject to the terms and conditions of the GNU Lesser General 
+ * Public License, v. 2.1. This program is distributed in the hope that it will be 
+ * useful, but WITHOUT A WARRANTY; without even the implied warranty of MERCHANTABILITY 
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for 
+ * more details. You should have received a copy of the GNU Lesser General Public License, 
+ * v.2.1 along with this distribution; if not, write to the Free Software Foundation, Inc., 
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.jboss.security.negotiation.spnego.encoding;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.ietf.jgss.GSSException;
+import org.ietf.jgss.Oid;
+
+/**
+ * NegTokenTarg Decoder.
+ * 
+ * @author <a href="darranlofthouse at hotmail.com">Darran Lofthouse</a>
+ */
+public class NegTokenTargDecoder extends NegTokenDecoder
+{
+
+   private static void decodeNegResult(final InputStream is, final NegTokenTarg negTokenTarg) throws IOException
+   {
+      int length = readLength(is);
+      byte type = (byte) is.read();
+
+      byte negResult = (byte) is.read();
+
+      switch (negResult)
+      {
+         case 0x00 :
+            negTokenTarg.setNegResult(NegTokenTarg.ACCEPT_COMPLETED);
+            break;
+         case 0x01 :
+            negTokenTarg.setNegResult(NegTokenTarg.ACCEPT_INCOMPLETE);
+            break;
+         case 0x02 :
+            negTokenTarg.setNegResult(NegTokenTarg.REJECTED);
+            break;
+         default :
+            throw new IOException("Unexpected negResult");
+      }
+   }
+
+   private static void decodeSupportedMech(final InputStream is, final NegTokenTarg negTokenTarg) throws IOException,
+         GSSException
+   {
+      int length = readLength(is);
+
+      negTokenTarg.setSupportedMech(new Oid(is));
+   }
+
+   private static void decodeResponseToken(final InputStream is, final NegTokenTarg negTokenTarg) throws IOException
+   {
+      int length = readLength(is);
+
+      byte type = (byte) is.read();
+      int tokenLength = readLength(is);
+
+      byte[] responseToken = new byte[tokenLength];
+      is.read(responseToken);
+
+      negTokenTarg.setResponseToken(responseToken);
+   }
+
+   private static void decodeMechListMIC(final InputStream is, final NegTokenTarg negTokenTarg) throws IOException
+   {
+      int length = readLength(is);
+
+      byte[] mechListMIC = new byte[length];
+      is.read(mechListMIC);
+
+      negTokenTarg.setMechListMIC(mechListMIC);
+   }
+
+   private static void decodeNegTokenTargSequence(final InputStream is, final NegTokenTarg negTokenTarg)
+         throws IOException, GSSException
+   {
+      byte type = (byte) is.read();
+      int sequenceLength = readLength(is);
+
+      int leftAfter = is.available() - sequenceLength;
+
+      while (is.available() > leftAfter)
+      {
+         byte sequenceType = (byte) is.read();
+
+         switch (sequenceType)
+         {
+            case (byte) 0xa0 :
+               decodeNegResult(is, negTokenTarg);
+               break;
+            case (byte) 0xa1 :
+               decodeSupportedMech(is, negTokenTarg);
+               break;
+            case (byte) 0xa2 :
+               decodeResponseToken(is, negTokenTarg);
+               break;
+            case (byte) 0xa3 :
+               decodeMechListMIC(is, negTokenTarg);
+               break;
+            default :
+               throw new IOException("Unexpected message type");
+         }
+      }
+
+   }
+
+   public static NegTokenTarg decode(final byte[] token) throws IOException, GSSException
+   {
+      NegTokenTarg negTokenTarg = new NegTokenTarg();
+      ByteArrayInputStream bais = new ByteArrayInputStream(token);
+
+      byte firstByte = (byte) bais.read();
+      int totalLength = readLength(bais);
+
+      decodeNegTokenTargSequence(bais, negTokenTarg);
+
+      return negTokenTarg;
+   }
+}

Copied: projects/security/security-negotiation/trunk/jboss-negotiation/src/main/org/jboss/security/negotiation/spnego/encoding/NegTokenTargEncoder.java (from rev 70965, projects/security/security-negotiation/trunk/jboss-negotiation/src/main/com/darranl/spnego/NegTokenTargEncoder.java)
===================================================================
--- projects/security/security-negotiation/trunk/jboss-negotiation/src/main/org/jboss/security/negotiation/spnego/encoding/NegTokenTargEncoder.java	                        (rev 0)
+++ projects/security/security-negotiation/trunk/jboss-negotiation/src/main/org/jboss/security/negotiation/spnego/encoding/NegTokenTargEncoder.java	2008-03-18 21:24:45 UTC (rev 70966)
@@ -0,0 +1,155 @@
+/*
+ * Copyright © 2008  Red Hat Middleware, LLC. or third-party contributors as indicated 
+ * by the @author tags or express copyright attribution statements applied by the 
+ * authors. All third-party contributions are distributed under license by Red Hat 
+ * Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify, copy, 
+ * or redistribute it subject to the terms and conditions of the GNU Lesser General 
+ * Public License, v. 2.1. This program is distributed in the hope that it will be 
+ * useful, but WITHOUT A WARRANTY; without even the implied warranty of MERCHANTABILITY 
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for 
+ * more details. You should have received a copy of the GNU Lesser General Public License, 
+ * v.2.1 along with this distribution; if not, write to the Free Software Foundation, Inc., 
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.jboss.security.negotiation.spnego.encoding;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.ietf.jgss.GSSException;
+import org.ietf.jgss.Oid;
+
+/**
+ * NegTokenTarg Encoder.
+ * 
+ * @author <a href="darranlofthouse at hotmail.com">Darran Lofthouse</a>
+ */
+public class NegTokenTargEncoder extends NegTokenEncoder
+{
+
+   protected static int getTotalLength(final List tokens)
+   {
+      int length = 0;
+      Iterator it = tokens.iterator();
+      while (it.hasNext())
+      {
+         byte[] current = (byte[]) it.next();
+         length += current.length;
+      }
+
+      return length;
+   }
+
+   protected static void encodeNegTokenTarg(final List tokens)
+   {
+      byte[] constructedSequence = createTypeLength((byte) 0xa1, getTotalLength(tokens));
+
+      tokens.add(0, constructedSequence);
+   }
+
+   protected static void encodeConstructedSequence(final List tokens)
+   {
+      byte[] constructedSequence = createTypeLength((byte) 0x30, getTotalLength(tokens));
+
+      tokens.add(0, constructedSequence);
+   }
+
+   protected static void encodeNegResult(final List tokens, final Integer negResult)
+   {
+      if (negResult == null)
+         return;
+
+      byte result;
+
+      if (NegTokenTarg.ACCEPT_COMPLETED.equals(negResult))
+      {
+         result = 0x00;
+      }
+      else if (NegTokenTarg.ACCEPT_INCOMPLETE.equals(negResult))
+      {
+         result = 0x01;
+      }
+      else
+      {
+         result = 0x02;
+      }
+
+      byte[] negResultToken =
+      {(byte) 0xa0, 0x03, 0x0a, 0x01, result};
+
+      tokens.add(0, negResultToken);
+   }
+
+   protected static void encodeSupportedMech(final List tokens, final Oid supportedMech) throws GSSException
+   {
+      if (supportedMech == null)
+         return;
+
+      byte[] supportedMechToken = supportedMech.getDER();
+      byte[] sequenceLength = createTypeLength((byte) 0xa1, supportedMechToken.length);
+
+      tokens.add(0, supportedMechToken);
+      tokens.add(0, sequenceLength);
+   }
+
+   protected static void encodeResponseToken(final List tokens, final byte[] responseToken)
+   {
+      if (responseToken == null || responseToken.length == 0)
+         return;
+
+      byte[] octletLength = createTypeLength((byte) 0x04, responseToken.length);
+      byte[] sequenceLength = createTypeLength((byte) 0xa2, responseToken.length + octletLength.length);
+
+      tokens.add(0, responseToken);
+      tokens.add(0, octletLength);
+      tokens.add(0, sequenceLength);
+   }
+
+   protected static void encodeMechListMIC(final List tokens, final byte[] mechListMIC)
+   {
+      if (mechListMIC == null || mechListMIC.length == 0)
+         return;
+
+      byte[] octletLength = createTypeLength((byte) 0x04, mechListMIC.length);
+      byte[] sequenceLength = createTypeLength((byte) 0xa3, mechListMIC.length + octletLength.length);
+
+      tokens.add(0, mechListMIC);
+      tokens.add(0, octletLength);
+      tokens.add(0, sequenceLength);
+   }
+
+   protected static byte[] contructMessage(final List tokens) throws IOException
+   {
+      int length = getTotalLength(tokens);
+
+      ByteArrayOutputStream baous = new ByteArrayOutputStream(length);
+
+      Iterator it = tokens.iterator();
+      while (it.hasNext())
+      {
+         baous.write((byte[]) it.next());
+      }
+
+      return baous.toByteArray();
+   }
+
+   public static byte[] encode(final NegTokenTarg negTokenTarg) throws GSSException, IOException
+   {
+      List tokens = new LinkedList();
+
+      encodeMechListMIC(tokens, negTokenTarg.getMechListMIC());
+      encodeResponseToken(tokens, negTokenTarg.getResponseToken());
+      encodeSupportedMech(tokens, negTokenTarg.getSupportedMech());
+      encodeNegResult(tokens, negTokenTarg.getNegResult());
+      encodeConstructedSequence(tokens);
+      encodeNegTokenTarg(tokens);
+
+      return contructMessage(tokens);
+   }
+}

Copied: projects/security/security-negotiation/trunk/jboss-negotiation/src/tests/org/jboss/security/negotiation/spnego/encoding/NegTokenEncoderTest.java (from rev 70965, projects/security/security-negotiation/trunk/jboss-negotiation/src/main/com/darranl/spnego/NegTokenEncoderTest.java)
===================================================================
--- projects/security/security-negotiation/trunk/jboss-negotiation/src/tests/org/jboss/security/negotiation/spnego/encoding/NegTokenEncoderTest.java	                        (rev 0)
+++ projects/security/security-negotiation/trunk/jboss-negotiation/src/tests/org/jboss/security/negotiation/spnego/encoding/NegTokenEncoderTest.java	2008-03-18 21:24:45 UTC (rev 70966)
@@ -0,0 +1,105 @@
+/*
+ * Copyright © 2008  Red Hat Middleware, LLC. or third-party contributors as indicated 
+ * by the @author tags or express copyright attribution statements applied by the 
+ * authors. All third-party contributions are distributed under license by Red Hat 
+ * Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify, copy, 
+ * or redistribute it subject to the terms and conditions of the GNU Lesser General 
+ * Public License, v. 2.1. This program is distributed in the hope that it will be 
+ * useful, but WITHOUT A WARRANTY; without even the implied warranty of MERCHANTABILITY 
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for 
+ * more details. You should have received a copy of the GNU Lesser General Public License, 
+ * v.2.1 along with this distribution; if not, write to the Free Software Foundation, Inc., 
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.jboss.security.negotiation.spnego.encoding;
+
+import java.util.Arrays;
+
+import junit.framework.TestCase;
+
+/**
+ * Test case to test NegTokenEncoder. 
+ * 
+ * @author <a href="darranlofthouse at hotmail.com">Darran Lofthouse</a>
+ */
+public class NegTokenEncoderTest extends TestCase
+{
+
+   private static void log(final byte[] name)
+   {
+      String hex = DebugHelper.convertToHex(name);
+      System.out.println(hex);
+   }
+
+   /**
+    *  Test the createTypeLength method correctly 
+    *  creates a lengh of one byte using both extremes 
+    *  and a value in the middle. 
+    */
+   public void testCreateTypeLength_OneBye()
+   {
+      byte[] tl_1 = NegTokenEncoder.createTypeLength((byte) 0x00, 1);
+      assertTrue(Arrays.equals(new byte[]
+      {0x00, 0x01}, tl_1));
+      log(tl_1);
+
+      byte[] tl_2 = NegTokenEncoder.createTypeLength((byte) 0x00, 64);
+      assertTrue(Arrays.equals(new byte[]
+      {0x00, 0x40}, tl_2));
+      log(tl_2);
+
+      byte[] tl_3 = NegTokenEncoder.createTypeLength((byte) 0x00, 127);
+      assertTrue(Arrays.equals(new byte[]
+      {0x00, 0x7F}, tl_3));
+      log(tl_3);
+
+      byte[] tl_4 = NegTokenEncoder.createTypeLength((byte) 0x00, 255);
+      assertTrue(Arrays.equals(new byte[]
+      {0x00, (byte) 0x81, (byte) 0xFF}, tl_4));
+      log(tl_4);
+   }
+
+   public void testCreateTypeLength_TwoBytes()
+   {
+      byte[] tl_1 = NegTokenEncoder.createTypeLength((byte) 0x00, 256);
+      assertTrue(Arrays.equals(new byte[]
+      {0x00, (byte) 0x82, 0x01, 0x00}, tl_1));
+      log(tl_1);
+
+      byte[] tl_2 = NegTokenEncoder.createTypeLength((byte) 0x00, 32768);
+      assertTrue(Arrays.equals(new byte[]
+      {0x00, (byte) 0x82, (byte) 0x80, 0x00}, tl_2));
+      log(tl_2);
+
+      byte[] tl_3 = NegTokenEncoder.createTypeLength((byte) 0x00, 65280);
+      assertTrue(Arrays.equals(new byte[]
+      {0x00, (byte) 0x82, (byte) 0xFF, 0x00}, tl_3));
+      log(tl_3);
+
+      byte[] tl_4 = NegTokenEncoder.createTypeLength((byte) 0x00, 65535);
+      assertTrue(Arrays.equals(new byte[]
+      {0x00, (byte) 0x82, (byte) 0xFF, (byte) 0xFF}, tl_4));
+      log(tl_4);
+   }
+
+   public void testCreateTypeLength_ThreeBytes()
+   {
+      byte[] tl_1 = NegTokenEncoder.createTypeLength((byte) 0x00, 65536);
+      assertTrue(Arrays.equals(new byte[]
+      {0x00, (byte) 0x83, 0x01, 0x00, 0x00}, tl_1));
+      log(tl_1);
+
+      byte[] tl_2 = NegTokenEncoder.createTypeLength((byte) 0x00, 8421375);
+      assertTrue(Arrays.equals(new byte[]
+      {0x00, (byte) 0x83, (byte) 0x80, 0x7F, (byte) 0xFF}, tl_2));
+      log(tl_2);
+
+      byte[] tl_3 = NegTokenEncoder.createTypeLength((byte) 0x00, 16777215);
+      assertTrue(Arrays.equals(new byte[]
+      {0x00, (byte) 0x83, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF}, tl_3));
+      log(tl_3);
+   }
+}

Copied: projects/security/security-negotiation/trunk/jboss-negotiation/src/tests/org/jboss/security/negotiation/spnego/encoding/NegTokenInitDecoderTest.java (from rev 70965, projects/security/security-negotiation/trunk/jboss-negotiation/src/main/com/darranl/spnego/NegTokenInitDecoderTest.java)
===================================================================
--- projects/security/security-negotiation/trunk/jboss-negotiation/src/tests/org/jboss/security/negotiation/spnego/encoding/NegTokenInitDecoderTest.java	                        (rev 0)
+++ projects/security/security-negotiation/trunk/jboss-negotiation/src/tests/org/jboss/security/negotiation/spnego/encoding/NegTokenInitDecoderTest.java	2008-03-18 21:24:45 UTC (rev 70966)
@@ -0,0 +1,85 @@
+/*
+ * Copyright © 2008  Red Hat Middleware, LLC. or third-party contributors as indicated 
+ * by the @author tags or express copyright attribution statements applied by the 
+ * authors. All third-party contributions are distributed under license by Red Hat 
+ * Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify, copy, 
+ * or redistribute it subject to the terms and conditions of the GNU Lesser General 
+ * Public License, v. 2.1. This program is distributed in the hope that it will be 
+ * useful, but WITHOUT A WARRANTY; without even the implied warranty of MERCHANTABILITY 
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for 
+ * more details. You should have received a copy of the GNU Lesser General Public License, 
+ * v.2.1 along with this distribution; if not, write to the Free Software Foundation, Inc., 
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.jboss.security.negotiation.spnego.encoding;
+
+import java.io.ByteArrayInputStream;
+
+import junit.framework.TestCase;
+
+/**
+ * Test case to test the NegTokenInitDecoder.
+ * 
+ * @author <a href="darranlofthouse at hotmail.com">Darran Lofthouse</a>
+ */
+public class NegTokenInitDecoderTest extends TestCase
+{
+
+   /**
+    * Test that the readLength method can correctly read 
+    * and decode the length.
+    *
+    */
+   public void testReadLength() throws Exception
+   {
+      NegTokenInitDecoder decoder = new NegTokenInitDecoder();
+
+      byte[] b1 = new byte[]
+      {0x01};
+      assertEquals(1, NegTokenDecoder.readLength(new ByteArrayInputStream(b1)));
+
+      byte[] b2 = new byte[]
+      {0x40};
+      assertEquals(64, NegTokenDecoder.readLength(new ByteArrayInputStream(b2)));
+
+      byte[] b3 = new byte[]
+      {0x7F};
+      assertEquals(127, NegTokenDecoder.readLength(new ByteArrayInputStream(b3)));
+
+      byte[] b4 = new byte[]
+      {(byte) 0x81, (byte) 0xFF};
+      assertEquals(255, NegTokenDecoder.readLength(new ByteArrayInputStream(b4)));
+
+      byte[] b5 = new byte[]
+      {(byte) 0x82, 0x01, 0x00};
+      assertEquals(256, NegTokenDecoder.readLength(new ByteArrayInputStream(b5)));
+
+      byte[] b6 = new byte[]
+      {(byte) 0x82, (byte) 0x80, 0x00};
+      assertEquals(32768, NegTokenDecoder.readLength(new ByteArrayInputStream(b6)));
+
+      byte[] b7 = new byte[]
+      {(byte) 0x82, (byte) 0xFF, 0x00};
+      assertEquals(65280, NegTokenDecoder.readLength(new ByteArrayInputStream(b7)));
+
+      byte[] b8 = new byte[]
+      {(byte) 0x82, (byte) 0xFF, (byte) 0xFF};
+      assertEquals(65535, NegTokenDecoder.readLength(new ByteArrayInputStream(b8)));
+
+      byte[] b9 = new byte[]
+      {(byte) 0x83, 0x01, 0x00, 0x00};
+      assertEquals(65536, NegTokenDecoder.readLength(new ByteArrayInputStream(b9)));
+
+      byte[] b10 = new byte[]
+      {(byte) 0x83, (byte) 0x80, 0x7F, (byte) 0xFF};
+      assertEquals(8421375, NegTokenDecoder.readLength(new ByteArrayInputStream(b10)));
+
+      byte[] b11 = new byte[]
+      {(byte) 0x83, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF};
+      assertEquals(16777215, NegTokenDecoder.readLength(new ByteArrayInputStream(b11)));
+
+   }
+}

Copied: projects/security/security-negotiation/trunk/jboss-negotiation/src/tests/org/jboss/security/negotiation/spnego/encoding/NegTokenTargEncoderTest.java (from rev 70965, projects/security/security-negotiation/trunk/jboss-negotiation/src/main/com/darranl/spnego/NegTokenTargEncoderTest.java)
===================================================================
--- projects/security/security-negotiation/trunk/jboss-negotiation/src/tests/org/jboss/security/negotiation/spnego/encoding/NegTokenTargEncoderTest.java	                        (rev 0)
+++ projects/security/security-negotiation/trunk/jboss-negotiation/src/tests/org/jboss/security/negotiation/spnego/encoding/NegTokenTargEncoderTest.java	2008-03-18 21:24:45 UTC (rev 70966)
@@ -0,0 +1,52 @@
+/*
+ * Copyright © 2008  Red Hat Middleware, LLC. or third-party contributors as indicated 
+ * by the @author tags or express copyright attribution statements applied by the 
+ * authors. All third-party contributions are distributed under license by Red Hat 
+ * Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify, copy, 
+ * or redistribute it subject to the terms and conditions of the GNU Lesser General 
+ * Public License, v. 2.1. This program is distributed in the hope that it will be 
+ * useful, but WITHOUT A WARRANTY; without even the implied warranty of MERCHANTABILITY 
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for 
+ * more details. You should have received a copy of the GNU Lesser General Public License, 
+ * v.2.1 along with this distribution; if not, write to the Free Software Foundation, Inc., 
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.jboss.security.negotiation.spnego.encoding;
+
+import java.io.IOException;
+
+import org.ietf.jgss.GSSException;
+import org.ietf.jgss.Oid;
+
+import junit.framework.TestCase;
+
+/**
+ * Test case for the NegTokenTargEncoder.
+ * 
+ * @author <a href="darranlofthouse at hotmail.com">Darran Lofthouse</a>
+ */
+public class NegTokenTargEncoderTest extends TestCase
+{
+
+   /**
+    * Test a NegTokenTarg response can be constructed to request 
+    * an alternate supported mechanism.
+    * @throws GSSException 
+    * @throws IOException 
+    *
+    */
+   public void testSupportedMech() throws GSSException, IOException
+   {
+      NegTokenTarg targ = new NegTokenTarg();
+      targ.setNegResult(NegTokenTarg.ACCEPT_INCOMPLETE);
+      targ.setSupportedMech(new Oid("1.2.840.113554.1.2.2"));
+
+      byte[] response = NegTokenTargEncoder.encode(targ);
+
+      String responseHex = DebugHelper.convertToHex(response);
+      System.out.println(responseHex);
+   }
+}




More information about the jboss-cvs-commits mailing list