Beispiel #1
0
        public TokenMethodProvider()
        {
            _createWorkflowToken = new GlobalMethod
            {
                Name   = "createWorkflowToken",
                Method = serviceProvider => (Func <string, string, int, string>)((workflowTypeId, activityId, days) =>
                {
                    var securityTokenService = serviceProvider.GetRequiredService <ISecurityTokenService>();

                    var payload = new WorkflowPayload(workflowTypeId, activityId);

                    if (days == 0)
                    {
                        days = HttpWorkflowController.NoExpiryTokenLifespan;
                    }

                    return(securityTokenService.CreateToken(payload, TimeSpan.FromDays(days)));
                })
            };
        }
        public TokenMethodProvider()
        {
            _createWorkflowToken = new GlobalMethod
            {
                Name   = "createWorkflowToken",
                Method = serviceProvider => (Func <string, string, string, string>)((workflowTypeId, activityId, lifetime) =>
                {
                    var securityTokenService = serviceProvider.GetRequiredService <ISecurityTokenService>();

                    var payload = new WorkflowPayload(workflowTypeId, activityId);
                    if (!TimeSpan.TryParse(lifetime, out var timespan))
                    {
                        timespan = TimeSpan.FromDays(7);
                    }

                    var token = securityTokenService.CreateToken(payload, timespan);
                    return(token);
                })
            };
        }