use of org.apache.thrift.transport.THttpClient in project simba-os by cegeka.
the class SimbaGatewayTest method setupSimbaServiceToReturnASimbaAuthenticationService.
private Client setupSimbaServiceToReturnASimbaAuthenticationService() throws TTransportException {
Client expectedClient = mock(Client.class);
THttpClient tHttpClientMock = mock(THttpClient.class);
when(simbaServiceFactoryMock.createTHttpClient(SIMBA_WEB_URL + "/" + SIMBA_AUTHENTICATION_SERVICE)).thenReturn(tHttpClientMock);
when(simbaServiceFactoryMock.createJSONAuthenticationFilterService(tHttpClientMock)).thenReturn(expectedClient);
return expectedClient;
}
use of org.apache.thrift.transport.THttpClient in project simba-os by cegeka.
the class SimbaJAXWSHandler method handleMessage.
@Override
public boolean handleMessage(final SOAPMessageContext context) {
if (isInboundMessage(context)) {
try {
final SOAPHeader header = context.getMessage().getSOAPHeader();
final HttpServletRequest httpServletRequest = (HttpServletRequest) context.get(MessageContext.SERVLET_REQUEST);
final ServletContext servletContext = (ServletContext) context.get(MessageContext.SERVLET_CONTEXT);
final RequestData requestData = RequestUtil.createWSSERequestData(httpServletRequest, header, getSimbaWebURL(servletContext));
THttpClient tHttpClient = null;
try {
tHttpClient = new THttpClient(SimbaConfiguration.getSimbaAuthenticationURL());
TProtocol tProtocol = new TJSONProtocol(tHttpClient);
AuthenticationFilterService.Client authenticationClient = new AuthenticationFilterService.Client(tProtocol);
ActionDescriptor actionDescriptor = authenticationClient.processRequest(requestData, "wsLoginChain");
if (!actionDescriptor.getActionTypes().contains(ActionType.DO_FILTER_AND_SET_PRINCIPAL)) {
throw new SimbaWSAuthenticationException("Authentication Failed");
}
String username = actionDescriptor.getPrincipal();
Principal principal = null;
if (username != null) {
principal = new UserPrincipal(username);
}
if (principal != null) {
context.put(SimbaPrincipal.SIMBA_USER_CTX_KEY, principal);
context.setScope(SimbaPrincipal.SIMBA_USER_CTX_KEY, MessageContext.Scope.APPLICATION);
}
} finally {
if (tHttpClient != null) {
tHttpClient.close();
}
}
} catch (Exception e) {
throw new SimbaWSAuthenticationException("Authentication Failed", e);
}
}
return true;
}
use of org.apache.thrift.transport.THttpClient in project simba-os by cegeka.
the class ManagerSecurityInterceptor method authenticationService.
private AuthenticationFilterService.Iface authenticationService() throws TTransportException {
THttpClient tHttpClient = new THttpClient(SimbaConfiguration.getSimbaAuthenticationURL());
TProtocol tProtocol = new TJSONProtocol(tHttpClient);
return new AuthenticationFilterService.Client(tProtocol);
}
use of org.apache.thrift.transport.THttpClient in project sw360portal by sw360.
the class TestAttachmentClient method main.
public static void main(String[] args) {
try {
THttpClient thriftClient = new THttpClient("http://127.0.0.1:8080/attachmentservice/thrift");
TProtocol protocol = new TCompactProtocol(thriftClient);
AttachmentService.Iface client = new AttachmentService.Client(protocol);
} catch (Exception e) {
assert (false);
}
}
use of org.apache.thrift.transport.THttpClient in project sw360portal by sw360.
the class Sw360ComponentService method getThriftComponentClient.
private ComponentService.Iface getThriftComponentClient() throws TTransportException {
THttpClient thriftClient = new THttpClient(thriftServerUrl + "/components/thrift");
TProtocol protocol = new TCompactProtocol(thriftClient);
return new ComponentService.Client(protocol);
}
Aggregations