Adds IP authentication to SP client
[mkjsf-moved-to-github.git] / src / main / java / com / indexdata / mkjsf / pazpar2 / Pz2ProxyBean.java
index 16b4319..4209aa2 100644 (file)
@@ -46,6 +46,17 @@ public class Pz2ProxyBean extends Pz2Bean implements ServiceProxyInterface {
                        "during construction of parent object Pz2Bean.");\r
     }\r
   }\r
+  \r
+  public void login(String un, String pw) {\r
+    if (user.isAuthenticated() && user.getName().equals(un) && ((ServiceProxyClient) searchClient).checkAuthentication(user)) {\r
+      logger.info("Repeat request from UI to authenticate user. Auth verified for given user name so skipping log-in.");\r
+    } else {\r
+      logger.info("doing un/pw login");\r
+      user.setName(un);\r
+      user.setPassword(pw);\r
+      login("dummy");\r
+    }\r
+  }\r
 \r
   @Override\r
   public String login(String navigateTo) {\r
@@ -56,6 +67,12 @@ public class Pz2ProxyBean extends Pz2Bean implements ServiceProxyInterface {
     pzresp.reset();\r
     return navigateTo;\r
   }\r
+  \r
+  public void ipAuthenticate (ServiceProxyUser user) {\r
+    if (!user.isAuthenticated()) {\r
+      ((ServiceProxyClient)searchClient).ipAuthenticate(user);\r
+    }\r
+  }\r
 \r
   @Override\r
   public void setServiceProxyUrl(String url) {\r
@@ -118,6 +135,4 @@ public class Pz2ProxyBean extends Pz2Bean implements ServiceProxyInterface {
     return null;\r
     // return getCommandParameterValue("record","acefilter","");\r
   }\r
-\r
-\r
 }\r