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.codec.krbError;
021
022
023import org.apache.directory.api.asn1.actions.CheckNotNullLength;
024import org.apache.directory.api.asn1.ber.grammar.AbstractGrammar;
025import org.apache.directory.api.asn1.ber.grammar.Grammar;
026import org.apache.directory.api.asn1.ber.grammar.GrammarTransition;
027import org.apache.directory.api.asn1.ber.tlv.UniversalTag;
028import org.apache.directory.shared.kerberos.KerberosConstants;
029import org.apache.directory.shared.kerberos.codec.krbError.actions.CheckMsgType;
030import org.apache.directory.shared.kerberos.codec.krbError.actions.KrbErrorInit;
031import org.apache.directory.shared.kerberos.codec.krbError.actions.StoreCName;
032import org.apache.directory.shared.kerberos.codec.krbError.actions.StoreCRealm;
033import org.apache.directory.shared.kerberos.codec.krbError.actions.StoreCTime;
034import org.apache.directory.shared.kerberos.codec.krbError.actions.StoreCusec;
035import org.apache.directory.shared.kerberos.codec.krbError.actions.StoreEData;
036import org.apache.directory.shared.kerberos.codec.krbError.actions.StoreEText;
037import org.apache.directory.shared.kerberos.codec.krbError.actions.StoreErrorCode;
038import org.apache.directory.shared.kerberos.codec.krbError.actions.StorePvno;
039import org.apache.directory.shared.kerberos.codec.krbError.actions.StoreRealm;
040import org.apache.directory.shared.kerberos.codec.krbError.actions.StoreSName;
041import org.apache.directory.shared.kerberos.codec.krbError.actions.StoreSTime;
042import org.apache.directory.shared.kerberos.codec.krbError.actions.StoreSusec;
043import org.slf4j.Logger;
044import org.slf4j.LoggerFactory;
045
046
047/**
048 * This class implements the KrbError structure. All the actions are declared
049 * in this class. As it is a singleton, these declaration are only done once. If
050 * an action is to be added or modified, this is where the work is to be done !
051 *
052 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
053 */
054public final class KrbErrorGrammar extends AbstractGrammar<KrbErrorContainer>
055{
056    /** The logger */
057    static final Logger LOG = LoggerFactory.getLogger( KrbErrorGrammar.class );
058
059    /** A speedup for logger */
060    static final boolean IS_DEBUG = LOG.isDebugEnabled();
061
062    /** The instance of grammar. KrbErrorGrammar is a singleton */
063    private static Grammar<KrbErrorContainer> instance = new KrbErrorGrammar();
064
065
066    /**
067     * Creates a new KrbErrorGrammar object.
068     */
069    @SuppressWarnings("unchecked")
070    private KrbErrorGrammar()
071    {
072        setName( KrbErrorGrammar.class.getName() );
073
074        // Create the transitions table
075        super.transitions = new GrammarTransition[KrbErrorStatesEnum.LAST_KRB_ERR_STATE.ordinal()][256];
076
077        // ============================================================================================
078        // KrbError
079        // ============================================================================================
080        // --------------------------------------------------------------------------------------------
081        // Transition from KrbError init to KrbError tag
082        // --------------------------------------------------------------------------------------------
083        // KRB-ERROR       ::= [APPLICATION 30]
084        super.transitions[KrbErrorStatesEnum.START_STATE.ordinal()][KerberosConstants.KRB_ERROR_TAG] =
085            new GrammarTransition<KrbErrorContainer>(
086                KrbErrorStatesEnum.START_STATE,
087                KrbErrorStatesEnum.KRB_ERR_TAG,
088                KerberosConstants.KRB_ERROR_TAG,
089                new KrbErrorInit() );
090
091        // --------------------------------------------------------------------------------------------
092        // Transition from KrbError tag to KrbError SEQ
093        // --------------------------------------------------------------------------------------------
094        // KRB-ERROR       ::= [APPLICATION 30] SEQUENCE {
095        super.transitions[KrbErrorStatesEnum.KRB_ERR_TAG.ordinal()][UniversalTag.SEQUENCE.getValue()] =
096            new GrammarTransition<KrbErrorContainer>(
097                KrbErrorStatesEnum.KRB_ERR_TAG,
098                KrbErrorStatesEnum.KRB_ERR_SEQ_STATE,
099                UniversalTag.SEQUENCE,
100                new CheckNotNullLength<KrbErrorContainer>() );
101
102        // --------------------------------------------------------------------------------------------
103        // Transition from KrbError SEQ to pvno tag
104        // --------------------------------------------------------------------------------------------
105        // KRB-ERROR         ::= SEQUENCE {
106        //         pvno            [0]
107        super.transitions[KrbErrorStatesEnum.KRB_ERR_SEQ_STATE.ordinal()][KerberosConstants.KRB_ERROR_PVNO_TAG] =
108            new GrammarTransition<KrbErrorContainer>(
109                KrbErrorStatesEnum.KRB_ERR_SEQ_STATE,
110                KrbErrorStatesEnum.KRB_ERR_PVNO_TAG_STATE,
111                KerberosConstants.KRB_ERROR_PVNO_TAG,
112                new CheckNotNullLength<KrbErrorContainer>() );
113
114        // --------------------------------------------------------------------------------------------
115        // Transition from pvno tag to pvno value
116        // --------------------------------------------------------------------------------------------
117        // KRB-ERROR         ::= SEQUENCE {
118        //         pvno            [0] INTEGER (5) ,
119        super.transitions[KrbErrorStatesEnum.KRB_ERR_PVNO_TAG_STATE.ordinal()][UniversalTag.INTEGER.getValue()] =
120            new GrammarTransition<KrbErrorContainer>(
121                KrbErrorStatesEnum.KRB_ERR_PVNO_TAG_STATE,
122                KrbErrorStatesEnum.KRB_ERR_PVNO_STATE,
123                UniversalTag.INTEGER.getValue(),
124                new StorePvno() );
125
126        // --------------------------------------------------------------------------------------------
127        // Transition from pvno to msg-type tag
128        // --------------------------------------------------------------------------------------------
129        // msg-type        [1]
130        super.transitions[KrbErrorStatesEnum.KRB_ERR_PVNO_STATE.ordinal()][KerberosConstants.KRB_ERROR_MSGTYPE_TAG] =
131            new GrammarTransition<KrbErrorContainer>(
132                KrbErrorStatesEnum.KRB_ERR_PVNO_STATE,
133                KrbErrorStatesEnum.KRB_ERR_MSG_TYPE_TAG_STATE,
134                KerberosConstants.KRB_ERROR_MSGTYPE_TAG,
135                new CheckNotNullLength<KrbErrorContainer>() );
136
137        // --------------------------------------------------------------------------------------------
138        // Transition from msg-type tag to msg-type value
139        // --------------------------------------------------------------------------------------------
140        // msg-type        [1] INTEGER (30)
141        super.transitions[KrbErrorStatesEnum.KRB_ERR_MSG_TYPE_TAG_STATE.ordinal()][UniversalTag.INTEGER.getValue()] =
142            new GrammarTransition<KrbErrorContainer>(
143                KrbErrorStatesEnum.KRB_ERR_MSG_TYPE_TAG_STATE,
144                KrbErrorStatesEnum.KRB_ERR_MSG_TYPE_STATE,
145                UniversalTag.INTEGER,
146                new CheckMsgType() );
147
148        // --------------------------------------------------------------------------------------------
149        // Transition from msg-type value to cTime tag
150        // --------------------------------------------------------------------------------------------
151        // ctime        [2]
152        super.transitions[KrbErrorStatesEnum.KRB_ERR_MSG_TYPE_STATE.ordinal()][KerberosConstants.KRB_ERROR_CTIME_TAG] =
153            new GrammarTransition<KrbErrorContainer>(
154                KrbErrorStatesEnum.KRB_ERR_MSG_TYPE_STATE,
155                KrbErrorStatesEnum.KRB_ERR_CTIME_TAG_STATE,
156                KerberosConstants.KRB_ERROR_CTIME_TAG,
157                new CheckNotNullLength<KrbErrorContainer>() );
158
159        // --------------------------------------------------------------------------------------------
160        // Transition from cTime tag to cTime value
161        // --------------------------------------------------------------------------------------------
162        // ctime        [2] KerberosTime OPTIONAL
163        super.transitions[KrbErrorStatesEnum.KRB_ERR_CTIME_TAG_STATE.ordinal()][UniversalTag.GENERALIZED_TIME
164            .getValue()] =
165            new GrammarTransition<KrbErrorContainer>(
166                KrbErrorStatesEnum.KRB_ERR_CTIME_TAG_STATE,
167                KrbErrorStatesEnum.KRB_ERR_CTIME_STATE,
168                UniversalTag.GENERALIZED_TIME,
169                new StoreCTime() );
170
171        // --------------------------------------------------------------------------------------------
172        // Transition from cTime value to cusec tag
173        // --------------------------------------------------------------------------------------------
174        // cusec           [3]
175        super.transitions[KrbErrorStatesEnum.KRB_ERR_CTIME_STATE.ordinal()][KerberosConstants.KRB_ERROR_CUSEC_TAG] =
176            new GrammarTransition<KrbErrorContainer>(
177                KrbErrorStatesEnum.KRB_ERR_CTIME_STATE,
178                KrbErrorStatesEnum.KRB_ERR_CUSEC_TAG_STATE,
179                KerberosConstants.KRB_ERROR_CUSEC_TAG,
180                new CheckNotNullLength<KrbErrorContainer>() );
181
182        // --------------------------------------------------------------------------------------------
183        // Transition from cusec tag to cusec value
184        // --------------------------------------------------------------------------------------------
185        // cusec           [3] Microseconds OPTIONAL
186        super.transitions[KrbErrorStatesEnum.KRB_ERR_CUSEC_TAG_STATE.ordinal()][UniversalTag.INTEGER.getValue()] =
187            new GrammarTransition<KrbErrorContainer>(
188                KrbErrorStatesEnum.KRB_ERR_CUSEC_TAG_STATE,
189                KrbErrorStatesEnum.KRB_ERR_CUSEC_STATE,
190                UniversalTag.INTEGER,
191                new StoreCusec() );
192
193        // --------------------------------------------------------------------------------------------
194        // Transition from cusec value to stime tag
195        // --------------------------------------------------------------------------------------------
196        // stime           [4]
197        super.transitions[KrbErrorStatesEnum.KRB_ERR_CUSEC_STATE.ordinal()][KerberosConstants.KRB_ERROR_STIME_TAG] =
198            new GrammarTransition<KrbErrorContainer>(
199                KrbErrorStatesEnum.KRB_ERR_CUSEC_STATE, KrbErrorStatesEnum.KRB_ERR_STIME_TAG_STATE,
200                KerberosConstants.KRB_ERROR_STIME_TAG,
201                new CheckNotNullLength<KrbErrorContainer>() );
202
203        // --------------------------------------------------------------------------------------------
204        // Transition from stime tag to stime value
205        // --------------------------------------------------------------------------------------------
206        // stime           [4] KerberosTime
207        super.transitions[KrbErrorStatesEnum.KRB_ERR_STIME_TAG_STATE.ordinal()][UniversalTag.GENERALIZED_TIME
208            .getValue()] =
209            new GrammarTransition<KrbErrorContainer>(
210                KrbErrorStatesEnum.KRB_ERR_STIME_TAG_STATE,
211                KrbErrorStatesEnum.KRB_ERR_STIME_STATE,
212                UniversalTag.GENERALIZED_TIME,
213                new StoreSTime() );
214
215        // --------------------------------------------------------------------------------------------
216        // Transition from stime value to susec tag
217        // --------------------------------------------------------------------------------------------
218        // susec           [5]
219        super.transitions[KrbErrorStatesEnum.KRB_ERR_STIME_STATE.ordinal()][KerberosConstants.KRB_ERROR_SUSEC_TAG] =
220            new GrammarTransition<KrbErrorContainer>(
221                KrbErrorStatesEnum.KRB_ERR_STIME_STATE,
222                KrbErrorStatesEnum.KRB_ERR_SUSEC_TAG_STATE,
223                KerberosConstants.KRB_ERROR_SUSEC_TAG,
224                new CheckNotNullLength<KrbErrorContainer>() );
225
226        // --------------------------------------------------------------------------------------------
227        // Transition from susec tag to susec value
228        // --------------------------------------------------------------------------------------------
229        // susec           [5] Microseconds
230        super.transitions[KrbErrorStatesEnum.KRB_ERR_SUSEC_TAG_STATE.ordinal()][UniversalTag.INTEGER.getValue()] =
231            new GrammarTransition<KrbErrorContainer>(
232                KrbErrorStatesEnum.KRB_ERR_SUSEC_TAG_STATE,
233                KrbErrorStatesEnum.KRB_ERR_SUSEC_STATE,
234                UniversalTag.INTEGER,
235                new StoreSusec() );
236
237        // --------------------------------------------------------------------------------------------
238        // Transition from susec value to error-code tag
239        // --------------------------------------------------------------------------------------------
240        // error-code      [6]
241        super.transitions[KrbErrorStatesEnum.KRB_ERR_SUSEC_STATE.ordinal()][KerberosConstants.KRB_ERROR_ERROR_CODE_TAG] =
242            new GrammarTransition<KrbErrorContainer>(
243                KrbErrorStatesEnum.KRB_ERR_SUSEC_STATE,
244                KrbErrorStatesEnum.KRB_ERR_ERROR_CODE_TAG_STATE,
245                KerberosConstants.KRB_ERROR_ERROR_CODE_TAG,
246                new CheckNotNullLength<KrbErrorContainer>() );
247
248        // --------------------------------------------------------------------------------------------
249        // Transition from error-code tag to error-code value
250        // --------------------------------------------------------------------------------------------
251        // error-code      [6] Int32
252        super.transitions[KrbErrorStatesEnum.KRB_ERR_ERROR_CODE_TAG_STATE.ordinal()][UniversalTag.INTEGER.getValue()] =
253            new GrammarTransition<KrbErrorContainer>(
254                KrbErrorStatesEnum.KRB_ERR_ERROR_CODE_TAG_STATE,
255                KrbErrorStatesEnum.KRB_ERR_ERROR_CODE_STATE,
256                UniversalTag.INTEGER,
257                new StoreErrorCode() );
258
259        // --------------------------------------------------------------------------------------------
260        // Transition from error-code value to crealm tag
261        // --------------------------------------------------------------------------------------------
262        // crealm          [7]
263        super.transitions[KrbErrorStatesEnum.KRB_ERR_ERROR_CODE_STATE.ordinal()][KerberosConstants.KRB_ERROR_CREALM_TAG] =
264            new GrammarTransition<KrbErrorContainer>(
265                KrbErrorStatesEnum.KRB_ERR_ERROR_CODE_STATE,
266                KrbErrorStatesEnum.KRB_ERR_CREALM_TAG_STATE,
267                KerberosConstants.KRB_ERROR_CREALM_TAG,
268                new CheckNotNullLength<KrbErrorContainer>() );
269
270        // --------------------------------------------------------------------------------------------
271        // Transition from crealm tag to crealm value
272        // --------------------------------------------------------------------------------------------
273        // crealm          [7] Realm
274        super.transitions[KrbErrorStatesEnum.KRB_ERR_CREALM_TAG_STATE.ordinal()][UniversalTag.GENERAL_STRING.getValue()] =
275            new GrammarTransition<KrbErrorContainer>(
276                KrbErrorStatesEnum.KRB_ERR_CREALM_TAG_STATE,
277                KrbErrorStatesEnum.KRB_ERR_CREALM_STATE,
278                UniversalTag.GENERAL_STRING,
279                new StoreCRealm() );
280
281        // --------------------------------------------------------------------------------------------
282        // Transition from crealm value to cname
283        // --------------------------------------------------------------------------------------------
284        // cname           [8] PrincipalName OPTIONAL,
285        super.transitions[KrbErrorStatesEnum.KRB_ERR_CREALM_STATE.ordinal()][KerberosConstants.KRB_ERROR_CNAME_TAG] =
286            new GrammarTransition<KrbErrorContainer>(
287                KrbErrorStatesEnum.KRB_ERR_CREALM_STATE,
288                KrbErrorStatesEnum.KRB_ERR_CNAME_STATE,
289                KerberosConstants.KRB_ERROR_CNAME_TAG,
290                new StoreCName() );
291
292        // --------------------------------------------------------------------------------------------
293        // Transition from cname value to realm tag
294        // --------------------------------------------------------------------------------------------
295        // realm           [9]
296        super.transitions[KrbErrorStatesEnum.KRB_ERR_CNAME_STATE.ordinal()][KerberosConstants.KRB_ERROR_REALM_TAG] =
297            new GrammarTransition<KrbErrorContainer>(
298                KrbErrorStatesEnum.KRB_ERR_CNAME_STATE,
299                KrbErrorStatesEnum.KRB_ERR_REALM_TAG_STATE,
300                KerberosConstants.KRB_ERROR_REALM_TAG,
301                new CheckNotNullLength<KrbErrorContainer>() );
302
303        // --------------------------------------------------------------------------------------------
304        // Transition from realm tag to realm value
305        // --------------------------------------------------------------------------------------------
306        // realm           [9] Realm
307        super.transitions[KrbErrorStatesEnum.KRB_ERR_REALM_TAG_STATE.ordinal()][UniversalTag.GENERAL_STRING.getValue()] =
308            new GrammarTransition<KrbErrorContainer>(
309                KrbErrorStatesEnum.KRB_ERR_REALM_TAG_STATE,
310                KrbErrorStatesEnum.KRB_ERR_REALM_STATE,
311                UniversalTag.GENERAL_STRING,
312                new StoreRealm() );
313
314        // --------------------------------------------------------------------------------------------
315        // Transition from realm value to sname
316        // --------------------------------------------------------------------------------------------
317        // sname           [10] PrincipalName,
318        super.transitions[KrbErrorStatesEnum.KRB_ERR_REALM_STATE.ordinal()][KerberosConstants.KRB_ERROR_SNAME_TAG] =
319            new GrammarTransition<KrbErrorContainer>(
320                KrbErrorStatesEnum.KRB_ERR_REALM_STATE,
321                KrbErrorStatesEnum.KRB_ERR_SNAME_STATE,
322                KerberosConstants.KRB_ERROR_SNAME_TAG,
323                new StoreSName() );
324
325        // --------------------------------------------------------------------------------------------
326        // Transition from sname value to etext tag
327        // --------------------------------------------------------------------------------------------
328        // e-text          [11]
329        super.transitions[KrbErrorStatesEnum.KRB_ERR_SNAME_STATE.ordinal()][KerberosConstants.KRB_ERROR_ETEXT_TAG] =
330            new GrammarTransition<KrbErrorContainer>(
331                KrbErrorStatesEnum.KRB_ERR_SNAME_STATE,
332                KrbErrorStatesEnum.KRB_ERR_ETEXT_TAG_STATE,
333                KerberosConstants.KRB_ERROR_ETEXT_TAG,
334                new CheckNotNullLength<KrbErrorContainer>() );
335
336        // --------------------------------------------------------------------------------------------
337        // Transition from etext tag to etext value
338        // --------------------------------------------------------------------------------------------
339        // e-text          [11] KerberosString OPTIONAL
340        super.transitions[KrbErrorStatesEnum.KRB_ERR_ETEXT_TAG_STATE.ordinal()][UniversalTag.GENERAL_STRING.getValue()] =
341            new GrammarTransition<KrbErrorContainer>(
342                KrbErrorStatesEnum.KRB_ERR_ETEXT_TAG_STATE,
343                KrbErrorStatesEnum.KRB_ERR_ETEXT_STATE,
344                UniversalTag.GENERAL_STRING,
345                new StoreEText() );
346
347        // --------------------------------------------------------------------------------------------
348        // Transition from etext value to edata tag
349        // --------------------------------------------------------------------------------------------
350        // e-data          [12]
351        super.transitions[KrbErrorStatesEnum.KRB_ERR_ETEXT_STATE.ordinal()][KerberosConstants.KRB_ERROR_EDATA_TAG] =
352            new GrammarTransition<KrbErrorContainer>(
353                KrbErrorStatesEnum.KRB_ERR_ETEXT_STATE,
354                KrbErrorStatesEnum.KRB_ERR_EDATA_TAG_STATE,
355                KerberosConstants.KRB_ERROR_EDATA_TAG,
356                new CheckNotNullLength<KrbErrorContainer>() );
357
358        // --------------------------------------------------------------------------------------------
359        // Transition from edata tag to edata value
360        // --------------------------------------------------------------------------------------------
361        // e-data          [12] OCTET STRING OPTIONAL
362        super.transitions[KrbErrorStatesEnum.KRB_ERR_EDATA_TAG_STATE.ordinal()][UniversalTag.OCTET_STRING.getValue()] =
363            new GrammarTransition<KrbErrorContainer>(
364                KrbErrorStatesEnum.KRB_ERR_EDATA_TAG_STATE,
365                KrbErrorStatesEnum.KRB_ERR_EDATA_STATE,
366                UniversalTag.OCTET_STRING,
367                new StoreEData() );
368
369        // ----------------------------------------- OPTIONAL transitions -----------------------------------------
370
371        // --------------------------------------------------------------------------------------------
372        // Transition from msg-type value to cusec tag
373        // --------------------------------------------------------------------------------------------
374        // cusec           [3]
375        super.transitions[KrbErrorStatesEnum.KRB_ERR_MSG_TYPE_STATE.ordinal()][KerberosConstants.KRB_ERROR_CUSEC_TAG] =
376            new GrammarTransition<KrbErrorContainer>(
377                KrbErrorStatesEnum.KRB_ERR_MSG_TYPE_STATE,
378                KrbErrorStatesEnum.KRB_ERR_CUSEC_TAG_STATE,
379                KerberosConstants.KRB_ERROR_CUSEC_TAG,
380                new CheckNotNullLength<KrbErrorContainer>() );
381
382        // --------------------------------------------------------------------------------------------
383        // Transition from msg-type value to stime tag
384        // --------------------------------------------------------------------------------------------
385        // stime           [4]
386        super.transitions[KrbErrorStatesEnum.KRB_ERR_MSG_TYPE_STATE.ordinal()][KerberosConstants.KRB_ERROR_STIME_TAG] =
387            new GrammarTransition<KrbErrorContainer>(
388                KrbErrorStatesEnum.KRB_ERR_MSG_TYPE_STATE,
389                KrbErrorStatesEnum.KRB_ERR_STIME_TAG_STATE,
390                KerberosConstants.KRB_ERROR_STIME_TAG,
391                new CheckNotNullLength<KrbErrorContainer>() );
392
393        // --------------------------------------------------------------------------------------------
394        // Transition from cTime value to stime tag
395        // --------------------------------------------------------------------------------------------
396        // stime           [4]
397        super.transitions[KrbErrorStatesEnum.KRB_ERR_CTIME_STATE.ordinal()][KerberosConstants.KRB_ERROR_STIME_TAG] =
398            new GrammarTransition<KrbErrorContainer>(
399                KrbErrorStatesEnum.KRB_ERR_CTIME_STATE,
400                KrbErrorStatesEnum.KRB_ERR_STIME_TAG_STATE,
401                KerberosConstants.KRB_ERROR_STIME_TAG,
402                new CheckNotNullLength<KrbErrorContainer>() );
403
404        // from erro-code to realm
405
406        // --------------------------------------------------------------------------------------------
407        // Transition from error-code value to realm tag
408        // --------------------------------------------------------------------------------------------
409        // realm           [9]
410        super.transitions[KrbErrorStatesEnum.KRB_ERR_ERROR_CODE_STATE.ordinal()][KerberosConstants.KRB_ERROR_REALM_TAG] =
411            new GrammarTransition<KrbErrorContainer>(
412                KrbErrorStatesEnum.KRB_ERR_ERROR_CODE_STATE,
413                KrbErrorStatesEnum.KRB_ERR_REALM_TAG_STATE,
414                KerberosConstants.KRB_ERROR_REALM_TAG,
415                new CheckNotNullLength<KrbErrorContainer>() );
416
417        // --------------------------------------------------------------------------------------------
418        // Transition from error-code value to cname
419        // --------------------------------------------------------------------------------------------
420        // cname           [8] PrincipalName OPTIONAL,
421        super.transitions[KrbErrorStatesEnum.KRB_ERR_ERROR_CODE_STATE.ordinal()][KerberosConstants.KRB_ERROR_CNAME_TAG] =
422            new GrammarTransition<KrbErrorContainer>(
423                KrbErrorStatesEnum.KRB_ERR_ERROR_CODE_STATE,
424                KrbErrorStatesEnum.KRB_ERR_CNAME_STATE,
425                KerberosConstants.KRB_ERROR_CNAME_TAG,
426                new StoreCName() );
427
428        // --------------------------------------------------------------------------------------------
429        // Transition from crealm value to realm tag
430        // --------------------------------------------------------------------------------------------
431        // realm           [9]
432        super.transitions[KrbErrorStatesEnum.KRB_ERR_CREALM_STATE.ordinal()][KerberosConstants.KRB_ERROR_REALM_TAG] =
433            new GrammarTransition<KrbErrorContainer>(
434                KrbErrorStatesEnum.KRB_ERR_CREALM_STATE,
435                KrbErrorStatesEnum.KRB_ERR_REALM_TAG_STATE,
436                KerberosConstants.KRB_ERROR_REALM_TAG,
437                new CheckNotNullLength<KrbErrorContainer>() );
438
439        // --------------------------------------------------------------------------------------------
440        // Transition from sname value to edata tag
441        // --------------------------------------------------------------------------------------------
442        // e-data          [12]
443        super.transitions[KrbErrorStatesEnum.KRB_ERR_SNAME_STATE.ordinal()][KerberosConstants.KRB_ERROR_EDATA_TAG] =
444            new GrammarTransition<KrbErrorContainer>(
445                KrbErrorStatesEnum.KRB_ERR_SNAME_STATE,
446                KrbErrorStatesEnum.KRB_ERR_EDATA_TAG_STATE,
447                KerberosConstants.KRB_ERROR_EDATA_TAG,
448                new CheckNotNullLength<KrbErrorContainer>() );
449    }
450
451
452    /**
453     * Get the instance of this grammar
454     *
455     * @return An instance on the KRB-ERROR Grammar
456     */
457    public static Grammar<KrbErrorContainer> getInstance()
458    {
459        return instance;
460    }
461}