Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 // Copyright 2012 Google Inc. All Rights Reserved. | 1 // Copyright 2012 Google Inc. All Rights Reserved. |
2 // | 2 // |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
6 // | 6 // |
7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
8 // | 8 // |
9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
42 import com.microsoft.schemas.sharepoint.soap.ContentDatabases; | 42 import com.microsoft.schemas.sharepoint.soap.ContentDatabases; |
43 import com.microsoft.schemas.sharepoint.soap.Files; | 43 import com.microsoft.schemas.sharepoint.soap.Files; |
44 import com.microsoft.schemas.sharepoint.soap.FolderData; | 44 import com.microsoft.schemas.sharepoint.soap.FolderData; |
45 import com.microsoft.schemas.sharepoint.soap.Folders; | 45 import com.microsoft.schemas.sharepoint.soap.Folders; |
46 import com.microsoft.schemas.sharepoint.soap.GroupDescription; | 46 import com.microsoft.schemas.sharepoint.soap.GroupDescription; |
47 import com.microsoft.schemas.sharepoint.soap.GroupMembership; | 47 import com.microsoft.schemas.sharepoint.soap.GroupMembership; |
48 import com.microsoft.schemas.sharepoint.soap.Item; | 48 import com.microsoft.schemas.sharepoint.soap.Item; |
49 import com.microsoft.schemas.sharepoint.soap.ItemData; | 49 import com.microsoft.schemas.sharepoint.soap.ItemData; |
50 import com.microsoft.schemas.sharepoint.soap.Lists; | 50 import com.microsoft.schemas.sharepoint.soap.Lists; |
51 import com.microsoft.schemas.sharepoint.soap.ObjectType; | 51 import com.microsoft.schemas.sharepoint.soap.ObjectType; |
52 import com.microsoft.schemas.sharepoint.soap.people.ArrayOfPrincipalInfo; | |
ejona
2013/08/15 21:59:32
Packages come later, so put these after .directory
| |
53 import com.microsoft.schemas.sharepoint.soap.people.ArrayOfString; | |
54 import com.microsoft.schemas.sharepoint.soap.people.PeopleSoap; | |
55 import com.microsoft.schemas.sharepoint.soap.people.PrincipalInfo; | |
56 import com.microsoft.schemas.sharepoint.soap.people.SPPrincipalType; | |
57 import com.microsoft.schemas.sharepoint.soap.Permission; | 52 import com.microsoft.schemas.sharepoint.soap.Permission; |
58 import com.microsoft.schemas.sharepoint.soap.PolicyUser; | 53 import com.microsoft.schemas.sharepoint.soap.PolicyUser; |
59 import com.microsoft.schemas.sharepoint.soap.SPContentDatabase; | 54 import com.microsoft.schemas.sharepoint.soap.SPContentDatabase; |
60 import com.microsoft.schemas.sharepoint.soap.SPFile; | 55 import com.microsoft.schemas.sharepoint.soap.SPFile; |
61 import com.microsoft.schemas.sharepoint.soap.SPFolder; | 56 import com.microsoft.schemas.sharepoint.soap.SPFolder; |
62 import com.microsoft.schemas.sharepoint.soap.SPList; | 57 import com.microsoft.schemas.sharepoint.soap.SPList; |
63 import com.microsoft.schemas.sharepoint.soap.SPListItem; | 58 import com.microsoft.schemas.sharepoint.soap.SPListItem; |
64 import com.microsoft.schemas.sharepoint.soap.SPSite; | 59 import com.microsoft.schemas.sharepoint.soap.SPSite; |
65 import com.microsoft.schemas.sharepoint.soap.SPWeb; | 60 import com.microsoft.schemas.sharepoint.soap.SPWeb; |
66 import com.microsoft.schemas.sharepoint.soap.Scopes; | 61 import com.microsoft.schemas.sharepoint.soap.Scopes; |
67 import com.microsoft.schemas.sharepoint.soap.Site; | 62 import com.microsoft.schemas.sharepoint.soap.Site; |
68 import com.microsoft.schemas.sharepoint.soap.SiteDataSoap; | 63 import com.microsoft.schemas.sharepoint.soap.SiteDataSoap; |
69 import com.microsoft.schemas.sharepoint.soap.Sites; | 64 import com.microsoft.schemas.sharepoint.soap.Sites; |
70 import com.microsoft.schemas.sharepoint.soap.TrueFalseType; | 65 import com.microsoft.schemas.sharepoint.soap.TrueFalseType; |
71 import com.microsoft.schemas.sharepoint.soap.UserDescription; | 66 import com.microsoft.schemas.sharepoint.soap.UserDescription; |
72 import com.microsoft.schemas.sharepoint.soap.VirtualServer; | 67 import com.microsoft.schemas.sharepoint.soap.VirtualServer; |
73 import com.microsoft.schemas.sharepoint.soap.Web; | 68 import com.microsoft.schemas.sharepoint.soap.Web; |
74 import com.microsoft.schemas.sharepoint.soap.Webs; | 69 import com.microsoft.schemas.sharepoint.soap.Webs; |
75 import com.microsoft.schemas.sharepoint.soap.Xml; | 70 import com.microsoft.schemas.sharepoint.soap.Xml; |
76 import com.microsoft.schemas.sharepoint.soap.directory.GetUserCollectionFromSite Response; | 71 import com.microsoft.schemas.sharepoint.soap.directory.GetUserCollectionFromSite Response; |
77 import com.microsoft.schemas.sharepoint.soap.directory.GetUserCollectionFromSite Response.GetUserCollectionFromSiteResult; | 72 import com.microsoft.schemas.sharepoint.soap.directory.GetUserCollectionFromSite Response.GetUserCollectionFromSiteResult; |
78 import com.microsoft.schemas.sharepoint.soap.directory.User; | 73 import com.microsoft.schemas.sharepoint.soap.directory.User; |
79 import com.microsoft.schemas.sharepoint.soap.directory.UserGroupSoap; | 74 import com.microsoft.schemas.sharepoint.soap.directory.UserGroupSoap; |
75 import com.microsoft.schemas.sharepoint.soap.people.ArrayOfPrincipalInfo; | |
76 import com.microsoft.schemas.sharepoint.soap.people.ArrayOfString; | |
77 import com.microsoft.schemas.sharepoint.soap.people.PeopleSoap; | |
78 import com.microsoft.schemas.sharepoint.soap.people.PrincipalInfo; | |
79 import com.microsoft.schemas.sharepoint.soap.people.SPPrincipalType; | |
80 | 80 |
81 import org.w3c.dom.Attr; | 81 import org.w3c.dom.Attr; |
82 import org.w3c.dom.Element; | 82 import org.w3c.dom.Element; |
83 import org.w3c.dom.NamedNodeMap; | 83 import org.w3c.dom.NamedNodeMap; |
84 import org.w3c.dom.Node; | 84 import org.w3c.dom.Node; |
85 import org.w3c.dom.NodeList; | 85 import org.w3c.dom.NodeList; |
86 | 86 |
87 import java.io.*; | 87 import java.io.*; |
88 import java.net.*; | 88 import java.net.*; |
89 import java.nio.charset.Charset; | 89 import java.nio.charset.Charset; |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
246 * value is used in case of error in certain situations. | 246 * value is used in case of error in certain situations. |
247 */ | 247 */ |
248 private boolean isSp2010; | 248 private boolean isSp2010; |
249 private NtlmAuthenticator ntlmAuthenticator; | 249 private NtlmAuthenticator ntlmAuthenticator; |
250 /** | 250 /** |
251 * Lock for refreshing MemberIdMapping. We use a unique lock because it is | 251 * Lock for refreshing MemberIdMapping. We use a unique lock because it is |
252 * held while waiting on I/O. | 252 * held while waiting on I/O. |
253 */ | 253 */ |
254 private final Object refreshMemberIdMappingLock = new Object(); | 254 private final Object refreshMemberIdMappingLock = new Object(); |
255 ·· | 255 ·· |
256 private static FormsAuthenticationHandler authenticationHandler; | 256 private FormsAuthenticationHandler authenticationHandler; |
257 | 257 |
258 public SharePointAdaptor() { | 258 public SharePointAdaptor() { |
259 this(new SoapFactoryImpl(), new HttpClientImpl(), | 259 this(new SoapFactoryImpl(), new HttpClientImpl(), |
260 new CachedThreadPoolFactory()); | 260 new CachedThreadPoolFactory()); |
261 } | 261 } |
262 | 262 |
263 @VisibleForTesting | 263 @VisibleForTesting |
264 SharePointAdaptor(SoapFactory soapFactory, HttpClient httpClient, | 264 SharePointAdaptor(SoapFactory soapFactory, HttpClient httpClient, |
265 Callable<ExecutorService> executorFactory) { | 265 Callable<ExecutorService> executorFactory) { |
266 if (soapFactory == null || httpClient == null || executorFactory == null) { | 266 if (soapFactory == null || httpClient == null || executorFactory == null) { |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
313 log.log(Level.CONFIG, "Username: {0}", username); | 313 log.log(Level.CONFIG, "Username: {0}", username); |
314 log.log(Level.CONFIG, "Password: {0}", password); | 314 log.log(Level.CONFIG, "Password: {0}", password); |
315 | 315 |
316 ntlmAuthenticator = new NtlmAuthenticator(username, password); | 316 ntlmAuthenticator = new NtlmAuthenticator(username, password); |
317 // Unfortunately, this is a JVM-wide modification. | 317 // Unfortunately, this is a JVM-wide modification. |
318 Authenticator.setDefault(ntlmAuthenticator); | 318 Authenticator.setDefault(ntlmAuthenticator); |
319 URL virtualServerUrl = new URL(virtualServer); | 319 URL virtualServerUrl = new URL(virtualServer); |
320 ntlmAuthenticator.addPermitForHost(virtualServerUrl); | 320 ntlmAuthenticator.addPermitForHost(virtualServerUrl); |
321 String authenticationEndPoint· | 321 String authenticationEndPoint· |
322 = virtualServer + "/_vti_bin/Authentication.asmx"; | 322 = virtualServer + "/_vti_bin/Authentication.asmx"; |
323 authenticationHandler = new FormsAuthenticationHandler(virtualServer, | 323 authenticationHandler = new FormsAuthenticationHandler(username, |
324 username, password, scheduledExecutor, | 324 password, scheduledExecutor, |
325 soapFactory.newAuthentication(authenticationEndPoint)); | 325 soapFactory.newAuthentication(authenticationEndPoint)); |
326 authenticationHandler.start(); | 326 authenticationHandler.start(); |
327 executor = executorFactory.call(); | 327 executor = executorFactory.call(); |
328 try { | 328 try { |
329 SiteDataClient virtualServerSiteDataClient = | 329 SiteDataClient virtualServerSiteDataClient = |
330 getSiteAdaptor(virtualServer, virtualServer).getSiteDataClient(); | 330 getSiteAdaptor(virtualServer, virtualServer).getSiteDataClient(); |
331 rareModCache | 331 rareModCache |
332 = new RareModificationCache(virtualServerSiteDataClient, executor); | 332 = new RareModificationCache(virtualServerSiteDataClient, executor); |
333 | 333 |
334 // Test out configuration. | 334 // Test out configuration. |
(...skipping 12 matching lines...) Expand all Loading... | |
347 try { | 347 try { |
348 executor.awaitTermination(10, TimeUnit.SECONDS); | 348 executor.awaitTermination(10, TimeUnit.SECONDS); |
349 scheduledExecutor.awaitTermination(10, TimeUnit.SECONDS); | 349 scheduledExecutor.awaitTermination(10, TimeUnit.SECONDS); |
350 } catch (InterruptedException ex) { | 350 } catch (InterruptedException ex) { |
351 Thread.currentThread().interrupt(); | 351 Thread.currentThread().interrupt(); |
352 } | 352 } |
353 ···· | 353 ···· |
354 executor.shutdownNow(); | 354 executor.shutdownNow(); |
355 scheduledExecutor.shutdownNow(); | 355 scheduledExecutor.shutdownNow(); |
356 executor = null; | 356 executor = null; |
357 scheduledExecutor = null; | |
357 rareModCache = null; | 358 rareModCache = null; |
358 Authenticator.setDefault(null); | 359 Authenticator.setDefault(null); |
359 ntlmAuthenticator = null; | 360 ntlmAuthenticator = null; |
360 } | 361 } |
361 | 362 |
362 @Override | 363 @Override |
363 public void getDocContent(Request request, Response response) | 364 public void getDocContent(Request request, Response response) |
364 throws IOException { | 365 throws IOException { |
365 log.entering("SharePointAdaptor", "getDocContent", | 366 log.entering("SharePointAdaptor", "getDocContent", |
366 new Object[] {request, response}); | 367 new Object[] {request, response}); |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
510 site = site.substring(0, site.length() - 1); | 511 site = site.substring(0, site.length() - 1); |
511 } | 512 } |
512 ntlmAuthenticator.addPermitForHost(new URL(web)); | 513 ntlmAuthenticator.addPermitForHost(new URL(web)); |
513 String endpoint = web + "/_vti_bin/SiteData.asmx"; | 514 String endpoint = web + "/_vti_bin/SiteData.asmx"; |
514 SiteDataSoap siteDataSoap = soapFactory.newSiteData(endpoint); | 515 SiteDataSoap siteDataSoap = soapFactory.newSiteData(endpoint); |
515 ······ | 516 ······ |
516 String endpointUserGroup = site + "/_vti_bin/UserGroup.asmx"; | 517 String endpointUserGroup = site + "/_vti_bin/UserGroup.asmx"; |
517 UserGroupSoap userGroupSoap = soapFactory.newUserGroup(endpointUserGroup); | 518 UserGroupSoap userGroupSoap = soapFactory.newUserGroup(endpointUserGroup); |
518 String endpointPeople= site + "/_vti_bin/People.asmx"; | 519 String endpointPeople= site + "/_vti_bin/People.asmx"; |
519 PeopleSoap peopleSoap = soapFactory.newPeople(endpointPeople); | 520 PeopleSoap peopleSoap = soapFactory.newPeople(endpointPeople); |
521 // JAX-WS RT 2.1.4 doesn't handle headers correctly and always assumes the | |
522 // list contains precisely one entry, so we work around it here. | |
520 if (authenticationHandler.isFormsAuthentication()) { | 523 if (authenticationHandler.isFormsAuthentication()) { |
521 addFormsAuthenticationCookies((BindingProvider) siteDataSoap); | 524 addFormsAuthenticationCookies((BindingProvider) siteDataSoap); |
522 addFormsAuthenticationCookies((BindingProvider) userGroupSoap);········ | 525 addFormsAuthenticationCookies((BindingProvider) userGroupSoap); |
526 addFormsAuthenticationCookies((BindingProvider) peopleSoap); | |
523 } | 527 } |
524 siteAdaptor = new SiteAdaptor(site, web, siteDataSoap, userGroupSoap, | 528 siteAdaptor = new SiteAdaptor(site, web, siteDataSoap, userGroupSoap, |
525 peopleSoap, new MemberIdMappingCallable(site), | 529 peopleSoap, new MemberIdMappingCallable(site), |
526 new SiteUserIdMappingCallable(site)); | 530 new SiteUserIdMappingCallable(site)); |
527 siteAdaptors.putIfAbsent(web, siteAdaptor); | 531 siteAdaptors.putIfAbsent(web, siteAdaptor); |
528 siteAdaptor = siteAdaptors.get(web); | 532 siteAdaptor = siteAdaptors.get(web); |
529 } | 533 } |
530 return siteAdaptor; | 534 return siteAdaptor; |
531 } | 535 } |
532 ·· | 536 ·· |
533 private void addFormsAuthenticationCookies(BindingProvider port) { | 537 private void addFormsAuthenticationCookies(BindingProvider port) { |
534 if (authenticationHandler.getAuthenticationCookies().isEmpty()) { | 538 if (authenticationHandler.getAuthenticationCookies().isEmpty()) { |
ejona
2013/08/15 21:59:32
Ahh... everything is mixed together :'(
| |
535 // JAX-WS RT 2.1.4 doesn't handle headers correctly and always assumes the | 539 // JAX-WS RT 2.1.4 doesn't handle headers correctly and always assumes the |
536 // list contains precisely one entry, so we work around it here. | 540 // list contains precisely one entry, so we work around it here. |
537 return; | 541 return; |
538 } | 542 } |
539 port.getRequestContext().put(MessageContext.HTTP_REQUEST_HEADERS, | 543 port.getRequestContext().put(MessageContext.HTTP_REQUEST_HEADERS, |
540 Collections.singletonMap("Cookie",· | 544 Collections.singletonMap("Cookie",· |
541 authenticationHandler.getAuthenticationCookies())); | 545 authenticationHandler.getAuthenticationCookies())); |
542 } | 546 } |
543 | 547 |
544 static URI spUrlToUri(String url) throws IOException { | 548 static URI spUrlToUri(String url) throws IOException { |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
735 List<UserPrincipal> permitUsers = new ArrayList<UserPrincipal>(); | 739 List<UserPrincipal> permitUsers = new ArrayList<UserPrincipal>(); |
736 List<GroupPrincipal> permitGroups = new ArrayList<GroupPrincipal>(); | 740 List<GroupPrincipal> permitGroups = new ArrayList<GroupPrincipal>(); |
737 List<UserPrincipal> denyUsers = new ArrayList<UserPrincipal>(); | 741 List<UserPrincipal> denyUsers = new ArrayList<UserPrincipal>(); |
738 List<GroupPrincipal> denyGroups = new ArrayList<GroupPrincipal>(); | 742 List<GroupPrincipal> denyGroups = new ArrayList<GroupPrincipal>(); |
739 List<String> policyUsers = new ArrayList<String>(); | 743 List<String> policyUsers = new ArrayList<String>(); |
740 for (PolicyUser policyUser : vs.getPolicies().getPolicyUser()) { | 744 for (PolicyUser policyUser : vs.getPolicies().getPolicyUser()) { |
741 policyUsers.add(policyUser.getLoginName()); | 745 policyUsers.add(policyUser.getLoginName()); |
742 } | 746 } |
743 Map<String, PrincipalInfo> resolvedPolicyUsers· | 747 Map<String, PrincipalInfo> resolvedPolicyUsers· |
744 = resolvePrincipals(policyUsers); | 748 = resolvePrincipals(policyUsers); |
745 for (PolicyUser policyUser : vs.getPolicies().getPolicyUser()) { | 749 for (PolicyUser policyUser : vs.getPolicies().getPolicyUser()) { |
ejona
2013/08/15 21:59:32
Loop over policyUsers instead?
| |
746 String loginName = policyUser.getLoginName(); | 750 String loginName = policyUser.getLoginName(); |
747 PrincipalInfo p = resolvedPolicyUsers.get(loginName); | 751 PrincipalInfo p = resolvedPolicyUsers.get(loginName); |
748 if (p == null || !p.isIsResolved()) { | 752 if (p == null || !p.isIsResolved()) { |
749 log.log(Level.WARNING,· | 753 log.log(Level.WARNING,· |
750 "Unable to resolve Policy User = {0}", loginName); | 754 "Unable to resolve Policy User = {0}", loginName); |
751 continue; | 755 continue; |
752 } | 756 } |
753 // TODO(ejona): special case NT AUTHORITY\LOCAL SERVICE. | 757 // TODO(ejona): special case NT AUTHORITY\LOCAL SERVICE. |
754 String accountName = decodeClaim(p.getAccountName(), p.getDisplayName() | 758 String accountName = decodeClaim(p.getAccountName(), p.getDisplayName(), |
755 , p.getPrincipalType() == SPPrincipalType.SECURITY_GROUP); | 759 p.getPrincipalType() == SPPrincipalType.SECURITY_GROUP); |
ejona
2013/08/15 21:59:32
Comma
| |
756 log.log(Level.FINER, "Policy User accountName = {0}", accountName); | 760 log.log(Level.FINER, "Policy User accountName = {0}", accountName); |
757 long grant = policyUser.getGrantMask().longValue(); | 761 long grant = policyUser.getGrantMask().longValue(); |
758 if ((necessaryPermissionMask & grant) == necessaryPermissionMask) { | 762 if ((necessaryPermissionMask & grant) == necessaryPermissionMask) { |
759 if (p.getPrincipalType() == SPPrincipalType.USER) { | 763 if (p.getPrincipalType() == SPPrincipalType.USER) { |
760 permitUsers.add(new UserPrincipal(accountName)); | 764 permitUsers.add(new UserPrincipal(accountName)); |
761 } else { | 765 } else { |
762 permitGroups.add(new GroupPrincipal(accountName)); | 766 permitGroups.add(new GroupPrincipal(accountName)); |
763 } | 767 } |
764 } | 768 } |
765 long deny = policyUser.getDenyMask().longValue(); | 769 long deny = policyUser.getDenyMask().longValue(); |
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1238 * security issues, this should only be used after the DocId has been | 1242 * security issues, this should only be used after the DocId has been |
1239 * verified to be a valid document on the SharePoint instance. In addition, | 1243 * verified to be a valid document on the SharePoint instance. In addition, |
1240 * ACLs and other metadata and security measures should be set before making | 1244 * ACLs and other metadata and security measures should be set before making |
1241 * this call. | 1245 * this call. |
1242 */ | 1246 */ |
1243 private void getFileDocContent(Request request, Response response) | 1247 private void getFileDocContent(Request request, Response response) |
1244 throws IOException { | 1248 throws IOException { |
1245 log.entering("SiteAdaptor", "getFileDocContent", | 1249 log.entering("SiteAdaptor", "getFileDocContent", |
1246 new Object[] {request, response}); | 1250 new Object[] {request, response}); |
1247 URI displayUrl = docIdToUri(request.getDocId()); | 1251 URI displayUrl = docIdToUri(request.getDocId()); |
1248 FileInfo fi = httpClient.issueGetRequest(displayUrl.toURL()); | 1252 FileInfo fi = httpClient.issueGetRequest(displayUrl.toURL(), |
1253 authenticationHandler.getAuthenticationCookies()); | |
1249 if (fi == null) { | 1254 if (fi == null) { |
1250 response.respondNotFound(); | 1255 response.respondNotFound(); |
1251 return; | 1256 return; |
1252 } | 1257 } |
1253 try { | 1258 try { |
1254 response.setDisplayUrl(displayUrl); | 1259 response.setDisplayUrl(displayUrl); |
1255 String contentType = fi.getFirstHeaderWithName("Content-Type"); | 1260 String contentType = fi.getFirstHeaderWithName("Content-Type"); |
1256 if (contentType != null) { | 1261 if (contentType != null) { |
1257 response.setContentType(contentType); | 1262 response.setContentType(contentType); |
1258 } | 1263 } |
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1698 } | 1703 } |
1699 | 1704 |
1700 private boolean isModified(String change) { | 1705 private boolean isModified(String change) { |
1701 return !"Unchanged".equals(change) && !"Delete".equals(change); | 1706 return !"Unchanged".equals(change) && !"Delete".equals(change); |
1702 } | 1707 } |
1703 | 1708 |
1704 private String decodeClaim(String loginName, String name | 1709 private String decodeClaim(String loginName, String name |
1705 , boolean isDomainGroup) { | 1710 , boolean isDomainGroup) { |
1706 if (!loginName.startsWith(IDENTITY_CLAIMS_PREFIX) | 1711 if (!loginName.startsWith(IDENTITY_CLAIMS_PREFIX) |
1707 && !loginName.startsWith(OTHER_CLAIMS_PREFIX)) { | 1712 && !loginName.startsWith(OTHER_CLAIMS_PREFIX)) { |
1708 return isDomainGroup ? name : loginName; | 1713 return loginName; |
1709 } | 1714 } |
1710 // AD User | 1715 // AD User |
1711 if (loginName.startsWith("i:0#.w|")) { | 1716 if (loginName.startsWith("i:0#.w|")) { |
1712 return loginName.substring(7); | 1717 return loginName.substring(7); |
1713 // AD Group | 1718 // AD Group |
1714 } else if (loginName.startsWith("c:0+.w|")) {········ | 1719 } else if (loginName.startsWith("c:0+.w|")) {········ |
ejona
2013/08/20 00:25:38
Remove randomly added spaces.
| |
1715 return name;········ | 1720 return name;········ |
1716 } else if (loginName.equals("c:0(.s|true")) { | 1721 } else if (loginName.equals("c:0(.s|true")) { |
1717 return "Everyone"; | 1722 return "Everyone"; |
1718 } else if (loginName.equals("c:0!.s|windows")) { | 1723 } else if (loginName.equals("c:0!.s|windows")) { |
1719 return "NT AUTHORITY\\authenticated users"; | 1724 return "NT AUTHORITY\\authenticated users"; |
1720 } | 1725 } |
1721 log.log(Level.WARNING, "Unsupported claims value {0}", loginName); | 1726 log.log(Level.WARNING, "Unsupported claims value {0}", loginName); |
1722 return null; | 1727 return null; |
1723 } | 1728 } |
1724 ···· | 1729 ···· |
1725 private Map<String,PrincipalInfo> resolvePrincipals( | 1730 private Map<String,PrincipalInfo> resolvePrincipals( |
1726 List<String> principalsToResolve) { | 1731 List<String> principalsToResolve) { |
1727 Map<String,PrincipalInfo> resolved = new HashMap<String, PrincipalInfo>(); | 1732 Map<String, PrincipalInfo> resolved· |
ejona
2013/08/15 21:59:32
Space before PrinicpalInfo
| |
1733 = new HashMap<String, PrincipalInfo>(); | |
1734 if (principalsToResolve.isEmpty()) { | |
1735 return resolved; | |
1736 } | |
1728 ArrayOfString aos = new ArrayOfString(); | 1737 ArrayOfString aos = new ArrayOfString(); |
1729 aos.getString().addAll(principalsToResolve); | 1738 aos.getString().addAll(principalsToResolve);······ |
1730 if (aos.getString().isEmpty()) { | |
ejona
2013/08/15 21:59:32
Check principalsToResolve.isEmpty() immediately wh
| |
1731 return resolved; | |
1732 } | |
1733 ArrayOfPrincipalInfo resolvePrincipals = people.resolvePrincipals( | 1739 ArrayOfPrincipalInfo resolvePrincipals = people.resolvePrincipals( |
1734 aos, SPPrincipalType.ALL, false); | 1740 aos, SPPrincipalType.ALL, false); |
1735 List<PrincipalInfo> principals = resolvePrincipals.getPrincipalInfo(); | 1741 List<PrincipalInfo> principals = resolvePrincipals.getPrincipalInfo(); |
1736 // using loginname from input list principalsToResolve as a key | 1742 // using loginname from input list principalsToResolve as a key |
1737 // instead of returned PrincipalInfo.getAccountName() as with claims· | 1743 // instead of returned PrincipalInfo.getAccountName() as with claims· |
1738 // authentication PrincipalInfo.getAccountName() is always encoded.· | 1744 // authentication PrincipalInfo.getAccountName() is always encoded.· |
1739 // e.g. if login name from Policy is NT Authority\Local Service | 1745 // e.g. if login name from Policy is NT Authority\Local Service |
1740 // returned account name is i:0#.w|NT Authority\Local Service | 1746 // returned account name is i:0#.w|NT Authority\Local Service |
1741 for (int i=0; i < principalsToResolve.size(); i++) { | 1747 for (int i = 0; i < principalsToResolve.size(); i++) { |
ejona
2013/08/15 21:59:32
spaces around =.
| |
1742 resolved.put(principalsToResolve.get(i), principals.get(i)); | 1748 resolved.put(principalsToResolve.get(i), principals.get(i)); |
1743 } | 1749 } |
1744 return resolved; | 1750 return resolved; |
1745 } | 1751 } |
1746 | 1752 |
1747 private MemberIdMapping retrieveMemberIdMapping() throws IOException { | 1753 private MemberIdMapping retrieveMemberIdMapping() throws IOException { |
1748 log.entering("SiteAdaptor", "retrieveMemberIdMapping"); | 1754 log.entering("SiteAdaptor", "retrieveMemberIdMapping"); |
1749 Site site = siteDataClient.getContentSite(); | 1755 Site site = siteDataClient.getContentSite(); |
1750 Map<Integer, String> groupMap = new HashMap<Integer, String>(); | 1756 Map<Integer, String> groupMap = new HashMap<Integer, String>(); |
1751 for (GroupMembership.Group group : site.getGroups().getGroup()) { | 1757 for (GroupMembership.Group group : site.getGroups().getGroup()) { |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1934 } | 1940 } |
1935 } | 1941 } |
1936 | 1942 |
1937 @VisibleForTesting | 1943 @VisibleForTesting |
1938 interface HttpClient { | 1944 interface HttpClient { |
1939 /** | 1945 /** |
1940 * The caller must call {@code fileInfo.getContents().close()} after use. | 1946 * The caller must call {@code fileInfo.getContents().close()} after use. |
1941 * | 1947 * |
1942 * @return {@code null} if not found, {@code FileInfo} instance otherwise | 1948 * @return {@code null} if not found, {@code FileInfo} instance otherwise |
1943 */ | 1949 */ |
1944 public FileInfo issueGetRequest(URL url) throws IOException; | 1950 public FileInfo issueGetRequest(URL url, List<String> authenticationCookies) |
1951 throws IOException; | |
1945 } | 1952 } |
1946 | 1953 |
1947 static class HttpClientImpl implements HttpClient { | 1954 static class HttpClientImpl implements HttpClient { |
1948 @Override | 1955 @Override |
1949 public FileInfo issueGetRequest(URL url) throws IOException { | 1956 public FileInfo issueGetRequest(URL url, List<String> authenticationCookies) |
1957 throws IOException { | |
1950 // Handle Unicode. Java does not properly encode the GET. | 1958 // Handle Unicode. Java does not properly encode the GET. |
1951 try { | 1959 try { |
1952 url = new URL(url.toURI().toASCIIString()); | 1960 url = new URL(url.toURI().toASCIIString()); |
1953 } catch (URISyntaxException ex) { | 1961 } catch (URISyntaxException ex) { |
1954 throw new IOException(ex); | 1962 throw new IOException(ex); |
1955 } | 1963 } |
1956 HttpURLConnection conn = (HttpURLConnection) url.openConnection(); | 1964 HttpURLConnection conn = (HttpURLConnection) url.openConnection(); |
1957 ····· | 1965 ····· |
1958 for (String cookie : authenticationHandler.getAuthenticationCookies()) { | 1966 for (String cookie : authenticationCookies) { |
1959 conn.addRequestProperty("Cookie", cookie); | 1967 conn.addRequestProperty("Cookie", cookie); |
1960 } | 1968 } |
1961 conn.setDoInput(true); | 1969 conn.setDoInput(true); |
1962 conn.setDoOutput(false); | 1970 conn.setDoOutput(false); |
1963 if (conn.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND) { | 1971 if (conn.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND) { |
1964 return null; | 1972 return null; |
1965 } | 1973 } |
1966 if (conn.getResponseCode() != HttpURLConnection.HTTP_OK) { | 1974 if (conn.getResponseCode() != HttpURLConnection.HTTP_OK) { |
1967 throw new IOException("Got status code: " + conn.getResponseCode()); | 1975 throw new IOException("Got status code: " + conn.getResponseCode()); |
1968 } | 1976 } |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2037 EndpointReference endpointRef = new W3CEndpointReferenceBuilder() | 2045 EndpointReference endpointRef = new W3CEndpointReferenceBuilder() |
2038 .address(endpoint).build(); | 2046 .address(endpoint).build(); |
2039 return· | 2047 return· |
2040 authenticationService.getPort(endpointRef, AuthenticationSoap.class); | 2048 authenticationService.getPort(endpointRef, AuthenticationSoap.class); |
2041 } | 2049 } |
2042 | 2050 |
2043 @Override | 2051 @Override |
2044 public PeopleSoap newPeople(String endpoint) { | 2052 public PeopleSoap newPeople(String endpoint) { |
2045 EndpointReference endpointRef = new W3CEndpointReferenceBuilder() | 2053 EndpointReference endpointRef = new W3CEndpointReferenceBuilder() |
2046 .address(endpoint).build(); | 2054 .address(endpoint).build(); |
2047 return· | 2055 return peopleService.getPort(endpointRef, PeopleSoap.class);······ |
2048 peopleService.getPort(endpointRef, PeopleSoap.class);······ | |
ejona
2013/08/15 21:59:32
Remove wrapping
| |
2049 } | 2056 } |
2050 } | 2057 } |
2051 | 2058 |
2052 private static class NtlmAuthenticator extends Authenticator { | 2059 private static class NtlmAuthenticator extends Authenticator { |
2053 private final String username; | 2060 private final String username; |
2054 private final char[] password; | 2061 private final char[] password; |
2055 private final Set<String> permittedHosts = new HashSet<String>(); | 2062 private final Set<String> permittedHosts = new HashSet<String>(); |
2056 | 2063 |
2057 public NtlmAuthenticator(String username, String password) { | 2064 public NtlmAuthenticator(String username, String password) { |
2058 this.username = username; | 2065 this.username = username; |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2157 @Override | 2164 @Override |
2158 protected Executor executor() { | 2165 protected Executor executor() { |
2159 return executor; | 2166 return executor; |
2160 } | 2167 } |
2161 | 2168 |
2162 @Override | 2169 @Override |
2163 public MemberIdMapping load(String site) throws IOException { | 2170 public MemberIdMapping load(String site) throws IOException { |
2164 return getSiteAdaptor(site, site).retrieveSiteUserMapping(); | 2171 return getSiteAdaptor(site, site).retrieveSiteUserMapping(); |
2165 } | 2172 } |
2166 } | 2173 } |
2167 ·· | 2174 ·· |
ejona
2013/08/15 21:59:32
Remove randomly added spaces.
|
ejona
2013/08/20 00:25:38
Remove randomly added spaces.
|
2168 private static class CachedThreadPoolFactory | 2175 private static class CachedThreadPoolFactory |
2169 implements Callable<ExecutorService> { | 2176 implements Callable<ExecutorService> { |
2170 @Override | 2177 @Override |
2171 public ExecutorService call() { | 2178 public ExecutorService call() { |
2172 return Executors.newCachedThreadPool(); | 2179 return Executors.newCachedThreadPool(); |
2173 } | 2180 } |
2174 } | 2181 } |
2175 } | 2182 } |
LEFT | RIGHT |