All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.antelopeframework.remoting.server.HessianServiceExporter Maven / Gradle / Ivy

The newest version!
package com.github.antelopeframework.remoting.server;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.github.antelopeframework.remoting.server.auth.RemoteCallAuthenticate;

import lombok.Setter;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class HessianServiceExporter extends org.springframework.remoting.caucho.HessianServiceExporter {
	public final static String HTTPINVOKER_PARAM_APP = "X-HttpRemoting-App";
	public final static String HTTPINVOKER_PARAM_XID = "X-HttpRemoting-xid";
	
	@Setter
	private RemoteCallAuthenticate remoteCallAuthenticate;
	
	@Override
	public void handleRequest(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		String auth = request.getHeader("Authorization");
		String app = request.getHeader(HTTPINVOKER_PARAM_APP); 
		String xid = request.getHeader(HTTPINVOKER_PARAM_XID); 
		
		if (log.isDebugEnabled()) {
			log.debug("remoting call: app={}, xid={}", app, xid);
		}
		
        if (remoteCallAuthenticate != null && !remoteCallAuthenticate.basicAuth(app, auth)) {
        	throw new ServletException("Authorization failed.");  
        }
        
		super.handleRequest(request, response);
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy