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 import org.apache.directory.api.ldap.model.constants.AuthenticationLevel; 24 25 26 /** 27 * The LastRequest types 28 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 29 */ 30 public enum LastReqType 31 { 32 /** 33 * Constant for the "none" last request type. 34 */ 35 NONE(0, AuthenticationLevel.NONE.toString()), 36 37 /** 38 * Constant for the "time of initial ticket" last request type. 39 */ 40 TIME_OF_INITIAL_TGT(1, "time of initial ticket"), 41 42 /** 43 * Constant for the "time of initial request" last request type. 44 */ 45 TIME_OF_INITIAL_REQ(2, "time of initial request"), 46 47 /** 48 * Constant for the "time of newest ticket" last request type. 49 */ 50 TIME_OF_NEWEST_TGT(3, "time of newest ticket"), 51 52 /** 53 * Constant for the "time of last renewal" last request type. 54 */ 55 TIME_OF_LAST_RENEWAL(4, "time of last renewal"), 56 57 /** 58 * Constant for the "time of last request" last request type. 59 */ 60 TIME_OF_LAST_REQ(5, "time of last request"), 61 62 /** 63 * Constant for the "time of password expiration" last request type. 64 */ 65 TIME_OF_PASSWORD_EXP(6, "time of password expiration"); 66 67 /** 68 * The name of the checksum type. 69 */ 70 private String name; 71 72 /** 73 * The value/code for the checksum type. 74 */ 75 private int value; 76 77 78 /** 79 * Private constructor prevents construction outside of this class. 80 */ 81 private LastReqType( int value, String name ) 82 { 83 this.value = value; 84 this.name = name; 85 } 86 87 88 /** 89 * Returns the last request type when specified by its ordinal. 90 * 91 * @param type The numeric type 92 * @return The last request type. 93 */ 94 public static LastReqType getTypeByValue( int type ) 95 { 96 for ( LastReqType lrt : LastReqType.values() ) 97 { 98 if ( type == lrt.getValue() ) 99 { 100 return lrt; 101 } 102 } 103 104 return NONE; 105 } 106 107 108 /** 109 * Returns the number associated with this last request type. 110 * 111 * @return The last request type ordinal. 112 */ 113 public int getValue() 114 { 115 return value; 116 } 117 118 119 /** 120 * @see Object#toString() 121 */ 122 @Override 123 public String toString() 124 { 125 return name + " (" + value + ")"; 126 } 127 }