directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From erodrig...@apache.org
Subject svn commit: r548168 - /directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/encoder/TicketEncoder.java
Date Mon, 18 Jun 2007 02:09:33 GMT
Author: erodriguez
Date: Sun Jun 17 19:09:33 2007
New Revision: 548168

URL: http://svn.apache.org/viewvc?view=rev&rev=548168
Log:
Added support for "one-shot" encoding of Tickets.

Modified:
    directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/encoder/TicketEncoder.java

Modified: directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/encoder/TicketEncoder.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/encoder/TicketEncoder.java?view=diff&rev=548168&r1=548167&r2=548168
==============================================================================
--- directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/encoder/TicketEncoder.java
(original)
+++ directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/encoder/TicketEncoder.java
Sun Jun 17 19:09:33 2007
@@ -20,7 +20,11 @@
 package org.apache.directory.server.kerberos.shared.io.encoder;
 
 
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+
 import org.apache.directory.server.kerberos.shared.messages.components.Ticket;
+import org.apache.directory.shared.asn1.der.ASN1OutputStream;
 import org.apache.directory.shared.asn1.der.DERApplicationSpecific;
 import org.apache.directory.shared.asn1.der.DERGeneralString;
 import org.apache.directory.shared.asn1.der.DERInteger;
@@ -34,6 +38,25 @@
  */
 public class TicketEncoder
 {
+    /**
+     * Encodes a {@link Ticket} into a its ASN.1 DER encoding.
+     * 
+     * @param ticket
+     * @return The byte[] containing the ASN.1 DER encoding of the {@link Ticket}.
+     * @throws IOException
+     */
+    public static byte[] encodeTicket( Ticket ticket ) throws IOException
+    {
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        ASN1OutputStream aos = new ASN1OutputStream( baos );
+
+        aos.writeObject( encode( ticket ) );
+        aos.close();
+
+        return baos.toByteArray();
+    }
+
+
     /**
      * Ticket ::=                    [APPLICATION 1] SEQUENCE {
      *     tkt-vno[0]                   INTEGER,



Mime
View raw message