@Test public void testProviderRefreshWithoutAccessBoundary() throws IOException { TestingTools.startServer(new FakeServer(fakeKDC), grpcCleanup); Configuration conf = TestingTools.getBrokerConfig(); conf.set("gcp.token.broker.access.boundary.enabled", "false"); Subject alice = fakeKDC.login(ALICE); UserGroupInformation.loginUserFromSubject(alice); AccessToken token = refresh(conf); assertEquals("FakeAccessToken/AuthenticatedUser=" + ALICE + ";Owner=" + ALICE + ";Target=", token.getToken()); UserGroupInformation.setLoginUser(null); }
@Override public void refresh() { UserGroupInformation currentUser; UserGroupInformation loginUser; try { currentUser = UserGroupInformation.getCurrentUser(); loginUser = UserGroupInformation.getLoginUser(); } catch (IOException e) { throw new RuntimeException(e); } BrokerServerInfo serverInfo = Utils.getBrokerDetailsFromConfig(config); BrokerBaseCredentials credentials; if (tokenIdentifier == null) { credentials = new BrokerKerberosCredentials( serverInfo, currentUser.getUserName(), Collections.singleton(BrokerTokenIdentifier.GCS_SCOPE), Utils.getTarget(config, service)); } else { credentials = new BrokerSessionCredentials(serverInfo, tokenIdentifier.getSessionToken()); } loginUser.doAs((PrivilegedAction<Void>) () -> { try { credentials.refresh(); } catch (IOException e) { throw new RuntimeException(e); } return null; }); com.google.auth.oauth2.AccessToken token = credentials.getAccessToken(); accessToken = new AccessToken(token.getTokenValue(), token.getExpirationTime().getTime()); }
BrokerAccessTokenProvider implements AccessTokenProvider { @Override public void refresh() { UserGroupInformation currentUser; UserGroupInformation loginUser; try { currentUser = UserGroupInformation.getCurrentUser(); loginUser = UserGroupInformation.getLoginUser(); } catch (IOException e) { throw new RuntimeException(e); } BrokerServerInfo serverInfo = Utils.getBrokerDetailsFromConfig(config); BrokerBaseCredentials credentials; if (tokenIdentifier == null) { credentials = new BrokerKerberosCredentials( serverInfo, currentUser.getUserName(), Collections.singleton(BrokerTokenIdentifier.GCS_SCOPE), Utils.getTarget(config, service)); } else { credentials = new BrokerSessionCredentials(serverInfo, tokenIdentifier.getSessionToken()); } loginUser.doAs((PrivilegedAction<Void>) () -> { try { credentials.refresh(); } catch (IOException e) { throw new RuntimeException(e); } return null; }); com.google.auth.oauth2.AccessToken token = credentials.getAccessToken(); accessToken = new AccessToken(token.getTokenValue(), token.getExpirationTime().getTime()); } }
BrokerAccessTokenProvider implements AccessTokenProvider { @Override public void refresh() { UserGroupInformation currentUser; UserGroupInformation loginUser; try { currentUser = UserGroupInformation.getCurrentUser(); loginUser = UserGroupInformation.getLoginUser(); } catch (IOException e) { throw new RuntimeException(e); } BrokerServerInfo serverInfo = Utils.getBrokerDetailsFromConfig(config); BrokerBaseCredentials credentials; if (tokenIdentifier == null) { credentials = new BrokerKerberosCredentials( serverInfo, currentUser.getUserName(), Collections.singleton(BrokerTokenIdentifier.GCS_SCOPE), Utils.getTarget(config, service)); } else { credentials = new BrokerSessionCredentials(serverInfo, tokenIdentifier.getSessionToken()); } loginUser.doAs((PrivilegedAction<Void>) () -> { try { credentials.refresh(); } catch (IOException e) { throw new RuntimeException(e); } return null; }); com.google.auth.oauth2.AccessToken token = credentials.getAccessToken(); accessToken = new AccessToken(token.getTokenValue(), token.getExpirationTime().getTime()); } BrokerAccessTokenProvider(Text service);  BrokerAccessTokenProvider(Text service, BrokerTokenIdentifier bti); }
BrokerAccessTokenProvider implements AccessTokenProvider { @Override public void refresh() { UserGroupInformation currentUser; UserGroupInformation loginUser; try { currentUser = UserGroupInformation.getCurrentUser(); loginUser = UserGroupInformation.getLoginUser(); } catch (IOException e) { throw new RuntimeException(e); } BrokerServerInfo serverInfo = Utils.getBrokerDetailsFromConfig(config); BrokerBaseCredentials credentials; if (tokenIdentifier == null) { credentials = new BrokerKerberosCredentials( serverInfo, currentUser.getUserName(), Collections.singleton(BrokerTokenIdentifier.GCS_SCOPE), Utils.getTarget(config, service)); } else { credentials = new BrokerSessionCredentials(serverInfo, tokenIdentifier.getSessionToken()); } loginUser.doAs((PrivilegedAction<Void>) () -> { try { credentials.refresh(); } catch (IOException e) { throw new RuntimeException(e); } return null; }); com.google.auth.oauth2.AccessToken token = credentials.getAccessToken(); accessToken = new AccessToken(token.getTokenValue(), token.getExpirationTime().getTime()); } BrokerAccessTokenProvider(Text service);  BrokerAccessTokenProvider(Text service, BrokerTokenIdentifier bti); @Override AccessToken getAccessToken(); @Override void refresh(); @Override void setConf(Configuration config); @Override Configuration getConf(); }
BrokerAccessTokenProvider implements AccessTokenProvider { @Override public void refresh() { UserGroupInformation currentUser; UserGroupInformation loginUser; try { currentUser = UserGroupInformation.getCurrentUser(); loginUser = UserGroupInformation.getLoginUser(); } catch (IOException e) { throw new RuntimeException(e); } BrokerServerInfo serverInfo = Utils.getBrokerDetailsFromConfig(config); BrokerBaseCredentials credentials; if (tokenIdentifier == null) { credentials = new BrokerKerberosCredentials( serverInfo, currentUser.getUserName(), Collections.singleton(BrokerTokenIdentifier.GCS_SCOPE), Utils.getTarget(config, service)); } else { credentials = new BrokerSessionCredentials(serverInfo, tokenIdentifier.getSessionToken()); } loginUser.doAs((PrivilegedAction<Void>) () -> { try { credentials.refresh(); } catch (IOException e) { throw new RuntimeException(e); } return null; }); com.google.auth.oauth2.AccessToken token = credentials.getAccessToken(); accessToken = new AccessToken(token.getTokenValue(), token.getExpirationTime().getTime()); } BrokerAccessTokenProvider(Text service);  BrokerAccessTokenProvider(Text service, BrokerTokenIdentifier bti); @Override AccessToken getAccessToken(); @Override void refresh(); @Override void setConf(Configuration config); @Override Configuration getConf();  }