Search in sources :

Example 6 with SecurityGroup

use of com.sequenceiq.cloudbreak.domain.SecurityGroup in project cloudbreak by hortonworks.

the class SecurityGroupController method convert.

private SecurityGroup convert(SecurityGroupRequest securityGroupRequest, boolean publicInAccount) {
    SecurityGroup securityGroup = conversionService.convert(securityGroupRequest, SecurityGroup.class);
    securityGroup.setPublicInAccount(publicInAccount);
    return securityGroup;
}
Also used : SecurityGroup(com.sequenceiq.cloudbreak.domain.SecurityGroup)

Example 7 with SecurityGroup

use of com.sequenceiq.cloudbreak.domain.SecurityGroup in project cloudbreak by hortonworks.

the class SecurityGroupController method createSecurityGroup.

private SecurityGroupResponse createSecurityGroup(IdentityUser user, SecurityGroupRequest securityGroupRequest, boolean publicInAccount) {
    SecurityGroup securityGroup = convert(securityGroupRequest, publicInAccount);
    securityGroup = securityGroupService.create(user, securityGroup);
    notify(user, ResourceEvent.SECURITY_GROUP_CREATED);
    return conversionService.convert(securityGroup, SecurityGroupResponse.class);
}
Also used : SecurityGroup(com.sequenceiq.cloudbreak.domain.SecurityGroup)

Example 8 with SecurityGroup

use of com.sequenceiq.cloudbreak.domain.SecurityGroup in project cloudbreak by hortonworks.

the class DefaultSecurityGroupCreator method createSecurityGroup.

private SecurityGroup createSecurityGroup(IdentityUser user, String platform, String name, String description) {
    SecurityGroup securityGroup = new SecurityGroup();
    securityGroup.setName(name);
    securityGroup.setOwner(user.getUserId());
    securityGroup.setAccount(user.getAccount());
    securityGroup.setDescription(description);
    securityGroup.setPublicInAccount(true);
    securityGroup.setCloudPlatform(platform);
    securityGroup.setStatus(ResourceStatus.DEFAULT);
    return securityGroup;
}
Also used : SecurityGroup(com.sequenceiq.cloudbreak.domain.SecurityGroup)

Example 9 with SecurityGroup

use of com.sequenceiq.cloudbreak.domain.SecurityGroup in project cloudbreak by hortonworks.

the class DefaultSecurityGroupCreator method addSecurityGroup.

private void addSecurityGroup(IdentityUser user, String platform, String name, Iterable<Port> securityGroupPorts, String securityGroupDesc) {
    SecurityGroup onlySshAndSsl = createSecurityGroup(user, platform, name, securityGroupDesc);
    SecurityRule sshAndSslRule = createSecurityRule(concatenatePorts(securityGroupPorts), onlySshAndSsl);
    onlySshAndSsl.setSecurityRules(new HashSet<>(Collections.singletonList(sshAndSslRule)));
    securityGroupService.create(user, onlySshAndSsl);
}
Also used : SecurityRule(com.sequenceiq.cloudbreak.domain.SecurityRule) SecurityGroup(com.sequenceiq.cloudbreak.domain.SecurityGroup)

Example 10 with SecurityGroup

use of com.sequenceiq.cloudbreak.domain.SecurityGroup in project cloudbreak by hortonworks.

the class SecurityGroupService method get.

public SecurityGroup get(Long id) {
    SecurityGroup securityGroup = groupRepository.findById(id);
    if (securityGroup == null) {
        throw new NotFoundException(String.format("SecurityGroup '%s' not found", id));
    }
    authorizationService.hasReadPermission(securityGroup);
    return securityGroup;
}
Also used : NotFoundException(com.sequenceiq.cloudbreak.controller.NotFoundException) SecurityGroup(com.sequenceiq.cloudbreak.domain.SecurityGroup)

Aggregations

SecurityGroup (com.sequenceiq.cloudbreak.domain.SecurityGroup)16 IdentityUser (com.sequenceiq.cloudbreak.common.model.user.IdentityUser)4 NotFoundException (com.sequenceiq.cloudbreak.controller.NotFoundException)2 InstanceGroup (com.sequenceiq.cloudbreak.domain.InstanceGroup)2 SecurityRule (com.sequenceiq.cloudbreak.domain.SecurityRule)2 Template (com.sequenceiq.cloudbreak.domain.Template)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 InstanceGroupParameterResponse (com.sequenceiq.cloudbreak.cloud.model.InstanceGroupParameterResponse)1 Json (com.sequenceiq.cloudbreak.domain.json.Json)1 Test (org.junit.Test)1 TypeDescriptor (org.springframework.core.convert.TypeDescriptor)1 AccessDeniedException (org.springframework.security.access.AccessDeniedException)1