001    /*
002     *  Licensed to the Apache Software Foundation (ASF) under one
003     *  or more contributor license agreements.  See the NOTICE file
004     *  distributed with this work for additional information
005     *  regarding copyright ownership.  The ASF licenses this file
006     *  to you under the Apache License, Version 2.0 (the
007     *  "License"); you may not use this file except in compliance
008     *  with the License.  You may obtain a copy of the License at
009     *  
010     *    http://www.apache.org/licenses/LICENSE-2.0
011     *  
012     *  Unless required by applicable law or agreed to in writing,
013     *  software distributed under the License is distributed on an
014     *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015     *  KIND, either express or implied.  See the License for the
016     *  specific language governing permissions and limitations
017     *  under the License. 
018     *  
019     */
020    package org.apache.directory.server.kerberos.shared.io.encoder;
021    
022    
023    import org.apache.directory.server.kerberos.shared.messages.value.TransitedEncoding;
024    import org.apache.directory.shared.asn1.der.DERInteger;
025    import org.apache.directory.shared.asn1.der.DEROctetString;
026    import org.apache.directory.shared.asn1.der.DERSequence;
027    import org.apache.directory.shared.asn1.der.DERTaggedObject;
028    
029    
030    /**
031     * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
032     * @version $Rev: 588371 $, $Date: 2007-10-26 00:13:41 +0200 (Fri, 26 Oct 2007) $
033     */
034    public class TransitedEncodingEncoder
035    {
036        /**
037         * TransitedEncoding ::=         SEQUENCE {
038         *     tr-type[0]  INTEGER, -- must be registered
039         *     contents[1]          OCTET STRING
040         * }
041         */
042        protected static DERSequence encode( TransitedEncoding te )
043        {
044    
045            DERSequence sequence = new DERSequence();
046    
047            sequence.add( new DERTaggedObject( 0, DERInteger.valueOf( te.getTrType().getOrdinal() ) ) );
048            sequence.add( new DERTaggedObject( 1, new DEROctetString( te.getContents() ) ) );
049    
050            return sequence;
051        }
052    }