use of cz.metacentrum.perun.core.api.BanOnFacility in project perun by CESNET.
the class urn_perun_member_resource_attribute_def_virt_isBannedTest method setUp.
@Before
public void setUp() {
classInstance = new urn_perun_member_resource_attribute_def_virt_isBanned();
session = mock(PerunSessionImpl.class, RETURNS_DEEP_STUBS);
facility = new Facility(1, "testFacility");
resource = new Resource(1, "testResource", "des\nc", 1, 1);
vo = new Vo(1, "testVo", "desc");
user = new User(1, "name", "surname", "middlename", "title", "title");
member = new Member(1, 1, 1, Status.VALID);
isBanned = new Attribute(classInstance.getAttributeDefinition());
event1 = new BanSetForResource(new BanOnResource(), member.getId(), resource.getId());
event2 = new BanUpdatedForResource(new BanOnResource(), member.getId(), resource.getId());
event3 = new BanRemovedForResource(new BanOnResource(), member.getId(), resource.getId());
event4 = new BanSetForFacility(new BanOnFacility(), user.getId(), facility.getId());
event5 = new BanUpdatedForFacility(new BanOnFacility(), user.getId(), facility.getId());
event6 = new BanRemovedForFacility(new BanOnFacility(), user.getId(), facility.getId());
wrongEvent = new SecurityTeamAssignedToFacility();
}
use of cz.metacentrum.perun.core.api.BanOnFacility in project perun by CESNET.
the class FacilitiesManagerEntry method updateBan.
@Override
public BanOnFacility updateBan(PerunSession sess, BanOnFacility banOnFacility) throws PrivilegeException, FacilityNotExistsException, UserNotExistsException, BanNotExistsException {
Utils.checkPerunSession(sess);
this.getFacilitiesManagerBl().checkBanExists(sess, banOnFacility.getId());
Facility facility = this.getFacilitiesManagerBl().getFacilityById(sess, banOnFacility.getFacilityId());
User user = getPerunBl().getUsersManagerBl().getUserById(sess, banOnFacility.getUserId());
// Authorization
if (!AuthzResolver.authorizedInternal(sess, "updateBan_BanOnFacility_policy", Arrays.asList(facility, user, banOnFacility))) {
throw new PrivilegeException(sess, "updateBan");
}
banOnFacility = getFacilitiesManagerBl().updateBan(sess, banOnFacility);
return banOnFacility;
}
use of cz.metacentrum.perun.core.api.BanOnFacility in project perun by CESNET.
the class FacilitiesManagerEntry method getBan.
@Override
public BanOnFacility getBan(PerunSession sess, int userId, int faclityId) throws BanNotExistsException, PrivilegeException, UserNotExistsException, FacilityNotExistsException {
Utils.checkPerunSession(sess);
User user = getPerunBl().getUsersManagerBl().getUserById(sess, userId);
Facility facility = getPerunBl().getFacilitiesManagerBl().getFacilityById(sess, faclityId);
// Authorization
if (!AuthzResolver.authorizedInternal(sess, "getBan_int_int_policy", Arrays.asList(user, facility))) {
throw new PrivilegeException(sess, "getBan");
}
return getFacilitiesManagerBl().getBan(sess, userId, faclityId);
}
use of cz.metacentrum.perun.core.api.BanOnFacility in project perun by CESNET.
the class FacilitiesManagerEntry method getBansForUser.
@Override
public List<BanOnFacility> getBansForUser(PerunSession sess, int userId) throws UserNotExistsException {
Utils.checkPerunSession(sess);
User user = getPerunBl().getUsersManagerBl().getUserById(sess, userId);
List<BanOnFacility> usersBans = getFacilitiesManagerBl().getBansForUser(sess, userId);
// Authorization
Iterator<BanOnFacility> iterator = usersBans.iterator();
while (iterator.hasNext()) {
BanOnFacility banForFiltering = iterator.next();
Facility facility = new Facility();
facility.setId(banForFiltering.getFacilityId());
if (!AuthzResolver.authorizedInternal(sess, "getBansForUser_int_policy", Arrays.asList(banForFiltering, facility))) {
iterator.remove();
}
}
return usersBans;
}
use of cz.metacentrum.perun.core.api.BanOnFacility in project perun by CESNET.
the class FacilitiesManagerEntry method removeBan.
@Override
public void removeBan(PerunSession sess, int banId) throws PrivilegeException, BanNotExistsException {
Utils.checkPerunSession(sess);
BanOnFacility ban = this.getFacilitiesManagerBl().getBanById(sess, banId);
Facility facility = new Facility();
facility.setId(ban.getId());
// Authorization
if (!AuthzResolver.authorizedInternal(sess, "removeBan_int_policy", Arrays.asList(ban, facility))) {
throw new PrivilegeException(sess, "removeBan");
}
getFacilitiesManagerBl().removeBan(sess, banId);
}
Aggregations