Decoding forms authentication claims
Code review : https://codereview.appspot.com/12991045/
diff --git a/src/com/google/enterprise/adaptor/sharepoint/SharePointAdaptor.java b/src/com/google/enterprise/adaptor/sharepoint/SharePointAdaptor.java
index a280a96..7b90ac5 100644
--- a/src/com/google/enterprise/adaptor/sharepoint/SharePointAdaptor.java
+++ b/src/com/google/enterprise/adaptor/sharepoint/SharePointAdaptor.java
@@ -729,6 +729,11 @@
         // TODO(ejona): special case NT AUTHORITY\LOCAL SERVICE.
         String loginName = decodeClaim(policyUser.getLoginName(),
             policyUser.getLoginName(), false);
+        if (loginName == null) {
+          log.log(Level.WARNING, 
+              "Unable to decode claim. Skipping policy user {0}",
+              policyUser.getLoginName());
+        }
         log.log(Level.FINER, "Policy User Login Name = {0}", loginName);
         long grant = policyUser.getGrantMask().longValue();
         if ((necessaryPermissionMask & grant) == necessaryPermissionMask) {
@@ -1688,6 +1693,12 @@
         return "Everyone";
       } else if (loginName.equals("c:0!.s|windows")) {
         return "NT AUTHORITY\\authenticated users";
+      // Forms authentication role  
+      } else if (loginName.startsWith("c:0-.f|")) {
+        return loginName.substring(7).replace("|", ":");
+      // Forms authentication user  
+      } else if (loginName.startsWith("i:0#.f|")) {
+        return loginName.substring(7).replace("|", ":");
       }
       log.log(Level.WARNING, "Unsupported claims value {0}", loginName);
       return null;
diff --git a/test/com/google/enterprise/adaptor/sharepoint/SharePointAdaptorTest.java b/test/com/google/enterprise/adaptor/sharepoint/SharePointAdaptorTest.java
index eef07b9..0bf8c65 100644
--- a/test/com/google/enterprise/adaptor/sharepoint/SharePointAdaptorTest.java
+++ b/test/com/google/enterprise/adaptor/sharepoint/SharePointAdaptorTest.java
@@ -491,7 +491,9 @@
     String permissions = "<permission memberid='11' mask='756052856929' />"
         + "<permission memberid='12' mask='756052856929' />"
         + "<permission memberid='13' mask='756052856929' />"
-        + "<permission memberid='14' mask='756052856929' /></permissions>";
+        + "<permission memberid='14' mask='756052856929' />"
+        + "<permission memberid='15' mask='756052856929' />"        
+        + "<permission memberid='19' mask='756052856929' /></permissions>";
     SoapFactory siteDataFactory = MockSoapFactory.blank()
         .endpoint(AUTH_ENDPOINT, new MockAuthenticationSoap())
         .endpoint(VS_ENDPOINT, MockSiteData.blank()
@@ -517,10 +519,12 @@
         .setEverythingCaseInsensitive()
         .setInheritFrom(new DocId(""))
         .setInheritanceType(Acl.InheritanceType.PARENT_OVERRIDES)
-        .setPermitUsers(users("GDC-PSL\\spuser1", "GSA-CONNECTORS\\User1"))
+        .setPermitUsers(users("GDC-PSL\\spuser1", "GSA-CONNECTORS\\User1",
+            "membershipprovider:user2007"))
         .setPermitGroups(groups("chinese1 Members", "chinese1 Owners",
             "chinese1 Visitors", "GSA-CONNECTORS\\domain users",
-            "Everyone", "NT AUTHORITY\\authenticated users")).build(),
+            "Everyone", "NT AUTHORITY\\authenticated users",
+            "roleprovider:super")).build(),
         response.getAcl());
   }
 
diff --git a/test/com/google/enterprise/adaptor/sharepoint/spresponses/sites-SiteCollection-s.xml b/test/com/google/enterprise/adaptor/sharepoint/spresponses/sites-SiteCollection-s.xml
index d0980a1..9240e28 100644
--- a/test/com/google/enterprise/adaptor/sharepoint/spresponses/sites-SiteCollection-s.xml
+++ b/test/com/google/enterprise/adaptor/sharepoint/spresponses/sites-SiteCollection-s.xml
@@ -30,6 +30,11 @@
 <User ID="14" Sid="" Name="User1" LoginName="i:0#.w|gsa-connectors\user1"
  IsSiteAdmin="False" IsDomainGroup="False" Flags="0"
  UserKey="i:0).w|s-1-5-21-3993744865-3521423997-1479072767-1720" />
+<User ID="15" Sid="" Name="user2007" 
+ LoginName="i:0#.f|membershipprovider|user2007" Email="user2007@google.com"
+ Notes="" IsSiteAdmin="False" IsDomainGroup="False" />
+<User ID="19" Sid="" Name="super" LoginName="c:0-.f|roleprovider|super" 
+ Email="" Notes="" IsSiteAdmin="False" IsDomainGroup="True" />
 </Users>
 <ACL><permissions>
 <permission memberid='2' mask='9223372036854775807' />
diff --git a/test/com/google/enterprise/adaptor/sharepoint/spresponses/sites-SiteCollection-sc.xml b/test/com/google/enterprise/adaptor/sharepoint/spresponses/sites-SiteCollection-sc.xml
index fa3ab6b..0b106a5 100644
--- a/test/com/google/enterprise/adaptor/sharepoint/spresponses/sites-SiteCollection-sc.xml
+++ b/test/com/google/enterprise/adaptor/sharepoint/spresponses/sites-SiteCollection-sc.xml
@@ -66,6 +66,11 @@
 <User ID="14" Sid="" Name="User1" LoginName="i:0#.w|gsa-connectors\user1"
  IsSiteAdmin="False" IsDomainGroup="False" Flags="0"
  UserKey="i:0).w|s-1-5-21-3993744865-3521423997-1479072767-1720" />
+<User ID="15" Sid="" Name="user2007" 
+ LoginName="i:0#.f|membershipprovider|user2007" Email="user2007@google.com"
+ Notes="" IsSiteAdmin="False" IsDomainGroup="False" />
+<User ID="19" Sid="" Name="super" LoginName="c:0-.f|roleprovider|super" 
+ Email="" Notes="" IsSiteAdmin="False" IsDomainGroup="True" />
 </Users>
 <ACL><permissions>
 <permission memberid='2' mask='206292717568' />