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.asRep;
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.asRep.actions.StoreKdcRep;
28 import org.slf4j.Logger;
29 import org.slf4j.LoggerFactory;
30
31
32 /**
33 * This class implements the AS-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 AsRepGrammar extends AbstractGrammar<AsRepContainer>
40 {
41 /** The logger */
42 static final Logger LOG = LoggerFactory.getLogger( AsRepGrammar.class );
43
44 /** A speedup for logger */
45 static final boolean IS_DEBUG = LOG.isDebugEnabled();
46
47 /** The instance of grammar. AsRepGrammar is a singleton */
48 private static Grammar<AsRepContainer> instance = new AsRepGrammar();
49
50
51 /**
52 * Creates a new AsRepGrammar object.
53 */
54 @SuppressWarnings("unchecked")
55 private AsRepGrammar()
56 {
57 setName( AsRepGrammar.class.getName() );
58
59 // Create the transitions table
60 super.transitions = new GrammarTransition[AsRepStatesEnum.LAST_AS_REP_STATE.ordinal()][256];
61
62 // ============================================================================================
63 // AS-REP
64 // ============================================================================================
65 // --------------------------------------------------------------------------------------------
66 // Transition from AS-REP init to KDC-REP
67 // --------------------------------------------------------------------------------------------
68 // AS-REP ::= [APPLICATION 11] KDC-REP
69 super.transitions[AsRepStatesEnum.START_STATE.ordinal()][KerberosConstants.AS_REP_TAG] =
70 new GrammarTransition<AsRepContainer>(
71 AsRepStatesEnum.START_STATE,
72 AsRepStatesEnum.AS_REP_STATE,
73 KerberosConstants.AS_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<AsRepContainer> getInstance()
84 {
85 return instance;
86 }
87 }