class MachineTokenProviderImpl implements MachineTokenProvider {

  @Override
  public String getToken(String workspaceId) throws MachineTokenException {
    final Subject subject = EnvironmentContext.getCurrent().getSubject();
    if (subject.isAnonymous()) {
      throw new IllegalStateException(
          format(
              "Unable to get machine token of the workspace '%s' "
                  + "because it does not exist for an anonymous user.",
              workspaceId));
    }
    return getToken(subject.getUserId(), workspaceId);
  }

  @Inject public  MachineTokenProviderImpl(
      PermissionChecker permissionChecker, MachineTokenRegistry tokenRegistry);

}