View Javadoc
1   /*
2    *  Licensed to the Apache Software Foundation (ASF) under one
3    *  or more contributor license agreements.  See the NOTICE file
4    *  distributed with this work for additional information
5    *  regarding copyright ownership.  The ASF licenses this file
6    *  to you under the Apache License, Version 2.0 (the
7    *  "License"); you may not use this file except in compliance
8    *  with the License.  You may obtain a copy of the License at
9    *  
10   *    http://www.apache.org/licenses/LICENSE-2.0
11   *  
12   *  Unless required by applicable law or agreed to in writing,
13   *  software distributed under the License is distributed on an
14   *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   *  KIND, either express or implied.  See the License for the
16   *  specific language governing permissions and limitations
17   *  under the License. 
18   *  
19   */
20  package org.apache.directory.shared.kerberos.codec;
21  
22  
23  import org.apache.directory.api.asn1.ber.AbstractContainer;
24  import org.apache.directory.shared.kerberos.components.PrincipalName;
25  import org.apache.directory.shared.kerberos.messages.KerberosMessage;
26  import org.apache.directory.shared.kerberos.messages.Ticket;
27  
28  
29  /**
30   * The KerberosMessage container stores all the messages decoded by the Asn1Decoder.
31   * When dealing with an incoding PDU, we will obtain a KerberosMessage in the
32   * container.
33   * 
34   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
35   */
36  public class KerberosMessageContainer extends AbstractContainer
37  {
38      /** The internal kerberos message */
39      private KerberosMessage message;
40  
41      /** A PrincipalName container */
42      private PrincipalName principalName;
43  
44      /** A flag used when the protocol used to transfer the PDU is TCP */
45      private boolean isTCP;
46  
47      /** When the connection is using a TCP protocol, the PDU length */
48      private int tcpLength = -1;
49  
50  
51      /**
52       * Creates a new KerberosMessageContainer object. We will store ten grammars,
53       * it's enough ...
54       */
55      public KerberosMessageContainer()
56      {
57          super();
58          setGrammar( KerberosMessageGrammar.getInstance() );
59          setTransition( KerberosMessageStatesEnum.START_STATE );
60      }
61  
62  
63      /**
64       * @return Returns the KerberosMessage.
65       */
66      public KerberosMessage getMessage()
67      {
68          return message;
69      }
70  
71  
72      /**
73       * Set a Message Object into the container. It will be completed by the
74       * KerberosDecoder.
75       * 
76       * @param message The message to set.
77       */
78      public void setMessage( KerberosMessage message )
79      {
80          this.message = message;
81      }
82  
83  
84      /**
85       * @return Returns the Ticket if the interned message is a Ticket.
86       */
87      public Ticket getTicket()
88      {
89          return ( Ticket ) message;
90      }
91  
92  
93      /**
94       * @return Returns the PrincipalName.
95       */
96      public PrincipalName getPrincipalName()
97      {
98          return principalName;
99      }
100 
101 
102     /**
103      * Set a PrincipalName Object into the container. It will be completed by the
104      * KerberosDecoder.
105      * 
106      * @param principalName The principalName to set.
107      */
108     public void setPrincipalName( PrincipalName principalName )
109     {
110         this.principalName = principalName;
111     }
112 
113 
114     /**
115      * @return the isTCP
116      */
117     public boolean isTCP()
118     {
119         return isTCP;
120     }
121 
122 
123     /**
124      * @param isTCP the isTCP to set
125      */
126     public void setTCP( boolean isTCP )
127     {
128         this.isTCP = isTCP;
129     }
130 
131 
132     /**
133      * @return the tcpLength
134      */
135     public int getTcpLength()
136     {
137         return tcpLength;
138     }
139 
140 
141     /**
142      * @param tcpLength the tcpLength to set
143      */
144     public void setTcpLength( int tcpLength )
145     {
146         this.tcpLength = tcpLength;
147     }
148 }