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.yarn.api.records; 020 021import java.nio.ByteBuffer; 022 023import org.apache.hadoop.classification.InterfaceAudience.Private; 024import org.apache.hadoop.classification.InterfaceAudience.Public; 025import org.apache.hadoop.classification.InterfaceStability.Stable; 026import org.apache.hadoop.classification.InterfaceStability.Unstable; 027import org.apache.hadoop.yarn.util.Records; 028 029/** 030 * <p><code>Token</code> is the security entity used by the framework 031 * to verify authenticity of any resource.</p> 032 */ 033@Public 034@Stable 035public abstract class Token { 036 037 @Private 038 @Unstable 039 public static Token newInstance(byte[] identifier, String kind, byte[] password, 040 String service) { 041 Token token = Records.newRecord(Token.class); 042 token.setIdentifier(ByteBuffer.wrap(identifier)); 043 token.setKind(kind); 044 token.setPassword(ByteBuffer.wrap(password)); 045 token.setService(service); 046 return token; 047 } 048 049 /** 050 * Get the token identifier. 051 * @return token identifier 052 */ 053 @Public 054 @Stable 055 public abstract ByteBuffer getIdentifier(); 056 057 @Private 058 @Unstable 059 public abstract void setIdentifier(ByteBuffer identifier); 060 061 /** 062 * Get the token password 063 * @return token password 064 */ 065 @Public 066 @Stable 067 public abstract ByteBuffer getPassword(); 068 069 @Private 070 @Unstable 071 public abstract void setPassword(ByteBuffer password); 072 073 /** 074 * Get the token kind. 075 * @return token kind 076 */ 077 @Public 078 @Stable 079 public abstract String getKind(); 080 081 @Private 082 @Unstable 083 public abstract void setKind(String kind); 084 085 /** 086 * Get the service to which the token is allocated. 087 * @return service to which the token is allocated 088 */ 089 @Public 090 @Stable 091 public abstract String getService(); 092 093 @Private 094 @Unstable 095 public abstract void setService(String service); 096 097}