Search in sources :

Example 6 with ArachneUser

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

the class TokenUtils method validateToken.

public Boolean validateToken(String token, UserDetails userDetails) {
    String uuid = getUUIDFromToken(token);
    boolean result = false;
    if (!invalidatedTokens.containsKey(uuid)) {
        ArachneUser user = (ArachneUser) userDetails;
        final String username = getUsernameFromToken(token);
        final Date created = getCreatedDateFromToken(token);
        result = (username.equals(user.getUsername()) && !(isTokenExpired(token)) && !(isCreatedBeforeLastPasswordReset(created, user.getLastPasswordReset())));
    }
    return result;
}
Also used : ArachneUser(com.odysseusinc.arachne.portal.model.security.ArachneUser) Date(java.util.Date)

Example 7 with ArachneUser

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

the class DataNodeToDataNodeDTOConverter method convert.

@Override
public DataNodeDTO convert(DataNode dataNode) {
    final DataNodeDTO dataNodeDTO = new DataNodeDTO();
    dataNodeDTO.setId(dataNode.getId());
    dataNodeDTO.setName(dataNode.getName());
    dataNodeDTO.setDescription(dataNode.getDescription());
    dataNodeDTO.setVirtual(dataNode.getVirtual());
    dataNodeDTO.setPublished(dataNode.getPublished());
    dataNodeDTO.setAtlasVerion(dataNode.getAtlasVersion());
    CommonHealthStatus healthStatus = dataNode.getHealthStatus();
    dataNodeDTO.setHealthStatus(healthStatus);
    dataNodeDTO.setHealthStatusTitle(healthStatus.toString());
    final Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    final Long loggedUserId = ((ArachneUser) principal).getId();
    final User loggedUser = new User();
    loggedUser.setId(loggedUserId);
    dataNodeDTO.setCurrentUserDataOwner(DataNodeUtils.isDataNodeOwner(dataNode, loggedUser));
    return dataNodeDTO;
}
Also used : CommonHealthStatus(com.odysseusinc.arachne.commons.api.v1.dto.CommonHealthStatus) ArachneUser(com.odysseusinc.arachne.portal.model.security.ArachneUser) User(com.odysseusinc.arachne.portal.model.User) DataNodeDTO(com.odysseusinc.arachne.portal.api.v1.dto.DataNodeDTO) ArachneUser(com.odysseusinc.arachne.portal.model.security.ArachneUser)

Example 8 with ArachneUser

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

the class BaseSubmissionToSubmissionDTOConverter method convert.

@Override
public DTO convert(T source) {
    DTO dto = super.convert(source);
    dto.setInsight(insightDTO(source.getSubmissionInsight()));
    final Status status = statusConverter(source.getStatus());
    final Boolean execConfirmed = status.isExecConfirmed();
    dto.setIsExecConfirmed(execConfirmed);
    final Boolean resultConfirmed = status.isResultConfirmed();
    dto.setIsResultConfirmed(resultConfirmed);
    dto.setAction(source.getStatus().toString());
    IDataSource dataSource = source.getDataSource();
    Long loggedUserId = ((ArachneUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal()).getId();
    final boolean isOwner = DataNodeUtils.isDataNodeOwner(dataSource.getDataNode(), loggedUserId);
    dto.setIsOwner(isOwner);
    return dto;
}
Also used : ArachneUser(com.odysseusinc.arachne.portal.model.security.ArachneUser) SubmissionInsightDTO(com.odysseusinc.arachne.portal.api.v1.dto.SubmissionInsightDTO) SubmissionDTO(com.odysseusinc.arachne.portal.api.v1.dto.SubmissionDTO) IDataSource(com.odysseusinc.arachne.portal.model.IDataSource)

Aggregations

ArachneUser (com.odysseusinc.arachne.portal.model.security.ArachneUser)8 PermissionDsl.domainObject (com.odysseusinc.arachne.portal.component.PermissionDsl.domainObject)2 IDataSource (com.odysseusinc.arachne.portal.model.IDataSource)2 User (com.odysseusinc.arachne.portal.model.User)2 ArachnePermission (com.odysseusinc.arachne.portal.security.ArachnePermission)2 LinkedList (java.util.LinkedList)2 List (java.util.List)2 Map (java.util.Map)2 Authentication (org.springframework.security.core.Authentication)2 Gson (com.google.gson.Gson)1 JsonObject (com.google.gson.JsonObject)1 CommonHealthStatus (com.odysseusinc.arachne.commons.api.v1.dto.CommonHealthStatus)1 JsonResult (com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult)1 DataNodeDTO (com.odysseusinc.arachne.portal.api.v1.dto.DataNodeDTO)1 SubmissionDTO (com.odysseusinc.arachne.portal.api.v1.dto.SubmissionDTO)1 SubmissionInsightDTO (com.odysseusinc.arachne.portal.api.v1.dto.SubmissionInsightDTO)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