import com.indexdata.mkjsf.pazpar2.commands.Pazpar2Command;\r
import com.indexdata.mkjsf.pazpar2.commands.sp.AuthCommand;\r
import com.indexdata.mkjsf.pazpar2.data.CommandError;\r
-import com.indexdata.mkjsf.pazpar2.sp.auth.ServiceProxyUser;\r
import com.indexdata.mkjsf.utils.Utils;\r
\r
public class ServiceProxyClient implements SearchClient {\r
c.printStackTrace();\r
} \r
}\r
- \r
- \r
- public boolean authenticate (ServiceProxyUser user) {\r
- logger.info("Authenticating [" + user.getProperty("name") + "]"); \r
- Pazpar2Command auth = new AuthCommand(null);\r
- auth.setParametersInState(new CommandParameter("action","=","login"), \r
- new CommandParameter("username","=",user.getProperty("name")), \r
- new CommandParameter("password","=",user.getProperty("password"))); \r
- ClientCommandResponse commandResponse = send(auth);\r
- String responseStr = commandResponse.getResponseString();\r
- logger.info(responseStr); \r
- if (responseStr.contains("FAIL")) {\r
- user.credentialsAuthenticationSucceeded(false);\r
- return false;\r
- } else {\r
- user.credentialsAuthenticationSucceeded(true);\r
- return true;\r
- } \r
- }\r
- \r
- public boolean checkAuthentication (ServiceProxyUser user) { \r
- ClientCommandResponse commandResponse = send(checkAuth); \r
- String responseStr = commandResponse.getResponseString(); \r
- logger.info(responseStr);\r
- if (responseStr.contains("FAIL")) { \r
- user.authenticationCheckFailed();\r
- return false;\r
- } else { \r
- return true;\r
- } \r
- }\r
- \r
- public boolean ipAuthenticate (ServiceProxyUser user) {\r
- ClientCommandResponse commandResponse = send(ipAuth); \r
- String responseStr = commandResponse.getResponseString();\r
- logger.info(responseStr);\r
- if (responseStr.contains("FAIL")) {\r
- user.ipAuthenticationSucceeded(false); \r
- return false;\r
- } else {\r
- user.ipAuthenticationSucceeded(true);\r
- return true;\r
- } \r
- }\r
- \r
+ \r
public boolean isAuthenticatingClient () {\r
return true;\r
}\r
- \r
- public boolean isAuthenticated (ServiceProxyUser user) {\r
- if (user.getProperty("name") != null && user.getProperty("password") != null) {\r
- return checkAuthentication(user);\r
- } else {\r
- return false;\r
- }\r
- }\r
- \r
+ \r
/**\r
* Makes the request\r
* @param request\r
* @throws ClientProtocolException\r
* @throws IOException\r
*/\r
- private ClientCommandResponse send(Pazpar2Command command) {\r
+ public ClientCommandResponse send(Pazpar2Command command) {\r
ClientCommandResponse commandResponse = null;\r
String url = serviceUrl + "?" + command.getEncodedQueryString(); \r
logger.info("Sending request "+url); \r