Search in sources :

Example 6 with THttpClient

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;
}
Also used : THttpClient(org.apache.thrift.transport.THttpClient) Client(org.simbasecurity.api.service.thrift.AuthenticationFilterService.Client) THttpClient(org.apache.thrift.transport.THttpClient)

Example 7 with THttpClient

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;
}
Also used : AuthenticationFilterService(org.simbasecurity.api.service.thrift.AuthenticationFilterService) ActionDescriptor(org.simbasecurity.api.service.thrift.ActionDescriptor) THttpClient(org.apache.thrift.transport.THttpClient) UserPrincipal(com.sun.security.auth.UserPrincipal) HttpServletRequest(javax.servlet.http.HttpServletRequest) TJSONProtocol(org.apache.thrift.protocol.TJSONProtocol) TProtocol(org.apache.thrift.protocol.TProtocol) RequestData(org.simbasecurity.api.service.thrift.RequestData) ServletContext(javax.servlet.ServletContext) THttpClient(org.apache.thrift.transport.THttpClient) SOAPHeader(javax.xml.soap.SOAPHeader) SimbaPrincipal(org.simbasecurity.client.principal.SimbaPrincipal) UserPrincipal(com.sun.security.auth.UserPrincipal) Principal(java.security.Principal)

Example 8 with THttpClient

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);
}
Also used : TJSONProtocol(org.apache.thrift.protocol.TJSONProtocol) TProtocol(org.apache.thrift.protocol.TProtocol) THttpClient(org.apache.thrift.transport.THttpClient) THttpClient(org.apache.thrift.transport.THttpClient)

Example 9 with THttpClient

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);
    }
}
Also used : TProtocol(org.apache.thrift.protocol.TProtocol) THttpClient(org.apache.thrift.transport.THttpClient) TCompactProtocol(org.apache.thrift.protocol.TCompactProtocol) THttpClient(org.apache.thrift.transport.THttpClient) AttachmentService(org.eclipse.sw360.datahandler.thrift.attachments.AttachmentService) TException(org.apache.thrift.TException) IOException(java.io.IOException)

Example 10 with THttpClient

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);
}
Also used : TProtocol(org.apache.thrift.protocol.TProtocol) THttpClient(org.apache.thrift.transport.THttpClient) TCompactProtocol(org.apache.thrift.protocol.TCompactProtocol) THttpClient(org.apache.thrift.transport.THttpClient)

Aggregations

THttpClient (org.apache.thrift.transport.THttpClient)51 TProtocol (org.apache.thrift.protocol.TProtocol)34 TCompactProtocol (org.apache.thrift.protocol.TCompactProtocol)18 TBinaryProtocol (org.apache.thrift.protocol.TBinaryProtocol)12 TJSONProtocol (org.apache.thrift.protocol.TJSONProtocol)9 Test (org.junit.Test)9 TTransport (org.apache.thrift.transport.TTransport)8 Hbase (org.apache.hadoop.hbase.thrift.generated.Hbase)5 DefaultHttpClient (org.apache.http.impl.client.DefaultHttpClient)5 RequestData (org.simbasecurity.api.service.thrift.RequestData)5 ApacheHttpTransport (com.google.api.client.http.apache.ApacheHttpTransport)4 IOException (java.io.IOException)4 PServiceCall (net.morimekta.providence.PServiceCall)4 TestService (net.morimekta.test.providence.service.TestService)4 Client (org.simbasecurity.api.service.thrift.AuthenticationFilterService.Client)4 HashMap (java.util.HashMap)3 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)3 TCLIService (org.apache.hive.service.rpc.thrift.TCLIService)3 CloseableHttpClient (org.apache.http.impl.client.CloseableHttpClient)3 ActionDescriptor (org.simbasecurity.api.service.thrift.ActionDescriptor)3