import java.util.Hashtable;
import org.apache.xmlrpc.secure.SecurityTool;
import org.apache.xmlrpc.secure.SecureWebServer;

public class XMLRPCSecureServer {

    public XMLRPCSecureServer() {
        // Our handler is a regular Java object. It can have a
        // constructor and member variables in the ordinary fashion.
        // Public methods will be exposed to XML-RPC clients.
    }
	
	public static void main(String[] args) {
		try {
			System.out.println("1");
        	SecurityTool.setKeyStore( "mykeystore" );
        	System.out.println("2");
        	SecurityTool.setKeyStorePassword( "password" );
        	System.out.println("3");
        	SecurityTool.setKeyStoreType( "JKS" );
        	System.out.println("4");
        	SecurityTool.setKeyManagerType( "SunX509" );
        	System.out.println("5");
        	SecurityTool.setSecurityProtocol( "TLS" );
        	System.out.println("6");

        	SecureWebServer server = new SecureWebServer( 8082 );
        	System.out.println("7");
        	server.addHandler( "functions", new XMLRPCSecureServer() );
        	System.out.println("8");

        	server.setParanoid( false );
        	System.out.println("9");
        	server.start();
        	System.out.println("10");
        		
        	System.out.println(" Server Started ");
	
		} 
		catch (Exception e) {
			e.printStackTrace();	
		}		
		
		
	}
	
	public Hashtable add(String num1, String num2) {
		System.out.println("Add method");
        
        Hashtable rslt = new Hashtable();
        
        int intNum1 = Integer.valueOf(num1).intValue();
        int intNum2 = Integer.valueOf(num2).intValue();
        
        int intResult = intNum1 + intNum2;
        
        String strResult = String.valueOf(intResult);
        
        rslt.put( "add", strResult ); 
        
        return rslt;
    } 
}

