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.etypeInfo2; 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.codec.etypeInfo2.actions.AddETypeInfo2Entry; 029import org.slf4j.Logger; 030import org.slf4j.LoggerFactory; 031 032 033/** 034 * This class implements the ETYPE-INFO2 structure. All the actions are declared 035 * in this class. As it is a singleton, these declaration are only done once. If 036 * an action is to be added or modified, this is where the work is to be done ! 037 * 038 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 039 */ 040public final class ETypeInfo2Grammar extends AbstractGrammar<ETypeInfo2Container> 041{ 042 /** The logger */ 043 static final Logger LOG = LoggerFactory.getLogger( ETypeInfo2Grammar.class ); 044 045 /** A speedup for logger */ 046 static final boolean IS_DEBUG = LOG.isDebugEnabled(); 047 048 /** The instance of grammar. ETypeInfo2Grammar is a singleton */ 049 private static Grammar<ETypeInfo2Container> instance = new ETypeInfo2Grammar(); 050 051 052 /** 053 * Creates a new ETypeInfo2Grammar object. 054 */ 055 @SuppressWarnings("unchecked") 056 private ETypeInfo2Grammar() 057 { 058 setName( ETypeInfo2Grammar.class.getName() ); 059 060 // Create the transitions table 061 super.transitions = new GrammarTransition[ETypeInfo2StatesEnum.LAST_ETYPE_INFO2_STATE.ordinal()][256]; 062 063 // ============================================================================================ 064 // ETYPE-INFO2 065 // ============================================================================================ 066 // -------------------------------------------------------------------------------------------- 067 // Transition from ETYPE-INFO2 init to ETYPE-INFO2 SEQ 068 // -------------------------------------------------------------------------------------------- 069 // ETYPE-INFO2-ENTRY ::= SEQUENCE 070 super.transitions[ETypeInfo2StatesEnum.START_STATE.ordinal()][UniversalTag.SEQUENCE.getValue()] = 071 new GrammarTransition<ETypeInfo2Container>( 072 ETypeInfo2StatesEnum.START_STATE, 073 ETypeInfo2StatesEnum.ETYPE_INFO2_SEQ_STATE, 074 UniversalTag.SEQUENCE, 075 new CheckNotNullLength<ETypeInfo2Container>() ); 076 077 // -------------------------------------------------------------------------------------------- 078 // Transition from ETYPE-INFO2 init to ETYPE-INFO2 SEQ 079 // -------------------------------------------------------------------------------------------- 080 // ETYPE-INFO2-ENTRY ::= SEQUENCE OF <ETYPE-INFO2-ENTRY> 081 // 082 super.transitions[ETypeInfo2StatesEnum.ETYPE_INFO2_SEQ_STATE.ordinal()][UniversalTag.SEQUENCE.getValue()] = 083 new GrammarTransition<ETypeInfo2Container>( 084 ETypeInfo2StatesEnum.ETYPE_INFO2_SEQ_STATE, 085 ETypeInfo2StatesEnum.ETYPE_INFO2_SEQ_STATE, 086 UniversalTag.SEQUENCE, 087 new AddETypeInfo2Entry() ); 088 } 089 090 091 /** 092 * Get the instance of this grammar 093 * 094 * @return An instance on the ETYPE-INFO Grammar 095 */ 096 public static Grammar<ETypeInfo2Container> getInstance() 097 { 098 return instance; 099 } 100}