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.etypeInfo2Entry; 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.etypeInfo2Entry.actions.ETypeInfo2EntryInit; 030import org.apache.directory.shared.kerberos.codec.etypeInfo2Entry.actions.StoreEType; 031import org.apache.directory.shared.kerberos.codec.etypeInfo2Entry.actions.StoreS2KParams; 032import org.apache.directory.shared.kerberos.codec.etypeInfo2Entry.actions.StoreSalt; 033import org.slf4j.Logger; 034import org.slf4j.LoggerFactory; 035 036 037/** 038 * This class implements the ETYPE-INFO2-ENTRY structure. All the actions are declared 039 * in this class. As it is a singleton, these declaration are only done once. If 040 * an action is to be added or modified, this is where the work is to be done ! 041 * 042 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 043 */ 044public final class ETypeInfo2EntryGrammar extends AbstractGrammar<ETypeInfo2EntryContainer> 045{ 046 /** The logger */ 047 static final Logger LOG = LoggerFactory.getLogger( ETypeInfo2EntryGrammar.class ); 048 049 /** A speedup for logger */ 050 static final boolean IS_DEBUG = LOG.isDebugEnabled(); 051 052 /** The instance of grammar. ETypeInfo2EntryGrammar is a singleton */ 053 private static Grammar<ETypeInfo2EntryContainer> instance = new ETypeInfo2EntryGrammar(); 054 055 056 /** 057 * Creates a new ETypeInfoEntryGrammar object. 058 */ 059 @SuppressWarnings("unchecked") 060 private ETypeInfo2EntryGrammar() 061 { 062 setName( ETypeInfo2EntryGrammar.class.getName() ); 063 064 // Create the transitions table 065 super.transitions = new GrammarTransition[ETypeInfo2EntryStatesEnum.LAST_ETYPE_INFO2_ENTRY_STATE.ordinal()][256]; 066 067 // ============================================================================================ 068 // ETYPE-INFO2-ENTRY 069 // ============================================================================================ 070 // -------------------------------------------------------------------------------------------- 071 // Transition from ETYPE-INFO2-ENTRY init to ETYPE-INFO2-ENTRY SEQ 072 // -------------------------------------------------------------------------------------------- 073 // ETYPE-INFO2-ENTRY ::= SEQUENCE { 074 super.transitions[ETypeInfo2EntryStatesEnum.START_STATE.ordinal()][UniversalTag.SEQUENCE.getValue()] = 075 new GrammarTransition<ETypeInfo2EntryContainer>( 076 ETypeInfo2EntryStatesEnum.START_STATE, 077 ETypeInfo2EntryStatesEnum.ETYPE_INFO2_ENTRY_SEQ_STATE, 078 UniversalTag.SEQUENCE, 079 new ETypeInfo2EntryInit() ); 080 081 // -------------------------------------------------------------------------------------------- 082 // Transition from ETYPE-INFO2-ENTRY SEQ to etype tag 083 // -------------------------------------------------------------------------------------------- 084 // ETYPE-INFO2-ENTRY ::= SEQUENCE { 085 // etype [0] 086 super.transitions[ETypeInfo2EntryStatesEnum.ETYPE_INFO2_ENTRY_SEQ_STATE.ordinal()][KerberosConstants.ETYPE_INFO2_ENTRY_ETYPE_TAG] = 087 new GrammarTransition<ETypeInfo2EntryContainer>( 088 ETypeInfo2EntryStatesEnum.ETYPE_INFO2_ENTRY_SEQ_STATE, 089 ETypeInfo2EntryStatesEnum.ETYPE_INFO2_ENTRY_ETYPE_TAG_STATE, 090 KerberosConstants.ETYPE_INFO2_ENTRY_ETYPE_TAG, 091 new CheckNotNullLength<ETypeInfo2EntryContainer>() ); 092 093 // -------------------------------------------------------------------------------------------- 094 // Transition from etype tag to etype value 095 // -------------------------------------------------------------------------------------------- 096 // ETYPE-INFO2-ENTRY ::= SEQUENCE { 097 // etype [0] Int32, 098 super.transitions[ETypeInfo2EntryStatesEnum.ETYPE_INFO2_ENTRY_ETYPE_TAG_STATE.ordinal()][UniversalTag.INTEGER 099 .getValue()] = 100 new GrammarTransition<ETypeInfo2EntryContainer>( 101 ETypeInfo2EntryStatesEnum.ETYPE_INFO2_ENTRY_ETYPE_TAG_STATE, 102 ETypeInfo2EntryStatesEnum.ETYPE_INFO2_ENTRY_ETYPE_STATE, 103 UniversalTag.INTEGER, 104 new StoreEType() ); 105 106 // -------------------------------------------------------------------------------------------- 107 // Transition from etype value to salt tag 108 // -------------------------------------------------------------------------------------------- 109 // ETYPE-INFO2-ENTRY ::= SEQUENCE { 110 // ... 111 // salt [1] 112 super.transitions[ETypeInfo2EntryStatesEnum.ETYPE_INFO2_ENTRY_ETYPE_STATE.ordinal()][KerberosConstants.ETYPE_INFO2_ENTRY_SALT_TAG] = 113 new GrammarTransition<ETypeInfo2EntryContainer>( 114 ETypeInfo2EntryStatesEnum.ETYPE_INFO2_ENTRY_ETYPE_STATE, 115 ETypeInfo2EntryStatesEnum.ETYPE_INFO2_ENTRY_SALT_TAG_STATE, 116 KerberosConstants.ETYPE_INFO2_ENTRY_SALT_TAG, 117 new CheckNotNullLength<ETypeInfo2EntryContainer>() ); 118 119 // -------------------------------------------------------------------------------------------- 120 // Transition from etype value to s2kparams tag 121 // -------------------------------------------------------------------------------------------- 122 // ETYPE-INFO2-ENTRY ::= SEQUENCE { 123 // ... 124 // s2kparams [2] 125 super.transitions[ETypeInfo2EntryStatesEnum.ETYPE_INFO2_ENTRY_ETYPE_STATE.ordinal()][KerberosConstants.ETYPE_INFO2_ENTRY_S2KPARAMS_TAG] = 126 new GrammarTransition<ETypeInfo2EntryContainer>( 127 ETypeInfo2EntryStatesEnum.ETYPE_INFO2_ENTRY_ETYPE_STATE, 128 ETypeInfo2EntryStatesEnum.ETYPE_INFO2_ENTRY_S2KPARAMS_TAG_STATE, 129 KerberosConstants.ETYPE_INFO2_ENTRY_S2KPARAMS_TAG, 130 new CheckNotNullLength<ETypeInfo2EntryContainer>() ); 131 132 // -------------------------------------------------------------------------------------------- 133 // Transition from salt tag to salt value 134 // -------------------------------------------------------------------------------------------- 135 // ETYPE-INFO2-ENTRY ::= SEQUENCE { 136 // ... 137 // salt [1] KerberosString OPTIONAL, 138 super.transitions[ETypeInfo2EntryStatesEnum.ETYPE_INFO2_ENTRY_SALT_TAG_STATE.ordinal()][UniversalTag.GENERAL_STRING 139 .getValue()] = 140 new GrammarTransition<ETypeInfo2EntryContainer>( 141 ETypeInfo2EntryStatesEnum.ETYPE_INFO2_ENTRY_SALT_TAG_STATE, 142 ETypeInfo2EntryStatesEnum.ETYPE_INFO2_ENTRY_SALT_STATE, 143 UniversalTag.GENERAL_STRING, 144 new StoreSalt() ); 145 146 // -------------------------------------------------------------------------------------------- 147 // Transition from salt value to s2kparams tag 148 // -------------------------------------------------------------------------------------------- 149 // ETYPE-INFO2-ENTRY ::= SEQUENCE { 150 // ... 151 // s2kparams [2] 152 super.transitions[ETypeInfo2EntryStatesEnum.ETYPE_INFO2_ENTRY_SALT_STATE.ordinal()][KerberosConstants.ETYPE_INFO2_ENTRY_S2KPARAMS_TAG] = 153 new GrammarTransition<ETypeInfo2EntryContainer>( 154 ETypeInfo2EntryStatesEnum.ETYPE_INFO2_ENTRY_SALT_STATE, 155 ETypeInfo2EntryStatesEnum.ETYPE_INFO2_ENTRY_S2KPARAMS_TAG_STATE, 156 KerberosConstants.ETYPE_INFO2_ENTRY_S2KPARAMS_TAG, 157 new CheckNotNullLength<ETypeInfo2EntryContainer>() ); 158 159 // -------------------------------------------------------------------------------------------- 160 // Transition from s2kparams tag to s2kparams value 161 // -------------------------------------------------------------------------------------------- 162 // ETYPE-INFO2-ENTRY ::= SEQUENCE { 163 // ... 164 // s2kparams [2] OCTET STRING OPTIONAL 165 super.transitions[ETypeInfo2EntryStatesEnum.ETYPE_INFO2_ENTRY_S2KPARAMS_TAG_STATE.ordinal()][UniversalTag.OCTET_STRING 166 .getValue()] = 167 new GrammarTransition<ETypeInfo2EntryContainer>( 168 ETypeInfo2EntryStatesEnum.ETYPE_INFO2_ENTRY_S2KPARAMS_TAG_STATE, 169 ETypeInfo2EntryStatesEnum.ETYPE_INFO2_ENTRY_S2KPARAMS_STATE, 170 UniversalTag.OCTET_STRING, 171 new StoreS2KParams() ); 172 } 173 174 175 /** 176 * Get the instance of this grammar 177 * 178 * @return An instance on the ETYPE-INFO2-ENTRY Grammar 179 */ 180 public static Grammar<ETypeInfo2EntryContainer> getInstance() 181 { 182 return instance; 183 } 184}