本文整理汇总了Java中org.ligoj.app.iam.CompanyOrg类的典型用法代码示例。如果您正苦于以下问题:Java CompanyOrg类的具体用法?Java CompanyOrg怎么用?Java CompanyOrg使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CompanyOrg类属于org.ligoj.app.iam包,在下文中一共展示了CompanyOrg类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findAllNotSecureByCompany
import org.ligoj.app.iam.CompanyOrg; //导入依赖的package包/类
@Test
public void findAllNotSecureByCompany() {
final Map<String, UserOrg> users = new HashMap<>();
final UserOrg user1 = newUser();
users.put("wuser", user1);
final UserOrg user2 = new UserOrg();
user2.setCompany("ing");
user2.setGroups(Collections.singletonList("any"));
users.put("user2", user2);
final GroupOrg groupOrg1 = new GroupOrg("cn=DIG,ou=fonction,ou=groups,dc=sample,dc=com", "DIG", Collections.singleton("wuser"));
final Map<String, GroupOrg> groupsMap = new HashMap<>();
groupsMap.put("dig", groupOrg1);
resource.groupResource = Mockito.mock(GroupResource.class);
final CompanyOrg company = new CompanyOrg("ou=ing,ou=france,ou=people,dc=sample,dc=com", "ing");
Mockito.when(companyRepository.findByIdExpected(DEFAULT_USER, "ing")).thenReturn(company);
groupFindById(DEFAULT_USER, "dig", groupOrg1);
Mockito.when(userRepository.findAll(ArgumentMatchers.any(), ArgumentMatchers.any(), ArgumentMatchers.any(), ArgumentMatchers.any()))
.thenReturn(new PageImpl<>(new ArrayList<>(users.values())));
Mockito.when(resource.groupResource.getContainers()).thenReturn(new HashSet<>(groupsMap.values()));
Mockito.when(resource.groupResource.getContainersForWrite()).thenReturn(new HashSet<>(groupsMap.values()));
final List<UserOrg> data = resource.findAllNotSecure("ing", null);
// Check the users
checkUser(data.get(0));
}
示例2: getLdapData
import org.ligoj.app.iam.CompanyOrg; //导入依赖的package包/类
/**
* Reset the database cache with the LDAP data.
*/
@CacheResult(cacheName = "ldap")
public Map<LdapData, Map<String, ? extends ResourceOrg>> getLdapData() {
final Map<LdapData, Map<String, ? extends ResourceOrg>> result = new EnumMap<>(LdapData.class);
// Fetch LDAP data
log.info("Fetching LDAP data ...");
final Map<String, CompanyOrg> companies = getCompany().findAllNoCache();
final Map<String, GroupOrg> groups = getGroup().findAllNoCache();
final Map<String, UserOrg> users = getUser().findAllNoCache(groups);
result.put(LdapData.COMPANY, companies);
result.put(LdapData.GROUP, groups);
result.put(LdapData.USER, users);
ldapCacheDao.reset(companies, groups, users);
return result;
}
示例3: findAllNoCache
import org.ligoj.app.iam.CompanyOrg; //导入依赖的package包/类
/**
* Fetch and return all normalized companies. Note the result use cache, so does not reflect the current state of
* LDAP.
*
* @return the companies. Key is the normalized name.
*/
public Map<String, CompanyOrg> findAllNoCache() {
final Map<String, CompanyOrg> companiesNameToDn = new HashMap<>();
for (final DirContextAdapter company : template.search(companyBaseDn, "objectClass=" + ORGANIZATIONAL_UNIT,
(Object ctx) -> (DirContextAdapter) ctx)) {
final CompanyOrg companyLdap = new CompanyOrg(company.getDn().toString(), company.getStringAttributes("ou")[0]);
companiesNameToDn.put(companyLdap.getId(), companyLdap);
}
// Also add/replace the quarantine zone
final CompanyOrg quarantine = new CompanyOrg(quarantineBaseDn, getQuarantineCompany());
quarantine.setLocked(true);
companiesNameToDn.put(quarantine.getId(), quarantine);
// The complete the hierarchy of companies
companiesNameToDn.values().forEach(this::buildLdapName);
companiesNameToDn.values().forEach(c -> this.buildHierarchy(companiesNameToDn, c));
return companiesNameToDn;
}
示例4: delete
import org.ligoj.app.iam.CompanyOrg; //导入依赖的package包/类
@Override
public void delete(final CompanyOrg container) {
/*
* Remove from the managed companies, all companies within (sub LDAP DN) this company. This operation is needed
* since we
* are not rebuilding the cache from the LDAP. This save a lot of computations.
*/
findAll().values().stream().filter(g -> DnUtils.equalsOrParentOf(container.getDn(), g.getDn())).collect(Collectors.toList())
.forEach(this::removeFromJavaCache);
// Remove from LDAP the recursively the node. Anything that was not nicely cleaned will be deleted there.
template.unbind(container.getDn(), true);
// Also, update the SQL cache
ldapCacheRepository.delete(container);
}
示例5: getLdapData
import org.ligoj.app.iam.CompanyOrg; //导入依赖的package包/类
@Test
public void getLdapData() {
// Only there for coverage
LdapData.values();
LdapData.valueOf(LdapData.COMPANY.name());
final Map<LdapData, Map<String, ? extends ResourceOrg>> ldapData = repository.getLdapData();
Assert.assertEquals("Company", ((CompanyOrg) ldapData.get(LdapData.COMPANY).get("company")).getName());
Assert.assertEquals("dnc", ((CompanyOrg) ldapData.get(LdapData.COMPANY).get("company")).getDn());
final GroupOrg groupLdap = (GroupOrg) ldapData.get(LdapData.GROUP).get("group");
Assert.assertEquals("dn", groupLdap.getDn());
Assert.assertEquals("group", groupLdap.getId());
Assert.assertEquals("Group", groupLdap.getName());
final UserOrg user = (UserOrg) ldapData.get(LdapData.USER).get("u");
Assert.assertEquals("u", user.getId());
Assert.assertEquals("f", user.getFirstName());
Assert.assertEquals("l", user.getLastName());
Assert.assertEquals("company", user.getCompany());
final UserOrg user2 = (UserOrg) ldapData.get(LdapData.USER).get("u2");
Assert.assertEquals("u2", user2.getId());
Assert.assertEquals("f", user2.getFirstName());
Assert.assertEquals("l", user2.getLastName());
Assert.assertEquals("company", user2.getCompany());
}
示例6: findByIdExpected
import org.ligoj.app.iam.CompanyOrg; //导入依赖的package包/类
@Test
public void findByIdExpected() {
UserLdapRepository repository = new UserLdapRepository() {
@Override
public UserOrg findById(final String login) {
UserOrg user = new UserOrg();
user.setId(login);
user.setCompany("company");
return user;
}
};
CompanyLdapRepository mock = Mockito.mock(CompanyLdapRepository.class);
Mockito.when(mock.findById("user1", "company")).thenReturn(new CompanyOrg("", ""));
repository.setCompanyRepository(mock);
repository.findByIdExpected("user1", "user2");
}
示例7: deleteNotEmptyParent
import org.ligoj.app.iam.CompanyOrg; //导入依赖的package包/类
@Test
public void deleteNotEmptyParent() {
thrown.expect(ValidationJsonException.class);
thrown.expect(MatcherUtil.validationMatcher("company", "not-empty-company"));
final CompanyOrg companyOrg1 = new CompanyOrg("ou=france,ou=people,dc=sample,dc=com", "france");
final CompanyOrg companyOrg2 = new CompanyOrg("ou=ing-internal,ou=ing,ou=external,ou=people,dc=sample,dc=com", "ing-internal");
final Map<String, CompanyOrg> companies = new HashMap<>();
companies.put("france", companyOrg1);
companies.put("ing-internal", companyOrg2);
final Map<String, UserOrg> users = new HashMap<>();
final UserOrg user1 = new UserOrg();
user1.setCompany("france");
users.put("user1", user1);
Mockito.when(userRepository.findAll()).thenReturn(users);
Mockito.when(companyRepository.findByIdExpected(DEFAULT_USER, "france")).thenReturn(companyOrg1);
Mockito.when(companyRepository.findAll()).thenReturn(companies);
resource.delete("france");
}
示例8: create
import org.ligoj.app.iam.CompanyOrg; //导入依赖的package包/类
@Test
public void create() {
final GroupOrg groupOrg1 = new GroupOrg("cn=DIG,ou=fonction,ou=groups,dc=sample,dc=com", "DIG", Collections.singleton("flasta"));
final GroupOrg groupOrg2 = new GroupOrg("cn=DIG RHA,cn=DIG AS,cn=DIG,ou=fonction,ou=groups,dc=sample,dc=com", "DIG RHA",
Collections.singleton("wuser"));
groupOrg2.setLocked(true);
final Map<String, GroupOrg> groupsMap = new HashMap<>();
groupsMap.put("dig rha", groupOrg2);
final CompanyOrg company = new CompanyOrg("ou=ing,ou=france,ou=people,dc=sample,dc=com", "ing");
Mockito.when(companyRepository.findByIdExpected(DEFAULT_USER, "ing")).thenReturn(company);
groupFindById(DEFAULT_USER, "dig", groupOrg1);
groupFindById(DEFAULT_USER, "dig rha", groupOrg2);
final UserOrgEditionVo user = new UserOrgEditionVo();
user.setId("flasta");
user.setFirstName("FirstA ");
user.setLastName(" LASTA");
user.setCompany("ing");
user.setMail("[email protected]");
final List<String> groups = new ArrayList<>();
groups.add("dig rHA");
user.setGroups(groups);
resource.create(user);
}
示例9: deleteLastMember
import org.ligoj.app.iam.CompanyOrg; //导入依赖的package包/类
@Test
public void deleteLastMember() {
thrown.expect(ValidationJsonException.class);
thrown.expect(MatcherUtil.validationMatcher("id", "last-member-of-group"));
final GroupOrg groupOrg1 = new GroupOrg("cn=DIG,ou=fonction,ou=groups,dc=sample,dc=com", "DIG", Collections.singleton("wuser"));
final Map<String, GroupOrg> groupsMap = new HashMap<>();
groupsMap.put("dig", groupOrg1);
final UserOrg user = new UserOrg();
user.setCompany("ing");
user.setGroups(Collections.singleton("dig"));
Mockito.when(userRepository.findByIdExpected(DEFAULT_USER, "wuser")).thenReturn(user);
Mockito.when(groupRepository.findAll()).thenReturn(groupsMap);
final CompanyOrg company = new CompanyOrg("ou=ing,ou=france,ou=people,dc=sample,dc=com", "ing");
Mockito.when(companyRepository.findById("ing")).thenReturn(company);
resource.delete("wuser");
}
示例10: deleteUserNoWriteCompany
import org.ligoj.app.iam.CompanyOrg; //导入依赖的package包/类
@Test
public void deleteUserNoWriteCompany() {
thrown.expect(ValidationJsonException.class);
thrown.expect(MatcherUtil.validationMatcher("id", BusinessException.KEY_UNKNOW_ID));
initSpringSecurityContext("mtuyer");
final CompanyOrg company = new CompanyOrg("ou=ing,ou=france,ou=people,dc=sample,dc=com", "ing");
final GroupOrg groupOrg1 = new GroupOrg("cn=DIG,ou=fonction,ou=groups,dc=sample,dc=com", "DIG",
new HashSet<>(Arrays.asList("wuser", "user1")));
final Map<String, GroupOrg> groupsMap = new HashMap<>();
groupsMap.put("dig", groupOrg1);
final UserOrg user = new UserOrg();
user.setCompany("ing");
user.setGroups(Collections.singleton("dig"));
Mockito.when(userRepository.findByIdExpected("mtuyer", "wuser")).thenReturn(user);
Mockito.when(companyRepository.findById("ing")).thenReturn(company);
Mockito.when(groupRepository.findAll()).thenReturn(groupsMap);
resource.delete("wuser");
}
示例11: resetPasswordUserNoWriteCompany
import org.ligoj.app.iam.CompanyOrg; //导入依赖的package包/类
@Test
public void resetPasswordUserNoWriteCompany() {
thrown.expect(ValidationJsonException.class);
thrown.expect(MatcherUtil.validationMatcher("id", BusinessException.KEY_UNKNOW_ID));
initSpringSecurityContext("mtuyer");
final CompanyOrg company = new CompanyOrg("ou=ing,ou=france,ou=people,dc=sample,dc=com", "ing");
final GroupOrg groupOrg1 = new GroupOrg("cn=DIG,ou=fonction,ou=groups,dc=sample,dc=com", "DIG",
new HashSet<>(Arrays.asList("wuser", "user1")));
final Map<String, GroupOrg> groupsMap = new HashMap<>();
groupsMap.put("dig", groupOrg1);
final UserOrg user = new UserOrg();
user.setCompany("ing");
user.setGroups(Collections.singleton("dig"));
Mockito.when(userRepository.findByIdExpected("mtuyer", "wuser")).thenReturn(user);
Mockito.when(companyRepository.findById("ing")).thenReturn(company);
Mockito.when(groupRepository.findAll()).thenReturn(groupsMap);
resource.resetPassword("wuser");
}
示例12: findAllNotSecureByManagedCompany
import org.ligoj.app.iam.CompanyOrg; //导入依赖的package包/类
@Test
public void findAllNotSecureByManagedCompany() {
final Map<String, UserOrg> users = new HashMap<>();
final UserOrg user1 = newUser();
users.put("wuser", user1);
final UserOrg user2 = new UserOrg();
user2.setCompany("ing");
user2.setGroups(Collections.singletonList("any"));
users.put("user2", user2);
final GroupOrg groupOrg1 = new GroupOrg("cn=DIG,ou=fonction,ou=groups,dc=sample,dc=com", "DIG", Collections.singleton("wuser"));
final Map<String, GroupOrg> groupsMap = new HashMap<>();
groupsMap.put("dig", groupOrg1);
resource.companyResource = Mockito.mock(CompanyResource.class);
final CompanyOrg company = new CompanyOrg("ou=ing,ou=france,ou=people,dc=sample,dc=com", "ing");
Mockito.when(companyRepository.findByIdExpected(DEFAULT_USER, "ing")).thenReturn(company);
groupFindById(DEFAULT_USER, "dig", groupOrg1);
Mockito.when(userRepository.findAll(ArgumentMatchers.any(), ArgumentMatchers.any(), ArgumentMatchers.any(), ArgumentMatchers.any()))
.thenReturn(new PageImpl<>(new ArrayList<>(users.values())));
Mockito.when(resource.companyResource.getContainers()).thenReturn(Collections.singleton(company));
Mockito.when(resource.companyResource.getContainersForWrite()).thenReturn(Collections.singleton(company));
final List<UserOrg> data = resource.findAllNotSecure("ing", null);
// Check the users
checkUser(data.get(0));
}
示例13: findAllNotSecureByGroup
import org.ligoj.app.iam.CompanyOrg; //导入依赖的package包/类
@Test
public void findAllNotSecureByGroup() {
final Map<String, UserOrg> users = new HashMap<>();
final UserOrg user1 = newUser();
users.put("wuser", user1);
final UserOrg user2 = new UserOrg();
user2.setCompany("ing");
user2.setGroups(Collections.singletonList("any"));
users.put("user2", user2);
final GroupOrg groupOrg1 = new GroupOrg("cn=DIG,ou=fonction,ou=groups,dc=sample,dc=com", "DIG", Collections.singleton("wuser"));
final Map<String, GroupOrg> groupsMap = new HashMap<>();
groupsMap.put("dig", groupOrg1);
resource.groupResource = Mockito.mock(GroupResource.class);
final CompanyOrg company = new CompanyOrg("ou=ing,ou=france,ou=people,dc=sample,dc=com", "ing");
Mockito.when(companyRepository.findByIdExpected(DEFAULT_USER, "ing")).thenReturn(company);
groupFindById(DEFAULT_USER, "dig", groupOrg1);
Mockito.when(userRepository.findAll(ArgumentMatchers.any(), ArgumentMatchers.any(), ArgumentMatchers.any(), ArgumentMatchers.any()))
.thenReturn(new PageImpl<>(new ArrayList<>(users.values())));
Mockito.when(resource.groupResource.getContainers()).thenReturn(new HashSet<>(groupsMap.values()));
Mockito.when(resource.groupResource.getContainersForWrite()).thenReturn(new HashSet<>(groupsMap.values()));
final List<UserOrg> data = resource.findAllNotSecure(null, "dig");
// Check the users
checkUser(data.get(0));
}
示例14: findAllNotSecureByManagedGroup
import org.ligoj.app.iam.CompanyOrg; //导入依赖的package包/类
@Test
public void findAllNotSecureByManagedGroup() {
final Map<String, UserOrg> users = new HashMap<>();
final UserOrg user1 = newUser();
users.put("wuser", user1);
final UserOrg user2 = new UserOrg();
user2.setCompany("ing");
user2.setGroups(Collections.singletonList("any"));
users.put("user2", user2);
final GroupOrg groupOrg1 = new GroupOrg("cn=DIG,ou=fonction,ou=groups,dc=sample,dc=com", "DIG", Collections.singleton("wuser"));
final Map<String, GroupOrg> groupsMap = new HashMap<>();
groupsMap.put("dig", groupOrg1);
resource.groupResource = Mockito.mock(GroupResource.class);
final CompanyOrg company = new CompanyOrg("ou=ing,ou=france,ou=people,dc=sample,dc=com", "ing");
Mockito.when(companyRepository.findByIdExpected(DEFAULT_USER, "ing")).thenReturn(company);
groupFindById(DEFAULT_USER, "dig", groupOrg1);
Mockito.when(userRepository.findAll(ArgumentMatchers.any(), ArgumentMatchers.any(), ArgumentMatchers.any(), ArgumentMatchers.any()))
.thenReturn(new PageImpl<>(new ArrayList<>(users.values())));
Mockito.when(resource.groupResource.getContainers()).thenReturn(new HashSet<>(groupsMap.values()));
Mockito.when(resource.groupResource.getContainersForWrite()).thenReturn(new HashSet<>(groupsMap.values()));
final List<UserOrg> data = resource.findAllNotSecure(null, "dig");
// Check the users
checkUser(data.get(0));
}
示例15: findAllNotSecure
import org.ligoj.app.iam.CompanyOrg; //导入依赖的package包/类
@Test
public void findAllNotSecure() {
final Map<String, UserOrg> users = new HashMap<>();
final UserOrg user1 = newUser();
users.put("wuser", user1);
final UserOrg user2 = new UserOrg();
user2.setCompany("ing");
user2.setGroups(Collections.singletonList("any"));
users.put("user2", user2);
final GroupOrg groupOrg1 = new GroupOrg("cn=DIG,ou=fonction,ou=groups,dc=sample,dc=com", "DIG", Collections.singleton("wuser"));
final Map<String, GroupOrg> groupsMap = new HashMap<>();
groupsMap.put("dig", groupOrg1);
resource.groupResource = Mockito.mock(GroupResource.class);
final CompanyOrg company = new CompanyOrg("ou=ing,ou=france,ou=people,dc=sample,dc=com", "ing");
Mockito.when(companyRepository.findByIdExpected(DEFAULT_USER, "ing")).thenReturn(company);
groupFindById(DEFAULT_USER, "dig", groupOrg1);
Mockito.when(userRepository.findAll(ArgumentMatchers.any(), ArgumentMatchers.any(), ArgumentMatchers.any(), ArgumentMatchers.any()))
.thenReturn(new PageImpl<>(new ArrayList<>(users.values())));
Mockito.when(resource.groupResource.getContainers()).thenReturn(new HashSet<>(groupsMap.values()));
Mockito.when(resource.groupResource.getContainersForWrite()).thenReturn(new HashSet<>(groupsMap.values()));
final List<UserOrg> data = resource.findAllNotSecure(null, null);
// Check the users
checkUser(data.get(0));
}