Sets all auth params at once to avoid state proliferation
authorNiels Erik G. Nielsen <nielserik@indexdata.com>
Sat, 13 Apr 2013 12:20:03 +0000 (08:20 -0400)
committerNiels Erik G. Nielsen <nielserik@indexdata.com>
Sat, 13 Apr 2013 12:20:03 +0000 (08:20 -0400)
src/main/java/com/indexdata/pz2utils4jsf/pazpar2/sp/ServiceProxyClient.java

index c4b77d8..2f96b13 100644 (file)
@@ -45,6 +45,7 @@ import com.indexdata.pz2utils4jsf.pazpar2.commands.CommandParameter;
 import com.indexdata.pz2utils4jsf.pazpar2.commands.Pazpar2Command;\r
 import com.indexdata.pz2utils4jsf.pazpar2.sp.auth.AuthenticationEntity;\r
 import com.indexdata.pz2utils4jsf.pazpar2.sp.auth.ServiceProxyUser;\r
+import com.indexdata.pz2utils4jsf.pazpar2.state.StateManager;\r
 import com.indexdata.pz2utils4jsf.utils.Utils;\r
 \r
 @Named @SessionScoped \r
@@ -96,10 +97,10 @@ public class ServiceProxyClient implements SearchClient {
     try {      \r
       logger.info("Authenticating [" + user.getProperty("name") + "]");\r
       this.user = (ServiceProxyUser) user;\r
-      Pazpar2Command auth = new Pazpar2Command("auth",null);\r
-      auth.setParameter(new CommandParameter("action","=","login"));\r
-      auth.setParameter(new CommandParameter("username","=",user.getProperty("name")));\r
-      auth.setParameter(new CommandParameter("password","=",user.getProperty("password")));\r
+      Pazpar2Command auth = new Pazpar2Command("auth",new StateManager());\r
+      auth.setParameters(new CommandParameter("action","=","login"), \r
+                         new CommandParameter("username","=",user.getProperty("name")), \r
+                         new CommandParameter("password","=",user.getProperty("password")));\r
       byte[] response = send(auth);\r
       String responseStr = new String(response,"UTF-8");\r
       logger.info(responseStr);      \r
@@ -121,7 +122,7 @@ public class ServiceProxyClient implements SearchClient {
   \r
   public boolean checkAuthentication () {\r
     try {\r
-      Pazpar2Command check = new Pazpar2Command("auth",null);\r
+      Pazpar2Command check = new Pazpar2Command("auth",new StateManager());\r
       check.setParameter(new CommandParameter("action","=","check"));\r
       byte[] response = send(check);\r
       logger.info(new String(response,"UTF-8"));\r