本文整理汇总了Java中com.google.enterprise.adaptor.Principal类的典型用法代码示例。如果您正苦于以下问题:Java Principal类的具体用法?Java Principal怎么用?Java Principal使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Principal类属于com.google.enterprise.adaptor包,在下文中一共展示了Principal类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDocIds
import com.google.enterprise.adaptor.Principal; //导入依赖的package包/类
/** Crawls/pushes all groups from all AdServers. */
@Override
public void getDocIds(DocIdPusher pusher) throws InterruptedException,
IOException {
log.log(Level.FINER, "getDocIds invoked - waiting for lock.");
mutex.lock();
try {
clearLastCompleteGroupCatalog();
GroupCatalog cumulativeCatalog = makeFullCatalog();
// all servers were able to successfully populate the catalog: do a push
// TODO(myk): Rework the structure so that a member variable of
// cumulativeCatalog isn't passed in as a parameter to its own method.
cumulativeCatalog.resolveForeignSecurityPrincipals(
cumulativeCatalog.entities);
Map<GroupPrincipal, List<Principal>> groups =
cumulativeCatalog.makeDefs(cumulativeCatalog.entities);
pusher.pushGroupDefinitions(groups, EVERYTHING_CASE_INSENSITIVE, REPLACE,
null, null);
// no longer clear cumulativeCatalog.members as part of fix for b/18028678
lastCompleteGroupCatalog = cumulativeCatalog;
} finally {
mutex.unlock();
log.log(Level.FINE, "getDocIds ending - lock released.");
}
}
示例2: testGroupCatalogMakeDefsWithDisabledGroup
import com.google.enterprise.adaptor.Principal; //导入依赖的package包/类
@Test
public void testGroupCatalogMakeDefsWithDisabledGroup() throws Exception {
AdAdaptor.GroupCatalog groupCatalog = new GroupCatalogBuilder().build();
MockLdapContext ldapContext = mockLdapContextForMakeDefs(true);
AdServer adServer = new AdServer("localhost", "" /*userSearchBaseDN*/,
"" /*groupSearchBaseDN*/, "" /*userSearchFilter*/,
"" /*groupSearchFilter*/, ldapContext);
adServer.initialize();
groupCatalog.readEverythingFrom(adServer, /*includeMembers=*/ true);
tweakGroupCatalogForMakeDefs(groupCatalog, adServer, true);
final Map<GroupPrincipal, List<Principal>> golden =
new HashMap<GroupPrincipal, List<Principal>>();
{
golden.put(new GroupPrincipal("[email protected]", "example.com"),
Collections.<Principal>emptyList());
golden.put(new GroupPrincipal("known_group", "example.com"),
Collections.<Principal>emptyList());
}
assertEquals(golden, groupCatalog.makeDefs(groupCatalog.entities));
}
示例3: testFakeAdaptorUserAndPasswordSpecified
import com.google.enterprise.adaptor.Principal; //导入依赖的package包/类
@Test
public void testFakeAdaptorUserAndPasswordSpecified() throws Exception {
AdAdaptor adAdaptor = new FakeAdaptor();
RecordingDocIdPusher pusher = new RecordingDocIdPusher();
Map<String, String> configEntries = new HashMap<String, String>();
configEntries.put("gsa.hostname", "localhost");
configEntries.put("ad.servers", "server1");
configEntries.put("ad.servers.server1.host", "localhost");
configEntries.put("ad.servers.server1.port", "1234");
configEntries.put("ad.servers.server1.user", "username");
configEntries.put("ad.servers.server1.password", "password");
configEntries.put("ad.servers.server1.method", "ssl");
configEntries.put("ad.userSearchBaseDN", "ou=DoesNotMatter");
configEntries.put("server.port", "5680");
configEntries.put("server.dashboardPort", "5681");
pushGroupDefinitions(adAdaptor, configEntries, pusher, /*fullPush=*/ true,
/*init=*/ true);
Map<GroupPrincipal, Collection<Principal>> results =
pusher.getGroupDefinitions();
// the above (eventually) calls AdAdaptor.init() with the specified config.
}
示例4: testFakeAdaptorDefaultUserAndPasswordSpecified
import com.google.enterprise.adaptor.Principal; //导入依赖的package包/类
@Test
public void testFakeAdaptorDefaultUserAndPasswordSpecified()
throws Exception {
AdAdaptor adAdaptor = new FakeAdaptor();
RecordingDocIdPusher pusher = new RecordingDocIdPusher();
Map<String, String> configEntries = new HashMap<String, String>();
configEntries.put("gsa.hostname", "localhost");
configEntries.put("ad.servers", "server1");
configEntries.put("ad.servers.server1.host", "localhost");
configEntries.put("ad.servers.server1.port", "1234");
configEntries.put("ad.servers.server1.method", "ssl");
configEntries.put("ad.defaultUser", "defaultUser");
configEntries.put("ad.defaultPassword", "defaultPassword");
configEntries.put("ad.groupSearchBaseDN", "ou=DoesNotMatter");
configEntries.put("server.port", "5680");
configEntries.put("server.dashboardPort", "5681");
pushGroupDefinitions(adAdaptor, configEntries, pusher, /*fullPush=*/ true,
/*init=*/ true);
Map<GroupPrincipal, Collection<Principal>> results =
pusher.getGroupDefinitions();
// the above (eventually) calls AdAdaptor.init() with the specified config.
}
示例5: testGetDocIdsMarkPublicFalse
import com.google.enterprise.adaptor.Principal; //导入依赖的package包/类
@Test
public void testGetDocIdsMarkPublicFalse() throws InterruptedException {
SoapFactoryMock soapFactory = new SoapFactoryMock();
OpentextAdaptor adaptor = new OpentextAdaptor(soapFactory);
AdaptorContext context = ProxyAdaptorContext.getInstance();
Config config = initConfig(adaptor, context);
config.overrideKey("adaptor.markAllDocsAsPublic", "false");
adaptor.init(context);
soapFactory.memberServiceMock.addMember(
getMember(1000, "user1", "User"));
soapFactory.memberServiceMock.addMember(
getMember(2000, "group1", "Group"));
soapFactory.memberServiceMock.addMemberToGroup(
2000, soapFactory.memberServiceMock.getMemberById(1000));
RecordingDocIdPusher pusher = new RecordingDocIdPusher();
adaptor.getDocIds(pusher);
Map<GroupPrincipal, List<Principal>> expected =
new HashMap<GroupPrincipal, List<Principal>>();
expected.put(newGroupPrincipal("group1"),
Lists.<Principal>newArrayList(newUserPrincipal("user1")));
assertEquals(expected, pusher.getGroupDefinitions());
}
示例6: testGetGroupsDeletedUser
import com.google.enterprise.adaptor.Principal; //导入依赖的package包/类
@Test
public void testGetGroupsDeletedUser() throws InterruptedException {
SoapFactoryMock soapFactory = new SoapFactoryMock();
Member active = getMember(1, "user1", "User");
Member deleted = getMember(2, "user2", "User");
deleted.setDeleted(true);
Member group = getMember(11, "group1", "Group");
soapFactory.memberServiceMock.addMember(active);
soapFactory.memberServiceMock.addMember(deleted);
soapFactory.memberServiceMock.addMember(group);
soapFactory.memberServiceMock.addMemberToGroup(group.getID(), active);
soapFactory.memberServiceMock.addMemberToGroup(group.getID(), deleted);
OpentextAdaptor adaptor = new OpentextAdaptor(soapFactory);
AdaptorContext context = ProxyAdaptorContext.getInstance();
Config config = initConfig(adaptor, context);
adaptor.init(context);
OpentextAdaptor.Groups groups =
adaptor.new Groups(soapFactory.newMemberService());
groups.addGroups();
Map<GroupPrincipal, List<Principal>> groupDefinitions =
groups.getGroupDefinitions();
assertEquals(Lists.newArrayList(newUserPrincipal("user1")),
groupDefinitions.get(newGroupPrincipal("group1")));
}
示例7: testGetGroupsDeletedGroup
import com.google.enterprise.adaptor.Principal; //导入依赖的package包/类
@Test
public void testGetGroupsDeletedGroup() throws InterruptedException {
SoapFactoryMock soapFactory = new SoapFactoryMock();
Member active = getMember(1, "user1", "User");
Member group = getMember(11, "group1", "Group");
group.setDeleted(true);
soapFactory.memberServiceMock.addMember(active);
soapFactory.memberServiceMock.addMember(group);
soapFactory.memberServiceMock.addMemberToGroup(group.getID(), active);
OpentextAdaptor adaptor = new OpentextAdaptor(soapFactory);
AdaptorContext context = ProxyAdaptorContext.getInstance();
Config config = initConfig(adaptor, context);
adaptor.init(context);
OpentextAdaptor.Groups groups =
adaptor.new Groups(soapFactory.newMemberService());
groups.addGroups();
Map<GroupPrincipal, List<Principal>> groupDefinitions =
groups.getGroupDefinitions();
assertEquals(null, groupDefinitions.get(newGroupPrincipal("group1")));
}
示例8: testGetGroupsDeletedMemberGroup
import com.google.enterprise.adaptor.Principal; //导入依赖的package包/类
@Test
public void testGetGroupsDeletedMemberGroup() throws InterruptedException {
SoapFactoryMock soapFactory = new SoapFactoryMock();
Member active = getMember(1, "user1", "User");
Member memberGroup = getMember(2, "memberGroup", "Group");
memberGroup.setDeleted(true);
Member group = getMember(11, "group1", "Group");
soapFactory.memberServiceMock.addMember(active);
soapFactory.memberServiceMock.addMember(memberGroup);
soapFactory.memberServiceMock.addMember(group);
soapFactory.memberServiceMock.addMemberToGroup(group.getID(), active);
soapFactory.memberServiceMock.addMemberToGroup(group.getID(), memberGroup);
OpentextAdaptor adaptor = new OpentextAdaptor(soapFactory);
AdaptorContext context = ProxyAdaptorContext.getInstance();
Config config = initConfig(adaptor, context);
adaptor.init(context);
OpentextAdaptor.Groups groups =
adaptor.new Groups(soapFactory.newMemberService());
groups.addGroups();
Map<GroupPrincipal, List<Principal>> groupDefinitions =
groups.getGroupDefinitions();
assertEquals(Lists.newArrayList(newUserPrincipal("user1")),
groupDefinitions.get(newGroupPrincipal("group1")));
}
示例9: testGetGroupsLoginDisabledUser
import com.google.enterprise.adaptor.Principal; //导入依赖的package包/类
@Test
public void testGetGroupsLoginDisabledUser() throws InterruptedException {
SoapFactoryMock soapFactory = new SoapFactoryMock();
Member active = getMember(1, "user1", "User");
User disabled = (User) getMember(2, "user2", "User");
MemberPrivileges memberPrivileges = disabled.getPrivileges();
memberPrivileges.setLoginEnabled(false);
Member group = getMember(11, "group1", "Group");
soapFactory.memberServiceMock.addMember(active);
soapFactory.memberServiceMock.addMember(disabled);
soapFactory.memberServiceMock.addMember(group);
soapFactory.memberServiceMock.addMemberToGroup(group.getID(), active);
soapFactory.memberServiceMock.addMemberToGroup(group.getID(), disabled);
OpentextAdaptor adaptor = new OpentextAdaptor(soapFactory);
AdaptorContext context = ProxyAdaptorContext.getInstance();
Config config = initConfig(adaptor, context);
adaptor.init(context);
OpentextAdaptor.Groups groups =
adaptor.new Groups(soapFactory.newMemberService());
groups.addGroups();
Map<GroupPrincipal, List<Principal>> groupDefinitions =
groups.getGroupDefinitions();
assertEquals(Lists.newArrayList(newUserPrincipal("user1")),
groupDefinitions.get(newGroupPrincipal("group1")));
}
示例10: testGetPublicAccessGroupDisabledUser
import com.google.enterprise.adaptor.Principal; //导入依赖的package包/类
@Test
public void testGetPublicAccessGroupDisabledUser()
throws InterruptedException {
SoapFactoryMock soapFactory = new SoapFactoryMock();
User active = (User) getMember(1, "user1", "User");
MemberPrivileges memberPrivileges = active.getPrivileges();
memberPrivileges.setPublicAccessEnabled(true);
User disabled = (User) getMember(2, "user2", "User");
memberPrivileges = disabled.getPrivileges();
memberPrivileges.setPublicAccessEnabled(true);
memberPrivileges.setLoginEnabled(false);
soapFactory.memberServiceMock.addMember(active);
soapFactory.memberServiceMock.addMember(disabled);
OpentextAdaptor adaptor = new OpentextAdaptor(soapFactory);
AdaptorContext context = ProxyAdaptorContext.getInstance();
Config config = initConfig(adaptor, context);
adaptor.init(context);
OpentextAdaptor.Groups groups =
adaptor.new Groups(soapFactory.newMemberService());
groups.addPublicAccessGroup("[Public Access]", LOCAL_NAMESPACE);
List<Principal> publicAccessGroup =
groups.getGroupDefinitions().get(newGroupPrincipal("[Public Access]"));
assertEquals(Lists.newArrayList(newUserPrincipal("user1")),
publicAccessGroup);
}
示例11: getDocIdsSiteCollectionOnly
import com.google.enterprise.adaptor.Principal; //导入依赖的package包/类
private void getDocIdsSiteCollectionOnly(DocIdPusher pusher)
throws InterruptedException,IOException {
log.entering("SharePointAdaptor", "getDocIdsSiteCollectionOnly", pusher);
SiteAdaptor scAdaptor = getSiteAdaptor(sharePointUrl.getSharePointUrl(),
sharePointUrl.getSharePointUrl());
SiteDataClient scClient = scAdaptor.getSiteDataClient();
Site site = scClient.getContentSite();
String siteCollectionUrl = getCanonicalUrl(site.getMetadata().getURL());
// Reset site collection URL instance to use correct URL.
scAdaptor = getSiteAdaptor(siteCollectionUrl, siteCollectionUrl);
DocId siteCollectionDocId = scAdaptor.encodeDocId(siteCollectionUrl);
pusher.pushDocIds(Arrays.asList(siteCollectionDocId));
Map<GroupPrincipal, Collection<Principal>> groupDefs
= new HashMap<GroupPrincipal, Collection<Principal>>();
groupDefs.putAll(scAdaptor.computeMembersForGroups(site.getGroups()));
String siteId = site.getMetadata().getID();
sitePushGroupDefinitions(siteId, pusher, groupDefs);
log.exiting("SharePointAdaptor", "getDocIdsSiteCollectionOnly");
}
示例12: generateAcl
import com.google.enterprise.adaptor.Principal; //导入依赖的package包/类
private Acl.Builder generateAcl(List<Permission> permissions,
final long necessaryPermissionMask) throws IOException {
List<Principal> permits = new LinkedList<Principal>();
IdMappings idMapping = new IdMappings();
for (Permission permission : permissions) {
// Although it is named "mask", this is really a bit-field of
// permissions.
long mask = permission.getMask().longValue();
if ((necessaryPermissionMask & mask) != necessaryPermissionMask) {
continue;
}
Integer id = permission.getMemberid();
Principal principal = idMapping.resolvePrincipal(id);
if (principal == null) {
log.log(Level.WARNING, "Could not resolve member id {0} for Web "
+ "[{1}] under Site Collection [{2}].",
new Object[] {id, webUrl, siteUrl});
continue;
}
permits.add(principal);
}
return new Acl.Builder().setEverythingCaseInsensitive()
.setPermits(permits);
}
示例13: addPermitUserToAcl
import com.google.enterprise.adaptor.Principal; //导入依赖的package包/类
private void addPermitUserToAcl(int userId, Acl.Builder aclToUpdate)
throws IOException {
if (userId == -1) {
return;
}
IdMappings idMapping = new IdMappings();
Principal principal = idMapping.resolvePrincipal(userId);
if (principal == null) {
log.log(Level.WARNING, "Could not resolve user id {0}", userId);
return;
}
List<Principal> permits
= new LinkedList<Principal>(aclToUpdate.build().getPermits());
permits.add(principal);
aclToUpdate.setPermits(permits);
}
示例14: retrieveMemberIdMapping
import com.google.enterprise.adaptor.Principal; //导入依赖的package包/类
private MemberIdMapping retrieveMemberIdMapping() throws IOException {
log.entering("SiteAdaptor", "retrieveMemberIdMapping");
Site site = siteDataClient.getContentSite();
Map<Integer, Principal> map = new HashMap<Integer, Principal>();
for (GroupMembership.Group group : site.getGroups().getGroup()) {
map.put(group.getGroup().getID(), new GroupPrincipal(
group.getGroup().getName(),
defaultNamespace + "_" + site.getMetadata().getURL()));
}
for (UserDescription user : site.getWeb().getUsers().getUser()) {
Principal principal = userDescriptionToPrincipal(user);
if (principal == null) {
log.log(Level.WARNING,
"Unable to determine login name. Skipping user with ID {0}",
user.getID());
continue;
}
map.put(user.getID(), principal);
}
MemberIdMapping mapping = new MemberIdMapping(map);
log.exiting("SiteAdaptor", "retrieveMemberIdMapping", mapping);
return mapping;
}
示例15: computeMembersForGroups
import com.google.enterprise.adaptor.Principal; //导入依赖的package包/类
private Map<GroupPrincipal, Collection<Principal>> computeMembersForGroups(
GroupMembership groups) {
Map<GroupPrincipal, Collection<Principal>> defs
= new HashMap<GroupPrincipal, Collection<Principal>>();
for (GroupMembership.Group group : groups.getGroup()) {
GroupPrincipal groupPrincipal = new GroupPrincipal(
group.getGroup().getName(), defaultNamespace + "_" + siteUrl);
Collection<Principal> members = new LinkedList<Principal>();
// We always provide membership details, even for empty groups.
defs.put(groupPrincipal, members);
if (group.getUsers() == null) {
continue;
}
for (UserDescription user : group.getUsers().getUser()) {
Principal principal = userDescriptionToPrincipal(user);
if (principal == null) {
log.log(Level.WARNING,
"Unable to determine login name. Skipping user with ID {0}",
user.getID());
continue;
}
members.add(principal);
}
}
return defs;
}