Search in sources :

Example 36 with TProtocol

use of org.apache.thrift.protocol.TProtocol in project jena by apache.

the class TRDF method protocol.

/**
     * Decode the contents of the input stream and send to the {@link StreamRDF}.
     * @param filename
     */
public static TProtocol protocol(String filename) {
    InputStream in = IO.openFile(filename);
    TProtocol protocol = protocol(in);
    return protocol;
}
Also used : TProtocol(org.apache.thrift.protocol.TProtocol) BufferedInputStream(java.io.BufferedInputStream) InputStream(java.io.InputStream)

Example 37 with TProtocol

use of org.apache.thrift.protocol.TProtocol in project simba-os by cegeka.

the class SimbaFilter method doFilter.

private void doFilter(final HttpServletRequest request, final HttpServletResponse response, final FilterChain chain) throws ServletException, IOException {
    if (isUrlExcluded(request)) {
        chain.doFilter(request, response);
        return;
    }
    RequestData requestData = RequestUtil.createRequestData(request, simbaWebURL, simbeEidSuccessUrl);
    FilterActionFactory actionFactory = new FilterActionFactory(request, response, chain);
    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, authenticationChainName);
        actionFactory.execute(actionDescriptor);
    } catch (Exception e) {
        throw new ServletException(e);
    } finally {
        if (tHttpClient != null) {
            tHttpClient.close();
        }
    }
}
Also used : FilterActionFactory(org.simbasecurity.client.filter.action.FilterActionFactory) TJSONProtocol(org.apache.thrift.protocol.TJSONProtocol) AuthenticationFilterService(org.simbasecurity.api.service.thrift.AuthenticationFilterService) TProtocol(org.apache.thrift.protocol.TProtocol) RequestData(org.simbasecurity.api.service.thrift.RequestData) ActionDescriptor(org.simbasecurity.api.service.thrift.ActionDescriptor) THttpClient(org.apache.thrift.transport.THttpClient) THttpClient(org.apache.thrift.transport.THttpClient) IOException(java.io.IOException)

Example 38 with TProtocol

use of org.apache.thrift.protocol.TProtocol 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(getSimbaURL(servletContext));
                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 39 with TProtocol

use of org.apache.thrift.protocol.TProtocol in project simba-os by cegeka.

the class BaseRESTService method cl.

T cl() throws TException {
    THttpClient tHttpClient = new THttpClient(serviceURL);
    TProtocol tProtocol = new TJSONProtocol(tHttpClient);
    return clientFactory.getClient(tProtocol);
}
Also used : TJSONProtocol(org.apache.thrift.protocol.TJSONProtocol) TProtocol(org.apache.thrift.protocol.TProtocol) THttpClient(org.apache.thrift.transport.THttpClient)

Example 40 with TProtocol

use of org.apache.thrift.protocol.TProtocol in project simba-os by cegeka.

the class ManagerSecurityInterceptor method authenticationService.

private AuthenticationFilterService.Iface authenticationService() throws TTransportException {
    THttpClient tHttpClient = new THttpClient(SystemConfiguration.getSimbaServiceURL());
    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)

Aggregations

TProtocol (org.apache.thrift.protocol.TProtocol)93 TTransport (org.apache.thrift.transport.TTransport)42 TBinaryProtocol (org.apache.thrift.protocol.TBinaryProtocol)36 TSocket (org.apache.thrift.transport.TSocket)36 TException (org.apache.thrift.TException)25 TFramedTransport (org.apache.thrift.transport.TFramedTransport)24 TCompactProtocol (org.apache.thrift.protocol.TCompactProtocol)18 IOException (java.io.IOException)16 TIOStreamTransport (org.apache.thrift.transport.TIOStreamTransport)10 THttpClient (org.apache.thrift.transport.THttpClient)9 ArrayList (java.util.ArrayList)8 TTransportException (org.apache.thrift.transport.TTransportException)8 ByteArrayOutputStream (java.io.ByteArrayOutputStream)7 TJSONProtocol (org.apache.thrift.protocol.TJSONProtocol)7 RDF_Term (org.apache.jena.riot.thrift.wire.RDF_Term)6 TProcessor (org.apache.thrift.TProcessor)6 InputStream (java.io.InputStream)5 TTransportFactory (org.apache.thrift.transport.TTransportFactory)5 ImageDatasetService (org.vcell.imagedataset.ImageDatasetService)5 Hbase (org.apache.hadoop.hbase.thrift.generated.Hbase)4