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.types; 21 22 23 /** 24 * Type safe enumeration of Single-use Authentication Mechanism types 25 * 26 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 27 */ 28 public enum SamType 29 { 30 /* 31 * Enumeration elements are constructed once upon class loading. 32 * Order of appearance here determines the order of compareTo. 33 */ 34 35 /** safe SAM type enum for Enigma Logic */ 36 PA_SAM_TYPE_ENIGMA(1, "Enigma Logic"), 37 38 /** safe SAM type enum for Digital Pathways */ 39 PA_SAM_TYPE_DIGI_PATH(2, "Digital Pathways"), 40 41 /** safe SAM type enum for S/key where KDC has key 0 */ 42 PA_SAM_TYPE_SKEY_K0(3, "S/key where KDC has key 0"), 43 44 /** safe SAM type enum for Traditional S/Key */ 45 PA_SAM_TYPE_SKEY(4, "Traditional S/Key"), 46 47 /** safe SAM type enum for Security Dynamics */ 48 PA_SAM_TYPE_SECURID(5, "Security Dynamics"), 49 50 /** safe SAM type enum for CRYPTOCard */ 51 PA_SAM_TYPE_CRYPTOCARD(6, "CRYPTOCard"), 52 53 /** safe SAM type enum for Apache Software Foundation */ 54 PA_SAM_TYPE_APACHE(7, "Apache Software Foundation"); 55 56 /** the name of the sam type */ 57 private String name; 58 59 /** the value/code for the sam type */ 60 private int ordinal; 61 62 63 /** 64 * Private constructor prevents construction outside of this class. 65 */ 66 private SamType( int ordinal, String name ) 67 { 68 this.ordinal = ordinal; 69 this.name = name; 70 } 71 72 73 /** 74 * Returns the name of the SamType. 75 * 76 * @return the name of the SAM type 77 */ 78 @Override 79 public String toString() 80 { 81 return name; 82 } 83 84 85 /** 86 * Gets the ordinal by its ordinal value. 87 * 88 * @param ordinal the ordinal value of the ordinal 89 * @return the type corresponding to the ordinal value 90 */ 91 public static SamType getTypeByOrdinal( int ordinal ) 92 { 93 for ( SamType st : SamType.values() ) 94 { 95 if ( ordinal == st.getOrdinal() ) 96 { 97 return st; 98 } 99 } 100 101 return PA_SAM_TYPE_APACHE; 102 } 103 104 105 /** 106 * Gets the ordinal value associated with this SAM type. 107 * 108 * @return the ordinal value associated with this SAM type 109 */ 110 public int getOrdinal() 111 { 112 return ordinal; 113 } 114 }