Search in sources :

Example 1 with HasArachnePermissions

use of com.odysseusinc.arachne.portal.security.HasArachnePermissions in project ArachneCentralAPI by OHDSI.

the class ArachnePermissionEvaluator method addPermissions.

public boolean addPermissions(ArachneUser user, HasArachnePermissions hasPermissionsObj) {
    Set<ArachnePermission> allPermissions = getAllPermissions(hasPermissionsObj, user);
    hasPermissionsObj.setPermissions(allPermissions);
    if (hasPermissionsObj instanceof Analysis) {
        final Analysis analysis = (Analysis) hasPermissionsObj;
        final List<SubmissionGroup> submissionGroups = analysis.getSubmissionGroups();
        if (!CollectionUtils.isEmpty(submissionGroups)) {
            submissionGroups.forEach(submissionGroup -> submissionGroup.getSubmissions().forEach(submission -> {
                final Set<ArachnePermission> submissionPermissions = getAllPermissions(submission, user);
                submission.setPermissions(submissionPermissions);
            }));
        }
        final List<AnalysisFile> files = analysis.getFiles();
        if (!CollectionUtils.isEmpty(files)) {
            files.forEach(file -> {
                final Set<ArachnePermission> filePermissions = getAllPermissions(file, user);
                file.setPermissions(filePermissions);
            });
        }
    }
    return true;
}
Also used : Arrays(java.util.Arrays) DomainObjectLoaderFactory(com.odysseusinc.arachne.portal.service.domain.DomainObjectLoaderFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) HashMap(java.util.HashMap) PermissionDsl.domainObject(com.odysseusinc.arachne.portal.component.PermissionDsl.domainObject) Submission(com.odysseusinc.arachne.portal.model.Submission) Paper(com.odysseusinc.arachne.portal.model.Paper) HashSet(java.util.HashSet) DataSource(com.odysseusinc.arachne.portal.model.DataSource) IDataSource(com.odysseusinc.arachne.portal.model.IDataSource) BaseArachneSecureService(com.odysseusinc.arachne.portal.service.BaseArachneSecureService) ParticipantRole(com.odysseusinc.arachne.portal.model.ParticipantRole) ObjectUtils(org.apache.commons.lang3.ObjectUtils) Analysis(com.odysseusinc.arachne.portal.model.Analysis) Map(java.util.Map) ArachneUser(com.odysseusinc.arachne.portal.model.security.ArachneUser) DELETE_ANALYSIS_FILES(com.odysseusinc.arachne.portal.security.ArachnePermission.DELETE_ANALYSIS_FILES) SubmissionInsight(com.odysseusinc.arachne.portal.model.SubmissionInsight) LinkedList(java.util.LinkedList) PermissionDslPredicates.analysisAuthorIs(com.odysseusinc.arachne.portal.component.PermissionDslPredicates.analysisAuthorIs) HasArachnePermissions(com.odysseusinc.arachne.portal.security.HasArachnePermissions) User(com.odysseusinc.arachne.portal.model.User) CommentTopic(com.odysseusinc.arachne.portal.model.CommentTopic) PermissionDslPredicates.analysisFileAuthorIs(com.odysseusinc.arachne.portal.component.PermissionDslPredicates.analysisFileAuthorIs) PublishState(com.odysseusinc.arachne.portal.model.PublishState) UserStudyGrouped(com.odysseusinc.arachne.portal.model.UserStudyGrouped) Set(java.util.Set) DELETE_DATASOURCE(com.odysseusinc.arachne.portal.security.ArachnePermission.DELETE_DATASOURCE) Page(org.springframework.data.domain.Page) PermissionEvaluator(org.springframework.security.access.PermissionEvaluator) Serializable(java.io.Serializable) Objects(java.util.Objects) AnalysisFile(com.odysseusinc.arachne.portal.model.AnalysisFile) List(java.util.List) Component(org.springframework.stereotype.Component) RawDataSource(com.odysseusinc.arachne.portal.model.RawDataSource) CollectionUtils(org.springframework.util.CollectionUtils) PermissionDslPredicates.userIsLeadInvestigator(com.odysseusinc.arachne.portal.component.PermissionDslPredicates.userIsLeadInvestigator) DataNode(com.odysseusinc.arachne.portal.model.DataNode) PermissionDslPredicates.hasRole(com.odysseusinc.arachne.portal.component.PermissionDslPredicates.hasRole) PermissionDslPredicates.instanceOf(com.odysseusinc.arachne.portal.component.PermissionDslPredicates.instanceOf) Authentication(org.springframework.security.core.Authentication) SubmissionGroup(com.odysseusinc.arachne.portal.model.SubmissionGroup) ArachnePermission(com.odysseusinc.arachne.portal.security.ArachnePermission) Collections(java.util.Collections) Study(com.odysseusinc.arachne.portal.model.Study) HashSet(java.util.HashSet) Set(java.util.Set) SubmissionGroup(com.odysseusinc.arachne.portal.model.SubmissionGroup) Analysis(com.odysseusinc.arachne.portal.model.Analysis) AnalysisFile(com.odysseusinc.arachne.portal.model.AnalysisFile) ArachnePermission(com.odysseusinc.arachne.portal.security.ArachnePermission)

Example 2 with HasArachnePermissions

use of com.odysseusinc.arachne.portal.security.HasArachnePermissions in project ArachneCentralAPI by OHDSI.

the class HasArachnePermissionsToPermissionDTOConverter method convert.

@Override
public PermissionsDTO convert(HasArachnePermissions hasArachnePermissions) {
    PermissionsDTO permissionsDTO = new PermissionsDTO();
    Set<ArachnePermission> permissions = hasArachnePermissions.getPermissions();
    if (permissions != null) {
        Arrays.stream(ArachnePermission.values()).filter(arachnePermission -> Stream.of(arachnePermission.getApplicableClass()).anyMatch(clazz -> clazz.isAssignableFrom(hasArachnePermissions.getClass()))).forEach(ap -> permissionsDTO.put(ap, permissions.contains(ap)));
    }
    return permissionsDTO;
}
Also used : Arrays(java.util.Arrays) Component(org.springframework.stereotype.Component) Stream(java.util.stream.Stream) Set(java.util.Set) BaseConversionServiceAwareConverter(com.odysseusinc.arachne.portal.api.v1.dto.converters.BaseConversionServiceAwareConverter) PermissionsDTO(com.odysseusinc.arachne.portal.api.v1.dto.PermissionsDTO) ArachnePermission(com.odysseusinc.arachne.portal.security.ArachnePermission) HasArachnePermissions(com.odysseusinc.arachne.portal.security.HasArachnePermissions) PermissionsDTO(com.odysseusinc.arachne.portal.api.v1.dto.PermissionsDTO) ArachnePermission(com.odysseusinc.arachne.portal.security.ArachnePermission)

Aggregations

ArachnePermission (com.odysseusinc.arachne.portal.security.ArachnePermission)2 HasArachnePermissions (com.odysseusinc.arachne.portal.security.HasArachnePermissions)2 Arrays (java.util.Arrays)2 Set (java.util.Set)2 PermissionsDTO (com.odysseusinc.arachne.portal.api.v1.dto.PermissionsDTO)1 BaseConversionServiceAwareConverter (com.odysseusinc.arachne.portal.api.v1.dto.converters.BaseConversionServiceAwareConverter)1 PermissionDsl.domainObject (com.odysseusinc.arachne.portal.component.PermissionDsl.domainObject)1 PermissionDslPredicates.analysisAuthorIs (com.odysseusinc.arachne.portal.component.PermissionDslPredicates.analysisAuthorIs)1 PermissionDslPredicates.analysisFileAuthorIs (com.odysseusinc.arachne.portal.component.PermissionDslPredicates.analysisFileAuthorIs)1 PermissionDslPredicates.hasRole (com.odysseusinc.arachne.portal.component.PermissionDslPredicates.hasRole)1 PermissionDslPredicates.instanceOf (com.odysseusinc.arachne.portal.component.PermissionDslPredicates.instanceOf)1 PermissionDslPredicates.userIsLeadInvestigator (com.odysseusinc.arachne.portal.component.PermissionDslPredicates.userIsLeadInvestigator)1 Analysis (com.odysseusinc.arachne.portal.model.Analysis)1 AnalysisFile (com.odysseusinc.arachne.portal.model.AnalysisFile)1 CommentTopic (com.odysseusinc.arachne.portal.model.CommentTopic)1 DataNode (com.odysseusinc.arachne.portal.model.DataNode)1 DataSource (com.odysseusinc.arachne.portal.model.DataSource)1 IDataSource (com.odysseusinc.arachne.portal.model.IDataSource)1 Paper (com.odysseusinc.arachne.portal.model.Paper)1 ParticipantRole (com.odysseusinc.arachne.portal.model.ParticipantRole)1