directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From erodrig...@apache.org
Subject svn commit: r178151 - in /directory/sandbox/trunk/kerberos-sam/trunk/sam/src/main/java/org/apache/kerberos/sam: io/ messages/
Date Tue, 24 May 2005 10:30:38 GMT
Author: erodriguez
Date: Tue May 24 03:30:35 2005
New Revision: 178151

URL: http://svn.apache.org/viewcvs?rev=178151&view=rev
Log:
Kerberos SAM codec and message classes.

Added:
    directory/sandbox/trunk/kerberos-sam/trunk/sam/src/main/java/org/apache/kerberos/sam/io/
    directory/sandbox/trunk/kerberos-sam/trunk/sam/src/main/java/org/apache/kerberos/sam/io/EncryptedSamResponseDecoder.java
    directory/sandbox/trunk/kerberos-sam/trunk/sam/src/main/java/org/apache/kerberos/sam/io/EncryptedSamResponseEncoder.java
    directory/sandbox/trunk/kerberos-sam/trunk/sam/src/main/java/org/apache/kerberos/sam/io/SamChallengeDecoder.java
    directory/sandbox/trunk/kerberos-sam/trunk/sam/src/main/java/org/apache/kerberos/sam/io/SamChallengeEncoder.java
    directory/sandbox/trunk/kerberos-sam/trunk/sam/src/main/java/org/apache/kerberos/sam/io/SamResponseDecoder.java
    directory/sandbox/trunk/kerberos-sam/trunk/sam/src/main/java/org/apache/kerberos/sam/io/SamResponseEncoder.java
    directory/sandbox/trunk/kerberos-sam/trunk/sam/src/main/java/org/apache/kerberos/sam/messages/
    directory/sandbox/trunk/kerberos-sam/trunk/sam/src/main/java/org/apache/kerberos/sam/messages/EncryptedSamResponse.java
    directory/sandbox/trunk/kerberos-sam/trunk/sam/src/main/java/org/apache/kerberos/sam/messages/EncryptedSamResponseModifier.java
    directory/sandbox/trunk/kerberos-sam/trunk/sam/src/main/java/org/apache/kerberos/sam/messages/SamChallenge.java
    directory/sandbox/trunk/kerberos-sam/trunk/sam/src/main/java/org/apache/kerberos/sam/messages/SamChallengeModifier.java
    directory/sandbox/trunk/kerberos-sam/trunk/sam/src/main/java/org/apache/kerberos/sam/messages/SamFlags.java
    directory/sandbox/trunk/kerberos-sam/trunk/sam/src/main/java/org/apache/kerberos/sam/messages/SamResponse.java
    directory/sandbox/trunk/kerberos-sam/trunk/sam/src/main/java/org/apache/kerberos/sam/messages/SamResponseModifier.java

Added: directory/sandbox/trunk/kerberos-sam/trunk/sam/src/main/java/org/apache/kerberos/sam/io/EncryptedSamResponseDecoder.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/kerberos-sam/trunk/sam/src/main/java/org/apache/kerberos/sam/io/EncryptedSamResponseDecoder.java?rev=178151&view=auto
==============================================================================
--- directory/sandbox/trunk/kerberos-sam/trunk/sam/src/main/java/org/apache/kerberos/sam/io/EncryptedSamResponseDecoder.java (added)
+++ directory/sandbox/trunk/kerberos-sam/trunk/sam/src/main/java/org/apache/kerberos/sam/io/EncryptedSamResponseDecoder.java Tue May 24 03:30:35 2005
@@ -0,0 +1,81 @@
+/*
+ *   Copyright 2005 The Apache Software Foundation
+ *
+ *   Licensed 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.
+ *
+ */
+
+package org.apache.kerberos.sam.io;
+
+import java.io.IOException;
+import java.util.Enumeration;
+
+import org.apache.asn1.der.ASN1InputStream;
+import org.apache.asn1.der.DEREncodable;
+import org.apache.asn1.der.DERInteger;
+import org.apache.asn1.der.DERSequence;
+import org.apache.asn1.der.DERString;
+import org.apache.asn1.der.DERTaggedObject;
+
+import org.apache.kerberos.sam.messages.EncryptedSamResponse;
+import org.apache.kerberos.sam.messages.EncryptedSamResponseModifier;
+
+
+public class EncryptedSamResponseDecoder
+{
+	public EncryptedSamResponse decode( byte[] encodedSamChallenge ) throws IOException
+	{
+		ASN1InputStream ais = new ASN1InputStream( encodedSamChallenge );
+		
+		DERSequence sequence = (DERSequence) ais.readObject();
+		
+		return decodeEncryptedSamResponse( sequence );
+	}
+	
+	/**
+	 *  PA-ENC-SAM-RESPONSE-ENC ::= SEQUENCE {
+	 *       sam-nonce[0]               INTEGER (0..4294967295),
+	 *       sam-sad[1]                 GeneralString OPTIONAL,
+	 *       ...
+	 *  }
+	 */
+	private EncryptedSamResponse decodeEncryptedSamResponse( DERSequence sequence )
+	{
+		EncryptedSamResponseModifier modifier = new EncryptedSamResponseModifier();
+		
+		for ( Enumeration e = sequence.getObjects(); e.hasMoreElements(); )
+		{
+			DERTaggedObject object = (DERTaggedObject) e.nextElement();
+			int tag = object.getTagNo();
+			DEREncodable derObject = object.getObject();
+			
+			switch ( tag )
+			{
+				case 0:
+					DERInteger tag0 = (DERInteger)derObject;
+					modifier.setSamNonce( tag0.intValue() );
+					break;
+				case 1:
+				    DERString tag1 = (DERString)derObject;
+					modifier.setSamSad( tag1.getString() );
+					break;
+			    default:
+			    	System.out.println( derObject );
+			    	break;
+			}
+		}
+		
+		return modifier.getEncryptedSamResponse();
+	}
+}
+

Added: directory/sandbox/trunk/kerberos-sam/trunk/sam/src/main/java/org/apache/kerberos/sam/io/EncryptedSamResponseEncoder.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/kerberos-sam/trunk/sam/src/main/java/org/apache/kerberos/sam/io/EncryptedSamResponseEncoder.java?rev=178151&view=auto
==============================================================================
--- directory/sandbox/trunk/kerberos-sam/trunk/sam/src/main/java/org/apache/kerberos/sam/io/EncryptedSamResponseEncoder.java (added)
+++ directory/sandbox/trunk/kerberos-sam/trunk/sam/src/main/java/org/apache/kerberos/sam/io/EncryptedSamResponseEncoder.java Tue May 24 03:30:35 2005
@@ -0,0 +1,62 @@
+/*
+ *   Copyright 2005 The Apache Software Foundation
+ *
+ *   Licensed 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.
+ *
+ */
+
+package org.apache.kerberos.sam.io;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+
+import org.apache.asn1.der.ASN1OutputStream;
+import org.apache.asn1.der.DERGeneralString;
+import org.apache.asn1.der.DERInteger;
+import org.apache.asn1.der.DERSequence;
+import org.apache.asn1.der.DERTaggedObject;
+import org.apache.kerberos.sam.messages.EncryptedSamResponse;
+
+
+public class EncryptedSamResponseEncoder
+{
+	public byte[] encode( EncryptedSamResponse encryptedResponse ) throws IOException
+	{
+		ByteArrayOutputStream baos = new ByteArrayOutputStream();
+		ASN1OutputStream aos = new ASN1OutputStream( baos );
+		
+		aos.writeObject( encodeEncryptedSamResponse( encryptedResponse ) );
+		aos.close();
+		
+		return baos.toByteArray();
+	}
+	
+	/**
+	 *  PA-ENC-SAM-RESPONSE-ENC ::= SEQUENCE {
+	 *       sam-nonce[0]               INTEGER (0..4294967295),
+	 *       sam-sad[1]                 GeneralString OPTIONAL,
+	 *       ...
+	 *  }
+	 */
+	private DERSequence encodeEncryptedSamResponse( EncryptedSamResponse encryptedResponse )
+	{
+		DERSequence sequence = new DERSequence();
+		
+		sequence.add( new DERTaggedObject( 0, DERInteger.valueOf( encryptedResponse.getSamNonce() ) ) );
+		
+		sequence.add( new DERTaggedObject( 1, DERGeneralString.valueOf( encryptedResponse.getSamSad() ) ) );
+		
+		return sequence;
+	}
+}
+

Added: directory/sandbox/trunk/kerberos-sam/trunk/sam/src/main/java/org/apache/kerberos/sam/io/SamChallengeDecoder.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/kerberos-sam/trunk/sam/src/main/java/org/apache/kerberos/sam/io/SamChallengeDecoder.java?rev=178151&view=auto
==============================================================================
--- directory/sandbox/trunk/kerberos-sam/trunk/sam/src/main/java/org/apache/kerberos/sam/io/SamChallengeDecoder.java (added)
+++ directory/sandbox/trunk/kerberos-sam/trunk/sam/src/main/java/org/apache/kerberos/sam/io/SamChallengeDecoder.java Tue May 24 03:30:35 2005
@@ -0,0 +1,168 @@
+/*
+ *   Copyright 2005 The Apache Software Foundation
+ *
+ *   Licensed 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.
+ *
+ */
+
+package org.apache.kerberos.sam.io;
+
+import java.io.IOException;
+import java.util.Enumeration;
+
+import org.apache.asn1.der.ASN1InputStream;
+import org.apache.asn1.der.DERBitString;
+import org.apache.asn1.der.DEREncodable;
+import org.apache.asn1.der.DERGeneralString;
+import org.apache.asn1.der.DERInteger;
+import org.apache.asn1.der.DEROctetString;
+import org.apache.asn1.der.DERSequence;
+import org.apache.asn1.der.DERTaggedObject;
+import org.apache.kerberos.io.decoder.ChecksumDecoder;
+import org.apache.kerberos.messages.value.Checksum;
+import org.apache.kerberos.sam.messages.SamChallenge;
+import org.apache.kerberos.sam.messages.SamChallengeModifier;
+import org.apache.kerberos.sam.messages.SamFlags;
+
+
+public class SamChallengeDecoder
+{
+	public SamChallenge decode( byte[] encodedSamChallenge ) throws IOException
+	{
+		ASN1InputStream ais = new ASN1InputStream( encodedSamChallenge );
+		
+		DERSequence sequence = (DERSequence) ais.readObject();
+		
+		return decodeSamChallenge( sequence );
+	}
+	
+	/**
+	 *  PA-SAM-CHALLENGE-2 ::= SEQUENCE {
+	 *      sam-body[0]                 PA-SAM-CHALLENGE-2-BODY,
+	 *      sam-cksum[1]                SEQUENCE (1..MAX) OF Checksum,
+	 *      ...
+	 *  }
+	 */
+	private SamChallenge decodeSamChallenge( DERSequence sequence )
+	{
+		SamChallengeModifier modifier = new SamChallengeModifier();
+		
+		for ( Enumeration e = sequence.getObjects(); e.hasMoreElements(); )
+		{
+			DERTaggedObject object = (DERTaggedObject) e.nextElement();
+			int tag = object.getTagNo();
+			DEREncodable derObject = object.getObject();
+			
+			switch ( tag )
+			{
+				case 0:
+					DERSequence tag0 = (DERSequence)derObject;
+					decodeSamChallengeBody( tag0, modifier );
+					break;
+				case 1:
+				    DERSequence tag1 = (DERSequence)derObject;
+					decodeSamChecksum( tag1, modifier );
+					break;
+			    default:
+			    	System.out.println( derObject );
+			    	break;
+			}
+		}
+		
+		return modifier.getSamChallenge();
+	}
+	
+	private void decodeSamChecksum( DERSequence sequence, SamChallengeModifier modifier )
+	{
+		for ( Enumeration e = sequence.getObjects(); e.hasMoreElements(); )
+		{
+			DERSequence object = (DERSequence) e.nextElement();
+			Checksum checksum = ChecksumDecoder.decode( object );
+			modifier.addChecksum( checksum );
+		}
+	}
+	
+	/**
+	 *  PA-SAM-CHALLENGE-2-BODY ::= SEQUENCE {
+	 *      sam-type[0]                 INTEGER (0..4294967295),
+	 *      sam-flags[1]                SAMFlags,
+	 *      sam-type-name[2]            GeneralString OPTIONAL,
+	 *      sam-track-id[3]             GeneralString OPTIONAL,
+	 *                                    -- Key usage of 26
+	 *      sam-challenge-label[4]      GeneralString OPTIONAL,
+	 *      sam-challenge[5]            GeneralString OPTIONAL,
+	 *      sam-response-prompt[6]      GeneralString OPTIONAL,
+	 *      sam-pk-for-sad[7]           OCTET STRING OPTIONAL,
+	 *      sam-nonce[8]                INTEGER (0..4294967295),
+	 *      sam-etype[9]                INTEGER (0..4294967295),
+	 *      ...
+	 *  }
+	 */
+	private void decodeSamChallengeBody( DERSequence sequence, SamChallengeModifier modifier )
+	{
+		for ( Enumeration e = sequence.getObjects(); e.hasMoreElements(); )
+		{
+			DERTaggedObject object = (DERTaggedObject) e.nextElement();
+			int tag = object.getTagNo();
+			DEREncodable derObject = object.getObject();
+			
+			switch ( tag )
+			{
+				case 0:
+					DERInteger tag0 = (DERInteger)derObject;
+					modifier.setSamType( tag0.intValue() );
+					break;
+				case 1:
+					DERBitString tag1 = (DERBitString)derObject;
+					modifier.setSamFlags( new SamFlags( tag1.getOctets() ) );
+					break;
+				case 2:
+				    DERGeneralString tag2 = (DERGeneralString)derObject;
+					modifier.setSamTypeName( tag2.getString() );
+					break;
+				case 3:
+				    DERGeneralString tag3 = (DERGeneralString)derObject;
+					modifier.setSamTrackId( tag3.getString() );
+					break;
+				case 4:
+				    DERGeneralString tag4 = (DERGeneralString)derObject;
+					modifier.setSamChallengeLabel( tag4.getString() );
+					break;
+				case 5:
+				    DERGeneralString tag5 = (DERGeneralString)derObject;
+					modifier.setSamChallenge( tag5.getString() );
+					break;
+				case 6:
+				    DERGeneralString tag6 = (DERGeneralString)derObject;
+					modifier.setSamResponsePrompt( tag6.getString() );
+					break;
+				case 7:
+					DEROctetString tag7 = (DEROctetString)derObject;
+					modifier.setSamPkForSad( tag7.getOctets() );
+					break;
+				case 8:
+				    DERInteger tag8 = (DERInteger)derObject;
+					modifier.setSamNonce( tag8.intValue() );
+					break;
+				case 9:
+				    DERInteger tag9 = (DERInteger)derObject;
+					modifier.setSamEncryptionType( tag9.intValue() );
+					break;
+			    default:
+			    	System.out.println( derObject );
+			    	break;
+			}
+		}
+	}
+}
+

Added: directory/sandbox/trunk/kerberos-sam/trunk/sam/src/main/java/org/apache/kerberos/sam/io/SamChallengeEncoder.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/kerberos-sam/trunk/sam/src/main/java/org/apache/kerberos/sam/io/SamChallengeEncoder.java?rev=178151&view=auto
==============================================================================
--- directory/sandbox/trunk/kerberos-sam/trunk/sam/src/main/java/org/apache/kerberos/sam/io/SamChallengeEncoder.java (added)
+++ directory/sandbox/trunk/kerberos-sam/trunk/sam/src/main/java/org/apache/kerberos/sam/io/SamChallengeEncoder.java Tue May 24 03:30:35 2005
@@ -0,0 +1,144 @@
+/*
+ *   Copyright 2005 The Apache Software Foundation
+ *
+ *   Licensed 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.
+ *
+ */
+
+package org.apache.kerberos.sam.io;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+
+import org.apache.asn1.der.ASN1OutputStream;
+import org.apache.asn1.der.DERBitString;
+import org.apache.asn1.der.DERGeneralString;
+import org.apache.asn1.der.DERInteger;
+import org.apache.asn1.der.DEROctetString;
+import org.apache.asn1.der.DERSequence;
+import org.apache.asn1.der.DERTaggedObject;
+import org.apache.kerberos.io.encoder.ChecksumEncoder;
+import org.apache.kerberos.messages.value.Checksum;
+import org.apache.kerberos.sam.messages.SamChallenge;
+
+
+public class SamChallengeEncoder
+{
+	public byte[] encode( SamChallenge samChallenge ) throws IOException
+	{
+		ByteArrayOutputStream baos = new ByteArrayOutputStream();
+		ASN1OutputStream aos = new ASN1OutputStream( baos );
+		
+		aos.writeObject( encodeSamChallenge( samChallenge ) );
+		aos.close();
+		
+		return baos.toByteArray();
+	}
+    
+    /**
+     *  PA-SAM-CHALLENGE-2 ::= SEQUENCE {
+     *      sam-body[0]                 PA-SAM-CHALLENGE-2-BODY,
+     *      sam-cksum[1]                SEQUENCE (1..MAX) OF Checksum,
+     *      ...
+     *  }
+     */
+	private DERSequence encodeSamChallenge( SamChallenge samChallenge )
+	{
+		DERSequence sequence = new DERSequence();
+		
+		sequence.add( new DERTaggedObject( 0, encodeSamChallengeBody( samChallenge ) ) );
+		sequence.add( new DERTaggedObject( 1, encodeChecksums( samChallenge.getSamChecksums() ) ) );
+		
+		return sequence;
+	}
+    
+    /**
+     *  PA-SAM-CHALLENGE-2-BODY ::= SEQUENCE {
+     *      sam-type[0]                 INTEGER (0..4294967295),
+     *      sam-flags[1]                SAMFlags,
+     *      sam-type-name[2]            GeneralString OPTIONAL,
+     *      sam-track-id[3]             GeneralString OPTIONAL,
+     *                                    -- Key usage of 26
+     *      sam-challenge-label[4]      GeneralString OPTIONAL,
+     *      sam-challenge[5]            GeneralString OPTIONAL,
+     *      sam-response-prompt[6]      GeneralString OPTIONAL,
+     *      sam-pk-for-sad[7]           OCTET STRING OPTIONAL,
+     *      sam-nonce[8]                INTEGER (0..4294967295),
+     *      sam-etype[9]                INTEGER (0..4294967295),
+     *      ...
+     *  }
+     */
+	private DERSequence encodeSamChallengeBody( SamChallenge samChallenge )
+	{
+		DERSequence sequence = new DERSequence();
+		
+		sequence.add( new DERTaggedObject( 0, DERInteger.valueOf( samChallenge.getSamType() ) ) );
+		
+		/**
+		 * SAMFlags ::= BIT STRING (SIZE (32..MAX))
+	     *     -- use-sad-as-key(0)
+	     *     -- send-encrypted-sad(1)
+	     *     -- must-pk-encrypt-sad(2)
+		 */
+		sequence.add( new DERTaggedObject( 1, new DERBitString( samChallenge.getSamFlags().getBytes() ) ) );
+		
+		if ( samChallenge.getSamTypeName() !=  null)
+		{
+		    sequence.add( new DERTaggedObject( 2, DERGeneralString.valueOf( samChallenge.getSamTypeName() ) ) );
+		}
+		
+		if ( samChallenge.getSamTrackId() !=  null)
+		{
+		    sequence.add( new DERTaggedObject( 3, DERGeneralString.valueOf( samChallenge.getSamTrackId() ) ) );
+		}
+		
+		if ( samChallenge.getSamChallengeLabel() !=  null)
+		{
+		    sequence.add( new DERTaggedObject( 4, DERGeneralString.valueOf( samChallenge.getSamChallengeLabel() ) ) );
+		}
+		
+		if ( samChallenge.getSamChallenge() !=  null)
+		{
+		    sequence.add( new DERTaggedObject( 5, DERGeneralString.valueOf( samChallenge.getSamChallenge() ) ) );
+		}
+		
+		if ( samChallenge.getSamResponsePrompt() !=  null)
+		{
+		    sequence.add( new DERTaggedObject( 6, DERGeneralString.valueOf( samChallenge.getSamResponsePrompt() ) ) );
+		}
+		
+		if ( samChallenge.getSamPkForSad() != null )
+		{
+		    sequence.add(new DERTaggedObject( 7, new DEROctetString( samChallenge.getSamPkForSad() ) ) );
+		}
+		
+		sequence.add( new DERTaggedObject( 8, DERInteger.valueOf( samChallenge.getSamNonce() ) ) );
+		
+		sequence.add( new DERTaggedObject( 9, DERInteger.valueOf( samChallenge.getSamEncryptionType() ) ) );
+		
+		return sequence;
+	}
+	
+	private DERSequence encodeChecksums( Checksum[] checksums )
+	{
+		DERSequence checksumSequence = new DERSequence();
+		
+		for ( int ii = 0; ii < checksums.length; ii++ )
+		{
+			checksumSequence.add( ChecksumEncoder.encode( checksums[ii] ) );
+		}
+		
+		return checksumSequence;
+	}
+}
+

Added: directory/sandbox/trunk/kerberos-sam/trunk/sam/src/main/java/org/apache/kerberos/sam/io/SamResponseDecoder.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/kerberos-sam/trunk/sam/src/main/java/org/apache/kerberos/sam/io/SamResponseDecoder.java?rev=178151&view=auto
==============================================================================
--- directory/sandbox/trunk/kerberos-sam/trunk/sam/src/main/java/org/apache/kerberos/sam/io/SamResponseDecoder.java (added)
+++ directory/sandbox/trunk/kerberos-sam/trunk/sam/src/main/java/org/apache/kerberos/sam/io/SamResponseDecoder.java Tue May 24 03:30:35 2005
@@ -0,0 +1,100 @@
+/*
+ *   Copyright 2005 The Apache Software Foundation
+ *
+ *   Licensed 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.
+ *
+ */
+
+package org.apache.kerberos.sam.io;
+
+import java.io.IOException;
+import java.util.Enumeration;
+
+import org.apache.asn1.der.ASN1InputStream;
+import org.apache.asn1.der.DERBitString;
+import org.apache.asn1.der.DEREncodable;
+import org.apache.asn1.der.DERGeneralString;
+import org.apache.asn1.der.DERInteger;
+import org.apache.asn1.der.DERSequence;
+import org.apache.asn1.der.DERTaggedObject;
+import org.apache.kerberos.io.decoder.EncryptedDataDecoder;
+import org.apache.kerberos.sam.messages.SamFlags;
+import org.apache.kerberos.sam.messages.SamResponse;
+import org.apache.kerberos.sam.messages.SamResponseModifier;
+
+
+public class SamResponseDecoder
+{
+    public SamResponse decode( byte[] encodedSamResponse ) throws IOException
+    {
+    	ASN1InputStream ais = new ASN1InputStream( encodedSamResponse );
+    	
+    	DERSequence sequence = (DERSequence) ais.readObject();
+    	
+    	return decodeSamResponse( sequence );
+    }
+    
+    /**
+     *  PA-SAM-RESPONSE-2 ::= SEQUENCE {
+     *      sam-type[0]                 INTEGER (0..4294967295),
+     *      sam-flags[1]                SAMFlags,
+     *      sam-track-id[2]             GeneralString OPTIONAL,
+     *      sam-enc-nonce-or-sad[3]     EncryptedData,
+     *                                     -- PA-ENC-SAM-RESPONSE-ENC
+     *                                     -- Key usage of 27
+     *      sam-nonce[4]                INTEGER (0..4294967295),
+     *      ...
+     *  }
+     */
+    private SamResponse decodeSamResponse( DERSequence sequence )
+    {
+    	SamResponseModifier modifier = new SamResponseModifier();
+    	
+    	for ( Enumeration e = sequence.getObjects(); e.hasMoreElements(); )
+    	{
+    		DERTaggedObject object = (DERTaggedObject) e.nextElement();
+    		int tag = object.getTagNo();
+    		DEREncodable derObject = object.getObject();
+    		
+    		switch ( tag )
+    		{
+    			case 0:
+    				DERInteger tag0 = (DERInteger)derObject;
+    				modifier.setSamType( tag0.intValue() );
+    				break;
+    			case 1:
+    			    DERBitString tag1 = (DERBitString)derObject;
+    				modifier.setSamFlags( new SamFlags( tag1.getOctets() ) );
+    				break;
+    			case 2:
+    				DERGeneralString tag2 = (DERGeneralString)derObject;
+    				modifier.setSamTrackId( tag2.getString() );
+    				break;
+    			case 3:
+    			    DERSequence tag3 = (DERSequence)derObject;
+    				modifier.setSamEncryptedData( EncryptedDataDecoder.decode( tag3 ) );
+    				break;
+    			case 4:
+    			    DERInteger tag4 = (DERInteger)derObject;
+    				modifier.setSamNonce( tag4.intValue() );
+    				break;
+    		    default:
+    		    	System.out.println( derObject );
+    		    	break;
+    		}
+    	}
+    	
+    	return modifier.getSamResponse();
+    }
+}
+

Added: directory/sandbox/trunk/kerberos-sam/trunk/sam/src/main/java/org/apache/kerberos/sam/io/SamResponseEncoder.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/kerberos-sam/trunk/sam/src/main/java/org/apache/kerberos/sam/io/SamResponseEncoder.java?rev=178151&view=auto
==============================================================================
--- directory/sandbox/trunk/kerberos-sam/trunk/sam/src/main/java/org/apache/kerberos/sam/io/SamResponseEncoder.java (added)
+++ directory/sandbox/trunk/kerberos-sam/trunk/sam/src/main/java/org/apache/kerberos/sam/io/SamResponseEncoder.java Tue May 24 03:30:35 2005
@@ -0,0 +1,81 @@
+/*
+ *   Copyright 2005 The Apache Software Foundation
+ *
+ *   Licensed 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.
+ *
+ */
+
+package org.apache.kerberos.sam.io;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+
+import org.apache.asn1.der.ASN1OutputStream;
+import org.apache.asn1.der.DERBitString;
+import org.apache.asn1.der.DERGeneralString;
+import org.apache.asn1.der.DERInteger;
+import org.apache.asn1.der.DERSequence;
+import org.apache.asn1.der.DERTaggedObject;
+import org.apache.kerberos.io.encoder.EncryptedDataEncoder;
+import org.apache.kerberos.sam.messages.SamResponse;
+
+
+public class SamResponseEncoder
+{
+	public byte[] encode( SamResponse samResponse ) throws IOException
+	{
+		ByteArrayOutputStream baos = new ByteArrayOutputStream();
+		ASN1OutputStream aos = new ASN1OutputStream( baos );
+		
+		aos.writeObject( encodeSamResponse( samResponse ) );
+		aos.close();
+		
+		return baos.toByteArray();
+	}
+	
+	/**
+	 *  PA-SAM-RESPONSE-2 ::= SEQUENCE {
+	 *      sam-type[0]                 INTEGER (0..4294967295),
+	 *      sam-flags[1]                SAMFlags,
+	 *      sam-track-id[2]             GeneralString OPTIONAL,
+	 *      sam-enc-nonce-or-sad[3]     EncryptedData,
+	 *                                     -- PA-ENC-SAM-RESPONSE-ENC
+	 *                                     -- Key usage of 27
+	 *      sam-nonce[4]                INTEGER (0..4294967295),
+	 *      ...
+	 *  }
+	 */
+	private DERSequence encodeSamResponse( SamResponse samResponse )
+	{
+		DERSequence sequence = new DERSequence();
+		
+		sequence.add( new DERTaggedObject( 0, DERInteger.valueOf( samResponse.getSamType() ) ) );
+		
+		/**
+		 * SAMFlags ::= BIT STRING (SIZE (32..MAX))
+	     *     -- use-sad-as-key(0)
+	     *     -- send-encrypted-sad(1)
+	     *     -- must-pk-encrypt-sad(2)
+		 */
+		sequence.add( new DERTaggedObject( 1, new DERBitString( samResponse.getSamFlags().getBytes() ) ) );
+
+		sequence.add( new DERTaggedObject( 2, DERGeneralString.valueOf( samResponse.getSamTrackId() ) ) );
+		
+		sequence.add( new DERTaggedObject( 3, EncryptedDataEncoder.encodeSequence( samResponse.getSamEncryptedData() ) ) );
+		
+		sequence.add( new DERTaggedObject( 4, DERInteger.valueOf( samResponse.getSamNonce() ) ) );
+		
+		return sequence;
+	}
+}
+

Added: directory/sandbox/trunk/kerberos-sam/trunk/sam/src/main/java/org/apache/kerberos/sam/messages/EncryptedSamResponse.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/kerberos-sam/trunk/sam/src/main/java/org/apache/kerberos/sam/messages/EncryptedSamResponse.java?rev=178151&view=auto
==============================================================================
--- directory/sandbox/trunk/kerberos-sam/trunk/sam/src/main/java/org/apache/kerberos/sam/messages/EncryptedSamResponse.java (added)
+++ directory/sandbox/trunk/kerberos-sam/trunk/sam/src/main/java/org/apache/kerberos/sam/messages/EncryptedSamResponse.java Tue May 24 03:30:35 2005
@@ -0,0 +1,56 @@
+/*
+ *   Copyright 2005 The Apache Software Foundation
+ *
+ *   Licensed 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.
+ *
+ */
+
+package org.apache.kerberos.sam.messages;
+
+/**
+ *  PA-ENC-SAM-RESPONSE-ENC ::= SEQUENCE {
+ *       sam-nonce[0]               INTEGER (0..4294967295),
+ *       sam-sad[1]                 GeneralString OPTIONAL,
+ *       ...
+ *  }
+ */
+public class EncryptedSamResponse
+{
+    private int    samNonce;
+    private String samSad;
+    
+    
+    public EncryptedSamResponse( int samNonce, String samSad )
+    {
+        this.samNonce = samNonce;
+        this.samSad   = samSad;
+    }
+    
+    
+    /**
+     * @return Returns the samNonce.
+     */
+    public int getSamNonce()
+    {
+        return samNonce;
+    }
+    
+    /**
+     * @return Returns the samSad.
+     */
+    public String getSamSad()
+    {
+        return samSad;
+    }
+}
+

Added: directory/sandbox/trunk/kerberos-sam/trunk/sam/src/main/java/org/apache/kerberos/sam/messages/EncryptedSamResponseModifier.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/kerberos-sam/trunk/sam/src/main/java/org/apache/kerberos/sam/messages/EncryptedSamResponseModifier.java?rev=178151&view=auto
==============================================================================
--- directory/sandbox/trunk/kerberos-sam/trunk/sam/src/main/java/org/apache/kerberos/sam/messages/EncryptedSamResponseModifier.java (added)
+++ directory/sandbox/trunk/kerberos-sam/trunk/sam/src/main/java/org/apache/kerberos/sam/messages/EncryptedSamResponseModifier.java Tue May 24 03:30:35 2005
@@ -0,0 +1,53 @@
+/*
+ *   Copyright 2005 The Apache Software Foundation
+ *
+ *   Licensed 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.
+ *
+ */
+
+package org.apache.kerberos.sam.messages;
+
+/**
+ *  PA-ENC-SAM-RESPONSE-ENC ::= SEQUENCE {
+ *       sam-nonce[0]               INTEGER (0..4294967295),
+ *       sam-sad[1]                 GeneralString OPTIONAL,
+ *       ...
+ *  }
+ */
+public class EncryptedSamResponseModifier
+{
+    private int    samNonce;
+    private String samSad;
+    
+    public EncryptedSamResponse getEncryptedSamResponse()
+    {
+        return new EncryptedSamResponse( samNonce, samSad );
+    }
+    
+    /**
+     * @param samNonce The samNonce to set.
+     */
+    public void setSamNonce( int samNonce )
+    {
+        this.samNonce = samNonce;
+    }
+    
+    /**
+     * @param samSad The samSad to set.
+     */
+    public void setSamSad( String samSad )
+    {
+        this.samSad = samSad;
+    }
+}
+

Added: directory/sandbox/trunk/kerberos-sam/trunk/sam/src/main/java/org/apache/kerberos/sam/messages/SamChallenge.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/kerberos-sam/trunk/sam/src/main/java/org/apache/kerberos/sam/messages/SamChallenge.java?rev=178151&view=auto
==============================================================================
--- directory/sandbox/trunk/kerberos-sam/trunk/sam/src/main/java/org/apache/kerberos/sam/messages/SamChallenge.java (added)
+++ directory/sandbox/trunk/kerberos-sam/trunk/sam/src/main/java/org/apache/kerberos/sam/messages/SamChallenge.java Tue May 24 03:30:35 2005
@@ -0,0 +1,167 @@
+/*
+ *   Copyright 2005 The Apache Software Foundation
+ *
+ *   Licensed 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.
+ *
+ */
+
+package org.apache.kerberos.sam.messages;
+
+import org.apache.kerberos.messages.value.Checksum;
+
+/**
+ *        PA-SAM-CHALLENGE-2 ::= SEQUENCE {
+ *            sam-body[0]                 PA-SAM-CHALLENGE-2-BODY,
+ *            sam-cksum[1]                SEQUENCE (1..MAX) OF Checksum,
+ *            ...
+ *        }
+ * 
+ *        PA-SAM-CHALLENGE-2-BODY ::= SEQUENCE {
+ *            sam-type[0]                 INTEGER (0..4294967295),
+ *            sam-flags[1]                SAMFlags,
+ *            sam-type-name[2]            GeneralString OPTIONAL,
+ *            sam-track-id[3]             GeneralString OPTIONAL,
+ *                                          -- Key usage of 26
+ *            sam-challenge-label[4]      GeneralString OPTIONAL,
+ *            sam-challenge[5]            GeneralString OPTIONAL,
+ *            sam-response-prompt[6]      GeneralString OPTIONAL,
+ *            sam-pk-for-sad[7]           OCTET STRING OPTIONAL,
+ *            sam-nonce[8]                INTEGER (0..4294967295),
+ *            sam-etype[9]                INTEGER (0..4294967295),
+ *            ...
+ *        }
+ */
+public class SamChallenge
+{
+    private int      samType;
+    private SamFlags samFlags;
+    private String   samTypeName;
+    private String   samTrackId;
+    private String   samChallengeLabel;
+    private String   samChallenge;
+    private String   samResponsePrompt;
+    private byte[]   samPkForSad;
+    private int      samNonce;
+    private int      samEncryptionType;
+    
+    private Checksum[] samChecksums;
+    
+    
+    public SamChallenge( int samType, SamFlags samFlags, String samTypeName,
+            String samTrackId, String samChallengeLabel, String samChallenge,
+            String samResponsePrompt, byte[] samPkForSad, int samNonce,
+            int samEncryptionType, Checksum[] samChecksums )
+    {
+        this.samType           = samType;
+        this.samFlags          = samFlags;
+        this.samTypeName       = samTypeName;
+        this.samTrackId        = samTrackId;
+        this.samChallengeLabel = samChallengeLabel;
+        this.samChallenge      = samChallenge;
+        this.samResponsePrompt = samResponsePrompt;
+        this.samPkForSad       = samPkForSad;
+        this.samNonce          = samNonce;
+        this.samEncryptionType = samEncryptionType;
+        this.samChecksums      = samChecksums;
+    }
+    
+    
+    /**
+     * @return Returns the samChallenge.
+     */
+    public String getSamChallenge()
+    {
+        return samChallenge;
+    }
+    
+    /**
+     * @return Returns the samChallengeLabel.
+     */
+    public String getSamChallengeLabel()
+    {
+        return samChallengeLabel;
+    }
+    
+    /**
+     * @return Returns the samEncryptionType.
+     */
+    public int getSamEncryptionType()
+    {
+        return samEncryptionType;
+    }
+    
+    /**
+     * @return Returns the samFlags.
+     */
+    public SamFlags getSamFlags()
+    {
+        return samFlags;
+    }
+    
+    /**
+     * @return Returns the samNonce.
+     */
+    public int getSamNonce()
+    {
+        return samNonce;
+    }
+    
+    /**
+     * @return Returns the samPkForSad.
+     */
+    public byte[] getSamPkForSad()
+    {
+        return samPkForSad;
+    }
+    
+    /**
+     * @return Returns the samResponsePrompt.
+     */
+    public String getSamResponsePrompt()
+    {
+        return samResponsePrompt;
+    }
+    
+    /**
+     * @return Returns the samTrackId.
+     */
+    public String getSamTrackId()
+    {
+        return samTrackId;
+    }
+    
+    /**
+     * @return Returns the samType.
+     */
+    public int getSamType()
+    {
+        return samType;
+    }
+    
+    /**
+     * @return Returns the samTypeName.
+     */
+    public String getSamTypeName()
+    {
+        return samTypeName;
+    }
+    
+    /**
+     * @return Returns the samChecksums.
+     */
+    public Checksum[] getSamChecksums()
+    {
+        return samChecksums;
+    }
+}
+

Added: directory/sandbox/trunk/kerberos-sam/trunk/sam/src/main/java/org/apache/kerberos/sam/messages/SamChallengeModifier.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/kerberos-sam/trunk/sam/src/main/java/org/apache/kerberos/sam/messages/SamChallengeModifier.java?rev=178151&view=auto
==============================================================================
--- directory/sandbox/trunk/kerberos-sam/trunk/sam/src/main/java/org/apache/kerberos/sam/messages/SamChallengeModifier.java (added)
+++ directory/sandbox/trunk/kerberos-sam/trunk/sam/src/main/java/org/apache/kerberos/sam/messages/SamChallengeModifier.java Tue May 24 03:30:35 2005
@@ -0,0 +1,159 @@
+/*
+ *   Copyright 2005 The Apache Software Foundation
+ *
+ *   Licensed 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.
+ *
+ */
+
+package org.apache.kerberos.sam.messages;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.kerberos.messages.value.Checksum;
+
+/**
+ *        PA-SAM-CHALLENGE-2 ::= SEQUENCE {
+ *            sam-body[0]                 PA-SAM-CHALLENGE-2-BODY,
+ *            sam-cksum[1]                SEQUENCE (1..MAX) OF Checksum,
+ *            ...
+ *        }
+ * 
+ *        PA-SAM-CHALLENGE-2-BODY ::= SEQUENCE {
+ *            sam-type[0]                 INTEGER (0..4294967295),
+ *            sam-flags[1]                SAMFlags,
+ *            sam-type-name[2]            GeneralString OPTIONAL,
+ *            sam-track-id[3]             GeneralString OPTIONAL,
+ *                                          -- Key usage of 26
+ *            sam-challenge-label[4]      GeneralString OPTIONAL,
+ *            sam-challenge[5]            GeneralString OPTIONAL,
+ *            sam-response-prompt[6]      GeneralString OPTIONAL,
+ *            sam-pk-for-sad[7]           OCTET STRING OPTIONAL,
+ *            sam-nonce[8]                INTEGER (0..4294967295),
+ *            sam-etype[9]                INTEGER (0..4294967295),
+ *            ...
+ *        }
+ */
+public class SamChallengeModifier
+{
+    private int      samType;
+    private SamFlags samFlags;
+    private String   samTypeName;
+    private String   samTrackId;
+    private String   samChallengeLabel;
+    private String   samChallenge;
+    private String   samResponsePrompt;
+    private byte[]   samPkForSad;
+    private int      samNonce;
+    private int      samEncryptionType;
+    
+    private List checksums = new ArrayList();
+    
+    public SamChallenge getSamChallenge()
+    {
+		Checksum[] samChecksums = (Checksum[])checksums.toArray( new Checksum[ checksums.size() ] );
+        
+        return new SamChallenge( samType, samFlags, samTypeName, samTrackId,
+                samChallengeLabel, samChallenge, samResponsePrompt,
+                samPkForSad, samNonce, samEncryptionType, samChecksums );
+    }
+    
+    /**
+     * @param samChallenge The samChallenge to set.
+     */
+    public void setSamChallenge( String samChallenge )
+    {
+        this.samChallenge = samChallenge;
+    }
+    
+    /**
+     * @param samChallengeLabel The samChallengeLabel to set.
+     */
+    public void setSamChallengeLabel( String samChallengeLabel )
+    {
+        this.samChallengeLabel = samChallengeLabel;
+    }
+    
+    /**
+     * @param samEncryptionType The samEncryptionType to set.
+     */
+    public void setSamEncryptionType( int samEncryptionType )
+    {
+        this.samEncryptionType = samEncryptionType;
+    }
+    
+    /**
+     * @param samFlags The samFlags to set.
+     */
+    public void setSamFlags( SamFlags samFlags )
+    {
+        this.samFlags = samFlags;
+    }
+    
+    /**
+     * @param samNonce The samNonce to set.
+     */
+    public void setSamNonce( int samNonce )
+    {
+        this.samNonce = samNonce;
+    }
+    
+    /**
+     * @param samPkForSad The samPkForSad to set.
+     */
+    public void setSamPkForSad( byte[] samPkForSad )
+    {
+        this.samPkForSad = samPkForSad;
+    }
+    
+    /**
+     * @param samResponsePrompt The samResponsePrompt to set.
+     */
+    public void setSamResponsePrompt( String samResponsePrompt )
+    {
+        this.samResponsePrompt = samResponsePrompt;
+    }
+    
+    /**
+     * @param samTrackId The samTrackId to set.
+     */
+    public void setSamTrackId( String samTrackId )
+    {
+        this.samTrackId = samTrackId;
+    }
+    
+    /**
+     * @param samType The samType to set.
+     */
+    public void setSamType( int samType )
+    {
+        this.samType = samType;
+    }
+    
+    /**
+     * @param samTypeName The samTypeName to set.
+     */
+    public void setSamTypeName( String samTypeName )
+    {
+        this.samTypeName = samTypeName;
+    }
+    
+    /**
+     * @param Checksum The Checksum to add.
+     */
+    public void addChecksum( Checksum checksum )
+    {
+        this.checksums.add( checksum );
+    }
+}
+

Added: directory/sandbox/trunk/kerberos-sam/trunk/sam/src/main/java/org/apache/kerberos/sam/messages/SamFlags.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/kerberos-sam/trunk/sam/src/main/java/org/apache/kerberos/sam/messages/SamFlags.java?rev=178151&view=auto
==============================================================================
--- directory/sandbox/trunk/kerberos-sam/trunk/sam/src/main/java/org/apache/kerberos/sam/messages/SamFlags.java (added)
+++ directory/sandbox/trunk/kerberos-sam/trunk/sam/src/main/java/org/apache/kerberos/sam/messages/SamFlags.java Tue May 24 03:30:35 2005
@@ -0,0 +1,71 @@
+/*
+ *   Copyright 2005 The Apache Software Foundation
+ *
+ *   Licensed 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.
+ *
+ */
+
+package org.apache.kerberos.sam.messages;
+
+import org.apache.kerberos.messages.value.Options;
+
+/**
+ *  SAMFlags ::= BIT STRING (SIZE (32..MAX))
+ *      -- use-sad-as-key(0)
+ *      -- send-encrypted-sad(1)
+ *      -- must-pk-encrypt-sad(2)
+ */
+public class SamFlags extends Options
+{
+    // SAM flag - use the data as the key
+	public static final int USE_SAD_AS_KEY      = 0;
+    // SAM flag - request that encrypted authentication data be returned
+	public static final int SEND_ENCRYPTED_SAD  = 1;
+    // SAM flag - reserved for future use
+	public static final int MUST_PK_ENCRYPT_SAD = 2;
+	
+    // SAM flag - maximum value
+	public static final int MAX_VALUE           = 32;
+	
+    /**
+     * Class constructors
+     */
+	public SamFlags()
+	{
+		super( MAX_VALUE );
+	}
+	
+	public SamFlags( byte[] options )
+	{
+		super( MAX_VALUE );
+		setBytes( options );
+	}
+	
+	/**
+	 * Converts the object to a printable string
+	 */
+	public String toString()
+	{
+		StringBuffer result = new StringBuffer();
+		
+		if ( get( USE_SAD_AS_KEY ) )
+			result.append( "USE_SAD_AS_KEY " );
+		if ( get( SEND_ENCRYPTED_SAD ) )
+			result.append( "SEND_ENCRYPTED_SAD " );
+		if ( get( MUST_PK_ENCRYPT_SAD ) )
+			result.append( "MUST_PK_ENCRYPT_SAD " );
+		
+		return result.toString().trim();
+	}
+}
+

Added: directory/sandbox/trunk/kerberos-sam/trunk/sam/src/main/java/org/apache/kerberos/sam/messages/SamResponse.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/kerberos-sam/trunk/sam/src/main/java/org/apache/kerberos/sam/messages/SamResponse.java?rev=178151&view=auto
==============================================================================
--- directory/sandbox/trunk/kerberos-sam/trunk/sam/src/main/java/org/apache/kerberos/sam/messages/SamResponse.java (added)
+++ directory/sandbox/trunk/kerberos-sam/trunk/sam/src/main/java/org/apache/kerberos/sam/messages/SamResponse.java Tue May 24 03:30:35 2005
@@ -0,0 +1,94 @@
+/*
+ *   Copyright 2005 The Apache Software Foundation
+ *
+ *   Licensed 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.
+ *
+ */
+
+package org.apache.kerberos.sam.messages;
+
+import org.apache.kerberos.messages.value.EncryptedData;
+
+/**
+ *  PA-SAM-RESPONSE-2 ::= SEQUENCE {
+ *      sam-type[0]                 INTEGER (0..4294967295),
+ *      sam-flags[1]                SAMFlags,
+ *      sam-track-id[2]             GeneralString OPTIONAL,
+ *      sam-enc-nonce-or-sad[3]     EncryptedData,
+ *                                     -- PA-ENC-SAM-RESPONSE-ENC
+ *                                     -- Key usage of 27
+ *      sam-nonce[4]                INTEGER (0..4294967295),
+ *      ...
+ *  }
+ */
+public class SamResponse
+{
+    private int           samType;
+    private SamFlags      samFlags;
+    private String        samTrackId;
+    private EncryptedData samEncryptedData;
+    private int           samNonce;
+    
+    
+    public SamResponse( int samType, SamFlags samFlags, String samTrackId,
+            EncryptedData samEncryptedData, int samNonce )
+    {
+        this.samType          = samType;
+        this.samFlags         = samFlags;
+        this.samTrackId       = samTrackId;
+        this.samEncryptedData = samEncryptedData;
+        this.samNonce         = samNonce;
+    }
+    
+    
+    /**
+     * @return Returns the samEncryptedData.
+     */
+    public EncryptedData getSamEncryptedData()
+    {
+        return samEncryptedData;
+    }
+    
+    /**
+     * @return Returns the samFlags.
+     */
+    public SamFlags getSamFlags()
+    {
+        return samFlags;
+    }
+    
+    /**
+     * @return Returns the samNonce.
+     */
+    public int getSamNonce()
+    {
+        return samNonce;
+    }
+    
+    /**
+     * @return Returns the samTrackId.
+     */
+    public String getSamTrackId()
+    {
+        return samTrackId;
+    }
+    
+    /**
+     * @return Returns the samType.
+     */
+    public int getSamType()
+    {
+        return samType;
+    }
+}
+

Added: directory/sandbox/trunk/kerberos-sam/trunk/sam/src/main/java/org/apache/kerberos/sam/messages/SamResponseModifier.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/kerberos-sam/trunk/sam/src/main/java/org/apache/kerberos/sam/messages/SamResponseModifier.java?rev=178151&view=auto
==============================================================================
--- directory/sandbox/trunk/kerberos-sam/trunk/sam/src/main/java/org/apache/kerberos/sam/messages/SamResponseModifier.java (added)
+++ directory/sandbox/trunk/kerberos-sam/trunk/sam/src/main/java/org/apache/kerberos/sam/messages/SamResponseModifier.java Tue May 24 03:30:35 2005
@@ -0,0 +1,89 @@
+/*
+ *   Copyright 2005 The Apache Software Foundation
+ *
+ *   Licensed 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.
+ *
+ */
+
+package org.apache.kerberos.sam.messages;
+
+import org.apache.kerberos.messages.value.EncryptedData;
+
+/**
+ *  PA-SAM-RESPONSE-2 ::= SEQUENCE {
+ *      sam-type[0]                 INTEGER (0..4294967295),
+ *      sam-flags[1]                SAMFlags,
+ *      sam-track-id[2]             GeneralString OPTIONAL,
+ *      sam-enc-nonce-or-sad[3]     EncryptedData,
+ *                                     -- PA-ENC-SAM-RESPONSE-ENC
+ *                                     -- Key usage of 27
+ *      sam-nonce[4]                INTEGER (0..4294967295),
+ *      ...
+ *  }
+ */
+public class SamResponseModifier
+{
+    private int           samType;
+    private SamFlags      samFlags;
+    private String        samTrackId;
+    private EncryptedData samEncryptedData;
+    private int           samNonce;
+    
+    
+    public SamResponse getSamResponse()
+    {
+        return new SamResponse( samType, samFlags, samTrackId,
+                samEncryptedData, samNonce );
+    }
+    
+    /**
+     * @param samEncryptedData The samEncryptedData to set.
+     */
+    public void setSamEncryptedData( EncryptedData samEncryptedData )
+    {
+        this.samEncryptedData = samEncryptedData;
+    }
+    
+    /**
+     * @param samFlags The samFlags to set.
+     */
+    public void setSamFlags( SamFlags samFlags )
+    {
+        this.samFlags = samFlags;
+    }
+    
+    /**
+     * @param samNonce The samNonce to set.
+     */
+    public void setSamNonce( int samNonce )
+    {
+        this.samNonce = samNonce;
+    }
+    
+    /**
+     * @param samTrackId The samTrackId to set.
+     */
+    public void setSamTrackId( String samTrackId )
+    {
+        this.samTrackId = samTrackId;
+    }
+    
+    /**
+     * @param samType The samType to set.
+     */
+    public void setSamType( int samType )
+    {
+        this.samType = samType;
+    }
+}
+



Mime
View raw message