1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, 13 * software distributed under the License is distributed on an 14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 * KIND, either express or implied. See the License for the 16 * specific language governing permissions and limitations 17 * under the License. 18 * 19 */ 20 package org.apache.directory.shared.kerberos.codec.krbPriv; 21 22 23 import org.apache.directory.api.asn1.ber.grammar.Grammar; 24 import org.apache.directory.api.asn1.ber.grammar.States; 25 26 27 /** 28 * This class stores the KRB-PRIV grammar's constants. It is also used for debugging 29 * purpose 30 * 31 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 32 */ 33 public enum KrbPrivStatesEnum implements States 34 { 35 // Start 36 START_STATE, // 0 37 38 // ----- KRB-SAFE component -------------------------------------- 39 KRB_PRIV_TAG_STATE, // 1 40 41 KRB_PRIV_SEQ_STATE, // 2 42 43 KRB_PRIV_PVNO_TAG_STATE, // 3 44 KRB_PRIV_PVNO_STATE, // 4 45 46 KRB_PRIV_MSGTYPE_TAG_STATE, // 5 47 KRB_PRIV_MSGTYPE_STATE, // 6 48 49 KRB_PRIV_EN_PART_TAG_STATE, // 7 50 51 // End 52 LAST_KRB_PRIV_STATE; // 8 53 54 /** 55 * Get the grammar name 56 * 57 * @param grammar The grammar code 58 * @return The grammar name 59 */ 60 public String getGrammarName( int grammar ) 61 { 62 return "KRB_PRIV_GRAMMAR"; 63 } 64 65 66 /** 67 * Get the grammar name 68 * 69 * @param grammar The grammar class 70 * @return The grammar name 71 */ 72 public String getGrammarName( Grammar<KrbPrivContainer> grammar ) 73 { 74 if ( grammar instanceof KrbPrivGrammar ) 75 { 76 return "KRB_PRIV_GRAMMAR"; 77 } 78 else 79 { 80 return "UNKNOWN GRAMMAR"; 81 } 82 } 83 84 85 /** 86 * Get the string representing the state 87 * 88 * @param state The state number 89 * @return The String representing the state 90 */ 91 public String getState( int state ) 92 { 93 return ( ( state == LAST_KRB_PRIV_STATE.ordinal() ) ? "LAST_KRB_PRIV_STATE" : name() ); 94 } 95 96 97 /** 98 * {@inheritDoc} 99 */ 100 public boolean isEndState() 101 { 102 return this == LAST_KRB_PRIV_STATE; 103 } 104 105 106 /** 107 * {@inheritDoc} 108 */ 109 public KrbPrivStatesEnum getStartState() 110 { 111 return START_STATE; 112 } 113 }