@Test public void getUserMustReturnNullWhenTokenIsMachinePrefixedButUserForSuchTokenDoesNotExist() throws NotFoundException { final Subject user = ssoClient.getSubject("machine123456789", "client"); assertNull(user); verify(registrySpy).getUserId("machine123456789"); }
@Override public Subject getSubject(String token, String clientUrl) { if (!token.startsWith("machine")) { return super.getSubject(token, clientUrl); } try { final User user = userManager.getById(tokenRegistry.getUserId(token)); return new SubjectImpl(user.getName(), user.getId(), token, false); } catch (ApiException x) { LOG.warn(x.getLocalizedMessage(), x); } return null; }
MachineSsoServerClient extends HttpSsoServerClient { @Override public Subject getSubject(String token, String clientUrl) { if (!token.startsWith("machine")) { return super.getSubject(token, clientUrl); } try { final User user = userManager.getById(tokenRegistry.getUserId(token)); return new SubjectImpl(user.getName(), user.getId(), token, false); } catch (ApiException x) { LOG.warn(x.getLocalizedMessage(), x); } return null; } }
MachineSsoServerClient extends HttpSsoServerClient { @Override public Subject getSubject(String token, String clientUrl) { if (!token.startsWith("machine")) { return super.getSubject(token, clientUrl); } try { final User user = userManager.getById(tokenRegistry.getUserId(token)); return new SubjectImpl(user.getName(), user.getId(), token, false); } catch (ApiException x) { LOG.warn(x.getLocalizedMessage(), x); } return null; } @Inject  MachineSsoServerClient(
      @Named("che.api") String apiEndpoint,
      HttpJsonRequestFactory requestFactory,
      MachineTokenRegistry tokenRegistry,
      UserManager userManager); }
MachineSsoServerClient extends HttpSsoServerClient { @Override public Subject getSubject(String token, String clientUrl) { if (!token.startsWith("machine")) { return super.getSubject(token, clientUrl); } try { final User user = userManager.getById(tokenRegistry.getUserId(token)); return new SubjectImpl(user.getName(), user.getId(), token, false); } catch (ApiException x) { LOG.warn(x.getLocalizedMessage(), x); } return null; } @Inject  MachineSsoServerClient(
      @Named("che.api") String apiEndpoint,
      HttpJsonRequestFactory requestFactory,
      MachineTokenRegistry tokenRegistry,
      UserManager userManager); @Override Subject getSubject(String token, String clientUrl); }
MachineSsoServerClient extends HttpSsoServerClient { @Override public Subject getSubject(String token, String clientUrl) { if (!token.startsWith("machine")) { return super.getSubject(token, clientUrl); } try { final User user = userManager.getById(tokenRegistry.getUserId(token)); return new SubjectImpl(user.getName(), user.getId(), token, false); } catch (ApiException x) { LOG.warn(x.getLocalizedMessage(), x); } return null; } @Inject  MachineSsoServerClient(
      @Named("che.api") String apiEndpoint,
      HttpJsonRequestFactory requestFactory,
      MachineTokenRegistry tokenRegistry,
      UserManager userManager); @Override Subject getSubject(String token, String clientUrl);  }