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.encTgsRepPart;
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.encTgsRepPart.actions.StoreEncTgsRepPart;
28  import org.slf4j.Logger;
29  import org.slf4j.LoggerFactory;
30  
31  
32  /**
33   * This class implements the EncTgsRepPart 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 EncTgsRepPartGrammar extends AbstractGrammar<EncTgsRepPartContainer>
40  {
41      /** The logger */
42      static final Logger LOG = LoggerFactory.getLogger( EncTgsRepPartGrammar.class );
43  
44      /** A speedup for logger */
45      static final boolean IS_DEBUG = LOG.isDebugEnabled();
46  
47      /** The instance of grammar. EncTgsRepPartGrammar is a singleton */
48      private static Grammar<EncTgsRepPartContainer> instance = new EncTgsRepPartGrammar();
49  
50  
51      /**
52       * Creates a new EncTgsRepPartGrammar object.
53       */
54      @SuppressWarnings("unchecked")
55      private EncTgsRepPartGrammar()
56      {
57          setName( EncTgsRepPartGrammar.class.getName() );
58  
59          // Create the transitions table
60          super.transitions = new GrammarTransition[EncTgsRepPartStatesEnum.LAST_ENC_TGS_REP_PART_STATE.ordinal()][256];
61  
62          // ============================================================================================
63          // EncTgsRepPart
64          // ============================================================================================
65          // --------------------------------------------------------------------------------------------
66          // Transition from EncTgsRepPart init to EncKDCRepPart
67          // --------------------------------------------------------------------------------------------
68          // EncASRepPart    ::= [APPLICATION 25] EncKDCRepPart
69          super.transitions[EncTgsRepPartStatesEnum.START_STATE.ordinal()][KerberosConstants.ENC_TGS_REP_PART_TAG] =
70              new GrammarTransition<EncTgsRepPartContainer>(
71                  EncTgsRepPartStatesEnum.START_STATE,
72                  EncTgsRepPartStatesEnum.ENC_TGS_REP_PART_STATE,
73                  KerberosConstants.ENC_TGS_REP_PART_TAG,
74                  new StoreEncTgsRepPart() );
75      }
76  
77  
78      /**
79       * Get the instance of this grammar
80       *
81       * @return An instance on the EncAsRepPart Grammar
82       */
83      public static Grammar<EncTgsRepPartContainer> getInstance()
84      {
85          return instance;
86      }
87  }