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, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018 019package org.apache.hadoop.security.token; 020 021import java.io.IOException; 022 023import org.apache.hadoop.classification.InterfaceAudience; 024import org.apache.hadoop.classification.InterfaceStability; 025import org.apache.hadoop.conf.Configuration; 026import org.apache.hadoop.io.Text; 027 028/** 029 * This is the interface for plugins that handle tokens. 030 */ 031@InterfaceAudience.Public 032@InterfaceStability.Evolving 033public abstract class TokenRenewer { 034 035 /** 036 * Does this renewer handle this kind of token? 037 * @param kind the kind of the token 038 * @return true if this renewer can renew it 039 */ 040 public abstract boolean handleKind(Text kind); 041 042 /** 043 * Is the given token managed? Only managed tokens may be renewed or 044 * cancelled. 045 * @param token the token being checked 046 * @return true if the token may be renewed or cancelled 047 * @throws IOException 048 */ 049 public abstract boolean isManaged(Token<?> token) throws IOException; 050 051 /** 052 * Renew the given token. 053 * @return the new expiration time 054 * @throws IOException 055 * @throws InterruptedException 056 */ 057 public abstract long renew(Token<?> token, 058 Configuration conf 059 ) throws IOException, InterruptedException; 060 061 /** 062 * Cancel the given token 063 * @throws IOException 064 * @throws InterruptedException 065 */ 066 public abstract void cancel(Token<?> token, 067 Configuration conf 068 ) throws IOException, InterruptedException; 069}