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 */
020package org.apache.directory.shared.kerberos.messages;
021
022
023import org.apache.directory.api.asn1.Asn1Object;
024import org.apache.directory.shared.kerberos.KerberosConstants;
025import org.apache.directory.shared.kerberos.KerberosMessageType;
026
027
028/**
029 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
030 */
031public abstract class KerberosMessage implements Asn1Object
032{
033    /** The protocol version (should be 5) */
034    private int protocolVersionNumber = KerberosConstants.KERBEROS_V5;
035
036    /** The message type */
037    private KerberosMessageType messageType;
038
039
040    /**
041     * Creates a new instance of KerberosMessage.
042     *
043     * @param type The message type
044     */
045    public KerberosMessage( KerberosMessageType type )
046    {
047        this( KerberosConstants.KERBEROS_V5, type );
048    }
049
050
051    /**
052     * Creates a new instance of KerberosMessage.
053     *
054     * @param versionNumber
055     * @param type
056     */
057    public KerberosMessage( int versionNumber, KerberosMessageType type )
058    {
059        protocolVersionNumber = versionNumber;
060        messageType = type;
061    }
062
063
064    /**
065     * Returns the {@link KerberosMessageType}.
066     *
067     * @return The {@link KerberosMessageType}.
068     */
069    public KerberosMessageType getMessageType()
070    {
071        return messageType;
072    }
073
074
075    /**
076     * Sets the {@link KerberosMessageType}.
077     *
078     * @param type
079     */
080    public void setMessageType( KerberosMessageType type )
081    {
082        messageType = type;
083    }
084
085
086    /**
087     * Returns the protocol version number.
088     *
089     * @return The protocol version number.
090     */
091    public int getProtocolVersionNumber()
092    {
093        return protocolVersionNumber;
094    }
095
096
097    /**
098     * Sets the protocol version number.
099     *
100     * @param versionNumber
101     */
102    public void setProtocolVersionNumber( int versionNumber )
103    {
104        protocolVersionNumber = versionNumber;
105    }
106}