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.security; 020 021import org.apache.hadoop.classification.InterfaceAudience.Public; 022import org.apache.hadoop.classification.InterfaceStability.Unstable; 023import org.apache.hadoop.security.UserGroupInformation; 024 025import java.util.List; 026 027/** 028 * This request object contains all the context information to determine whether 029 * a user has permission to access the target entity. 030 * user : the user who's currently accessing 031 * accessType : the access type against the entity. 032 * entity : the target object user is accessing. 033 * appId : the associated app Id for current access. This could be null 034 * if no app is associated. 035 * appName : the associated app name for current access. This could be null if 036 * no app is associated. 037 * remoteAddress : The caller's remote ip address. 038 * forwardedAddresses : In case this is an http request, this contains the 039 * originating IP address of a client connecting to a web 040 * server through an HTTP proxy or load balancer. This 041 * parameter is null, if it's a RPC request. 042 */ 043@Public 044@Unstable 045public class AccessRequest { 046 047 private PrivilegedEntity entity; 048 private UserGroupInformation user; 049 private AccessType accessType; 050 private String appId; 051 private String appName; 052 private String remoteAddress; 053 private List<String> forwardedAddresses; 054 055 public AccessRequest(PrivilegedEntity entity, UserGroupInformation user, 056 AccessType accessType, String appId, String appName, String remoteAddress, 057 List<String> forwardedAddresses) { 058 this.entity = entity; 059 this.user = user; 060 this.accessType = accessType; 061 this.appId = appId; 062 this.appName = appName; 063 this.remoteAddress = remoteAddress; 064 this.forwardedAddresses = forwardedAddresses; 065 } 066 067 public UserGroupInformation getUser() { 068 return user; 069 } 070 071 public AccessType getAccessType() { 072 return accessType; 073 } 074 075 public String getAppId() { 076 return appId; 077 } 078 079 public String getAppName() { 080 return appName; 081 } 082 083 public PrivilegedEntity getEntity() { 084 return entity; 085 } 086 087 088 public List<String> getForwardedAddresses() { 089 return forwardedAddresses; 090 } 091 092 public String getRemoteAddress() { 093 return remoteAddress; 094 } 095}