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.tgsRep; 021 022 023import org.apache.directory.api.asn1.ber.grammar.AbstractGrammar; 024import org.apache.directory.api.asn1.ber.grammar.Grammar; 025import org.apache.directory.api.asn1.ber.grammar.GrammarTransition; 026import org.apache.directory.shared.kerberos.KerberosConstants; 027import org.apache.directory.shared.kerberos.codec.tgsRep.actions.StoreKdcRep; 028import org.slf4j.Logger; 029import org.slf4j.LoggerFactory; 030 031 032/** 033 * This class implements the TGS-REP structure. All the actions are declared 034 * in this class. As it is a singleton, these declaration are only done once. If 035 * an action is to be added or modified, this is where the work is to be done ! 036 * 037 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 038 */ 039public final class TgsRepGrammar extends AbstractGrammar<TgsRepContainer> 040{ 041 /** The logger */ 042 static final Logger LOG = LoggerFactory.getLogger( TgsRepGrammar.class ); 043 044 /** A speedup for logger */ 045 static final boolean IS_DEBUG = LOG.isDebugEnabled(); 046 047 /** The instance of grammar. TgsRepGrammar is a singleton */ 048 private static Grammar<TgsRepContainer> instance = new TgsRepGrammar(); 049 050 051 /** 052 * Creates a new TgsRepGrammar object. 053 */ 054 @SuppressWarnings("unchecked") 055 private TgsRepGrammar() 056 { 057 setName( TgsRepGrammar.class.getName() ); 058 059 // Create the transitions table 060 super.transitions = new GrammarTransition[TgsRepStatesEnum.LAST_TGS_REP_STATE.ordinal()][256]; 061 062 // ============================================================================================ 063 // TS-REP 064 // ============================================================================================ 065 // -------------------------------------------------------------------------------------------- 066 // Transition from TS-REP init to KDC-REP 067 // -------------------------------------------------------------------------------------------- 068 // TGS-REP ::= [APPLICATION 13] KDC-REP 069 super.transitions[TgsRepStatesEnum.START_STATE.ordinal()][KerberosConstants.TGS_REP_TAG] = 070 new GrammarTransition<TgsRepContainer>( 071 TgsRepStatesEnum.START_STATE, 072 TgsRepStatesEnum.TGS_REP_STATE, 073 KerberosConstants.TGS_REP_TAG, 074 new StoreKdcRep() ); 075 } 076 077 078 /** 079 * Get the instance of this grammar 080 * 081 * @return An instance on the AS-REP Grammar 082 */ 083 public static Grammar<TgsRepContainer> getInstance() 084 { 085 return instance; 086 } 087}