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 */ 020package org.apache.directory.shared.kerberos.codec.types; 021 022 023import org.apache.directory.api.ldap.model.constants.AuthenticationLevel; 024 025 026/** 027 * The LastRequest types 028 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 029 */ 030public enum LastReqType 031{ 032 /** 033 * Constant for the "none" last request type. 034 */ 035 NONE(0, AuthenticationLevel.NONE.toString()), 036 037 /** 038 * Constant for the "time of initial ticket" last request type. 039 */ 040 TIME_OF_INITIAL_TGT(1, "time of initial ticket"), 041 042 /** 043 * Constant for the "time of initial request" last request type. 044 */ 045 TIME_OF_INITIAL_REQ(2, "time of initial request"), 046 047 /** 048 * Constant for the "time of newest ticket" last request type. 049 */ 050 TIME_OF_NEWEST_TGT(3, "time of newest ticket"), 051 052 /** 053 * Constant for the "time of last renewal" last request type. 054 */ 055 TIME_OF_LAST_RENEWAL(4, "time of last renewal"), 056 057 /** 058 * Constant for the "time of last request" last request type. 059 */ 060 TIME_OF_LAST_REQ(5, "time of last request"), 061 062 /** 063 * Constant for the "time of password expiration" last request type. 064 */ 065 TIME_OF_PASSWORD_EXP(6, "time of password expiration"); 066 067 /** 068 * The name of the checksum type. 069 */ 070 private String name; 071 072 /** 073 * The value/code for the checksum type. 074 */ 075 private int value; 076 077 078 /** 079 * Private constructor prevents construction outside of this class. 080 */ 081 private LastReqType( int value, String name ) 082 { 083 this.value = value; 084 this.name = name; 085 } 086 087 088 /** 089 * Returns the last request type when specified by its ordinal. 090 * 091 * @param type The numeric type 092 * @return The last request type. 093 */ 094 public static LastReqType getTypeByValue( int type ) 095 { 096 for ( LastReqType lrt : LastReqType.values() ) 097 { 098 if ( type == lrt.getValue() ) 099 { 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}