From: Niels Erik G. Nielsen Date: Sat, 13 Apr 2013 12:20:03 +0000 (-0400) Subject: Sets all auth params at once to avoid state proliferation X-Git-Tag: v0.0.7~174 X-Git-Url: http://lists.indexdata.com/cgi-bin?a=commitdiff_plain;h=ec5e0970638fda5967e190b6ed13c2ee8b7bf40d;p=mkjsf-moved-to-github.git Sets all auth params at once to avoid state proliferation --- diff --git a/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/sp/ServiceProxyClient.java b/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/sp/ServiceProxyClient.java index c4b77d8..2f96b13 100644 --- a/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/sp/ServiceProxyClient.java +++ b/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/sp/ServiceProxyClient.java @@ -45,6 +45,7 @@ import com.indexdata.pz2utils4jsf.pazpar2.commands.CommandParameter; import com.indexdata.pz2utils4jsf.pazpar2.commands.Pazpar2Command; import com.indexdata.pz2utils4jsf.pazpar2.sp.auth.AuthenticationEntity; import com.indexdata.pz2utils4jsf.pazpar2.sp.auth.ServiceProxyUser; +import com.indexdata.pz2utils4jsf.pazpar2.state.StateManager; import com.indexdata.pz2utils4jsf.utils.Utils; @Named @SessionScoped @@ -96,10 +97,10 @@ public class ServiceProxyClient implements SearchClient { try { logger.info("Authenticating [" + user.getProperty("name") + "]"); this.user = (ServiceProxyUser) user; - Pazpar2Command auth = new Pazpar2Command("auth",null); - auth.setParameter(new CommandParameter("action","=","login")); - auth.setParameter(new CommandParameter("username","=",user.getProperty("name"))); - auth.setParameter(new CommandParameter("password","=",user.getProperty("password"))); + Pazpar2Command auth = new Pazpar2Command("auth",new StateManager()); + auth.setParameters(new CommandParameter("action","=","login"), + new CommandParameter("username","=",user.getProperty("name")), + new CommandParameter("password","=",user.getProperty("password"))); byte[] response = send(auth); String responseStr = new String(response,"UTF-8"); logger.info(responseStr); @@ -121,7 +122,7 @@ public class ServiceProxyClient implements SearchClient { public boolean checkAuthentication () { try { - Pazpar2Command check = new Pazpar2Command("auth",null); + Pazpar2Command check = new Pazpar2Command("auth",new StateManager()); check.setParameter(new CommandParameter("action","=","check")); byte[] response = send(check); logger.info(new String(response,"UTF-8"));