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 */ 020 package org.apache.directory.shared.ldap.codec.extended.operations.certGeneration; 021 022 023 import org.apache.directory.shared.asn1.ber.grammar.IGrammar; 024 import org.apache.directory.shared.asn1.ber.grammar.IStates; 025 026 /** 027 * This class store the CertGeneration's grammar constants. It is also used 028 * for debugging purposes. 029 * 030 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 031 * @version $Rev: 664290 $, $Date: 2008-06-07 11:58:06 +0530 (Sat, 07 Jun 2008) $, 032 */ 033 public class CertGenerationStatesEnum implements IStates 034 { 035 036 /** start state*/ 037 public static final int START_STATE = 0; 038 039 /** sequence*/ 040 public static final int CERT_GENERATION_REQUEST_SEQUENCE_STATE = 1; 041 042 /** the target DN*/ 043 public static final int TARGETDN_STATE = 2; 044 045 /** the issuer DN*/ 046 public static final int ISSUER_STATE = 3; 047 048 /** the subject DN*/ 049 public static final int SUBJECT_STATE = 4; 050 051 /** the key algorithm*/ 052 public static final int KEY_ALGORITHM_STATE = 5; 053 054 /** terminal state */ 055 public static final int LAST_CERT_GENERATION_STATE = 6; 056 057 private static String[] certGenerationString = new String[] 058 { 059 "START_STATE", 060 "CERT_GENERATION_REQUEST_SEQUENCE_STATE", 061 "TARGETDN_STATE", "ISSUER_STATE", 062 "SUBJECT_STATE", 063 "KEY_ALGORITHM_STATE" 064 }; 065 066 /** a singleton instance*/ 067 private static CertGenerationStatesEnum instance = new CertGenerationStatesEnum(); 068 069 070 /** 071 * Get the grammar name 072 * 073 * @param grammar The grammar class 074 * @return The grammar name 075 */ 076 public String getGrammarName( IGrammar grammar ) 077 { 078 if ( grammar instanceof CertGenerationGrammar ) 079 { 080 return "CERT_GENERATION_GRAMMER"; 081 } 082 083 return "UNKNOWN GRAMMAR"; 084 } 085 086 087 /** 088 * Get the grammar name 089 * 090 * @param grammar The grammar code 091 * @return The grammar name 092 */ 093 public String getGrammarName( int grammar ) 094 { 095 return "CERT_GENERATION_GRAMMER"; 096 } 097 098 099 /** 100 * Get the string representing the state 101 * 102 * @param state The state number 103 * @return The String representing the state 104 */ 105 public String getState( int state ) 106 { 107 return ( ( state == GRAMMAR_END ) ? "CERT_GENERATION_END_STATE" : certGenerationString[state] ); 108 } 109 110 /** 111 * Get an instance of this class 112 * 113 * @return An instance on this class 114 */ 115 public static IStates getInstance() 116 { 117 return instance; 118 } 119 }