use of org.apache.thrift.protocol.TJSONProtocol 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();
}
}
}
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 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.protocol.TJSONProtocol 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.protocol.TJSONProtocol in project bookkeeper by apache.
the class ZKAccessControl method deserialize.
static AccessControlEntry deserialize(String zkPath, byte[] data) throws IOException {
if (data.length == 0) {
return DEFAULT_ACCESS_CONTROL_ENTRY;
}
AccessControlEntry ace = new AccessControlEntry();
TMemoryInputTransport transport = new TMemoryInputTransport(data);
TJSONProtocol protocol = new TJSONProtocol(transport);
try {
ace.read(protocol);
} catch (TException e) {
throw new CorruptedAccessControlException(zkPath, e);
}
return ace;
}
Aggregations