/*
 *  Licensed to the Apache Software Foundation (ASF) under one
 *  or more contributor license agreements.  See the NOTICE file
 *  distributed with this work for additional information
 *  regarding copyright ownership.  The ASF licenses this file
 *  to you 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.directory.shared.kerberos.codec.asRep;


import java.nio.ByteBuffer;

import org.apache.directory.shared.kerberos.codec.kdcRep.KdcRepContainer;
import org.apache.directory.shared.kerberos.messages.AsRep;


/**
 * The AS-REP container stores the KdcRep decoded by the Asn1Decoder.
 * 
 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
 */
public class AsRepContainer extends KdcRepContainer
{
    /** An AS-REP container */
    private AsRep asRep;


    /**
     * Creates a new AsRepContainer object.
     * @param stream The stream containing the data to decode
     */
    public AsRepContainer( ByteBuffer stream )
    {
        super( stream );
        this.stateStack = new int[1];
        this.grammar = AsRepGrammar.getInstance();
        setTransition( AsRepStatesEnum.START_STATE );
    }


    /**
     * @return Returns the AsRep.
     */
    public AsRep getAsRep()
    {
        return asRep;
    }


    /**
     * Set an AsRep Object into the container. It will be completed by the
     * KerberosDecoder.
     * 
     * @param asRep The AsRep to set.
     */
    public void setAsRep( AsRep asRep )
    {
        this.asRep = asRep;
    }
}
