use of cz.metacentrum.perun.core.api.Candidate in project perun by CESNET.
the class MembersManagerEntryIntegrationTest method setUpMember.
private Member setUpMember(Vo vo) throws Exception {
Candidate candidate = setUpCandidate();
// candidates.get(0)
Member member = perun.getMembersManagerBl().createMemberSync(sess, vo, candidate);
// set first candidate as member of test VO
assertNotNull("No member created", member);
usersForDeletion.add(perun.getUsersManager().getUserByMember(sess, member));
Attribute attrEmail = new Attribute(attributesManagerEntry.getAttributeDefinition(sess, AttributesManager.NS_MEMBER_ATTR_DEF + ":mail"));
attrEmail.setValue("test@test.test");
attributesManagerEntry.setAttribute(sess, member, attrEmail);
User user = usersManagerEntry.getUserByMember(sess, member);
Attribute attrLogin = new Attribute();
attrLogin.setNamespace(AttributesManager.NS_USER_ATTR_DEF);
attrLogin.setFriendlyName("login-namespace:testMichal");
attrLogin.setType(String.class.getName());
attrLogin = new Attribute(attributesManagerEntry.createAttribute(sess, attrLogin));
attrLogin.setValue("TestovaciLogin");
attributesManagerEntry.setAttribute(sess, user, attrLogin);
return member;
}
use of cz.metacentrum.perun.core.api.Candidate in project perun by CESNET.
the class GroupsManagerEntryIntegrationTest method setUpMemberInGroup.
private Member setUpMemberInGroup(Vo vo) throws Exception {
Candidate candidate = new Candidate();
candidate.setFirstName("TestName");
candidate.setId(0);
candidate.setMiddleName("");
candidate.setLastName("TestLastName");
candidate.setTitleBefore("");
candidate.setTitleAfter("");
String extLogin = Long.toHexString(Double.doubleToLongBits(Math.random()));
UserExtSource ues = new UserExtSource(extSource, extLogin);
candidate.setUserExtSource(ues);
candidate.setAttributes(new HashMap<>());
Member member = perun.getMembersManagerBl().createMemberSync(sess, vo, candidate);
groupsManagerBl.createGroup(sess, vo, group);
groupsManagerBl.addMember(sess, group, member);
return member;
}
use of cz.metacentrum.perun.core.api.Candidate in project perun by CESNET.
the class ExtSourcesManagerEntry method getCandidate.
@Override
public Candidate getCandidate(PerunSession perunSession, Map<String, String> subjectData, ExtSource source) throws PrivilegeException, ExtSourceNotExistsException {
Utils.checkPerunSession(perunSession);
Utils.notNull(subjectData, "subjectData");
Utils.notNull(subjectData.get("login"), "subjectLogin");
getExtSourcesManagerBl().checkExtSourceExists(perunSession, source);
// Authorization
if (!AuthzResolver.authorizedInternal(perunSession, "getCandidate_Map<String_String>_ExtSource_policy", source))
throw new PrivilegeException(perunSession, "getCandidate");
return new Candidate(getExtSourcesManagerBl().getCandidate(perunSession, subjectData, source, subjectData.get("login")));
}
use of cz.metacentrum.perun.core.api.Candidate in project perun by CESNET.
the class ExtSourcesManagerEntry method getCandidate.
@Override
public Candidate getCandidate(PerunSession sess, ExtSource source, String login) throws PrivilegeException, ExtSourceNotExistsException, CandidateNotExistsException, ExtSourceUnsupportedOperationException {
Utils.checkPerunSession(sess);
getExtSourcesManagerBl().checkExtSourceExists(sess, source);
// Authorization
if (!AuthzResolver.authorizedInternal(sess, "getCandidate_ExtSource_String_policy", source))
throw new PrivilegeException(sess, "getCandidate");
try {
return new Candidate(getExtSourcesManagerBl().getCandidate(sess, source, login));
// we need to close the extsource here because we don't want to always do it in the BL layer
} finally {
if (source instanceof ExtSourceSimpleApi) {
try {
((ExtSourceSimpleApi) source).close();
} catch (ExtSourceUnsupportedOperationException e) {
// silently skip
} catch (Exception e) {
log.error("Failed to close connection to extsource", e);
}
}
}
}
use of cz.metacentrum.perun.core.api.Candidate in project perun by CESNET.
the class UsersManagerBlImplTest method setUp.
@Before
public void setUp() throws Exception {
candidate = new Candidate();
candidate.setFirstName("some");
candidate.setId(0);
candidate.setMiddleName("");
candidate.setLastName("testingUser");
candidate.setTitleBefore("");
candidate.setTitleAfter("");
ues = new UserExtSource(extSource, "extLogin");
candidate.setUserExtSource(ues);
candidate.setAttributes(new HashMap<>());
sess = perun.getPerunSession(new PerunPrincipal("perunTests", ExtSourcesManager.EXTSOURCE_NAME_INTERNAL, ExtSourcesManager.EXTSOURCE_INTERNAL), new PerunClient());
vo = new Vo(0, "UsersBlImplTestVo", "UsrMgrBlImplTestVo");
vo = perun.getVosManagerBl().createVo(sess, vo);
member = perun.getMembersManagerBl().createMemberSync(sess, vo, candidate);
group = new Group("testGroup", "testGroup");
group = perun.getGroupsManagerBl().createGroup(sess, vo, group);
perun.getGroupsManagerBl().addMember(sess, group, member);
facility = new Facility(0, "testFac");
facility = perun.getFacilitiesManagerBl().createFacility(sess, facility);
resource = new Resource(0, "testRes", null, facility.getId(), vo.getId());
resource = perun.getResourcesManagerBl().createResource(sess, resource, vo, facility);
perun.getResourcesManagerBl().assignGroupToResource(sess, group, resource, false, false, false);
// second branch
vo2 = new Vo(0, "FacilitiesManagerBlImplTestVo2", "FacMgrBlImplTestVo2");
vo2 = perun.getVosManagerBl().createVo(sess, vo2);
member2 = perun.getMembersManagerBl().createMemberSync(sess, vo2, candidate);
group2 = new Group("testGroup", "testGroup");
group2 = perun.getGroupsManagerBl().createGroup(sess, vo2, group2);
perun.getGroupsManagerBl().addMember(sess, group2, member2);
resource2 = new Resource(0, "testRes2", null, facility.getId(), vo2.getId());
resource2 = perun.getResourcesManagerBl().createResource(sess, resource2, vo2, facility);
// third branch
facility2 = new Facility(0, "testFac2");
facility2 = perun.getFacilitiesManagerBl().createFacility(sess, facility2);
resource3 = new Resource(0, "testRes3", null, facility2.getId(), vo2.getId());
resource3 = perun.getResourcesManagerBl().createResource(sess, resource3, vo2, facility2);
perun.getResourcesManagerBl().assignGroupToResources(sess, group2, Arrays.asList(resource2, resource3), false, false, false);
user = perun.getUsersManagerBl().getUserByMember(sess, member);
}
Aggregations