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.krbSafeBody; 021 022 023import org.apache.directory.api.asn1.ber.grammar.Grammar; 024import org.apache.directory.api.asn1.ber.grammar.States; 025 026 027/** 028 * This class stores the KRB-SAFE-BODY grammar's constants. It is also used for debugging 029 * purpose 030 * 031 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 032 */ 033public enum KrbSafeBodyStatesEnum implements States 034{ 035 // Start 036 START_STATE, // 0 037 038 // ----- KRB-ERROR component -------------------------------------- 039 KRB_SAFE_BODY_SEQ_TAG_STATE, // 1 040 041 KRB_SAFE_BODY_USER_DATA_TAG_STATE, // 2 042 KRB_SAFE_BODY_USER_DATA_STATE, // 3 043 044 KRB_SAFE_BODY_TIMESTAMP_TAG_STATE, // 4 045 KRB_SAFE_BODY_TIMESTAMP_STATE, // 5 046 047 KRB_SAFE_BODY_USEC_TAG_STATE, // 6 048 KRB_SAFE_BODY_USEC_STATE, // 7 049 050 KRB_SAFE_BODY_SEQ_NUMBER_TAG_STATE, // 8 051 KRB_SAFE_BODY_SEQ_NUMBER_STATE, // 9 052 053 KRB_SAFE_BODY_SENDER_ADDRESS_TAG_STATE, // 10 054 055 KRB_SAFE_BODY_RECIPIENT_ADDRESS_TAG_STATE, // 11 056 057 // End 058 LAST_KRB_SAFE_BODY_STATE; // 12 059 060 /** 061 * Get the grammar name 062 * 063 * @param grammar The grammar code 064 * @return The grammar name 065 */ 066 public String getGrammarName( int grammar ) 067 { 068 return "KRB_SAFE_BODY_GRAMMAR"; 069 } 070 071 072 /** 073 * Get the grammar name 074 * 075 * @param grammar The grammar class 076 * @return The grammar name 077 */ 078 public String getGrammarName( Grammar<KrbSafeBodyContainer> grammar ) 079 { 080 if ( grammar instanceof KrbSafeBodyGrammar ) 081 { 082 return "KRB_SAFE_BODY_GRAMMAR"; 083 } 084 else 085 { 086 return "UNKNOWN GRAMMAR"; 087 } 088 } 089 090 091 /** 092 * Get the string representing the state 093 * 094 * @param state The state number 095 * @return The String representing the state 096 */ 097 public String getState( int state ) 098 { 099 return ( ( state == LAST_KRB_SAFE_BODY_STATE.ordinal() ) ? "LAST_KRB_SAFE_BODY_STATE" : name() ); 100 } 101 102 103 /** 104 * {@inheritDoc} 105 */ 106 public boolean isEndState() 107 { 108 return this == LAST_KRB_SAFE_BODY_STATE; 109 } 110 111 112 /** 113 * {@inheritDoc} 114 */ 115 public KrbSafeBodyStatesEnum getStartState() 116 { 117 return START_STATE; 118 } 119}