Skip to content

Commit

Permalink
Merge branch 'master' into production
Browse files Browse the repository at this point in the history
  • Loading branch information
xflord committed Oct 10, 2023
2 parents b1809ab + 63a59e3 commit 7635aad
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -720,13 +720,13 @@ public interface FacilitiesManager {
*
* @param banId the id of ban
*/
void removeBan(PerunSession sess, int banId) throws BanNotExistsException, PrivilegeException;
void removeBan(PerunSession sess, int banId) throws BanNotExistsException, PrivilegeException, FacilityNotExistsException;

/**
* Remove existing ban by id of user and facility.
*
* @param userId the id of user
* @param facilityId the id of facility
*/
void removeBan(PerunSession sess, int userId, int facilityId) throws BanNotExistsException, PrivilegeException;
void removeBan(PerunSession sess, int userId, int facilityId) throws BanNotExistsException, PrivilegeException, FacilityNotExistsException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -1391,31 +1391,27 @@ public BanOnFacility updateBan(PerunSession sess, BanOnFacility banOnFacility) t
}

@Override
public void removeBan(PerunSession sess, int banId) throws PrivilegeException, BanNotExistsException {
public void removeBan(PerunSession sess, int banId) throws PrivilegeException, BanNotExistsException, FacilityNotExistsException {
Utils.checkPerunSession(sess);
BanOnFacility ban = this.getFacilitiesManagerBl().getBanById(sess, banId);

Facility facility = new Facility();
facility.setId(ban.getId());
BanOnFacility banOnFacility = this.getFacilitiesManagerBl().getBanById(sess, banId);
Facility facility = this.getFacilitiesManagerBl().getFacilityById(sess, banOnFacility.getFacilityId());

// Authorization
if (!AuthzResolver.authorizedInternal(sess, "removeBan_int_policy", Arrays.asList(ban, facility))) {
if (!AuthzResolver.authorizedInternal(sess, "removeBan_int_policy", Arrays.asList(banOnFacility, facility))) {
throw new PrivilegeException(sess, "removeBan");
}

getFacilitiesManagerBl().removeBan(sess, banId);
}

@Override
public void removeBan(PerunSession sess, int userId, int facilityId) throws BanNotExistsException, PrivilegeException {
public void removeBan(PerunSession sess, int userId, int facilityId) throws BanNotExistsException, PrivilegeException, FacilityNotExistsException {
Utils.checkPerunSession(sess);
BanOnFacility ban = this.getFacilitiesManagerBl().getBan(sess, userId, facilityId);

Facility facility = new Facility();
facility.setId(ban.getId());
BanOnFacility banOnFacility = this.getFacilitiesManagerBl().getBan(sess, userId, facilityId);
Facility facility = this.getFacilitiesManagerBl().getFacilityById(sess, banOnFacility.getFacilityId());

// Authorization
if (!AuthzResolver.authorizedInternal(sess, "removeBan_int_int_policy", Arrays.asList(ban, facility))) {
if (!AuthzResolver.authorizedInternal(sess, "removeBan_int_int_policy", Arrays.asList(banOnFacility, facility))) {
throw new PrivilegeException(sess, "removeBan");
}

Expand Down

0 comments on commit 7635aad

Please sign in to comment.