/** * Returns the full user name. For Kerberos principals this will include * the host and realm portions of the principal name. * * @return User full name. */ public String getName() { return ugi.getUserName(); }
@VisibleForTesting String getUserName() { if (ugi != null) { return ugi.getUserName(); } else { return null; } } }
@VisibleForTesting String getUserName() { if (ugi != null) { return ugi.getUserName(); } else { return null; } } }
private void renameScriptFile(final Path renamedScriptPath) throws IOException, InterruptedException { appSubmitterUgi.doAs(new PrivilegedExceptionAction<Void>() { @Override public Void run() throws IOException { FileSystem fs = renamedScriptPath.getFileSystem(conf); fs.rename(new Path(jstormMasterContext.scriptPath), renamedScriptPath); return null; } }); LOG.info("User " + appSubmitterUgi.getUserName() + " added suffix(.sh/.bat) to script file as " + renamedScriptPath); }
/** * @deprecated Use {@link org.apache.gobblin.data.management.trash.TrashFactory}. */ @Deprecated public Trash(FileSystem fs, Properties props) throws IOException { this(fs, props, UserGroupInformation.getCurrentUser().getUserName()); }
/** * @return the user name set in hadoop.job.ugi param or the current user from System * @throws IOException if underlying Hadoop call throws LoginException */ public static String getUser() throws IOException { try { UserGroupInformation ugi = getUGI(); return ugi.getUserName(); } catch (LoginException le) { throw new IOException(le); } }
/** * @return the user name set in hadoop.job.ugi param or the current user from System * @throws IOException */ public String getUser() throws IOException { try { UserGroupInformation ugi = Utils.getUGI(); return ugi.getUserName(); } catch (LoginException le) { throw new IOException(le); } }
@Override public void run() { try { ugi.checkTGTAndReloginFromKeytab(); } catch (IOException e) { LOG.warn("Error occured during checkTGTAndReloginFromKeytab() for user " + ugi.getUserName(), e); } } }, CHECK_TGT_INTERVAL, CHECK_TGT_INTERVAL, TimeUnit.SECONDS);
public String makeIdentity(Schedulable obj) { UserGroupInformation ugi = obj.getUserGroupInformation(); if (ugi == null) { return null; } return ugi.getUserName(); } }
private void print() throws IOException { System.out.println("User: " + getUserName()); System.out.print("Group Ids: "); System.out.println(); String[] groups = getGroupNames(); System.out.print("Groups: "); for(int i=0; i < groups.length; i++) { System.out.print(groups[i] + " "); } System.out.println(); }
public String run() throws IOException, MetaException, TException { String u = ugi.getUserName(); return client.getDelegationToken(c.getUser(), u); } });
private String getRequestUser(HookContext hookContext) { String requestuser = hookContext.getUserName(); if (requestuser == null) { requestuser = hookContext.getUgi().getUserName(); } return requestuser; }
private static UserGroupInformation loginAndProxyAsUser(@NonNull String userNameToProxyAs, @NonNull String superUserName, Path superUserKeytabLocation) throws IOException { if (!UserGroupInformation.getLoginUser().getUserName().equals(superUserName)) { Preconditions.checkNotNull(superUserKeytabLocation); UserGroupInformation.loginUserFromKeytab(superUserName, superUserKeytabLocation.toString()); } return UserGroupInformation.createProxyUser(userNameToProxyAs, UserGroupInformation.getLoginUser()); }
public synchronized void cancelDelegationToken(String tokenStrForm) throws IOException { Token<DelegationTokenIdentifier> t= new Token<>(); t.decodeFromUrlString(tokenStrForm); String user = UserGroupInformation.getCurrentUser().getUserName(); cancelToken(t, user); }
private void printUGI(UserGroupInformation ugi) { if (ugi != null) { // dump login information AuthenticationMethod authMethod = ugi.getAuthenticationMethod(); LOG.info("\n{} \nUser: {} \nAuth method: {} \nKeytab: {} \n", new Object[] { authMethod.equals(AuthenticationMethod.PROXY) ? "Proxy as: " : "Logged as: ", ugi.getUserName(), authMethod, ugi.isFromKeytab() } ); } }
private void mockUserGroupInformation(String username) throws IOException { // need to mock out since FileSystem.create calls UGI, which occasionally has issues on some // systems PowerMockito.mockStatic(UserGroupInformation.class); final UserGroupInformation ugi = mock(UserGroupInformation.class); when(UserGroupInformation.getCurrentUser()).thenReturn(ugi); when(ugi.getUserName()).thenReturn(username); when(ugi.getShortUserName()).thenReturn(username.split("@")[0]); }
@Test public void testUserReplacement() throws IOException { Properties properties = new Properties(); properties.setProperty(Trash.TRASH_LOCATION_KEY, "/trash/$USER/dir"); Path expectedTrashPath = new Path("/trash/" + UserGroupInformation.getCurrentUser().getUserName() + "/dir"); TrashTestBase trash = new TrashTestBase(properties); Assert.assertTrue(trash.trash.getTrashLocation().equals(expectedTrashPath)); }
public static UserInformation toProtoUserInfo(User user) { UserInformation.Builder userInfoPB = UserInformation.newBuilder(); userInfoPB.setEffectiveUser(user.getName()); if (user.getUGI().getRealUser() != null) { userInfoPB.setRealUser(user.getUGI().getRealUser().getUserName()); } return userInfoPB.build(); }
@Test public void testRpcFallbackToSimpleAuth() throws Exception { String clientUsername = "testuser"; UserGroupInformation clientUgi = UserGroupInformation.createUserForTesting(clientUsername, new String[] { clientUsername }); // check that the client user is insecure assertNotSame(ugi, clientUgi); assertEquals(AuthenticationMethod.SIMPLE, clientUgi.getAuthenticationMethod()); assertEquals(clientUsername, clientUgi.getUserName()); clientConf.set(User.HBASE_SECURITY_CONF_KEY, "simple"); serverConf.setBoolean(RpcServer.FALLBACK_TO_INSECURE_CLIENT_AUTH, true); callRpcService(User.create(clientUgi)); }
@Test public void testRpcCallWithEnabledKerberosSaslAuth() throws Exception { UserGroupInformation ugi2 = UserGroupInformation.getCurrentUser(); // check that the login user is okay: assertSame(ugi2, ugi); assertEquals(AuthenticationMethod.KERBEROS, ugi.getAuthenticationMethod()); assertEquals(krbPrincipal, ugi.getUserName()); callRpcService(User.create(ugi2)); }