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.tgsRep;
21  
22  
23  import org.apache.directory.api.asn1.ber.grammar.AbstractGrammar;
24  import org.apache.directory.api.asn1.ber.grammar.Grammar;
25  import org.apache.directory.api.asn1.ber.grammar.GrammarTransition;
26  import org.apache.directory.shared.kerberos.KerberosConstants;
27  import org.apache.directory.shared.kerberos.codec.tgsRep.actions.StoreKdcRep;
28  import org.slf4j.Logger;
29  import org.slf4j.LoggerFactory;
30  
31  
32  /**
33   * This class implements the TGS-REP structure. All the actions are declared
34   * in this class. As it is a singleton, these declaration are only done once. If
35   * an action is to be added or modified, this is where the work is to be done !
36   *
37   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
38   */
39  public final class TgsRepGrammar extends AbstractGrammar<TgsRepContainer>
40  {
41      /** The logger */
42      static final Logger LOG = LoggerFactory.getLogger( TgsRepGrammar.class );
43  
44      /** A speedup for logger */
45      static final boolean IS_DEBUG = LOG.isDebugEnabled();
46  
47      /** The instance of grammar. TgsRepGrammar is a singleton */
48      private static Grammar<TgsRepContainer> instance = new TgsRepGrammar();
49  
50  
51      /**
52       * Creates a new TgsRepGrammar object.
53       */
54      @SuppressWarnings("unchecked")
55      private TgsRepGrammar()
56      {
57          setName( TgsRepGrammar.class.getName() );
58  
59          // Create the transitions table
60          super.transitions = new GrammarTransition[TgsRepStatesEnum.LAST_TGS_REP_STATE.ordinal()][256];
61  
62          // ============================================================================================
63          // TS-REP
64          // ============================================================================================
65          // --------------------------------------------------------------------------------------------
66          // Transition from TS-REP init to KDC-REP
67          // --------------------------------------------------------------------------------------------
68          // TGS-REP          ::= [APPLICATION 13] KDC-REP
69          super.transitions[TgsRepStatesEnum.START_STATE.ordinal()][KerberosConstants.TGS_REP_TAG] =
70              new GrammarTransition<TgsRepContainer>(
71                  TgsRepStatesEnum.START_STATE,
72                  TgsRepStatesEnum.TGS_REP_STATE,
73                  KerberosConstants.TGS_REP_TAG,
74                  new StoreKdcRep() );
75      }
76  
77  
78      /**
79       * Get the instance of this grammar
80       *
81       * @return An instance on the AS-REP Grammar
82       */
83      public static Grammar<TgsRepContainer> getInstance()
84      {
85          return instance;
86      }
87  }