use of org.apache.thrift.protocol.TJSONProtocol 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);
}
use of org.apache.thrift.protocol.TJSONProtocol 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);
}
use of org.apache.thrift.protocol.TJSONProtocol in project hive by apache.
the class QueryPlan method toThriftJSONString.
public String toThriftJSONString() throws IOException {
org.apache.hadoop.hive.ql.plan.api.Query q = getQueryPlan();
TMemoryBuffer tmb = new TMemoryBuffer(q.toString().length() * 5);
TJSONProtocol oprot = new TJSONProtocol(tmb);
try {
q.write(oprot);
} catch (TException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return q.toString();
}
return tmb.toString("UTF-8");
}
use of org.apache.thrift.protocol.TJSONProtocol in project distributedlog by twitter.
the class ZKAccessControl method serialize.
static byte[] serialize(AccessControlEntry ace) throws IOException {
TMemoryBuffer transport = new TMemoryBuffer(BUFFER_SIZE);
TJSONProtocol protocol = new TJSONProtocol(transport);
try {
ace.write(protocol);
transport.flush();
return transport.toString(UTF_8.name()).getBytes(UTF_8);
} catch (TException e) {
throw new IOException("Failed to serialize access control entry : ", e);
} catch (UnsupportedEncodingException uee) {
throw new IOException("Failed to serialize acesss control entry : ", uee);
}
}
use of org.apache.thrift.protocol.TJSONProtocol in project simba-os by cegeka.
the class JerseyBasicAuthenticationFilter method filter.
@Override
public void filter(ContainerRequestContext containerRequestContext) throws IOException {
ContainerRequest containerRequest = (ContainerRequest) containerRequestContext.getRequest();
Map<String, String> requestParameters = toMap(containerRequestContext.getUriInfo().getQueryParameters());
List<String> auth = containerRequest.getRequestHeader("authorization");
if (auth == null || auth.isEmpty()) {
throw new WebApplicationException(Response.Status.UNAUTHORIZED);
}
String[] credentials = decode(auth.get(0));
requestParameters.put(AuthenticationConstants.USERNAME, credentials[0]);
requestParameters.put(AuthenticationConstants.PASSWORD, credentials[1]);
RequestData requestData = new RequestData(requestParameters, toMap(containerRequest.getRequestHeaders()), containerRequest.getAbsolutePath().toString(), simbaWebURL, null, /* SSO Token */
null, /* Client IP */
false, false, false, false, false, containerRequest.getMethod(), RequestUtil.HOST_SERVER_NAME, null, null);
THttpClient tHttpClient = null;
try {
tHttpClient = new THttpClient(simbaWebURL + "/authenticationService");
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 WebApplicationException(Response.Status.UNAUTHORIZED);
}
} catch (Exception e) {
e.printStackTrace();
throw new WebApplicationException(e, Response.Status.UNAUTHORIZED);
} finally {
if (tHttpClient != null) {
tHttpClient.close();
}
}
}
Aggregations