org.eclipse.che.api.core.rest.HttpJsonRequestFactory Java Examples

The following examples show how to use org.eclipse.che.api.core.rest.HttpJsonRequestFactory. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SeleniumWebDriver.java    From che with Eclipse Public License 2.0 6 votes vote down vote up
@Inject
public SeleniumWebDriver(
    @Named("sys.browser") TestBrowser browser,
    @Named("sys.driver.port") String webDriverPort,
    @Named("sys.grid.mode") boolean gridMode,
    HttpJsonRequestFactory httpJsonRequestFactory,
    DockerUtil dockerUtil,
    @Named("tests.tmp_dir") String downloadDir) {
  this.browser = browser;
  this.webDriverPort = webDriverPort;
  this.gridMode = gridMode;
  this.httpJsonRequestFactory = httpJsonRequestFactory;
  this.dockerUtil = dockerUtil;
  this.downloadDir = downloadDir;

  try {
    URL webDriverUrl =
        new URL(format("http://localhost:%s%s", webDriverPort, gridMode ? "/wd/hub" : ""));
    this.driver = createDriver(webDriverUrl);
  } catch (MalformedURLException e) {
    throw new RuntimeException("Error of construction URL to web driver.", e);
  }
}
 
Example #2
Source File: MachineSsoServerClientTest.java    From codenvy with Eclipse Public License 1.0 6 votes vote down vote up
@BeforeMethod
public void initClient() throws Exception {
  registrySpy = spy(new MachineTokenRegistry());

  userManagerMock = mock(UserManager.class);

  final HttpJsonResponse responseMock = mock(HttpJsonResponse.class);
  when(responseMock.asDto(SubjectDto.class)).thenReturn(newDto(SubjectDto.class));

  final HttpJsonRequest requestMock = mock(HttpJsonRequest.class, new SelfReturningAnswer());
  when(requestMock.request()).thenReturn(responseMock);

  final HttpJsonRequestFactory requestFactoryMock = mock(HttpJsonRequestFactory.class);
  when(requestFactoryMock.fromLink(any())).thenReturn(requestMock);
  when(requestFactoryMock.fromUrl(any())).thenReturn(requestMock);

  ssoClient =
      new MachineSsoServerClient(ENDPOINT, requestFactoryMock, registrySpy, userManagerMock);
}
 
Example #3
Source File: WsAgentURLProvider.java    From codenvy with Eclipse Public License 1.0 5 votes vote down vote up
@Inject
public WsAgentURLProvider(
    @Named("che.api") String apiEndpoint,
    @Named("env.USER_TOKEN") String machineToken,
    @Named("env.CHE_WORKSPACE_ID") String wsId,
    HttpJsonRequestFactory requestFactory) {
  this.wsId = wsId;
  this.machineToken = machineToken;
  this.workspaceApiEndpoint = apiEndpoint + "/workspace/";
  this.requestFactory = requestFactory;
}
 
Example #4
Source File: TestProfileServiceClient.java    From che with Eclipse Public License 2.0 5 votes vote down vote up
@Inject
public TestProfileServiceClient(
    TestApiEndpointUrlProvider apiEndpointProvider,
    HttpJsonRequestFactory requestFactory,
    DefaultTestUser defaultTestUser) {
  this.apiEndpoint = apiEndpointProvider.get().toString();
  this.requestFactory = requestFactory;
  this.defaultTestUser = defaultTestUser;
}
 
Example #5
Source File: TestUserPreferencesServiceClient.java    From che with Eclipse Public License 2.0 5 votes vote down vote up
@Inject
public TestUserPreferencesServiceClient(
    TestApiEndpointUrlProvider apiEndpointProvider, HttpJsonRequestFactory httpRequestFactory)
    throws Exception {
  this.apiEndpoint = apiEndpointProvider.get().toString();
  this.httpRequestFactory = httpRequestFactory;

  // Set application.confirmExit property to 'never' to avoid web page closing confirmation pop-up
  this.setProperty("theia-user-preferences", "{\"application.confirmExit\":\"never\"}");
}
 
Example #6
Source File: TestFactoryServiceClient.java    From che with Eclipse Public License 2.0 5 votes vote down vote up
@Inject
public TestFactoryServiceClient(
    TestApiEndpointUrlProvider testApiEndpointUrlProvider,
    TestIdeUrlProvider ideUrlProvider,
    HttpJsonRequestFactory requestFactory)
    throws Exception {
  this.factoryApiEndpoint = testApiEndpointUrlProvider.get() + "factory/";
  this.ideUrl = ideUrlProvider.get().toString();
  this.requestFactory = requestFactory;
}
 
Example #7
Source File: TestProjectServiceClient.java    From che with Eclipse Public License 2.0 5 votes vote down vote up
@Inject
public TestProjectServiceClient(
    TestMachineServiceClient machineServiceClient,
    HttpJsonRequestFactory requestFactory,
    TestWorkspaceAgentApiEndpointUrlProvider workspaceAgentApiEndpointUrlProvider) {
  this.machineServiceClient = machineServiceClient;
  this.requestFactory = requestFactory;
  this.workspaceAgentApiEndpointUrlProvider = workspaceAgentApiEndpointUrlProvider;
}
 
Example #8
Source File: KeycloakTokenProvider.java    From che with Eclipse Public License 2.0 5 votes vote down vote up
@Inject
public KeycloakTokenProvider(
    @Nullable @Named("che.keycloak.github.endpoint") String gitHubEndpoint,
    @Nullable @Named("che.keycloak.oso.endpoint") String openShiftEndpoint,
    HttpJsonRequestFactory httpJsonRequestFactory) {
  this.gitHubEndpoint = gitHubEndpoint;
  this.openShiftEndpoint = openShiftEndpoint;
  this.httpJsonRequestFactory = httpJsonRequestFactory;
}
 
Example #9
Source File: KeycloakProfileRetriever.java    From che with Eclipse Public License 2.0 5 votes vote down vote up
@Inject
public KeycloakProfileRetriever(
    KeycloakSettings keycloakSettings, HttpJsonRequestFactory requestFactory) {
  this.requestFactory = requestFactory;
  this.keyclockCurrentUserInfoUrl =
      keycloakSettings.get().get(KeycloakConstants.USERINFO_ENDPOINT_SETTING);
}
 
Example #10
Source File: KeycloakModule.java    From che with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected void configure() {

  bind(HttpJsonRequestFactory.class)
      .to(org.eclipse.che.multiuser.keycloak.server.KeycloakHttpJsonRequestFactory.class);
  bind(TokenValidator.class).to(KeycloakTokenValidator.class);
  bind(KeycloakConfigurationService.class);

  bind(ProfileDao.class).to(KeycloakProfileDao.class);
  bind(JwkProvider.class).toProvider(KeycloakJwkProvider.class);
  bind(JwtParser.class).toProvider(KeycloakJwtParserProvider.class);
  bind(PersonalAccountUserManager.class).to(KeycloakUserManager.class);

  bind(OAuthAPI.class).toProvider(OAuthAPIProvider.class);
}
 
Example #11
Source File: HttpPermissionCheckerImpl.java    From che with Eclipse Public License 2.0 5 votes vote down vote up
@Inject
public HttpPermissionCheckerImpl(
    @Named("che.api") String apiEndpoint, HttpJsonRequestFactory requestFactory) {
  // TODO mb make configurable size of cache and expiration time
  this.permissionsCache =
      CacheBuilder.newBuilder()
          .maximumSize(1000)
          .expireAfterWrite(1, TimeUnit.MINUTES)
          .build(
              new CacheLoader<Key, Set<String>>() {
                @Override
                public Set<String> load(Key key) throws Exception {
                  UriBuilder currentUsersPermissions =
                      UriBuilder.fromUri(apiEndpoint).path("permissions/" + key.domain);
                  if (key.instance != null) {
                    currentUsersPermissions.queryParam("instance", key.instance);
                  }
                  String userPermissionsUrl = currentUsersPermissions.build().toString();
                  try {
                    PermissionsDto usersPermissions =
                        requestFactory
                            .fromUrl(userPermissionsUrl)
                            .useGetMethod()
                            .request()
                            .asDto(PermissionsDto.class);
                    return new HashSet<>(usersPermissions.getActions());
                  } catch (NotFoundException e) {
                    // user doesn't have permissions
                    return new HashSet<>();
                  }
                }
              });
}
 
Example #12
Source File: TenantDataCacheLoader.java    From rh-che with Eclipse Public License 2.0 5 votes vote down vote up
@Inject
TenantDataCacheLoader(
    HttpJsonRequestFactory httpJsonRequestFactory,
    @Named("che.fabric8.auth.endpoint") String fabric8AuthEndpoint) {
  this.fabric8UserServiceEndpoint = fabric8AuthEndpoint + API_USER_SERVICES_PATH;
  this.httpJsonRequestFactory = httpJsonRequestFactory;
}
 
Example #13
Source File: BitbucketConnectionProvider.java    From codenvy with Eclipse Public License 1.0 5 votes vote down vote up
@Inject
BitbucketConnectionProvider(
    OAuthTokenProvider tokenProvider,
    OAuthAuthorizationHeaderProvider headerProvider,
    HttpJsonRequestFactory requestFactory,
    @Named("che.api") String apiEndpoint) {

  this.tokenProvider = tokenProvider;
  this.headerProvider = headerProvider;
  this.requestFactory = requestFactory;
  this.apiEndpoint = apiEndpoint;
}
 
Example #14
Source File: MachineSsoServerClient.java    From codenvy with Eclipse Public License 1.0 5 votes vote down vote up
@Inject
public MachineSsoServerClient(
    @Named("che.api") String apiEndpoint,
    HttpJsonRequestFactory requestFactory,
    MachineTokenRegistry tokenRegistry,
    UserManager userManager) {
  super(apiEndpoint, requestFactory);
  this.tokenRegistry = tokenRegistry;
  this.userManager = userManager;
}
 
Example #15
Source File: WsAgentModule.java    From codenvy with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected void configure() {

  bind(PermissionChecker.class).to(HttpPermissionCheckerImpl.class);
  // bind(TokenHandler.class).to(com.codenvy.api.permission.server.PermissionTokenHandler.class);
  bind(TokenHandler.class)
      .annotatedWith(Names.named("delegated.handler"))
      .to(com.codenvy.auth.sso.client.NoUserInteractionTokenHandler.class);

  bindConstant()
      .annotatedWith(Names.named("auth.sso.cookies_disabled_error_page_url"))
      .to("/site/error/error-cookies-disabled");
  bindConstant().annotatedWith(Names.named("auth.sso.login_page_url")).to("/site/login");
  bind(ProjectServiceLinksInjector.class).to(CodenvyProjectServiceLinksInjector.class);
  bind(HttpJsonRequestFactory.class).to(AuthorizeTokenHttpJsonRequestFactory.class);
  bind(RequestTokenExtractor.class)
      .to(com.codenvy.auth.sso.client.token.ChainedTokenExtractor.class);

  bind(WsAgentAnalyticsAddresser.class);

  bind(String.class).annotatedWith(Names.named("user.token")).toProvider(UserTokenProvider.class);
  bind(String.class)
      .annotatedWith(Names.named("event.bus.url"))
      .toProvider(EventBusURLProvider.class);
  bind(String.class)
      .annotatedWith(Names.named("wsagent.endpoint"))
      .toProvider(com.codenvy.api.agent.WsAgentURLProvider.class);
}
 
Example #16
Source File: OnpremSeleniumSuiteModule.java    From codenvy with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void configure() {
  TestConfiguration config = new SeleniumTestConfiguration();
  config
      .getMap()
      .forEach((key, value) -> bindConstant().annotatedWith(Names.named(key)).to(value));

  bind(TestSvnPasswordProvider.class).to(CheTestSvnPasswordProvider.class);
  bind(TestSvnUsernameProvider.class).to(CheTestSvnUsernameProvider.class);
  bind(TestSvnRepo1Provider.class).to(CheTestSvnRepo1Provider.class);
  bind(TestSvnRepo2Provider.class).to(CheTestSvnRepo2Provider.class);

  bind(TestWorkspaceUrlResolver.class).to(OnpremTestWorkspaceUrlResolver.class);
  bind(TestUserNamespaceResolver.class).to(OnpremTestUserNamespaceResolver.class);

  bind(TestApiEndpointUrlProvider.class).to(OnpremTestApiEndpointUrlProvider.class);
  bind(TestIdeUrlProvider.class).to(OnpremTestIdeUrlProvider.class);
  bind(TestDashboardUrlProvider.class).to(OnpremTestDashboardUrlProvider.class);
  bind(HttpJsonRequestFactory.class).to(TestDefaultUserHttpJsonRequestFactory.class);

  install(new FactoryModuleBuilder().build(TestUserHttpJsonRequestFactoryCreator.class));

  bind(TestUserServiceClient.class).to(OnpremTestUserServiceClient.class);
  bind(TestAuthServiceClient.class).to(OnpremTestAuthServiceClient.class);
  bind(TestMachineServiceClient.class).to(OnpremTestMachineServiceClient.class);

  bind(TestUser.class).to(OnpremTestUserImpl.class);
  bind(TestWorkspaceProvider.class).to(TestWorkspaceProviderImpl.class).asEagerSingleton();

  install(new FactoryModuleBuilder().build(TestWorkspaceServiceClientFactory.class));

  install(
      new FactoryModuleBuilder()
          .implement(TestUser.class, TestUserImpl.class)
          .build(TestUserFactory.class));

  bind(AdminTestUser.class).to(OnpremAdminTestUser.class);
  bind(PageObjectsInjector.class).to(PageObjectsInjectorImpl.class);
}
 
Example #17
Source File: WsAgentHealthCheckerWithAuth.java    From codenvy with Eclipse Public License 1.0 5 votes vote down vote up
@Inject
public WsAgentHealthCheckerWithAuth(
    WsAgentPingRequestFactory pingRequestFactory,
    HttpJsonRequestFactory httpJsonRequestFactory,
    @Named("che.api") String apiEndpoint) {
  super(pingRequestFactory);
  this.apiEndpoint = apiEndpoint;
  this.httpJsonRequestFactory = httpJsonRequestFactory;
}
 
Example #18
Source File: OnpremTestAuthServiceClient.java    From codenvy with Eclipse Public License 1.0 5 votes vote down vote up
@Inject
public OnpremTestAuthServiceClient(
    TestApiEndpointUrlProvider apiEndpointProvider,
    Provider<HttpJsonRequestFactory> requestFactoryProvider) {
  this.apiEndpoint = apiEndpointProvider.get().toString();
  this.requestFactory = requestFactoryProvider.get();
}
 
Example #19
Source File: TestGitHubServiceClient.java    From che with Eclipse Public License 2.0 4 votes vote down vote up
@Inject
public TestGitHubServiceClient(HttpJsonRequestFactory requestFactory) {
  this.requestFactory = requestFactory;
}
 
Example #20
Source File: CheSeleniumSuiteModule.java    From che with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void configure() {
  TestConfiguration config = new SeleniumTestConfiguration();
  config.getMap().forEach((key, value) -> bindConstant().annotatedWith(named(key)).to(value));

  bind(DefaultTestUser.class).toProvider(DefaultTestUserProvider.class);
  install(
      new FactoryModuleBuilder()
          .build(Key.get(new TypeLiteral<TestUserFactory<DefaultTestUser>>() {}.getType())));

  bind(TestUserServiceClient.class).to(CheTestUserServiceClient.class);

  bind(HttpJsonRequestFactory.class).to(TestUserHttpJsonRequestFactory.class);
  bind(TestUserHttpJsonRequestFactory.class).to(CheTestDefaultHttpJsonRequestFactory.class);

  bind(TestApiEndpointUrlProvider.class).to(CheTestApiEndpointUrlProvider.class);
  bind(TestIdeUrlProvider.class).to(CheTestIdeUrlProvider.class);
  bind(TestDashboardUrlProvider.class).to(CheTestDashboardUrlProvider.class);
  bind(TestWorkspaceAgentApiEndpointUrlProvider.class)
      .to(CheTestWorkspaceAgentApiEndpointUrlProvider.class);

  bind(TestWorkspaceUrlResolver.class).to(CheTestWorkspaceUrlResolver.class);

  install(
      new FactoryModuleBuilder()
          .implement(TestWorkspaceServiceClient.class, CheTestWorkspaceServiceClient.class)
          .build(TestWorkspaceServiceClientFactory.class));

  bind(TestWorkspaceServiceClient.class).to(CheTestWorkspaceServiceClient.class);
  bind(TestWorkspaceProvider.class).to(CheTestWorkspaceProvider.class).asEagerSingleton();

  install(new FactoryModuleBuilder().build(TestUserHttpJsonRequestFactoryCreator.class));
  install(new FactoryModuleBuilder().build(TestUserServiceClientFactory.class));
  install(new FactoryModuleBuilder().build(WebDriverLogsReaderFactory.class));

  bind(PageObjectsInjector.class).to(PageObjectsInjectorImpl.class);

  configureInfrastructureRelatedDependencies(config);

  if (config.getBoolean(CHE_MULTIUSER_VARIABLE)) {
    install(new CheSeleniumMultiUserModule());
  } else {
    install(new CheSeleniumSingleUserModule());
  }

  install(new TestExecutionModule());
}
 
Example #21
Source File: TestSshServiceClient.java    From che with Eclipse Public License 2.0 4 votes vote down vote up
@Inject
public TestSshServiceClient(
    TestApiEndpointUrlProvider apiEndpointProvider, HttpJsonRequestFactory requestFactory) {
  this.apiEndpoint = apiEndpointProvider.get().toString();
  this.requestFactory = requestFactory;
}
 
Example #22
Source File: AbstractTestWorkspaceServiceClient.java    From che with Eclipse Public License 2.0 4 votes vote down vote up
public AbstractTestWorkspaceServiceClient(
    TestApiEndpointUrlProvider apiEndpointProvider, HttpJsonRequestFactory requestFactory) {
  this.apiEndpointProvider = apiEndpointProvider;
  this.requestFactory = requestFactory;
}
 
Example #23
Source File: TestCommandServiceClient.java    From che with Eclipse Public License 2.0 4 votes vote down vote up
@Inject
public TestCommandServiceClient(
    TestApiEndpointUrlProvider apiEndpointProvider, HttpJsonRequestFactory requestFactory) {
  this.apiEndpoint = apiEndpointProvider.get().toString();
  this.requestFactory = requestFactory;
}
 
Example #24
Source File: OnpremTestOAuthServiceClient.java    From codenvy with Eclipse Public License 1.0 4 votes vote down vote up
@Inject
public OnpremTestOAuthServiceClient(
    TestApiEndpointUrlProvider apiEndpointProvider, HttpJsonRequestFactory requestFactory) {
  this.apiEndpoint = apiEndpointProvider.get().toString();
  this.requestFactory = requestFactory;
}
 
Example #25
Source File: TestOrganizationServiceClient.java    From che with Eclipse Public License 2.0 4 votes vote down vote up
public TestOrganizationServiceClient(
    TestApiEndpointUrlProvider apiEndpointUrlProvider, HttpJsonRequestFactory requestFactory) {
  this.apiEndpoint = apiEndpointUrlProvider.get().toString();
  this.requestFactory = requestFactory;
}
 
Example #26
Source File: CheTestWorkspaceServiceClient.java    From che with Eclipse Public License 2.0 4 votes vote down vote up
@Inject
public CheTestWorkspaceServiceClient(
    TestApiEndpointUrlProvider apiEndpointProvider, HttpJsonRequestFactory requestFactory) {
  super(apiEndpointProvider, requestFactory);
}
 
Example #27
Source File: OnpremTestMachineServiceClient.java    From codenvy with Eclipse Public License 1.0 4 votes vote down vote up
@Inject
public OnpremTestMachineServiceClient(
    TestApiEndpointUrlProvider apiEndpointProvider, HttpJsonRequestFactory requestFactory) {
  this.apiEndpoint = apiEndpointProvider.get().toString();
  this.requestFactory = requestFactory;
}
 
Example #28
Source File: HttpSsoServerClient.java    From codenvy with Eclipse Public License 1.0 4 votes vote down vote up
@Inject
public HttpSsoServerClient(
    @Named("che.api") String apiEndpoint, HttpJsonRequestFactory requestFactory) {
  this.apiEndpoint = apiEndpoint;
  this.requestFactory = requestFactory;
}
 
Example #29
Source File: UserConnection.java    From codenvy with Eclipse Public License 1.0 4 votes vote down vote up
@Inject
public UserConnection(
    HttpJsonRequestFactory httpJsonRequestFactory, @Named("che.api") String baseUrl) {
  this.httpJsonRequestFactory = httpJsonRequestFactory;
  this.baseUrl = baseUrl;
}
 
Example #30
Source File: AuthConnection.java    From codenvy with Eclipse Public License 1.0 4 votes vote down vote up
@Inject
public AuthConnection(
    HttpJsonRequestFactory httpJsonRequestFactory, @Named("che.api") String baseUrl) {
  this.httpJsonRequestFactory = httpJsonRequestFactory;
  this.baseUrl = baseUrl;
}