Author: kwright
Date: Sun Jan 12 20:03:24 2014
New Revision: 1557606

URL: http://svn.apache.org/r1557606
Log:
Fix for CONNECTORS-754.

Modified:
    manifoldcf/trunk/CHANGES.txt
    
manifoldcf/trunk/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/sharepoint/SPSProxyHelper.java
    
manifoldcf/trunk/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/sharepoint/SharePointAuthority.java
    
manifoldcf/trunk/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/sharepoint/SharePointConfig.java
    
manifoldcf/trunk/connectors/sharepoint/connector/src/main/native2ascii/org/apache/manifoldcf/authorities/authorities/sharepoint/common_en_US.properties
    
manifoldcf/trunk/connectors/sharepoint/connector/src/main/native2ascii/org/apache/manifoldcf/authorities/authorities/sharepoint/common_ja_JP.properties
    
manifoldcf/trunk/connectors/sharepoint/connector/src/main/resources/org/apache/manifoldcf/authorities/authorities/sharepoint/editConfiguration_Server.html
    
manifoldcf/trunk/connectors/sharepoint/connector/src/main/resources/org/apache/manifoldcf/authorities/authorities/sharepoint/viewConfiguration.html

Modified: manifoldcf/trunk/CHANGES.txt
URL: 
http://svn.apache.org/viewvc/manifoldcf/trunk/CHANGES.txt?rev=1557606&r1=1557605&r2=1557606&view=diff
==============================================================================
--- manifoldcf/trunk/CHANGES.txt (original)
+++ manifoldcf/trunk/CHANGES.txt Sun Jan 12 20:03:24 2014
@@ -3,6 +3,10 @@ $Id$
 
 ======================= 1.5-dev =====================
 
+CONNECTORS-754: Add claim space selection for SharePoint native
+authority, so that it works with Claim Space servers.
+(Will Parkinson, Karl Wright)
+
 CONNECTORS-854: Enable stale connection checks on all http fetches.
 Not sure why it was disabled long ago, but it causes problems when
 connections are pooled for longer than the server wants the connection

Modified: 
manifoldcf/trunk/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/sharepoint/SPSProxyHelper.java
URL: 
http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/sharepoint/SPSProxyHelper.java?rev=1557606&r1=1557605&r2=1557606&view=diff
==============================================================================
--- 
manifoldcf/trunk/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/sharepoint/SPSProxyHelper.java
 (original)
+++ 
manifoldcf/trunk/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/sharepoint/SPSProxyHelper.java
 Sun Jan 12 20:03:24 2014
@@ -69,14 +69,15 @@ public class SPSProxyHelper {
 
   public static final String HTTPCLIENT_PROPERTY = 
org.apache.manifoldcf.sharepoint.CommonsHTTPSender.HTTPCLIENT_PROPERTY;
 
-  private String serverUrl;
-  private String serverLocation;
-  private String decodedServerLocation;
-  private String baseUrl;
-  private String userName;
-  private String password;
-  private EngineConfiguration configuration;
-  private HttpClient httpClient;
+  private final String serverUrl;
+  private final String serverLocation;
+  private final String decodedServerLocation;
+  private final String baseUrl;
+  private final String userName;
+  private final String password;
+  private final boolean isClaimSpace;
+  private final EngineConfiguration configuration;
+  private final HttpClient httpClient;
 
   /**
   *
@@ -85,7 +86,7 @@ public class SPSProxyHelper {
   * @param password
   */
   public SPSProxyHelper( String serverUrl, String serverLocation, String 
decodedServerLocation, String userName, String password,
-    Class resourceClass, String configFileName, HttpClient httpClient )
+    Class resourceClass, String configFileName, HttpClient httpClient, boolean 
isClaimSpace )
   {
     this.serverUrl = serverUrl;
     this.serverLocation = serverLocation;
@@ -98,6 +99,7 @@ public class SPSProxyHelper {
     this.password = password;
     this.configuration = new ResourceProvider(resourceClass,configFileName);
     this.httpClient = httpClient;
+    this.isClaimSpace = isClaimSpace;
   }
 
   /**
@@ -110,6 +112,8 @@ public class SPSProxyHelper {
     {
       if ( site.compareTo("/") == 0 )
         site = ""; // root case
+
+      userLoginName = mapToClaimSpace(userLoginName);
       
       UserGroupWS userService = new UserGroupWS( baseUrl + site, userName, 
password, configuration, httpClient  );
       com.microsoft.schemas.sharepoint.soap.directory.UserGroupSoap userCall = 
userService.getUserGroupSoapHandler( );
@@ -207,51 +211,71 @@ public class SPSProxyHelper {
         }
       }
 
-      
com.microsoft.schemas.sharepoint.soap.directory.GetRoleCollectionFromUserResponseGetRoleCollectionFromUserResult
 userRoleResp =
-        userCall.getRoleCollectionFromUser( userLoginName );
-      org.apache.axis.message.MessageElement[] rolesList = 
userRoleResp.get_any();
-
-      if (rolesList.length != 1)
-        throw new ManifoldCFException("Bad response - expecting one outer 
'GetRoleCollectionFromUser' node, saw "+Integer.toString(rolesList.length));
-      
-      if (Logging.authorityConnectors.isDebugEnabled()){
-        Logging.authorityConnectors.debug("SharePoint authority: 
getRoleCollectionFromUser xml response: '" + rolesList[0].toString() + "'");
-      }
+      // AxisFault is expected for case where user has no assigned roles
+      try
+      {
+        
com.microsoft.schemas.sharepoint.soap.directory.GetRoleCollectionFromUserResponseGetRoleCollectionFromUserResult
 userRoleResp =
+          userCall.getRoleCollectionFromUser( userLoginName );
+        org.apache.axis.message.MessageElement[] rolesList = 
userRoleResp.get_any();
+
+        if (rolesList.length != 1)
+          throw new ManifoldCFException("Bad response - expecting one outer 
'GetRoleCollectionFromUser' node, saw "+Integer.toString(rolesList.length));
+        
+        if (Logging.authorityConnectors.isDebugEnabled()){
+          Logging.authorityConnectors.debug("SharePoint authority: 
getRoleCollectionFromUser xml response: '" + rolesList[0].toString() + "'");
+        }
 
-      // Not specified in doc and must be determined experimentally
-      /*
+        // Not specified in doc and must be determined experimentally
+        /*
 <ns1:GetRoleCollectionFromUser 
xmlns:ns1="http://schemas.microsoft.com/sharepoint/soap/directory/";>
   <ns1:Roles>
     <ns1:Role ID="1073741825" Name="Limited Access" Description="Can view 
specific lists, document libraries, list items, folders, or documents when 
given permissions."
       Order="160" Hidden="True" Type="Guest" BasePermissions="ViewFormPages, 
Open, BrowseUserInfo, UseClientIntegration, UseRemoteAPIs"/>
   </ns1:Roles>
 </ns1:GetRoleCollectionFromUser>'
-      */
-      
-      MessageElement roles = rolesList[0];
-      if 
(!roles.getElementName().getLocalName().equals("GetRoleCollectionFromUser"))
-        throw new ManifoldCFException("Bad response - outer node should have 
been 'GetRoleCollectionFromUser' node");
-          
-      Iterator rolesIter = roles.getChildElements();
-      while (rolesIter.hasNext())
-      {
-        MessageElement child = (MessageElement)rolesIter.next();
-        if (child.getElementName().getLocalName().equals("Roles"))
+        */
+        
+        MessageElement roles = rolesList[0];
+        if 
(!roles.getElementName().getLocalName().equals("GetRoleCollectionFromUser"))
+          throw new ManifoldCFException("Bad response - outer node should have 
been 'GetRoleCollectionFromUser' node");
+            
+        Iterator rolesIter = roles.getChildElements();
+        while (rolesIter.hasNext())
         {
-          Iterator roleIter = child.getChildElements();
-          while (roleIter.hasNext())
+          MessageElement child = (MessageElement)rolesIter.next();
+          if (child.getElementName().getLocalName().equals("Roles"))
           {
-            MessageElement role = (MessageElement)roleIter.next();
-            if (role.getElementName().getLocalName().equals("Role"))
+            Iterator roleIter = child.getChildElements();
+            while (roleIter.hasNext())
             {
-              String roleID = role.getAttribute("ID");
-              String roleName = role.getAttribute("Name");
-              // Add to the access token list
-              accessTokens.add("R"+roleName);
+              MessageElement role = (MessageElement)roleIter.next();
+              if (role.getElementName().getLocalName().equals("Role"))
+              {
+                String roleID = role.getAttribute("ID");
+                String roleName = role.getAttribute("Name");
+                // Add to the access token list
+                accessTokens.add("R"+roleName);
+              }
             }
           }
         }
       }
+      catch (org.apache.axis.AxisFault e)
+      {
+        if (e.getFaultCode().equals(new 
javax.xml.namespace.QName("http://schemas.xmlsoap.org/soap/envelope/","Server";)))
+        {
+          org.w3c.dom.Element elem = e.lookupFaultDetail(new 
javax.xml.namespace.QName("http://schemas.microsoft.com/sharepoint/soap/","errorcode";));
+          if (elem != null)
+          {
+            elem.normalize();
+            String sharepointErrorCode = 
elem.getFirstChild().getNodeValue().trim();
+            if (!sharepointErrorCode.equals("0x80131600"))
+              throw e;
+          }
+        }
+        else
+          throw e;
+      }
       
       return accessTokens;
     }
@@ -364,11 +388,9 @@ public class SPSProxyHelper {
       com.microsoft.schemas.sharepoint.soap.directory.UserGroupSoap userCall = 
userService.getUserGroupSoapHandler( );
 
       // Get the info for the admin user
-      
com.microsoft.schemas.sharepoint.soap.directory.GetUserInfoResponseGetUserInfoResult
 userResp = userCall.getUserInfo( userName );
+      
com.microsoft.schemas.sharepoint.soap.directory.GetUserInfoResponseGetUserInfoResult
 userResp = userCall.getUserInfo( mapToClaimSpace(userName) );
       org.apache.axis.message.MessageElement[] userList = userResp.get_any();
 
-      // MHL
-
       return true;
     }
     catch (java.net.MalformedURLException e)
@@ -437,6 +459,17 @@ public class SPSProxyHelper {
       throw new ManifoldCFException("Got an unexpected remote exception 
accessing site "+site+": "+e.getMessage(),e);
     }
   }
+  
+  /** Conditionally map SharePoint user login name to claim space.
+  */
+  protected String mapToClaimSpace(String userLoginName)
+  {
+    if (isClaimSpace)
+    {
+      return "i:0#.w|" + userLoginName.toLowerCase(java.util.Locale.ROOT);
+    }
+    return userLoginName;
+  }
 
   /**
   * SharePoint UserGroup Service Wrapper Class

Modified: 
manifoldcf/trunk/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/sharepoint/SharePointAuthority.java
URL: 
http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/sharepoint/SharePointAuthority.java?rev=1557606&r1=1557605&r2=1557606&view=diff
==============================================================================
--- 
manifoldcf/trunk/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/sharepoint/SharePointAuthority.java
 (original)
+++ 
manifoldcf/trunk/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/sharepoint/SharePointAuthority.java
 Sun Jan 12 20:03:24 2014
@@ -72,6 +72,7 @@ public class SharePointAuthority extends
   
   // SharePoint server parameters
   // These are needed for caching, so they are set at connect() time
+  private boolean isClaimSpace = false;
   private String serverProtocol = null;
   private String serverUrl = null;
   private String fileBaseUrl = null;
@@ -164,7 +165,12 @@ public class SharePointAuthority extends
     if (serverVersion == null)
       serverVersion = "2.0";
     // Authority needs to do nothing with SharePoint version right now.
-      
+
+    String serverClaimSpace = configParams.getParameter( 
SharePointConfig.PARAM_SERVERCLAIMSPACE);
+    if (serverClaimSpace == null)
+      serverClaimSpace = "false";
+    isClaimSpace = serverClaimSpace.equals("true");
+    
     serverProtocol = configParams.getParameter( 
SharePointConfig.PARAM_SERVERPROTOCOL );
     if (serverProtocol == null)
       serverProtocol = "http";
@@ -267,6 +273,7 @@ public class SharePointAuthority extends
     
     // Clean up SharePoint parameters
     
+    isClaimSpace = false;
     serverUrl = null;
     fileBaseUrl = null;
     serverUserName = null;
@@ -421,6 +428,10 @@ public class SharePointAuthority extends
     String serverVersion = 
parameters.getParameter(SharePointConfig.PARAM_SERVERVERSION);
     if (serverVersion == null)
       serverVersion = "2.0";
+    
+    String serverClaimSpace = 
parameters.getParameter(SharePointConfig.PARAM_SERVERCLAIMSPACE);
+    if (serverClaimSpace == null)
+      serverClaimSpace = "false";
 
     String serverProtocol = 
parameters.getParameter(SharePointConfig.PARAM_SERVERPROTOCOL);
     if (serverProtocol == null)
@@ -471,6 +482,7 @@ public class SharePointAuthority extends
     
     // Fill in context
     velocityContext.put("SERVERVERSION", serverVersion);
+    velocityContext.put("SERVERCLAIMSPACE", serverClaimSpace);
     velocityContext.put("SERVERPROTOCOL", serverProtocol);
     velocityContext.put("SERVERNAME", serverName);
     velocityContext.put("SERVERPORT", serverPort);
@@ -523,6 +535,10 @@ public class SharePointAuthority extends
     if (serverVersion != null)
       
parameters.setParameter(SharePointConfig.PARAM_SERVERVERSION,serverVersion);
 
+    String serverClaimSpace = variableContext.getParameter("serverClaimSpace");
+    if (serverClaimSpace != null)
+      
parameters.setParameter(SharePointConfig.PARAM_SERVERCLAIMSPACE,serverClaimSpace);
+    
     String serverProtocol = variableContext.getParameter("serverProtocol");
     if (serverProtocol != null)
       
parameters.setParameter(SharePointConfig.PARAM_SERVERPROTOCOL,serverProtocol);
@@ -732,7 +748,7 @@ public class SharePointAuthority extends
       
       proxy = new SPSProxyHelper( serverUrl, encodedServerLocation, 
serverLocation, serverUserName, password,
         org.apache.manifoldcf.sharepoint.CommonsHTTPSender.class, 
"sharepoint-client-config.wsdd",
-        httpClient );
+        httpClient, isClaimSpace );
       
     }
     sharepointSessionTimeout = System.currentTimeMillis() + 
SharePointExpirationInterval;

Modified: 
manifoldcf/trunk/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/sharepoint/SharePointConfig.java
URL: 
http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/sharepoint/SharePointConfig.java?rev=1557606&r1=1557605&r2=1557606&view=diff
==============================================================================
--- 
manifoldcf/trunk/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/sharepoint/SharePointConfig.java
 (original)
+++ 
manifoldcf/trunk/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/sharepoint/SharePointConfig.java
 Sun Jan 12 20:03:24 2014
@@ -34,6 +34,8 @@ public class SharePointConfig
 
   /** SharePoint server version */
   public static final String PARAM_SERVERVERSION = "serverVersion";
+  /** Claim space enabled? */
+  public static final String PARAM_SERVERCLAIMSPACE = "serverClaimSpace";
   /** SharePoint server protocol */
   public static final String PARAM_SERVERPROTOCOL = "serverProtocol";
   /** SharePoint server name */

Modified: 
manifoldcf/trunk/connectors/sharepoint/connector/src/main/native2ascii/org/apache/manifoldcf/authorities/authorities/sharepoint/common_en_US.properties
URL: 
http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/sharepoint/connector/src/main/native2ascii/org/apache/manifoldcf/authorities/authorities/sharepoint/common_en_US.properties?rev=1557606&r1=1557605&r2=1557606&view=diff
==============================================================================
--- 
manifoldcf/trunk/connectors/sharepoint/connector/src/main/native2ascii/org/apache/manifoldcf/authorities/authorities/sharepoint/common_en_US.properties
 (original)
+++ 
manifoldcf/trunk/connectors/sharepoint/connector/src/main/native2ascii/org/apache/manifoldcf/authorities/authorities/sharepoint/common_en_US.properties
 Sun Jan 12 20:03:24 2014
@@ -43,6 +43,9 @@ SharePointAuthority.certificate=certific
 
 SharePointAuthority.Server=Server
 SharePointAuthority.ServerSharePointVersion=Server SharePoint version:
+SharePointAuthority.ServerClaimSpace=Claim space authorization:
+SharePointAuthority.Disabled=Disabled
+SharePointAuthority.Enabled=Enabled
 SharePointAuthority.ServerProtocol=Server protocol:
 SharePointAuthority.ServerName=Server name:
 SharePointAuthority.ServerPort=Server port:

Modified: 
manifoldcf/trunk/connectors/sharepoint/connector/src/main/native2ascii/org/apache/manifoldcf/authorities/authorities/sharepoint/common_ja_JP.properties
URL: 
http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/sharepoint/connector/src/main/native2ascii/org/apache/manifoldcf/authorities/authorities/sharepoint/common_ja_JP.properties?rev=1557606&r1=1557605&r2=1557606&view=diff
==============================================================================
--- 
manifoldcf/trunk/connectors/sharepoint/connector/src/main/native2ascii/org/apache/manifoldcf/authorities/authorities/sharepoint/common_ja_JP.properties
 (original)
+++ 
manifoldcf/trunk/connectors/sharepoint/connector/src/main/native2ascii/org/apache/manifoldcf/authorities/authorities/sharepoint/common_ja_JP.properties
 Sun Jan 12 20:03:24 2014
@@ -43,6 +43,9 @@ SharePointAuthority.certificate=証æ
 
 SharePointAuthority.Server=サーバ
 
SharePointAuthority.ServerSharePointVersion=サーバSharePointバージョン:
+SharePointAuthority.ServerClaimSpace=Claim space authorization:
+SharePointAuthority.Disabled=Disabled
+SharePointAuthority.Enabled=Enabled
 SharePointAuthority.ServerProtocol=サーバプロトコル:
 SharePointAuthority.ServerName=サーバ名:
 SharePointAuthority.ServerPort=サーバポート番号:

Modified: 
manifoldcf/trunk/connectors/sharepoint/connector/src/main/resources/org/apache/manifoldcf/authorities/authorities/sharepoint/editConfiguration_Server.html
URL: 
http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/sharepoint/connector/src/main/resources/org/apache/manifoldcf/authorities/authorities/sharepoint/editConfiguration_Server.html?rev=1557606&r1=1557605&r2=1557606&view=diff
==============================================================================
--- 
manifoldcf/trunk/connectors/sharepoint/connector/src/main/resources/org/apache/manifoldcf/authorities/authorities/sharepoint/editConfiguration_Server.html
 (original)
+++ 
manifoldcf/trunk/connectors/sharepoint/connector/src/main/resources/org/apache/manifoldcf/authorities/authorities/sharepoint/editConfiguration_Server.html
 Sun Jan 12 20:03:24 2014
@@ -46,6 +46,23 @@
     </td>
   </tr>
   <tr>
+    <td 
class="description"><nobr>$Encoder.bodyEscape($ResourceBundle.getString('SharePointAuthority.ServerClaimSpace'))</nobr></td>
+    <td class="value">
+      <select name="serverClaimSpace">
+  #if($SERVERCLAIMSPACE == 'false')
+        <option value="false" 
selected="true">$Encoder.bodyEscape($ResourceBundle.getString('SharePointAuthority.Disabled'))</option>
+  #else
+        <option 
value="false">$Encoder.bodyEscape($ResourceBundle.getString('SharePointAuthority.Disabled'))</option>
+  #end
+  #if($SERVERCLAIMSPACE == 'true')
+        <option value="true" 
selected="true">$Encoder.bodyEscape($ResourceBundle.getString('SharePointAuthority.Enabled'))</option>
+  #else
+        <option 
value="true">$Encoder.bodyEscape($ResourceBundle.getString('SharePointAuthority.Enabled'))</option>
+  #end
+      </select>
+    </td>
+  </tr>
+  <tr>
     <td 
class="description"><nobr>$Encoder.bodyEscape($ResourceBundle.getString('SharePointAuthority.ServerProtocol'))</nobr></td>
     <td class="value">
       <select name="serverProtocol">
@@ -112,6 +129,8 @@
 
 #else
 
+<input type="hidden" name="serverVersion" value="$SERVERVERSION"/>
+<input type="hidden" name="serverClaimSpace" value="$SERVERCLAIMSPACE"/>
 <input type="hidden" name="serverProtocol" value="$SERVERPROTOCOL"/>
 <input type="hidden" name="serverName" 
value="$Encoder.attributeEscape($SERVERNAME)"/>
 <input type="hidden" name="serverPort" value="$SERVERPORT"/>

Modified: 
manifoldcf/trunk/connectors/sharepoint/connector/src/main/resources/org/apache/manifoldcf/authorities/authorities/sharepoint/viewConfiguration.html
URL: 
http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/sharepoint/connector/src/main/resources/org/apache/manifoldcf/authorities/authorities/sharepoint/viewConfiguration.html?rev=1557606&r1=1557605&r2=1557606&view=diff
==============================================================================
--- 
manifoldcf/trunk/connectors/sharepoint/connector/src/main/resources/org/apache/manifoldcf/authorities/authorities/sharepoint/viewConfiguration.html
 (original)
+++ 
manifoldcf/trunk/connectors/sharepoint/connector/src/main/resources/org/apache/manifoldcf/authorities/authorities/sharepoint/viewConfiguration.html
 Sun Jan 12 20:03:24 2014
@@ -31,6 +31,18 @@
     </td>
   </tr>
   <tr>
+    <td 
class="description"><nobr>$Encoder.bodyEscape($ResourceBundle.getString('SharePointAuthority.ServerClaimSpace'))</nobr></td>
+    <td class="value">
+  #if($SERVERCLAIMSPACE == 'false')
+        
$Encoder.bodyEscape($ResourceBundle.getString('SharePointAuthority.Disabled'))
+  #elseif($SERVERCLAIMSPACE == 'true')
+        
$Encoder.bodyEscape($ResourceBundle.getString('SharePointAuthority.Enabled'))
+  #else
+        Unknown
+  #end
+    </td>
+  </tr>
+  <tr>
     <td 
class="description"><nobr>$Encoder.bodyEscape($ResourceBundle.getString('SharePointAuthority.ServerProtocol'))</nobr></td>
     <td class="value">
       $SERVERPROTOCOL


Reply via email to