Search in sources :

Example 1 with TRole

use of org.simbasecurity.api.service.thrift.TRole in project simba-os by cegeka.

the class GroupServiceImpl method removeRole.

@Override
public void removeRole(TGroup group, TRole role) throws TException {
    simbaExceptionHandlingCaller.call(() -> {
        Role attachedRole = roleRepository.refreshWithOptimisticLocking(role.getId(), role.getVersion());
        Group attachedGroup = groupRepository.refreshWithOptimisticLocking(group.getId(), group.getVersion());
        audit.log("Role ''{0}'' removed from group ''{1}''", attachedRole.getName(), attachedGroup.getName());
        attachedGroup.removeRole(attachedRole);
    });
}
Also used : TRole(org.simbasecurity.api.service.thrift.TRole) Role(org.simbasecurity.core.domain.Role) TGroup(org.simbasecurity.api.service.thrift.TGroup) Group(org.simbasecurity.core.domain.Group)

Example 2 with TRole

use of org.simbasecurity.api.service.thrift.TRole in project simba-os by cegeka.

the class GroupServiceImpl method addRoles.

@Override
public void addRoles(TGroup group, List<TRole> roles) throws TException {
    simbaExceptionHandlingCaller.call(() -> {
        Group attachedGroup = groupRepository.refreshWithOptimisticLocking(group.getId(), group.getVersion());
        Collection<Role> attachedRoles = roles.stream().map(r -> roleRepository.refreshWithOptimisticLocking(r.getId(), r.getVersion())).collect(Collectors.toList());
        audit.log("Roles ''{0}'' added to group ''{1}''", join(attachedRoles, Role::getName));
        attachedGroup.addRoles(attachedRoles);
    });
}
Also used : TRole(org.simbasecurity.api.service.thrift.TRole) Role(org.simbasecurity.core.domain.Role) TRole(org.simbasecurity.api.service.thrift.TRole) RoleRepository(org.simbasecurity.core.domain.repository.RoleRepository) Role(org.simbasecurity.core.domain.Role) TGroup(org.simbasecurity.api.service.thrift.TGroup) Group(org.simbasecurity.core.domain.Group) Collection(java.util.Collection) TException(org.apache.thrift.TException) Autowired(org.springframework.beans.factory.annotation.Autowired) SimbaExceptionHandlingCaller(org.simbasecurity.core.service.errors.SimbaExceptionHandlingCaller) Collectors(java.util.stream.Collectors) ManagementAudit(org.simbasecurity.core.audit.ManagementAudit) TUser(org.simbasecurity.api.service.thrift.TUser) GroupRepository(org.simbasecurity.core.domain.repository.GroupRepository) List(java.util.List) StringUtil.join(org.simbasecurity.common.util.StringUtil.join) Service(org.springframework.stereotype.Service) GroupService(org.simbasecurity.api.service.thrift.GroupService) ThriftAssembler(org.simbasecurity.core.service.thrift.ThriftAssembler) Transactional(org.springframework.transaction.annotation.Transactional) TGroup(org.simbasecurity.api.service.thrift.TGroup) Group(org.simbasecurity.core.domain.Group)

Example 3 with TRole

use of org.simbasecurity.api.service.thrift.TRole in project simba-os by cegeka.

the class PolicyServiceImpl method addRoles.

@Override
public void addRoles(TPolicy policy, Set<TRole> roles) throws TException {
    simbaExceptionHandlingCaller.call(() -> {
        Policy attachedPolicy = policyRepository.refreshWithOptimisticLocking(policy.getId(), policy.getVersion());
        Set<Role> attachedRoles = roles.stream().map(r -> roleRepository.refreshWithOptimisticLocking(r.getId(), r.getVersion())).collect(Collectors.toSet());
        audit.log("Roles ''{0}'' added to policy ''{1}''", join(attachedRoles, Role::getName), attachedPolicy.getName());
        attachedPolicy.addRoles(attachedRoles);
    });
}
Also used : TPolicy(org.simbasecurity.api.service.thrift.TPolicy) Policy(org.simbasecurity.core.domain.Policy) TRole(org.simbasecurity.api.service.thrift.TRole) Role(org.simbasecurity.core.domain.Role) PolicyRepository(org.simbasecurity.core.domain.repository.PolicyRepository) RoleRepository(org.simbasecurity.core.domain.repository.RoleRepository) Autowired(org.springframework.beans.factory.annotation.Autowired) PolicyEntity(org.simbasecurity.core.domain.PolicyEntity) SimbaExceptionHandlingCaller(org.simbasecurity.core.service.errors.SimbaExceptionHandlingCaller) EntityFilterService(org.simbasecurity.core.service.filter.EntityFilterService) StringUtil.join(org.simbasecurity.common.util.StringUtil.join) TPolicy(org.simbasecurity.api.service.thrift.TPolicy) Service(org.springframework.stereotype.Service) DTOValidator(org.simbasecurity.core.service.validation.DTOValidator) RuleRepository(org.simbasecurity.core.domain.repository.RuleRepository) ValidationException(org.owasp.esapi.errors.ValidationException) TRole(org.simbasecurity.api.service.thrift.TRole) Role(org.simbasecurity.core.domain.Role) TException(org.apache.thrift.TException) Set(java.util.Set) TRule(org.simbasecurity.api.service.thrift.TRule) Collectors(java.util.stream.Collectors) Rule(org.simbasecurity.core.domain.Rule) ManagementAudit(org.simbasecurity.core.audit.ManagementAudit) List(java.util.List) Policy(org.simbasecurity.core.domain.Policy) ThriftAssembler(org.simbasecurity.core.service.thrift.ThriftAssembler) PolicyService(org.simbasecurity.api.service.thrift.PolicyService) Transactional(org.springframework.transaction.annotation.Transactional)

Example 4 with TRole

use of org.simbasecurity.api.service.thrift.TRole in project simba-os by cegeka.

the class GroupServiceImpl method addRole.

@Override
public void addRole(TGroup group, TRole role) throws TException {
    simbaExceptionHandlingCaller.call(() -> {
        Role attachedRole = roleRepository.refreshWithOptimisticLocking(role.getId(), role.getVersion());
        Group attachedGroup = groupRepository.refreshWithOptimisticLocking(group.getId(), group.getVersion());
        audit.log("Role ''{0}'' added to group ''{1}''", attachedRole.getName(), attachedGroup.getName());
        attachedGroup.addRole(attachedRole);
    });
}
Also used : TRole(org.simbasecurity.api.service.thrift.TRole) Role(org.simbasecurity.core.domain.Role) TGroup(org.simbasecurity.api.service.thrift.TGroup) Group(org.simbasecurity.core.domain.Group)

Example 5 with TRole

use of org.simbasecurity.api.service.thrift.TRole in project simba-os by cegeka.

the class PolicyServiceImpl method removeRole.

@Override
public void removeRole(TPolicy policy, TRole role) throws TException {
    simbaExceptionHandlingCaller.call(() -> {
        Policy attachedPolicy = policyRepository.refreshWithOptimisticLocking(policy.getId(), policy.getVersion());
        Role attachedRole = roleRepository.refreshWithOptimisticLocking(role.getId(), role.getVersion());
        audit.log("Role ''{0}'' removed from policy ''{1}''", attachedRole.getName(), attachedPolicy.getName());
        attachedPolicy.removeRole(attachedRole);
    });
}
Also used : TPolicy(org.simbasecurity.api.service.thrift.TPolicy) Policy(org.simbasecurity.core.domain.Policy) TRole(org.simbasecurity.api.service.thrift.TRole) Role(org.simbasecurity.core.domain.Role)

Aggregations

TRole (org.simbasecurity.api.service.thrift.TRole)5 Role (org.simbasecurity.core.domain.Role)5 TGroup (org.simbasecurity.api.service.thrift.TGroup)3 Group (org.simbasecurity.core.domain.Group)3 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 TException (org.apache.thrift.TException)2 TPolicy (org.simbasecurity.api.service.thrift.TPolicy)2 StringUtil.join (org.simbasecurity.common.util.StringUtil.join)2 ManagementAudit (org.simbasecurity.core.audit.ManagementAudit)2 Policy (org.simbasecurity.core.domain.Policy)2 RoleRepository (org.simbasecurity.core.domain.repository.RoleRepository)2 SimbaExceptionHandlingCaller (org.simbasecurity.core.service.errors.SimbaExceptionHandlingCaller)2 ThriftAssembler (org.simbasecurity.core.service.thrift.ThriftAssembler)2 Autowired (org.springframework.beans.factory.annotation.Autowired)2 Service (org.springframework.stereotype.Service)2 Transactional (org.springframework.transaction.annotation.Transactional)2 Collection (java.util.Collection)1 Set (java.util.Set)1 ValidationException (org.owasp.esapi.errors.ValidationException)1