Skip to content

Commit 7635aad

Browse files
committed
Merge branch 'master' into production
2 parents b1809ab + 63a59e3 commit 7635aad

File tree

2 files changed

+10
-14
lines changed

2 files changed

+10
-14
lines changed

perun-core/src/main/java/cz/metacentrum/perun/core/api/FacilitiesManager.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -720,13 +720,13 @@ public interface FacilitiesManager {
720720
*
721721
* @param banId the id of ban
722722
*/
723-
void removeBan(PerunSession sess, int banId) throws BanNotExistsException, PrivilegeException;
723+
void removeBan(PerunSession sess, int banId) throws BanNotExistsException, PrivilegeException, FacilityNotExistsException;
724724

725725
/**
726726
* Remove existing ban by id of user and facility.
727727
*
728728
* @param userId the id of user
729729
* @param facilityId the id of facility
730730
*/
731-
void removeBan(PerunSession sess, int userId, int facilityId) throws BanNotExistsException, PrivilegeException;
731+
void removeBan(PerunSession sess, int userId, int facilityId) throws BanNotExistsException, PrivilegeException, FacilityNotExistsException;
732732
}

perun-core/src/main/java/cz/metacentrum/perun/core/entry/FacilitiesManagerEntry.java

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1391,31 +1391,27 @@ public BanOnFacility updateBan(PerunSession sess, BanOnFacility banOnFacility) t
13911391
}
13921392

13931393
@Override
1394-
public void removeBan(PerunSession sess, int banId) throws PrivilegeException, BanNotExistsException {
1394+
public void removeBan(PerunSession sess, int banId) throws PrivilegeException, BanNotExistsException, FacilityNotExistsException {
13951395
Utils.checkPerunSession(sess);
1396-
BanOnFacility ban = this.getFacilitiesManagerBl().getBanById(sess, banId);
1397-
1398-
Facility facility = new Facility();
1399-
facility.setId(ban.getId());
1396+
BanOnFacility banOnFacility = this.getFacilitiesManagerBl().getBanById(sess, banId);
1397+
Facility facility = this.getFacilitiesManagerBl().getFacilityById(sess, banOnFacility.getFacilityId());
14001398

14011399
// Authorization
1402-
if (!AuthzResolver.authorizedInternal(sess, "removeBan_int_policy", Arrays.asList(ban, facility))) {
1400+
if (!AuthzResolver.authorizedInternal(sess, "removeBan_int_policy", Arrays.asList(banOnFacility, facility))) {
14031401
throw new PrivilegeException(sess, "removeBan");
14041402
}
14051403

14061404
getFacilitiesManagerBl().removeBan(sess, banId);
14071405
}
14081406

14091407
@Override
1410-
public void removeBan(PerunSession sess, int userId, int facilityId) throws BanNotExistsException, PrivilegeException {
1408+
public void removeBan(PerunSession sess, int userId, int facilityId) throws BanNotExistsException, PrivilegeException, FacilityNotExistsException {
14111409
Utils.checkPerunSession(sess);
1412-
BanOnFacility ban = this.getFacilitiesManagerBl().getBan(sess, userId, facilityId);
1413-
1414-
Facility facility = new Facility();
1415-
facility.setId(ban.getId());
1410+
BanOnFacility banOnFacility = this.getFacilitiesManagerBl().getBan(sess, userId, facilityId);
1411+
Facility facility = this.getFacilitiesManagerBl().getFacilityById(sess, banOnFacility.getFacilityId());
14161412

14171413
// Authorization
1418-
if (!AuthzResolver.authorizedInternal(sess, "removeBan_int_int_policy", Arrays.asList(ban, facility))) {
1414+
if (!AuthzResolver.authorizedInternal(sess, "removeBan_int_int_policy", Arrays.asList(banOnFacility, facility))) {
14191415
throw new PrivilegeException(sess, "removeBan");
14201416
}
14211417

0 commit comments

Comments
 (0)