use of cz.metacentrum.perun.core.api.BanOnVo in project perun by CESNET.
the class VosManagerEntry method getBanById.
@Override
public BanOnVo getBanById(PerunSession sess, int banId) throws BanNotExistsException, PrivilegeException {
Utils.checkPerunSession(sess);
BanOnVo ban = vosManagerBl.getBanById(sess, banId);
// Authorization
if (!AuthzResolver.authorizedInternal(sess, "vo-getBanById_int_policy", ban)) {
throw new PrivilegeException("getBanById");
}
return ban;
}
use of cz.metacentrum.perun.core.api.BanOnVo in project perun by CESNET.
the class VosManagerEntry method getBansForVo.
@Override
public List<BanOnVo> getBansForVo(PerunSession sess, int voId) throws PrivilegeException, VoNotExistsException {
Utils.checkPerunSession(sess);
Vo vo = vosManagerBl.getVoById(sess, voId);
// Authorization
if (!AuthzResolver.authorizedInternal(sess, "getBansForVo_int_policy", vo)) {
throw new PrivilegeException("getBansForVo");
}
return vosManagerBl.getBansForVo(sess, voId);
}
use of cz.metacentrum.perun.core.api.BanOnVo in project perun by CESNET.
the class VosManagerEntry method removeBan.
@Override
public void removeBan(PerunSession sess, int banId) throws PrivilegeException, BanNotExistsException {
Utils.checkPerunSession(sess);
BanOnVo banOnVo = perunBl.getVosManagerBl().getBanById(sess, banId);
// Authorization
if (!AuthzResolver.authorizedInternal(sess, "vo-removeBan_int_policy", banOnVo)) {
throw new PrivilegeException("removeBan");
}
vosManagerBl.removeBan(sess, banId);
}
use of cz.metacentrum.perun.core.api.BanOnVo in project perun by CESNET.
the class MembersManagerBlImpl method moveMembersBans.
/**
* Moves bans on resources and ban on VO from source member to target member.
*
* @param sess
* @param sourceMember member to move bans from
* @param targetMember member to move bans to
*/
private void moveMembersBans(PerunSession sess, Member sourceMember, Member targetMember) {
// move members bans on resources
List<BanOnResource> bansOnResources = getPerunBl().getResourcesManagerBl().getBansForMember(sess, sourceMember.getId());
for (BanOnResource banOnResource : bansOnResources) {
try {
banOnResource.setMemberId(targetMember.getId());
getPerunBl().getResourcesManagerBl().setBan(sess, banOnResource);
} catch (BanAlreadyExistsException e) {
log.warn("Moving ban on resource {} from source member {} to target member {}, but the target member" + " already has ban on the resource.", banOnResource, sourceMember, targetMember);
}
}
// move members ban on VO
Optional<BanOnVo> banOnVo = getPerunBl().getVosManagerBl().getBanForMember(sess, sourceMember.getId());
if (banOnVo.isPresent()) {
banOnVo.get().setMemberId(targetMember.getId());
try {
getPerunBl().getVosManagerBl().setBan(sess, banOnVo.get());
} catch (MemberNotExistsException e) {
throw new InternalErrorException(e);
}
}
}
use of cz.metacentrum.perun.core.api.BanOnVo in project perun by CESNET.
the class urn_perun_member_attribute_def_virt_isSuspended method getAttributeValue.
@Override
public Attribute getAttributeValue(PerunSessionImpl sess, Member member, AttributeDefinition attributeDefinition) {
Attribute attribute = new Attribute(attributeDefinition);
Optional<BanOnVo> ban = sess.getPerunBl().getVosManagerBl().getBanForMember(sess, member.getId());
if (!ban.isPresent()) {
attribute.setValue(false);
} else {
Date startOfToday = Date.from(LocalDate.now().atStartOfDay(ZoneId.systemDefault()).toInstant());
attribute.setValue(ban.get().getValidityTo().after(startOfToday));
}
return attribute;
}
Aggregations