Line data Source code
1 : // Copyright (C) 2010 The Android Open Source Project 2 : // 3 : // Licensed under the Apache License, Version 2.0 (the "License"); 4 : // you may not use this file except in compliance with the License. 5 : // You may obtain a copy of the License at 6 : // 7 : // http://www.apache.org/licenses/LICENSE-2.0 8 : // 9 : // Unless required by applicable law or agreed to in writing, software 10 : // distributed under the License is distributed on an "AS IS" BASIS, 11 : // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 : // See the License for the specific language governing permissions and 13 : // limitations under the License. 14 : 15 : package com.google.gerrit.server; 16 : 17 : import com.google.gerrit.server.account.GroupMembership; 18 : import com.google.inject.Inject; 19 : import com.google.inject.assistedinject.Assisted; 20 : import java.net.SocketAddress; 21 : 22 : /** Identity of a peer daemon process that isn't this JVM. */ 23 : public class PeerDaemonUser extends CurrentUser { 24 : /** Magic username used by peers when they authenticate. */ 25 : public static final String USER_NAME = "Gerrit Code Review"; 26 : 27 : public interface Factory { 28 : PeerDaemonUser create(@Assisted SocketAddress peer); 29 : } 30 : 31 : private final SocketAddress peer; 32 : 33 : @Inject 34 1 : protected PeerDaemonUser(@Assisted SocketAddress peer) { 35 1 : this.peer = peer; 36 1 : } 37 : 38 : @Override 39 : public GroupMembership getEffectiveGroups() { 40 1 : return GroupMembership.EMPTY; 41 : } 42 : 43 : @Override 44 : public Object getCacheKey() { 45 0 : return getRemoteAddress(); 46 : } 47 : 48 : public SocketAddress getRemoteAddress() { 49 0 : return peer; 50 : } 51 : 52 : @Override 53 : public String toString() { 54 0 : return "PeerDaemon[address " + getRemoteAddress() + "]"; 55 : } 56 : }