Search in sources :

Example 56 with PermissionKey

use of com.synopsys.integration.alert.common.persistence.model.PermissionKey in project hub-alert by blackducksoftware.

the class RoleActions method convertPermissionMatrixModel.

private Set<PermissionModel> convertPermissionMatrixModel(PermissionMatrixModel permissionMatrixModel) {
    Set<PermissionModel> permissionMatrix = new HashSet<>();
    for (Map.Entry<PermissionKey, Integer> matrixRow : permissionMatrixModel.getPermissions().entrySet()) {
        Integer accessOperations = matrixRow.getValue();
        PermissionKey permissionKey = matrixRow.getKey();
        String descriptorDisplayName = descriptorMap.getDescriptorKey(permissionKey.getDescriptorName()).map(DescriptorKey::getDisplayName).orElse(permissionKey.getDescriptorName());
        PermissionModel permissionModel = new PermissionModel(descriptorDisplayName, permissionKey.getContext(), BitwiseUtil.containsBits(accessOperations, AccessOperation.CREATE.getBit()), BitwiseUtil.containsBits(accessOperations, AccessOperation.READ.getBit()), BitwiseUtil.containsBits(accessOperations, AccessOperation.WRITE.getBit()), BitwiseUtil.containsBits(accessOperations, AccessOperation.DELETE.getBit()), BitwiseUtil.containsBits(accessOperations, AccessOperation.EXECUTE.getBit()), BitwiseUtil.containsBits(accessOperations, AccessOperation.UPLOAD_FILE_READ.getBit()), BitwiseUtil.containsBits(accessOperations, AccessOperation.UPLOAD_FILE_WRITE.getBit()), BitwiseUtil.containsBits(accessOperations, AccessOperation.UPLOAD_FILE_DELETE.getBit()));
        permissionMatrix.add(permissionModel);
    }
    return permissionMatrix;
}
Also used : PermissionKey(com.synopsys.integration.alert.common.persistence.model.PermissionKey) DescriptorMap(com.synopsys.integration.alert.common.descriptor.DescriptorMap) Map(java.util.Map) HashSet(java.util.HashSet)

Aggregations

PermissionKey (com.synopsys.integration.alert.common.persistence.model.PermissionKey)56 PermissionMatrixModel (com.synopsys.integration.alert.common.persistence.model.PermissionMatrixModel)49 AuthenticationTestUtils (com.synopsys.integration.alert.test.common.AuthenticationTestUtils)43 DescriptorKey (com.synopsys.integration.alert.descriptor.api.model.DescriptorKey)42 Test (org.junit.jupiter.api.Test)38 AuthorizationManager (com.synopsys.integration.alert.common.security.authorization.AuthorizationManager)35 ChannelKey (com.synopsys.integration.alert.descriptor.api.model.ChannelKey)23 ActionResponse (com.synopsys.integration.alert.common.action.ActionResponse)16 EmailGlobalConfigurationValidator (com.synopsys.integration.alert.channel.email.validator.EmailGlobalConfigurationValidator)12 EmailGlobalConfigModel (com.synopsys.integration.alert.service.email.model.EmailGlobalConfigModel)12 EmailGlobalConfigAccessor (com.synopsys.integration.alert.channel.email.database.accessor.EmailGlobalConfigAccessor)10 ValidationActionResponse (com.synopsys.integration.alert.common.action.ValidationActionResponse)9 ValidationResponseModel (com.synopsys.integration.alert.common.rest.model.ValidationResponseModel)6 PermissionMatrixRelation (com.synopsys.integration.alert.database.authorization.PermissionMatrixRelation)5 ConfigContextEntity (com.synopsys.integration.alert.database.configuration.ConfigContextEntity)5 RegisteredDescriptorEntity (com.synopsys.integration.alert.database.configuration.RegisteredDescriptorEntity)5 HashMap (java.util.HashMap)4 UUID (java.util.UUID)4 RoleEntity (com.synopsys.integration.alert.database.user.RoleEntity)3 Map (java.util.Map)3