public DocumentForSignatureValidator(
            IAlfrescoHttpClient alfrescoHttpClient,
            IIdentityUser identityUser,
            IAlfrescoConfiguration alfrescoConfiguration,
            ISimpleMemoryCache simpleMemoryCache,
            ISystemLoginService systemLoginService)
        {
            var adminHttpClient = new AlfrescoHttpClient(alfrescoConfiguration, new AdminAuthentification(simpleMemoryCache, alfrescoConfiguration, systemLoginService));

            RuleFor(o => o)
            .Cascade(CascadeMode.StopOnFirstFailure)
            .MustAsync(async(context, cancellationToken) =>
            {
                _nodeEntry = await alfrescoHttpClient.GetNodeInfo(context.NodeId, ImmutableList <Parameter> .Empty
                                                                  .Add(new Parameter(AlfrescoNames.Headers.Include, $"{AlfrescoNames.Includes.Path}", ParameterType.QueryString)));
                _groupPagingCurrentUser = await alfrescoHttpClient.GetPersonGroups(identityUser.Id);
                _groupPagingNextOwner   = await adminHttpClient.GetPersonGroups(context.Body.User);

                return(_nodeEntry?.Entry?.Id != null && _groupPagingCurrentUser != null && _groupPagingNextOwner != null);
            })
            .WithName(x => nameof(x.NodeId))
            .WithMessage("Something went wrong with alfresco server.")
            .DependentRules(() =>
            {
                RuleFor(x => x)
                .Must(y => _groupPagingCurrentUser?.List?.Entries?.Any(q => q.Entry.Id == identityUser.RequestGroup) ?? false)
                .WithName(x => "Group")
                .WithMessage($"User isn't member of group {identityUser.RequestGroup}.");

                RuleFor(x => x)
                .Must(y => _groupPagingNextOwner?.List?.Entries?.Any(q => q.Entry.Id == $"{y.Body.Group}_Sign") ?? false)
                .WithName(x => "Group")
                .WithMessage("User for signing isn't member of group with postfix _Sign.");

                RuleFor(x => x.NodeId)
                .Must(x => _nodeEntry?.Entry?.NodeType == SpisumNames.NodeTypes.Document)
                .WithMessage($"NodeId must be type of {SpisumNames.NodeTypes.Document}.");

                RuleFor(x => x)
                .Must(x => _nodeEntry?.Entry?.Path?.Name?.StartsWith(AlfrescoNames.Prefixes.Path + SpisumNames.Paths.Evidence, StringComparison.OrdinalIgnoreCase) == true)
                .OnAnyFailure(x => throw new BadRequestException("Document must be in evidence site."));

                RuleFor(x => x.NodeId)
                .Must(x => _nodeEntry.Entry.Path.Name.Equals(AlfrescoNames.Prefixes.Path + SpisumNames.Paths.EvidenceDocumentsForProcessing(identityUser.RequestGroup)) ||
                      _nodeEntry.Entry.Path.Name.Equals(AlfrescoNames.Prefixes.Path + SpisumNames.Paths.EvidenceFilesDocumentsForProcessing(identityUser.RequestGroup)))
                .WithMessage($"NodeId must be in path {SpisumNames.Paths.EvidenceDocumentsForProcessing(identityUser.RequestGroup)} or {SpisumNames.Paths.EvidenceFilesDocumentsForProcessing(identityUser.RequestGroup)}.");
            });

            RuleFor(x => x)
            .Must(x => !string.IsNullOrEmpty(x?.Body?.User))
            .When(x => x?.Body != null)
            .WithName(x => nameof(x.Body.User))
            .WithMessage("You have to fill user.");

            RuleFor(x => x)
            .Must(x => !string.IsNullOrEmpty(x?.Body?.Group))
            .When(x => x?.Body != null)
            .WithName(x => nameof(x.Body.Group))
            .WithMessage("You have to fill group.");
        }
Beispiel #2
0
 public SignerService(
     ISignerClient signerClient,
     ISimpleMemoryCache simpleMemoryCache,
     IAlfrescoConfiguration alfrescoConfiguration,
     IPersonService personService,
     IIdentityUser identityUser,
     IMapper mapper,
     ITransactionHistoryService transactionHistoryService,
     IAuditLogService auditLogService,
     IRepositoryService repositoryService,
     IAlfrescoHttpClient alfrescoHttpClient,
     IPdfService pdfService,
     ISystemLoginService systemLoginService
     )
 {
     _signerClient          = signerClient;
     _simpleMemoryCache     = simpleMemoryCache;
     _alfrescoConfiguration = alfrescoConfiguration;
     _personService         = personService;
     _identityUser          = identityUser;
     _mapper = mapper;
     _transactionHistoryService = transactionHistoryService;
     _auditLogService           = auditLogService;
     _repositoryService         = repositoryService;
     _alfrescoHttpClient        = alfrescoHttpClient;
     _pdfService         = pdfService;
     _systemLoginService = systemLoginService;
 }
 public InitialSiteService(
     IAlfrescoConfiguration alfrescoConfiguration,
     ISimpleMemoryCache simpleMemoryCache,
     ISystemLoginService systemLoginService)
 {
     _alfrescoHttpClient = new AlfrescoHttpClient(alfrescoConfiguration, new AdminAuthentification(simpleMemoryCache, alfrescoConfiguration, systemLoginService));
 }
Beispiel #4
0
 public CodeListsController(IAlfrescoConfiguration alfrescoConfiguration, IAlfrescoHttpClient alfrescoHttpClient, ISimpleMemoryCache simpleMemoryCache, INodesService nodesService)
 {
     _alfrescoConfig     = alfrescoConfiguration;
     _alfrescoHttpClient = alfrescoHttpClient;
     _simpleMemoryCache  = simpleMemoryCache;
     _nodesService       = nodesService;
 }
Beispiel #5
0
 public InitialChangeAdminPassword(
     IAlfrescoConfiguration alfrescoConfiguration,
     ISimpleMemoryCache simpleMemoryCache,
     ISystemLoginService systemLoginService)
 {
     _systemLoginService    = systemLoginService;
     _alfrescoConfiguration = alfrescoConfiguration;
 }
Beispiel #6
0
 public PathsController(
     IAlfrescoConfiguration alfrescoConfiguration,
     ISimpleMemoryCache simpleMemoryCache,
     ISystemLoginService systemLoginService
     )
 {
     _alfrescoConfig     = alfrescoConfiguration;
     _alfrescoHttpClient = new AlfrescoHttpClient(alfrescoConfiguration, new AdminAuthentification(simpleMemoryCache, alfrescoConfiguration, systemLoginService));
     _simpleMemoryCache  = simpleMemoryCache;
 }
Beispiel #7
0
 public SignerAppController(
     ISimpleMemoryCache simpleMemoryCache,
     IApiConfiguration apiConfiguration,
     ISignerService signerService
     )
 {
     _simpleMemoryCache = simpleMemoryCache;
     _apiConfiguration  = apiConfiguration;
     _signerService     = signerService;
 }
 public InitialGroups(
     IAlfrescoConfiguration alfrescoConfiguration,
     IInitialGroupService initialGroup,
     ISimpleMemoryCache simpleMemoryCache,
     ISystemLoginService systemLoginService
     )
 {
     _alfrescoHttpClient = new AlfrescoHttpClient(alfrescoConfiguration, new AdminAuthentification(simpleMemoryCache, alfrescoConfiguration, systemLoginService));
     _alfrescoConfig     = alfrescoConfiguration;
     _initialGroup       = initialGroup;
 }
Beispiel #9
0
 public AuthenticationController(
     IAlfrescoHttpClient alfrescoHttpClient,
     IAuthorizationService authorizationService,
     IIdentityUser identityUser,
     ISimpleMemoryCache simpleMemoryCache
     )
 {
     _alfrescoHttpClient   = alfrescoHttpClient;
     _authorizationService = authorizationService;
     _identityUser         = identityUser;
     _simpleMemoryCache    = simpleMemoryCache;
 }
 public SignerController(
     ISimpleMemoryCache simpleMemoryCache,
     IApiConfiguration apiConfiguration,
     IAlfrescoHttpClient alfrescoHttpClient,
     ISignerService signerService
     )
 {
     _simpleMemoryCache  = simpleMemoryCache;
     _apiConfiguration   = apiConfiguration;
     _alfrescoHttpClient = alfrescoHttpClient;
     _signerService      = signerService;
 }
 public AlfrescoAuthenticationHandler(
     IOptionsMonitor <AlfrescoAuthenticationOptions> options,
     ILoggerFactory logger,
     UrlEncoder encoder,
     ISystemClock clock,
     ISimpleMemoryCache simpleMemoryCache,
     IAlfrescoHttpClient alfrescoHttpClient,
     IMapper mapper,
     IAlfrescoConfiguration alfrescoConfiguration) : base(options, logger, encoder, clock)
 {
     _simpleMemoryCache     = simpleMemoryCache;
     _alfrescoHttpClient    = alfrescoHttpClient;
     _mapper                = mapper;
     _alfrescoConfiguration = alfrescoConfiguration;
 }
Beispiel #12
0
 public InitialUserService(IAlfrescoConfiguration alfrescoConfiguration, ISimpleMemoryCache simpleMemoryCache, ISystemLoginService systemLoginService) =>
 public TranslateService(ISimpleMemoryCache simpleMemoryCache) =>
        public DocumentBorrowValidator(IAlfrescoHttpClient alfrescoHttpClient,
                                       IIdentityUser identityUser,
                                       IAlfrescoConfiguration alfrescoConfiguration,
                                       ISimpleMemoryCache simpleMemoryCache,
                                       ISystemLoginService systemLoginService)
        {
            var adminHttpClient = new AlfrescoHttpClient(alfrescoConfiguration, new AdminAuthentification(simpleMemoryCache, alfrescoConfiguration, systemLoginService));

            _identityUser = identityUser;

            RuleFor(o => o)
            .Cascade(CascadeMode.StopOnFirstFailure)
            .MustAsync(async(context, cancellationToken) =>
            {
                _nodeEntry = await alfrescoHttpClient.GetNodeInfo(context.NodeId, ImmutableList <Parameter> .Empty
                                                                  .Add(new Parameter(AlfrescoNames.Headers.Include, AlfrescoNames.Includes.Path, ParameterType.QueryString)));

                var documentProperties = _nodeEntry?.Entry?.Properties?.As <JObject>().ToDictionary();
                _borrowedUser          = documentProperties.GetNestedValueOrDefault(SpisumNames.Properties.Borrower)?.ToString();

                _groupPaging = await alfrescoHttpClient.GetPersonGroups(identityUser.Id);

                _groupRepository = await alfrescoHttpClient.GetGroupMembers(SpisumNames.Groups.RepositoryGroup,
                                                                            ImmutableList <Parameter> .Empty.Add(new Parameter(AlfrescoNames.Headers.Where, AlfrescoNames.MemberType.Group, ParameterType.QueryString)));

                _groupPagingNextOwner = await adminHttpClient.GetPersonGroups(context.Body.User);

                return(_nodeEntry?.Entry?.Id != null && _groupPaging != null && _groupPagingNextOwner != null && _groupRepository != null);
            })
            .WithName(x => nameof(x.NodeId))
            .WithMessage("Something went wrong with alfresco server.")
            .DependentRules(() =>
            {
                RuleFor(x => x)
                .Must(y =>
                {
                    return(_groupPagingNextOwner?.List?.Entries?.Any(q => q.Entry.Id == y.Body.Group) ?? false);
                })
                .WithName(x => "User")
                .WithMessage("User isn't member of the Group.");

                RuleFor(x => x)
                .Must(y =>
                {
                    return(_groupRepository?.List?.Entries?.Any(x => x.Entry.Id == identityUser.RequestGroup) ?? false);
                })
                .WithName(x => "User")
                .WithMessage("User isn't member of repository group");

                RuleFor(x => x)
                .Must(y => _groupPaging?.List?.Entries?.Any(q => q.Entry.Id == identityUser.RequestGroup) ?? false)
                .WithName(x => "Group")
                .WithMessage($"User isn't member of group {identityUser.RequestGroup}.");

                RuleFor(x => x.NodeId)
                .Must(x => _nodeEntry.Entry.NodeType == SpisumNames.NodeTypes.Document)
                .WithMessage($"NodeId must be type of {SpisumNames.NodeTypes.Document}.");

                RuleFor(x => x)
                .Must(x => _nodeEntry?.Entry?.Path?.Name?.StartsWith(AlfrescoNames.Prefixes.Path + SpisumNames.Paths.RepositoryDocuments, StringComparison.OrdinalIgnoreCase) == true)
                .OnAnyFailure(x => throw new BadRequestException("Document must be in repository site."));

                RuleFor(x => x)
                .Must(x => string.IsNullOrWhiteSpace(_borrowedUser))
                .WithMessage("Document is already borrowed");
            });
        }
Beispiel #15
0
 public SignerAuthentification(ISimpleMemoryCache simpleMemoryCache, string token)
 {
     _simpleMemoryCache = simpleMemoryCache;
     _token             = token;
 }
Beispiel #16
0
        public DocumentOwnerHandOverValidator(
            IAlfrescoHttpClient alfrescoHttpClient,
            IIdentityUser identityUser,
            IAlfrescoConfiguration alfrescoConfiguration,
            ISimpleMemoryCache simpleMemoryCache,
            ISystemLoginService systemLoginService)
        {
            var adminHttpClient = new AlfrescoHttpClient(alfrescoConfiguration, new AdminAuthentification(simpleMemoryCache, alfrescoConfiguration, systemLoginService));

            _identityUser = identityUser;

            RuleFor(o => o)
            .Cascade(CascadeMode.StopOnFirstFailure)
            .MustAsync(async(context, cancellationToken) =>
            {
                _nodeEntry = await alfrescoHttpClient.GetNodeInfo(context.NodeId, ImmutableList <Parameter> .Empty
                                                                  .Add(new Parameter(AlfrescoNames.Headers.Include, $"{AlfrescoNames.Includes.Properties},{AlfrescoNames.Includes.Permissions},{AlfrescoNames.Includes.Path}", ParameterType.QueryString)));
                _groupPagingCurrentUser = await alfrescoHttpClient.GetPersonGroups(identityUser.Id);

                if (context?.Body?.NextOwner != null)
                {
                    _groupPagingNextOwner = await adminHttpClient.GetPersonGroups(context.Body.NextOwner);
                }

                return(_nodeEntry?.Entry?.Id != null && _groupPagingCurrentUser != null);
            })
            .WithName(x => nameof(x.NodeId))
            .WithMessage("Something went wrong with alfresco server.")
            .DependentRules(() =>
            {
                RuleFor(x => x)
                .Must(y =>
                {
                    if (y?.Body?.NextOwner == null)
                    {
                        return(true);
                    }
                    return(_groupPagingNextOwner?.List?.Entries?.Any(q => q.Entry.Id == y.Body.NextGroup) ?? false);
                })
                .WithName(x => "Group")
                .WithMessage("NextOwner isn't member of group NextGroup.");

                RuleFor(x => x)
                .Must(y => _groupPagingCurrentUser?.List?.Entries?.Any(q => q.Entry.Id == identityUser.RequestGroup) ?? false)
                .WithName(x => "Group")
                .WithMessage($"User isn't member of group {identityUser.RequestGroup}.");

                RuleFor(x => x)
                .Must(x => _nodeEntry?.Entry?.Path?.Name?.StartsWith(AlfrescoNames.Prefixes.Path + SpisumNames.Paths.Evidence, StringComparison.OrdinalIgnoreCase) == true)
                .OnAnyFailure(x => throw new BadRequestException("Document must be in evidence site."));

                RuleFor(x => x.NodeId)
                .Must(x => _nodeEntry?.Entry?.NodeType == SpisumNames.NodeTypes.Document || _nodeEntry?.Entry?.NodeType == SpisumNames.NodeTypes.File || _nodeEntry?.Entry?.NodeType == SpisumNames.NodeTypes.Concept)
                .WithMessage($"NodeId must be type of {SpisumNames.NodeTypes.Document} or {SpisumNames.NodeTypes.File} or {SpisumNames.NodeTypes.Concept}");

                RuleFor(x => x.NodeId)
                .Must(HasAction)
                .WithName(x => nameof(x.NodeId))
                .WithMessage("NodeIs is being handled to different owner. You have cancel it first.");

                RuleFor(x => x.NodeId)
                .Must(CanUserMakeAction)
                .WithMessage("User has no access to this action.");
            });

            RuleFor(x => x)
            .Must(x => !string.IsNullOrEmpty(x?.Body?.NextOwner) || !string.IsNullOrEmpty(x?.Body?.NextGroup))
            .WithName(x => nameof(x.Body.NextOwner))
            .WithMessage("You have to fill nextGroup or nextOwner.");

            RuleFor(x => x)
            .Must(x => x?.Body?.NextOwner == null || !string.IsNullOrEmpty(x?.Body?.NextGroup))
            .WithName(x => nameof(x.Body.NextGroup))
            .WithMessage("You have to fill NextGroup.");
        }
 public PlayersController(IPlayerService playerService, ISimpleMemoryCache <TransactionResponse> transactionResponseMemoryCache)
 {
     _playerService = playerService;
     _transactionResponseMemoryCache = transactionResponseMemoryCache;
 }
 public AdminAuthentification(ISimpleMemoryCache simpleMemoryCache, IAlfrescoConfiguration alfrescoConfiguration, ISystemLoginService systemLoginService)
 {
     _simpleMemoryCache     = simpleMemoryCache;
     _alfrescoConfiguration = alfrescoConfiguration;
     _systemLoginService    = systemLoginService;
 }