private String getUserNameForGroups(SessionState ss) { // This should be removed when authenticator and the 2-username mess is cleaned up. if (ss.getAuthenticator() != null) { String userName = ss.getAuthenticator().getUserName(); if (userName != null) return userName; } return ss.getUserName(); }
private List<String> getGroupNames() { SessionState ss = SessionState.get(); if (ss != null && ss.getAuthenticator() != null) { return ss.getAuthenticator().getGroupNames(); } return null; }
private List<String> getGroupNames() { SessionState ss = SessionState.get(); if (ss != null && ss.getAuthenticator() != null) { return ss.getAuthenticator().getGroupNames(); } return null; }
public static List<String> getGroupsFromAuthenticator() { if (SessionState.get() != null && SessionState.get().getAuthenticator() != null) { return SessionState.get().getAuthenticator().getGroupNames(); } return null; }
/** * * @return username from current SessionState authenticator. username will be * null if there is no current SessionState object or authenticator is * null. */ public static String getUserFromAuthenticator() { if (SessionState.get() != null && SessionState.get().getAuthenticator() != null) { return SessionState.get().getAuthenticator().getUserName(); } return null; }
/** * * @return username from current SessionState authenticator. username will be * null if there is no current SessionState object or authenticator is * null. */ public static String getUserFromAuthenticator() { if (SessionState.get() != null && SessionState.get().getAuthenticator() != null) { return SessionState.get().getAuthenticator().getUserName(); } return null; }
private boolean cancelOperation(Operation operation, boolean isAdmin, String errMsg) throws HiveSQLException { if (isAdmin || operation.getParentSession().getUserName().equals(SessionState.get() .getAuthenticator().getUserName())) { OperationHandle handle = operation.getHandle(); operationManager.cancelOperation(handle, errMsg); return true; } else { return false; } }
authorizerProviders = HiveUtils.getMetaStoreAuthorizeProviderManagers( hiveConf, HiveConf.ConfVars.HIVE_METASTORE_AUTHORIZATION_MANAGER, SessionState.get().getAuthenticator()); for (HiveMetastoreAuthorizationProvider authProvider : authorizerProviders) { if (authProvider.getHivePolicyProvider() != null) {
String userName = null; if (ss != null) { userName = ss.getAuthenticator() != null ? ss.getAuthenticator().getUserName() : ss.getUserName();
authorizerProviders = HiveUtils.getMetaStoreAuthorizeProviderManagers( hiveConf, HiveConf.ConfVars.HIVE_METASTORE_AUTHORIZATION_MANAGER, SessionState.get().getAuthenticator()); for (HiveMetastoreAuthorizationProvider authProvider : authorizerProviders) { if (authProvider.getHivePolicyProvider() != null) {
object.put("OUTPUTS", jsonOutput); String userName = SessionState.get().getAuthenticator().getUserName(); Object jsonUser = toJson("CURRENT_USER", userName, out, work); if (work.isFormatted()) {
/** * Test if the authorization factory gets the username set in the SessionState constructor * @throws Exception */ @Test public void testSessionConstructorUser() throws Exception { final String USER_NAME = "authtestuser"; SessionState ss = new SessionState(getAuthV2HiveConf(), USER_NAME); setupDataNucleusFreeHive(ss.getConf()); SessionState.start(ss); ss.getAuthenticator(); Assert.assertEquals("check username", USER_NAME, HiveAuthorizerStoringUserNameFactory.username); }
/** * Test that the groupNames are retrieved properly from UGI * @throws Exception */ @Test public void testSessionGetGroupNames() throws Exception { final String testUser = "authtestuser"; final List<String> testGroups = Arrays.asList("group1", "group2"); UserGroupInformation.createUserForTesting(testUser, testGroups.toArray(new String[0])); SessionState ss = new SessionState(getAuthV2HiveConf(), testUser); setupDataNucleusFreeHive(ss.getConf()); assertEquals("check groups", testGroups, ss.getAuthenticator().getGroupNames()); }
MetastoreConf.getVar(hiveConf, MetastoreConf.ConfVars.HIVE_AUTHORIZATION_MANAGER)!= null) { List<HiveMetastoreAuthorizationProvider> providers = HiveUtils.getMetaStoreAuthorizeProviderManagers( hiveConf, HiveConf.ConfVars.HIVE_METASTORE_AUTHORIZATION_MANAGER, SessionState.get().getAuthenticator()); for (HiveMetastoreAuthorizationProvider provider : providers) { if (provider.getHivePolicyProvider() != null) {
object.put("OUTPUTS", jsonOutput); String userName = SessionState.get().getAuthenticator().getUserName(); Object jsonUser = toJson("CURRENT_USER", userName, out, work); if (work.isFormatted()) {
/** * Test if the authorization factory gets the username provided by * the authenticator, if SesstionState is created without username * @throws Exception */ @Test public void testSessionDefaultUser() throws Exception { SessionState ss = new SessionState(getAuthV2HiveConf()); setupDataNucleusFreeHive(ss.getConf()); SessionState.start(ss); Assert.assertEquals("check username", ss.getAuthenticator().getUserName(), HiveAuthorizerStoringUserNameFactory.username); }
/** * Test that the groupNames returned is null, when the user name is null. The user name is null * in the case of embedded HS2 and we assert that we don't throw an NPE in that case. * @throws Exception */ @Test public void testSessionNullUser() throws Exception { SessionState ss = new SessionState(getAuthV2HiveConf(), null); setupDataNucleusFreeHive(ss.getConf()); SessionState.start(ss); assertNull("getGroupNames when userName == null", ss.getAuthenticator().getGroupNames()); }
private List<String> getGroupNames() { SessionState ss = SessionState.get(); if (ss != null && ss.getAuthenticator() != null) { return ss.getAuthenticator().getGroupNames(); } return null; }
private String getUserName() { SessionState ss = SessionState.get(); if (ss != null && ss.getAuthenticator() != null) { return ss.getAuthenticator().getUserName(); } return null; }
/** * * @return username from current SessionState authenticator. username will be * null if there is no current SessionState object or authenticator is * null. */ public static String getUserFromAuthenticator() { if (SessionState.get() != null && SessionState.get().getAuthenticator() != null) { return SessionState.get().getAuthenticator().getUserName(); } return null; }