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.principalName; 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 store the PrincipalName 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 PrincipalNameStatesEnum implements States 34 { 35 // Start 36 START_STATE, // 0 37 38 // ----- PrincipalName message -------------------------------------- 39 PRINCIPAL_NAME_SEQ_STATE, // 1 40 41 PRINCIPAL_NAME_NAME_TYPE_TAG_STATE, // 2 42 PRINCIPAL_NAME_NAME_TYPE_STATE, // 3 43 44 PRINCIPAL_NAME_NAME_STRING_SEQ_STATE, // 4 45 46 PRINCIPAL_NAME_NAME_STRING_TAG_STATE, // 5 47 PRINCIPAL_NAME_NAME_STRING_STATE, // 6 48 49 // End 50 LAST_PRINCIPAL_NAME_STATE; // 7 51 52 /** 53 * Get the grammar name 54 * 55 * @param grammar The grammar code 56 * @return The grammar name 57 */ 58 public String getGrammarName( int grammar ) 59 { 60 return "PRINCIPAL_NAME_GRAMMAR"; 61 } 62 63 64 /** 65 * Get the grammar name 66 * 67 * @param grammar The grammar class 68 * @return The grammar name 69 */ 70 public String getGrammarName( Grammar<PrincipalNameContainer> grammar ) 71 { 72 if ( grammar instanceof PrincipalNameGrammar ) 73 { 74 return "PRINCIPAL_NAME_GRAMMAR"; 75 } 76 else 77 { 78 return "UNKNOWN GRAMMAR"; 79 } 80 } 81 82 83 /** 84 * Get the string representing the state 85 * 86 * @param state The state number 87 * @return The String representing the state 88 */ 89 public String getState( int state ) 90 { 91 return ( ( state == LAST_PRINCIPAL_NAME_STATE.ordinal() ) ? "PRINCIPAL_NAME_END_STATE" : name() ); 92 } 93 94 95 /** 96 * {@inheritDoc} 97 */ 98 public boolean isEndState() 99 { 100 return this == LAST_PRINCIPAL_NAME_STATE; 101 } 102 103 104 /** 105 * {@inheritDoc} 106 */ 107 public PrincipalNameStatesEnum getStartState() 108 { 109 return START_STATE; 110 } 111 }