import com.indexdata.mkjsf.pazpar2.data.ResponseDataObject;\r
import com.indexdata.mkjsf.pazpar2.data.ResponseParser;\r
import com.indexdata.mkjsf.pazpar2.data.Responses;\r
-import com.indexdata.mkjsf.pazpar2.data.sp.AuthResponse;\r
import com.indexdata.mkjsf.pazpar2.data.sp.CategoriesResponse;\r
import com.indexdata.mkjsf.utils.Utils;\r
\r
//stateMgr.addStateListener(this);\r
}\r
\r
-\r
- \r
- public void login(String un, String pw) {\r
- logger.info("doing un/pw login");\r
- pzreq.getSp().getAuth().setUsername(un);\r
- pzreq.getSp().getAuth().setPassword(pw);\r
- login("");\r
- }\r
-\r
-\r
- \r
- @Override \r
- public String login(String navigateTo) {\r
- logger.info("doing login using " + pz2 + " and client " + pz2.getSpClient());\r
+ public void authenticate() {\r
pz2.resetSearchAndRecordCommands();\r
pzresp.getSp().resetAuthAndBeyond(true);\r
- AuthCommand auth = pzreq.getSp().getAuth(); \r
- auth.setParameterInState(new CommandParameter("action","=","login"));\r
- ClientCommandResponse commandResponse = pz2.getSpClient().send(auth);\r
+ AuthCommand auth = pzreq.getSp().getAuth(); \r
+ ClientCommandResponse commandResponse = pz2.getSpClient().send(auth); \r
String renamedResponse = renameResponseElement(commandResponse.getResponseString(), "auth");\r
commandResponse.setResponseToParse(renamedResponse);\r
- AuthResponse responseObject = (AuthResponse) ResponseParser.getParser().getDataObject(commandResponse);\r
+ ResponseDataObject responseObject = ResponseParser.getParser().getDataObject(commandResponse);\r
if (ResponseParser.docTypes.contains(responseObject.getType())) {\r
pzresp.put(auth.getCommandName(), responseObject);\r
}\r
String responseStr = commandResponse.getResponseString();\r
- logger.info(responseStr); \r
- return navigateTo;\r
+ logger.info(responseStr); \r
}\r
\r
+ public void login(String un, String pw) { \r
+ login(un,pw,"");\r
+ }\r
\r
+ public void login(String un, String pw, String navigateTo) { \r
+ pzreq.getSp().getAuth().setUsername(un);\r
+ pzreq.getSp().getAuth().setPassword(pw);\r
+ login("");\r
+ } \r
+ \r
+ @Override \r
+ public String login(String navigateTo) {\r
+ AuthCommand auth = pzreq.getSp().getAuth(); \r
+ auth.setParameterInState(new CommandParameter("action","=","login"));\r
+ authenticate();\r
+ return navigateTo;\r
+ }\r
+ \r
public void ipAuthenticate () { \r
- pz2.resetSearchAndRecordCommands();\r
- pzresp.getSp().resetAuthAndBeyond(true);\r
AuthCommand auth = pzreq.getSp().getAuth(); \r
auth.setParameterInState(new CommandParameter("action","=","ipAuth"));\r
- ClientCommandResponse commandResponse = pz2.getSpClient().send(auth); \r
- String renamedResponse = renameResponseElement(commandResponse.getResponseString(), "auth");\r
- commandResponse.setResponseToParse(renamedResponse);\r
- ResponseDataObject responseObject = ResponseParser.getParser().getDataObject(commandResponse);\r
- if (ResponseParser.docTypes.contains(responseObject.getType())) {\r
- pzresp.put(auth.getCommandName(), responseObject);\r
- }\r
- String responseStr = commandResponse.getResponseString();\r
- logger.info(responseStr); \r
+ authenticate();\r
}\r
\r
private String renameResponseElement(String responseString, String newName) {\r