use of org.apache.camel.component.bonita.api.filter.BonitaAuthFilter in project camel by apache.
the class BonitaAPIUtil method getInstance.
public static BonitaAPIUtil getInstance(BonitaAPIConfig bonitaAPIConfig) {
if (instance == null) {
instance = new BonitaAPIUtil();
ClientConfig clientConfig = new ClientConfig();
clientConfig.register(MultiPartFeature.class);
clientConfig.register(JacksonJsonProvider.class);
Logger logger = Logger.getLogger("org.bonitasoft.camel.bonita.api.util.BonitaAPIUtil");
Feature feature = new LoggingFeature(logger, Level.INFO, null, null);
clientConfig.register(feature);
ClientBuilder clientBuilder = ClientBuilder.newBuilder().withConfig(clientConfig);
Client client = clientBuilder.build();
client.register(new JsonClientFilter());
client.register(new BonitaAuthFilter(bonitaAPIConfig));
instance.setWebTarget(client.target(bonitaAPIConfig.getBaseBonitaURI()));
}
return instance;
}
use of org.apache.camel.component.bonita.api.filter.BonitaAuthFilter in project camel by apache.
the class BonitaAuthFilterConnectionTest method testConnectionSupportCSRF.
@Test
public void testConnectionSupportCSRF() throws Exception {
String port = wireMockRule.port() + "";
stubFor(post(urlEqualTo("/bonita/loginservice")).willReturn(aResponse().withHeader("Set-Cookie", "JSESSIONID=something", "X-Bonita-API-Token=something")));
BonitaAPIConfig bonitaApiConfig = new BonitaAPIConfig("localhost", port, "username", "password");
BonitaAuthFilter bonitaAuthFilter = new BonitaAuthFilter(bonitaApiConfig);
bonitaAuthFilter.filter(requestContext);
assertEquals(2, requestContext.getHeaders().size());
}
use of org.apache.camel.component.bonita.api.filter.BonitaAuthFilter in project camel by apache.
the class BonitaAuthFilterTest method testBonitaAuthFilterUsernameEmpty.
@Test(expected = IllegalArgumentException.class)
public void testBonitaAuthFilterUsernameEmpty() throws IOException {
BonitaAPIConfig bonitaApiConfig = new BonitaAPIConfig("localhost", "port", "", "password");
BonitaAuthFilter bonitaAuthFilter = new BonitaAuthFilter(bonitaApiConfig);
bonitaAuthFilter.filter(requestContext);
}
use of org.apache.camel.component.bonita.api.filter.BonitaAuthFilter in project camel by apache.
the class BonitaAPIBuilder method build.
public static BonitaAPI build(BonitaAPIConfig bonitaAPIConfig) {
if (bonitaAPIConfig == null) {
throw new IllegalArgumentException("bonitaApiConfig is null");
}
ClientConfig clientConfig = new ClientConfig();
clientConfig.register(JacksonJsonProvider.class);
ClientBuilder clientBuilder = ClientBuilder.newBuilder().withConfig(clientConfig);
Client client = clientBuilder.build();
client.register(new BonitaAuthFilter(bonitaAPIConfig));
WebTarget webTarget = client.target(bonitaAPIConfig.getBaseBonitaURI()).path("/API/bpm");
return new BonitaAPI(bonitaAPIConfig, webTarget);
}
use of org.apache.camel.component.bonita.api.filter.BonitaAuthFilter in project camel by apache.
the class BonitaAuthFilterAlreadyConnectedTest method testAlreadyConnected.
@Test
public void testAlreadyConnected() throws Exception {
BonitaAPIConfig bonitaApiConfig = new BonitaAPIConfig("hostname", "port", "username", "password");
BonitaAuthFilter bonitaAuthFilter = new BonitaAuthFilter(bonitaApiConfig);
bonitaAuthFilter.filter(requestContext);
}
Aggregations