Search in sources :

Example 1 with BanOnFacility

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();
}
Also used : BanRemovedForResource(cz.metacentrum.perun.audit.events.ResourceManagerEvents.BanRemovedForResource) SecurityTeamAssignedToFacility(cz.metacentrum.perun.audit.events.FacilityManagerEvents.SecurityTeamAssignedToFacility) BanRemovedForFacility(cz.metacentrum.perun.audit.events.FacilityManagerEvents.BanRemovedForFacility) User(cz.metacentrum.perun.core.api.User) Attribute(cz.metacentrum.perun.core.api.Attribute) BanUpdatedForResource(cz.metacentrum.perun.audit.events.ResourceManagerEvents.BanUpdatedForResource) Resource(cz.metacentrum.perun.core.api.Resource) BanSetForResource(cz.metacentrum.perun.audit.events.ResourceManagerEvents.BanSetForResource) BanOnResource(cz.metacentrum.perun.core.api.BanOnResource) BanUpdatedForResource(cz.metacentrum.perun.audit.events.ResourceManagerEvents.BanUpdatedForResource) BanRemovedForResource(cz.metacentrum.perun.audit.events.ResourceManagerEvents.BanRemovedForResource) PerunSessionImpl(cz.metacentrum.perun.core.impl.PerunSessionImpl) BanOnResource(cz.metacentrum.perun.core.api.BanOnResource) BanSetForResource(cz.metacentrum.perun.audit.events.ResourceManagerEvents.BanSetForResource) BanOnFacility(cz.metacentrum.perun.core.api.BanOnFacility) Vo(cz.metacentrum.perun.core.api.Vo) BanOnFacility(cz.metacentrum.perun.core.api.BanOnFacility) SecurityTeamAssignedToFacility(cz.metacentrum.perun.audit.events.FacilityManagerEvents.SecurityTeamAssignedToFacility) BanRemovedForFacility(cz.metacentrum.perun.audit.events.FacilityManagerEvents.BanRemovedForFacility) Facility(cz.metacentrum.perun.core.api.Facility) BanUpdatedForFacility(cz.metacentrum.perun.audit.events.FacilityManagerEvents.BanUpdatedForFacility) BanSetForFacility(cz.metacentrum.perun.audit.events.FacilityManagerEvents.BanSetForFacility) Member(cz.metacentrum.perun.core.api.Member) BanSetForFacility(cz.metacentrum.perun.audit.events.FacilityManagerEvents.BanSetForFacility) BanUpdatedForFacility(cz.metacentrum.perun.audit.events.FacilityManagerEvents.BanUpdatedForFacility) Before(org.junit.Before)

Example 2 with BanOnFacility

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;
}
Also used : User(cz.metacentrum.perun.core.api.User) RichUser(cz.metacentrum.perun.core.api.RichUser) PrivilegeException(cz.metacentrum.perun.core.api.exceptions.PrivilegeException) BanOnFacility(cz.metacentrum.perun.core.api.BanOnFacility) Facility(cz.metacentrum.perun.core.api.Facility) RichFacility(cz.metacentrum.perun.core.api.RichFacility) EnrichedFacility(cz.metacentrum.perun.core.api.EnrichedFacility)

Example 3 with 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);
}
Also used : User(cz.metacentrum.perun.core.api.User) RichUser(cz.metacentrum.perun.core.api.RichUser) PrivilegeException(cz.metacentrum.perun.core.api.exceptions.PrivilegeException) BanOnFacility(cz.metacentrum.perun.core.api.BanOnFacility) Facility(cz.metacentrum.perun.core.api.Facility) RichFacility(cz.metacentrum.perun.core.api.RichFacility) EnrichedFacility(cz.metacentrum.perun.core.api.EnrichedFacility)

Example 4 with BanOnFacility

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;
}
Also used : User(cz.metacentrum.perun.core.api.User) RichUser(cz.metacentrum.perun.core.api.RichUser) BanOnFacility(cz.metacentrum.perun.core.api.BanOnFacility) BanOnFacility(cz.metacentrum.perun.core.api.BanOnFacility) Facility(cz.metacentrum.perun.core.api.Facility) RichFacility(cz.metacentrum.perun.core.api.RichFacility) EnrichedFacility(cz.metacentrum.perun.core.api.EnrichedFacility)

Example 5 with BanOnFacility

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);
}
Also used : BanOnFacility(cz.metacentrum.perun.core.api.BanOnFacility) PrivilegeException(cz.metacentrum.perun.core.api.exceptions.PrivilegeException) BanOnFacility(cz.metacentrum.perun.core.api.BanOnFacility) Facility(cz.metacentrum.perun.core.api.Facility) RichFacility(cz.metacentrum.perun.core.api.RichFacility) EnrichedFacility(cz.metacentrum.perun.core.api.EnrichedFacility)

Aggregations

BanOnFacility (cz.metacentrum.perun.core.api.BanOnFacility)22 User (cz.metacentrum.perun.core.api.User)16 RichUser (cz.metacentrum.perun.core.api.RichUser)15 Member (cz.metacentrum.perun.core.api.Member)12 Resource (cz.metacentrum.perun.core.api.Resource)12 Group (cz.metacentrum.perun.core.api.Group)11 RichResource (cz.metacentrum.perun.core.api.RichResource)11 Vo (cz.metacentrum.perun.core.api.Vo)11 AbstractPerunIntegrationTest (cz.metacentrum.perun.core.AbstractPerunIntegrationTest)10 Date (java.util.Date)10 Test (org.junit.Test)10 Facility (cz.metacentrum.perun.core.api.Facility)8 EnrichedFacility (cz.metacentrum.perun.core.api.EnrichedFacility)7 RichFacility (cz.metacentrum.perun.core.api.RichFacility)7 PrivilegeException (cz.metacentrum.perun.core.api.exceptions.PrivilegeException)6 BanNotExistsException (cz.metacentrum.perun.core.api.exceptions.BanNotExistsException)3 InternalErrorException (cz.metacentrum.perun.core.api.exceptions.InternalErrorException)3 RelationExistsException (cz.metacentrum.perun.core.api.exceptions.RelationExistsException)3 WrongAttributeValueException (cz.metacentrum.perun.core.api.exceptions.WrongAttributeValueException)3 WrongReferenceAttributeValueException (cz.metacentrum.perun.core.api.exceptions.WrongReferenceAttributeValueException)3