1 25 26 27 package org.snipsnap.xmlrpc; 28 29 import org.apache.xmlrpc.XmlRpcException; 30 import org.radeox.util.logging.Logger; 31 import org.snipsnap.app.Application; 32 import org.snipsnap.user.AuthenticationService; 33 import org.snipsnap.user.User; 34 35 45 public abstract class XmlRpcSupport implements XmlRpcHandler { 46 protected AuthenticationService authenticationService; 47 48 public static final int AUTHORIZATION_EXCEPTION = 0001; 49 public static final String AUTHORIZATION_EXCEPTION_MSG = "Invalid Username and/or Password"; 50 51 public static final int UNKNOWN_EXCEPTION = 1000; 52 public static final String UNKNOWN_EXCEPTION_MSG = "An error occured processing your request"; 53 54 public static final int UNSUPPORTED_EXCEPTION = 1001; 55 public static final String UNSUPPORTED_EXCEPTION_MSG = "Unsupported method - Snipsnap does not support this XML-RPC concept"; 56 57 58 67 68 protected User authenticate(String username, String password) throws XmlRpcException { 69 User user = authenticationService.authenticate(username, password); 70 if (user != null) { 71 Application.get().setUser(user); 72 return user; 73 } 74 Logger.warn("XML-RPC authenticate: invalid login for "+username); 75 throw new XmlRpcException(AUTHORIZATION_EXCEPTION, AUTHORIZATION_EXCEPTION_MSG); 76 } 77 78 } 79 | Popular Tags |