Return-Path: Delivered-To: apmail-incubator-directory-cvs-archive@www.apache.org Received: (qmail 4672 invoked from network); 3 Feb 2005 18:49:11 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 3 Feb 2005 18:49:11 -0000 Received: (qmail 85259 invoked by uid 500); 3 Feb 2005 18:49:11 -0000 Delivered-To: apmail-incubator-directory-cvs-archive@incubator.apache.org Received: (qmail 85226 invoked by uid 500); 3 Feb 2005 18:49:11 -0000 Mailing-List: contact directory-cvs-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: directory-dev@incubator.apache.org Delivered-To: mailing list directory-cvs@incubator.apache.org Received: (qmail 85213 invoked by uid 99); 3 Feb 2005 18:49:11 -0000 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from minotaur.apache.org (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.28) with SMTP; Thu, 03 Feb 2005 10:49:10 -0800 Received: (qmail 4642 invoked by uid 65534); 3 Feb 2005 18:49:09 -0000 Message-ID: <20050203184909.4641.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Mailer: svnmailer-1.0.0-dev Date: Thu, 03 Feb 2005 18:49:09 -0000 Subject: svn commit: r151204 - in incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io: decoder/EncryptedTimestampDecoder.java encoder/EncryptedDataEncoder.java To: directory-cvs@incubator.apache.org From: erodriguez@apache.org X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Author: erodriguez Date: Thu Feb 3 10:49:07 2005 New Revision: 151204 URL: http://svn.apache.org/viewcvs?view=3Drev&rev=3D151204 Log: More codec work. Added: incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io= /encoder/EncryptedDataEncoder.java Modified: incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io= /decoder/EncryptedTimestampDecoder.java Modified: incubator/directory/kerberos/trunk/core/src/java/org/apache/kerbe= ros/io/decoder/EncryptedTimestampDecoder.java URL: http://svn.apache.org/viewcvs/incubator/directory/kerberos/trunk/core/= src/java/org/apache/kerberos/io/decoder/EncryptedTimestampDecoder.java?view= =3Ddiff&r1=3D151203&r2=3D151204 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io= /decoder/EncryptedTimestampDecoder.java (original) +++ incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io= /decoder/EncryptedTimestampDecoder.java Thu Feb 3 10:49:07 2005 @@ -44,7 +44,11 @@ { ASN1InputStream ais =3D new ASN1InputStream( encodedEncryptedTimestamp ); =09 - DERSequence sequence =3D (DERSequence) ais.readObject(); + Object obj =3D ais.readObject(); + =09 + System.out.println( "Class to be cast to " + obj ); + =09 + DERSequence sequence =3D (DERSequence) obj; =09 return decodeEncryptedTimestamp( sequence ); } Added: incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos= /io/encoder/EncryptedDataEncoder.java URL: http://svn.apache.org/viewcvs/incubator/directory/kerberos/trunk/core/= src/java/org/apache/kerberos/io/encoder/EncryptedDataEncoder.java?view=3Dau= to&rev=3D151204 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io= /encoder/EncryptedDataEncoder.java (added) +++ incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/io= /encoder/EncryptedDataEncoder.java Thu Feb 3 10:49:07 2005 @@ -0,0 +1,67 @@ +/* + * 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 impli= ed. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.kerberos.io.encoder; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; + +import org.apache.asn1.der.ASN1OutputStream; +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.messages.value.EncryptedData; + + +public class EncryptedDataEncoder +{ + public byte[] encode( EncryptedData encryptedData ) throws IOException + { + ByteArrayOutputStream baos =3D new ByteArrayOutputStream(); + ASN1OutputStream aos =3D new ASN1OutputStream( baos ); + =09 + aos.writeObject( encodeEncryptedData( encryptedData ) ); + aos.close(); + + return baos.toByteArray(); + } +=09 + /** + * EncryptedData ::=3D SEQUENCE { + * etype[0] INTEGER, -- EncryptionEngine + * kvno[1] INTEGER OPTIONAL, + * cipher[2] OCTET STRING -- ciphertext + * } + */ + protected DERSequence encodeEncryptedData( EncryptedData encryptedData ) + { + DERSequence sequence =3D new DERSequence(); + =09 + sequence.add( new DERTaggedObject( 0, DERInteger.valueOf( encryptedData.= getEncryptionType().getOrdinal() ) ) ); + =09 + if ( encryptedData.getKeyVersion() > 0 ) + { + sequence.add( new DERTaggedObject( 1, DERInteger.valueOf( encryptedData= .getKeyVersion() ) ) ); + } + =09 + sequence.add( new DERTaggedObject( 2, new DEROctetString( encryptedData.= getCipherText() ) ) ); + =09 + return sequence; + } +} +