use of cz.metacentrum.perun.core.api.SecurityTeam in project perun by CESNET.
the class SecurityTeamsManagerEntryIntegrationTest method testGetAdminsWithoutSecurityTeam.
@Test(expected = SecurityTeamNotExistsException.class)
public void testGetAdminsWithoutSecurityTeam() throws Exception {
System.out.println(CLASS_NAME + "testGetAdminsWithoutSecurityTeam");
SecurityTeam st = new SecurityTeam(0, "Name", "Desc");
securityTeamsManagerEntry.getAdmins(sess, st);
}
use of cz.metacentrum.perun.core.api.SecurityTeam in project perun by CESNET.
the class SecurityTeamsManagerEntryIntegrationTest method testGetBlacklistBySecurityTeamSecurityTeamNotExists.
@Test(expected = SecurityTeamNotExistsException.class)
public void testGetBlacklistBySecurityTeamSecurityTeamNotExists() throws Exception {
System.out.println(CLASS_NAME + "testGetBlacklistBySecurityTeamSecurityTeamNotExists");
setUpSecurityTeams();
setUpUsers();
setUpFacilities();
setUpBlacklists();
SecurityTeam st = new SecurityTeam(0, "Security0", "Description test 0");
securityTeamsManagerEntry.getBlacklist(sess, st);
}
use of cz.metacentrum.perun.core.api.SecurityTeam in project perun by CESNET.
the class SecurityTeamsManagerEntryIntegrationTest method testGetSecurityTeamsSecurityAdmin.
@Test
public void testGetSecurityTeamsSecurityAdmin() throws Exception {
System.out.println(CLASS_NAME + "testGetSecurityTeamsSecurityAdmin");
AuthzRoles roles = sess.getPerunPrincipal().getRoles();
try {
setUpSecurityTeams();
setUpUsers();
List<SecurityTeam> expected = new ArrayList<>();
expected.add(st0);
sess.getPerunPrincipal().setRoles(new AuthzRoles(Role.SECURITYADMIN, st0));
List<SecurityTeam> actual = securityTeamsManagerEntry.getSecurityTeams(sess);
assertEquals(expected, actual);
} finally {
sess.getPerunPrincipal().setRoles(roles);
}
}
use of cz.metacentrum.perun.core.api.SecurityTeam in project perun by CESNET.
the class SecurityTeamsManagerEntry method updateSecurityTeam.
@Override
public SecurityTeam updateSecurityTeam(PerunSession sess, SecurityTeam securityTeam) throws InternalErrorException, PrivilegeException, SecurityTeamNotExistsException, SecurityTeamExistsException {
Utils.checkPerunSession(sess);
Utils.notNull(securityTeam, "securityTeam");
Utils.notNull(securityTeam.getName(), "securityTeam.name");
if (!AuthzResolver.isAuthorized(sess, Role.SECURITYADMIN, securityTeam)) {
throw new PrivilegeException(sess, "updateSecurityTeam");
}
if (securityTeam.getName().length() > 128) {
throw new InternalErrorException("Security Team name is too long, >128 characters");
}
if (!securityTeam.getName().matches("^[-_a-zA-z0-9.]{1,128}$")) {
throw new InternalErrorException("Wrong Security name - must matches [-_a-zA-z0-9.]+ and not be longer than 128 characters.");
}
getSecurityTeamsManagerBl().checkSecurityTeamExists(sess, securityTeam);
try {
SecurityTeam existingTeam = getSecurityTeamsManagerBl().getSecurityTeamByName(sess, securityTeam.getName());
if (existingTeam != null && existingTeam.getId() != securityTeam.getId()) {
throw new SecurityTeamExistsException("SecurityTeam with name='" + securityTeam.getName() + "' already exists.");
}
} catch (SecurityTeamNotExistsException ex) {
// OK since we are renaming security team to non-taken value
}
// don't store empty description
if (securityTeam.getDescription() != null && securityTeam.getDescription().trim().isEmpty()) {
securityTeam.setDescription(null);
}
return getSecurityTeamsManagerBl().updateSecurityTeam(sess, securityTeam);
}
use of cz.metacentrum.perun.core.api.SecurityTeam in project perun by CESNET.
the class FacilitiesManagerBlImpl method deleteFacility.
public void deleteFacility(PerunSession sess, Facility facility) throws InternalErrorException, RelationExistsException, FacilityAlreadyRemovedException, HostAlreadyRemovedException, GroupAlreadyRemovedException, ResourceAlreadyRemovedException, GroupAlreadyRemovedFromResourceException {
if (getFacilitiesManagerImpl().getAssignedResources(sess, facility).size() > 0) {
throw new RelationExistsException("Facility is still used as a resource");
}
//remove hosts
List<Host> hosts = this.getHosts(sess, facility);
for (Host host : hosts) {
this.removeHost(sess, host);
}
//remove destinations
getPerunBl().getServicesManagerBl().removeAllDestinations(sess, facility);
// remove assigned security teams
List<SecurityTeam> teams = getAssignedSecurityTeams(sess, facility);
for (SecurityTeam team : teams) {
removeSecurityTeam(sess, facility, team);
}
// remove assigned facility contacts
List<ContactGroup> contacts = getFacilityContactGroups(sess, facility);
if (contacts != null && !contacts.isEmpty()) {
removeFacilityContacts(sess, contacts);
}
// remove associated attributes
try {
getPerunBl().getAttributesManagerBl().removeAllAttributes(sess, facility);
} catch (WrongAttributeValueException e) {
throw new InternalErrorException(e);
} catch (WrongReferenceAttributeValueException e) {
throw new InternalErrorException(e);
}
//Remove all facility bans
List<BanOnFacility> bansOnFacility = this.getBansForFacility(sess, facility.getId());
for (BanOnFacility banOnFacility : bansOnFacility) {
try {
this.removeBan(sess, banOnFacility.getId());
} catch (BanNotExistsException ex) {
//it is ok, we just want to remove it anyway
}
}
// delete facility
getFacilitiesManagerImpl().deleteFacilityOwners(sess, facility);
getFacilitiesManagerImpl().deleteFacility(sess, facility);
getPerunBl().getAuditer().log(sess, "Facility deleted {}.", facility);
}
Aggregations