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.etypeInfo; 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.etypeInfo.actions.AddETypeInfoEntry; 029import org.slf4j.Logger; 030import org.slf4j.LoggerFactory; 031 032 033/** 034 * This class implements the ETYPE-INFO 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 ETypeInfoGrammar extends AbstractGrammar<ETypeInfoContainer> 041{ 042 /** The logger */ 043 static final Logger LOG = LoggerFactory.getLogger( ETypeInfoGrammar.class ); 044 045 /** A speedup for logger */ 046 static final boolean IS_DEBUG = LOG.isDebugEnabled(); 047 048 /** The instance of grammar. ETypeInfoGrammar is a singleton */ 049 private static Grammar<ETypeInfoContainer> instance = new ETypeInfoGrammar(); 050 051 052 /** 053 * Creates a new ETypeInfoGrammar object. 054 */ 055 @SuppressWarnings("unchecked") 056 private ETypeInfoGrammar() 057 { 058 setName( ETypeInfoGrammar.class.getName() ); 059 060 // Create the transitions table 061 super.transitions = new GrammarTransition[ETypeInfoStatesEnum.LAST_ETYPE_INFO_STATE.ordinal()][256]; 062 063 // ============================================================================================ 064 // ETYPE-INFO 065 // ============================================================================================ 066 // -------------------------------------------------------------------------------------------- 067 // Transition from ETYPE-INFO init to ETYPE-INFO SEQ 068 // -------------------------------------------------------------------------------------------- 069 // ETYPE-INFO-ENTRY ::= SEQUENCE 070 super.transitions[ETypeInfoStatesEnum.START_STATE.ordinal()][UniversalTag.SEQUENCE.getValue()] = 071 new GrammarTransition<ETypeInfoContainer>( 072 ETypeInfoStatesEnum.START_STATE, 073 ETypeInfoStatesEnum.ETYPE_INFO_SEQ_STATE, 074 UniversalTag.SEQUENCE, 075 new CheckNotNullLength<ETypeInfoContainer>() ); 076 077 // -------------------------------------------------------------------------------------------- 078 // Transition from ETYPE-INFO init to ETYPE-INFO SEQ 079 // -------------------------------------------------------------------------------------------- 080 // ETYPE-INFO-ENTRY ::= SEQUENCE OF <ETYPE-INFO-ENTRY> 081 // 082 super.transitions[ETypeInfoStatesEnum.ETYPE_INFO_SEQ_STATE.ordinal()][UniversalTag.SEQUENCE.getValue()] = 083 new GrammarTransition<ETypeInfoContainer>( 084 ETypeInfoStatesEnum.ETYPE_INFO_SEQ_STATE, 085 ETypeInfoStatesEnum.ETYPE_INFO_SEQ_STATE, 086 UniversalTag.SEQUENCE, 087 new AddETypeInfoEntry() ); 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<ETypeInfoContainer> getInstance() 097 { 098 return instance; 099 } 100}