You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@manifoldcf.apache.org by sc...@apache.org on 2019/09/11 14:18:33 UTC

svn commit: r1866797 - /manifoldcf/trunk/connectors/csws/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/csws/CswsAuthority.java

Author: schuch
Date: Wed Sep 11 14:18:33 2019
New Revision: 1866797

URL: http://svn.apache.org/viewvc?rev=1866797&view=rev
Log:
Fixed the csws authority connection check

Modified:
    manifoldcf/trunk/connectors/csws/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/csws/CswsAuthority.java

Modified: manifoldcf/trunk/connectors/csws/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/csws/CswsAuthority.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/csws/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/csws/CswsAuthority.java?rev=1866797&r1=1866796&r2=1866797&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/csws/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/csws/CswsAuthority.java (original)
+++ manifoldcf/trunk/connectors/csws/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/csws/CswsAuthority.java Wed Sep 11 14:18:33 2019
@@ -66,7 +66,7 @@ public class CswsAuthority extends org.a
   private long expirationTime = -1L;
   // Idle session expiration interval
   private final static long expirationInterval = 300000L;
-  
+
   // Data from the parameters
   private String serverProtocol = null;
   private String serverName = null;
@@ -94,7 +94,7 @@ public class CswsAuthority extends org.a
 
   /** Cache manager. */
   protected ICacheManager cacheManager = null;
-  
+
   // Csws does not have "deny" permissions, and there is no such thing as a document with no tokens, so it is safe to not have a local "deny" token.
   // However, people feel that a suspenders-and-belt approach is called for, so this restriction has been added.
   // Csws tokens are numbers, "SYSTEM", or "GUEST", so they can't collide with the standard form.
@@ -114,7 +114,7 @@ public class CswsAuthority extends org.a
     super.setThreadContext(tc);
     cacheManager = CacheManagerFactory.make(tc);
   }
-  
+
   /** Clear thread context.
   */
   @Override
@@ -150,7 +150,7 @@ public class CswsAuthority extends org.a
       //documentManagementServicePath = params.getParameter(CswsParameters.documentManagementPath);
       //contentServiceServicePath = params.getParameter(CswsParameters.contentServicePath);
       memberServiceServicePath = params.getParameter(CswsParameters.memberServicePath);
-      //searchServiceServicePath = params.getParameter(CswsParameters.searchServicePath);      
+      //searchServiceServicePath = params.getParameter(CswsParameters.searchServicePath);
       serverHTTPNTLMDomain = params.getParameter(CswsParameters.serverHTTPNTLMDomain);
       serverHTTPNTLMUsername = params.getParameter(CswsParameters.serverHTTPNTLMUsername);
       serverHTTPNTLMPassword = params.getObfuscatedParameter(CswsParameters.serverHTTPNTLMPassword);
@@ -159,12 +159,12 @@ public class CswsAuthority extends org.a
 
       if (serverProtocol == null || serverProtocol.length() == 0)
         serverProtocol = "http";
-        
+
       if (serverPortString == null)
         serverPort = 2099;
       else
         serverPort = new Integer(serverPortString).intValue();
-        
+
       if (serverHTTPNTLMDomain != null && serverHTTPNTLMDomain.length() == 0)
         serverHTTPNTLMDomain = null;
       if (serverHTTPNTLMUsername == null || serverHTTPNTLMUsername.length() == 0)
@@ -184,7 +184,7 @@ public class CswsAuthority extends org.a
       cacheLRUsize = params.getParameter(CswsParameters.cacheLRUSize);
       if (cacheLRUsize == null)
         cacheLRUsize = "1000";
-      
+
       try
       {
         responseLifetime = Long.parseLong(this.cacheLifetime) * 60L * 1000L;
@@ -203,7 +203,7 @@ public class CswsAuthority extends org.a
       hasSessionParameters = true;
     }
   }
-  
+
   /** Set up a session.
   */
   protected void getSession()
@@ -219,7 +219,7 @@ public class CswsAuthority extends org.a
       //final String contentServiceServiceURL = baseURL + contentServiceServicePath;
       final String memberServiceServiceURL = baseURL + memberServiceServicePath;
       //final String searchServiceServiceURL = baseURL + searchServiceServicePath;
-      
+
       if (Logging.authorityConnectors.isDebugEnabled())
       {
         Logging.authorityConnectors.debug("Csws: Csws session created.");
@@ -247,9 +247,9 @@ public class CswsAuthority extends org.a
       // Reestablish the session
       cswsSession = null;
       getSession();
-      
-      final User user = cswsSession.getUserByLoginName("Admin");
-      if (user == null) {
+
+      final User user = cswsSession.getUserByLoginName(this.serverUsername);
+      if (user != null) {
         return super.check();
       }
       return "Connection failed: User authentication failed";
@@ -301,7 +301,7 @@ public class CswsAuthority extends org.a
     hasSessionParameters = false;
     cswsSession = null;
     expirationTime = -1L;
-    
+
     serverProtocol = null;
     serverName = null;
     serverPort = -1;
@@ -342,7 +342,7 @@ public class CswsAuthority extends org.a
       authenticationServicePath, memberServiceServicePath,
       serverHTTPSKeystore,
       responseLifetime,LRUsize);
-      
+
     // Enter the cache
     ICacheHandle ch = cacheManager.enterCache(new ICacheDescription[]{objectDescription},null,null);
     try
@@ -371,7 +371,7 @@ public class CswsAuthority extends org.a
       cacheManager.leaveCache(ch);
     }
   }
-  
+
   /** Uncached method to get access tokens for a user name. */
   protected AuthorizationResponse getAuthorizationResponseUncached(String userName)
     throws ManifoldCFException
@@ -414,18 +414,18 @@ public class CswsAuthority extends org.a
         // Since the user cannot become undeleted, then this should be treated as 'user does not exist'.
         return RESPONSE_USERNOTFOUND;
       }
-      
+
       final MemberPrivileges memberPrivileges = user.getPrivileges();
       if (memberPrivileges.isPublicAccessEnabled()) {
         // if ((privs & LAPI_USERS.PRIV_PERM_WORLD) == LAPI_USERS.PRIV_PERM_WORLD) ??
         list.add("GUEST");
       }
-      
+
       if (memberPrivileges. isCanAdministerSystem()) {
         // if ((privs & LAPI_USERS.PRIV_PERM_BYPASS) == LAPI_USERS.PRIV_PERM_BYPASS)
         list.add("SYSTEM");
       }
-      
+
       final Member member = cswsSession.getMemberByLoginName(domainAndUser);
       if (member == null) {
         if (Logging.authorityConnectors.isDebugEnabled())
@@ -455,7 +455,7 @@ public class CswsAuthority extends org.a
       // These objects are returned by the corresponding GetObjectRights() call made during
       // the ingestion process.  We have to figure out how to map these to things that are
       // the equivalent of acls.
-        
+
       // Idea:
       // 1) RIGHT_WORLD is based on some property of the user.
       // 2) RIGHT_SYSTEM is based on some property of the user.
@@ -496,7 +496,7 @@ public class CswsAuthority extends org.a
   //
   // These support methods are involved in setting up authority connection configuration information. The configuration methods cannot assume that the
   // current authority object is connected.  That is why they receive a thread context argument.
-    
+
   /** Output the configuration header section.
   * This method is called in the head section of the connector's configuration page.  Its purpose is to add the required tabs to the list, and to output any
   * javascript methods that might be needed by the configuration editing HTML.
@@ -513,9 +513,9 @@ public class CswsAuthority extends org.a
     tabsArray.add(Messages.getString(locale,"CswsConnector.Server"));
     tabsArray.add(Messages.getString(locale,"CswsConnector.Cache"));
 
-    Messages.outputResourceWithVelocity(out, locale, EDIT_CONFIGURATION_JS, null, true);  
+    Messages.outputResourceWithVelocity(out, locale, EDIT_CONFIGURATION_JS, null, true);
   }
-  
+
   /** Output the configuration body section.
   * This method is called in the body section of the authority connector's configuration page.  Its purpose is to present the required form elements for editing.
   * The coder can presume that the HTML that is output from this configuration will be within appropriate <html>, <body>, and <form> tags.  The name of the
@@ -529,7 +529,7 @@ public class CswsAuthority extends org.a
   public void outputConfigurationBody(IThreadContext threadContext, IHTTPOutput out,
     Locale locale, ConfigParams parameters, String tabName)
     throws ManifoldCFException, IOException
-  {        
+  {
     Map<String, Object> velocityContext = new HashMap<>();
     velocityContext.put("TabName",tabName);
 
@@ -561,14 +561,14 @@ public class CswsAuthority extends org.a
       serverPassword = "";
     else
       serverPassword = out.mapPasswordToKey(serverPassword);
-    
+
     String authenticationServicePath = parameters.getParameter(CswsParameters.authenticationPath);
     if (authenticationServicePath == null)
       authenticationServicePath = CswsParameters.authenticationPathDefault;
     String memberServiceServicePath = parameters.getParameter(CswsParameters.memberServicePath);
     if (memberServiceServicePath == null)
       memberServiceServicePath = CswsParameters.memberServicePathDefault;
-    
+
     String serverHTTPNTLMDomain = parameters.getParameter(CswsParameters.serverHTTPNTLMDomain);
     if(serverHTTPNTLMDomain == null)
       serverHTTPNTLMDomain = "";
@@ -618,7 +618,7 @@ public class CswsAuthority extends org.a
     velocityContext.put("SERVERPORT",serverPort);
     velocityContext.put("SERVERUSERNAME",serverUserName);
     velocityContext.put("SERVERPASSWORD",serverPassword);
-    
+
     velocityContext.put("AUTHENTICATIONSERVICEPATH", authenticationServicePath);
     velocityContext.put("MEMBERSERVICESERVICEPATH", memberServiceServicePath);
 
@@ -645,8 +645,8 @@ public class CswsAuthority extends org.a
 
     velocityContext.put("CACHELIFETIME",cacheLifetime);
     velocityContext.put("CACHELRUSIZE",cacheLRUsize);
-  }  
-  
+  }
+
   /** Process a configuration post.
   * This method is called at the start of the authority connector's configuration page, whenever there is a possibility that form data for a connection has been
   * posted.  Its purpose is to gather form information and modify the configuration parameters accordingly.
@@ -677,7 +677,7 @@ public class CswsAuthority extends org.a
     String serverPassword = variableContext.getParameter("serverpassword");
     if (serverPassword != null)
       parameters.setObfuscatedParameter(CswsParameters.serverPassword,variableContext.mapKeyToPassword(serverPassword));
-    
+
     String authenticationServicePath = variableContext.getParameter("authenticationservicepath");
     if (authenticationServicePath != null)
       parameters.setParameter(CswsParameters.authenticationPath, authenticationServicePath);
@@ -739,7 +739,7 @@ public class CswsAuthority extends org.a
       }
     }
     parameters.setParameter(CswsParameters.serverHTTPSKeystore,serverHTTPSKeystoreValue);
-    
+
     // Cache parameters
     String cacheLifetime = variableContext.getParameter("cachelifetime");
     if (cacheLifetime != null)
@@ -750,7 +750,7 @@ public class CswsAuthority extends org.a
 
     return null;
   }
-  
+
   /** View configuration.
   * This method is called in the body section of the authority connector's view configuration page.  Its purpose is to present the connection information to the user.
   * The coder can presume that the HTML that is output from this configuration will be within appropriate &lt;html&gt; and &lt;body&gt; tags.
@@ -788,11 +788,11 @@ public class CswsAuthority extends org.a
     }
 
     paramMap.put("CONFIGMAP",configMap);
-    Messages.outputResourceWithVelocity(out, locale, VIEW_CONFIGURATION_HTML, paramMap);    
+    Messages.outputResourceWithVelocity(out, locale, VIEW_CONFIGURATION_HTML, paramMap);
   }
 
   protected static StringSet emptyStringSet = new StringSet();
-  
+
   /** This is the cache object descriptor for cached access tokens from
   * this connector.
   */
@@ -800,7 +800,7 @@ public class CswsAuthority extends org.a
   {
     /** The user name associated with the access tokens */
     protected final String userName;
-    
+
     // The server connection parameters
     protected final String serverProtocol;
     protected final String serverName;
@@ -812,10 +812,10 @@ public class CswsAuthority extends org.a
     protected final String serverHTTPSKeystore;
 
     protected long responseLifetime;
-    
+
     /** The expiration time */
     protected long expirationTime = -1;
-    
+
     /** Constructor. */
     public AuthorizationResponseDescription(String userName,
       String serverProtocol,
@@ -828,7 +828,7 @@ public class CswsAuthority extends org.a
     {
       super("CswsAuthority",LRUsize);
       this.userName = userName;
-      
+
       this.serverProtocol = serverProtocol;
       this.serverName = serverName;
       this.serverPort = serverPort;
@@ -874,7 +874,7 @@ public class CswsAuthority extends org.a
         authenticationServicePath.hashCode() + memberServicePath.hashCode() +
         ((serverHTTPSKeystore==null)?0:serverHTTPSKeystore.hashCode());
     }
-    
+
     public boolean equals(Object o)
     {
       if (!(o instanceof AuthorizationResponseDescription))
@@ -888,7 +888,7 @@ public class CswsAuthority extends org.a
         ((ard.serverHTTPSKeystore != null && serverHTTPSKeystore != null && ard.serverHTTPSKeystore.equals(serverHTTPSKeystore)) ||
           ((ard.serverHTTPSKeystore == null || serverHTTPSKeystore == null) && ard.serverHTTPSKeystore == serverHTTPSKeystore));
     }
-    
+
   }
 
 }