use of org.apache.thrift.protocol.TJSONProtocol in project simba-os by cegeka.
the class AuthorizationServiceClient method getAuthorizationServiceClient.
protected AuthorizationService.Iface getAuthorizationServiceClient() throws TTransportException {
THttpClient tHttpClient = new THttpClient(SimbaConfiguration.getSimbaAuthorizationURL());
TProtocol tProtocol = new TJSONProtocol(tHttpClient);
return new AuthorizationService.Client(tProtocol);
}
use of org.apache.thrift.protocol.TJSONProtocol in project simba-os by cegeka.
the class FeedingServlet method doPost.
@Override
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
THttpClient tHttpClient = null;
try {
tHttpClient = new THttpClient(SystemConfiguration.getSimbaServiceURL(getServletContext()) + "/authorizationService");
TProtocol tProtocol = new TJSONProtocol(tHttpClient);
AuthorizationService.Client authorizationClient = new AuthorizationService.Client(tProtocol);
PolicyDecision decision = authorizationClient.isResourceRuleAllowed(request.getUserPrincipal().getName(), "ANIMAL", "WRITE");
if (!decision.isAllowed()) {
response.sendError(HttpServletResponse.SC_UNAUTHORIZED);
return;
}
response.sendRedirect("jsp/feeding.jsp");
} catch (Exception e) {
throw new ServletException(e);
} finally {
if (tHttpClient != null) {
tHttpClient.close();
}
}
}
Aggregations