Jochen Wiedmann wrote: > On Mon, Jul 14, 2008 at 3:46 PM, TomazM <[EMAIL PROTECTED]> wrote: > >> Is there any example hoe to use Basic Authentication in server side? > > See http://ws.apache.org/xmlrpc/server.html (section "Basic > Authentication"), and http://ws.apache.org/xmlrpc/client.html > (properties basicUsername and basicPassword). > > Jochen > I alredy try it but I have exception:
java.lang.NullPointerException at org.apache.xmlrpc.webserver.XmlRpcServlet.newPropertyHandlerMapping(XmlRpcServlet.java:180) at org.apache.xmlrpc.webserver.XmlRpcServlet.newXmlRpcHandlerMapping(XmlRpcServlet.java:161) at server.xml.MySecureServlet.newXmlRpcHandlerMapping(MySecureServlet.java:24) at server.xml.XmlRpcStreznik.main(XmlRpcStreznik.java:24) null I use: public class MyServlet extends XmlRpcServlet { private boolean isAuthenticated(String pUserName, String pPassword) { return "foo".equals(pUserName) && "bar".equals(pPassword); } protected XmlRpcHandlerMapping newXmlRpcHandlerMapping() throws XmlRpcException { PropertyHandlerMapping mapping = (PropertyHandlerMapping) super.newXmlRpcHandlerMapping(); AbstractReflectiveHandlerMapping.AuthenticationHandler handler = new AbstractReflectiveHandlerMapping.AuthenticationHandler(){ public boolean isAuthorized(XmlRpcRequest pRequest){ XmlRpcHttpRequestConfig config = (XmlRpcHttpRequestConfig) pRequest.getConfig(); return isAuthenticated(config.getBasicUserName(), config.getBasicPassword()); }; }; mapping.setAuthenticationHandler(handler); return mapping; } } and in Server: ServerSocket socket_server = new ServerSocket(); //PropertyHandlerMapping phm = new PropertyHandlerMapping(); MySecureServlet ss = new MySecureServlet(); ss.newXmlRpcHandlerMapping(); PropertyHandlerMapping phm = new PropertyHandlerMapping (); //PropertyHandlerMapping phm = (PropertyHandlerMapping) ss.newXmlRpcHandlerMapping(); phm.addHandler("Kalkulator", server.xml.Kalkulator.class); //phm.load(Thread.currentThread().getContextClassLoader(),"XmlRpcServlet.properties"); /** * You may also provide the handler classes directly, like this: * phm.addHandler("Calculator",server.Kalkulator.class); */ WebServer web_server = new WebServer(port); //ServletWebServer servlet_ser = new ServletWebServer (ss, port); XmlRpcServer xml_server = web_server.getXmlRpcServer(); //XmlRpcServer xml_server = servlet_ser.getXmlRpcServer(); xml_server.setHandlerMapping(phm); XmlRpcServerConfigImpl serverConfig = (XmlRpcServerConfigImpl) xml_server.getConfig(); serverConfig.setEnabledForExtensions(true); serverConfig.setContentLengthOptional(false); //xml_server.getHandlerMapping(); web_server.start(); The error is in code PropertyHandlerMapping mapping = (PropertyHandlerMapping) super.newXmlRpcHandlerMapping(); So in Server how do I access this myServlet? Before i was using old rpc-xml 1.2 and it was realy easy using basic: I have MyServers implements AuthenticatedHandler and inside i have method authenticate is this posibile now. And Is there any way to pass Kerberos ticket using this method? Tomaz