public GetIncidentsByTicketCreateIfNeededRequest(
     string ticketId,
     AuthenticatedUserContext userContext
     ) : base(userContext)
 {
     TicketId = ticketId;
 }
Example #2
0
 public GetUncorrelatedEventsRequest(PaginationMetadata pagination,
                                     EventFilters filter,
                                     AuthenticatedUserContext userContext)
     : base(userContext)
 {
     Pagination = pagination;
     Filter     = filter;
 }
Example #3
0
 public GetEventsRequest(long incidentId,
                         PaginationMetadata pagination,
                         EventFilters filter,
                         AuthenticatedUserContext userContext)
     : base(userContext)
 {
     IncidentId = incidentId;
     Pagination = pagination;
     Filter     = filter;
 }
 public void Setup()
 {
     claimsIdentity = new ClaimsIdentity();
     claimsIdentity.AddClaim(new Claim(ClaimType.Permission, Permission));
     claimsIdentity.AddClaim(new Claim(ClaimType.Permission, "OtherPermission"));
     claimsIdentity.AddClaim(new Claim(ClaimType.Role, Role));
     claimsIdentity.AddClaim(new Claim(ClaimType.Role, "OtherRole"));
     claimsIdentity.AddClaim(new Claim(ClaimType.Group, Group));
     claimsIdentity.AddClaim(new Claim(ClaimType.Group, "OtherGroup"));
     sut = new AuthenticatedUserContext(claimsIdentity);
 }
Example #5
0
 public PostEventRequest(
     long incidentId,
     NewEvent newEvent,
     AuthenticatedUserContext userContext,
     Lazy <string> lazyToken,
     int?port
     ) : base(userContext)
 {
     IncidentId = incidentId;
     NewEvent   = ThrowIf.Null(newEvent, nameof(newEvent));
     LazyToken  = ThrowIf.Null(lazyToken, nameof(lazyToken));
     Port       = port;
 }
Example #6
0
        public static async Task <string> AcquireTokenAsync(AuthenticatedUserContext authenticationInfo)
        {
            //Todo: per-user auth based on delegated identity
            //string userObjectID = (authenticationInfo.User.FindFirst("http://schemas.microsoft.com/identity/claims/objectidentifier"))?.Value;
            string userObjectID = "Test";

            var authContext = new AuthenticationContext(authenticationInfo.AuthConfig.Authority, new NaiveSessionCache(userObjectID, authenticationInfo.Session));
            var credential  = new ClientCredential(authenticationInfo.AuthConfig.ClientId, authenticationInfo.AuthConfig.ClientSecret);

            try
            {
                var result = await authContext.AcquireTokenSilentAsync(authenticationInfo.AuthConfig.Resource, credential, new UserIdentifier(userObjectID, UserIdentifierType.UniqueId));

                return(result.AccessToken);
            }
            catch (AdalSilentTokenAcquisitionException)
            {
                var result = await authContext.AcquireTokenAsync(authenticationInfo.AuthConfig.Resource, credential);

                return(result.AccessToken);
            }
        }
 protected AuthenticatedRequestBase(AuthenticatedUserContext userContext)
 {
     UserContext = userContext;
 }
Example #8
0
 public GetIncidentRequest(long id, AuthenticatedUserContext userContext)
     : base(userContext)
 {
     Id = id;
 }
Example #9
0
 public GetEventTypesRequest(AuthenticatedUserContext userContext)
     : base(userContext)
 {
 }
Example #10
0
 public PostIncidentRequest(NewIncident incident, AuthenticatedUserContext userContext)
     : base(userContext)
 {
     Incident = incident;
 }
Example #11
0
 public PutEngagementRequest(long incidentId, long engagementId, UpdateEngagement updateEngagement, AuthenticatedUserContext userContext)
     : base(userContext)
 {
     IncidentId       = incidentId;
     UpdateEngagement = updateEngagement;
     EngagementId     = engagementId;
 }
Example #12
0
 public static async Task <HttpResponseMessage> GetAsync(this HttpClient client, string requestUri, AuthenticatedUserContext authenticationInfo)
 {
     return(await client
            .SendAsync(requestUri, authenticationInfo, HttpMethod.Get)
            .ConfigureAwait(continueOnCapturedContext: false));
 }
Example #13
0
 public PostEngagementRequest(long incidentId, NewEngagement newEngagement, AuthenticatedUserContext userContext)
     : base(userContext)
 {
     IncidentId    = incidentId;
     NewEngagement = newEngagement;
 }
Example #14
0
 public GetEventRequest(long incidentId, long id, AuthenticatedUserContext userContext)
     : base(userContext)
 {
     IncidentId = incidentId;
     Id         = id;
 }
Example #15
0
 public GetEventTypeRequest(long id, AuthenticatedUserContext userContext)
     : base(userContext)
 {
     EventTypeId = id;
 }
Example #16
0
 public PutEngagementRequest(long incidentId, long engagementId, UpdateEngagement updateEngagement, AuthenticatedUserContext userContext)
     : base(userContext)
 {
     IncidentId       = incidentId;
     UpdateEngagement = ThrowIf.Null(updateEngagement, nameof(updateEngagement));
     EngagementId     = engagementId;
 }
Example #17
0
 public static async Task <HttpResponseMessage> GetAsync(this HttpClient client, string requestUri, AuthenticatedUserContext authenticationInfo)
 {
     return(await client.SendAsync(requestUri, authenticationInfo, HttpMethod.Get));
 }
Example #18
0
        private static async Task <HttpRequestMessage> GenerateRequest(string requestUri, AuthenticatedUserContext authenticationInfo, HttpMethod method)
        {
            var tokenResult = await AcquireTokenAsync(authenticationInfo);

            var request = new HttpRequestMessage(method, requestUri);

            request.Headers.Authorization = new AuthenticationHeaderValue(authenticationInfo.AuthConfig.Scheme, tokenResult);
            return(request);
        }
Example #19
0
        private static async Task <HttpResponseMessage> SendAsync(this HttpClient client, string requestUri, HttpContent postContent, AuthenticatedUserContext authenticationInfo, HttpMethod method)
        {
            HttpRequestMessage request = await GenerateRequest(requestUri, authenticationInfo, method);

            request.Content = postContent;

            return(await client.SendAsync(request));
        }
Example #20
0
 public PostEngagementRequest(long incidentId, NewEngagement newEngagement, AuthenticatedUserContext userContext)
     : base(userContext)
 {
     IncidentId    = incidentId;
     NewEngagement = ThrowIf.Null(newEngagement, nameof(newEngagement));
 }
 protected AuthenticatedRequest(AuthenticatedUserContext userContext) : base(userContext)
 {
 }
Example #22
0
 public GetIncidentsRequest(PaginationMetadata pagination, AuthenticatedUserContext userContext)
     : base(userContext)
 {
     Pagination = pagination;
 }
Example #23
0
 public PostIncidentRequest(NewIncident incident, AuthenticatedUserContext userContext)
     : base(userContext)
 {
     Incident = ThrowIf.Null(incident, nameof(incident));
 }
Example #24
0
 public GetGlobalActionsRequest(AuthenticatedUserContext userContext)
     : base(userContext)
 {
 }
Example #25
0
        private static async Task <HttpResponseMessage> SendAsync(this HttpClient client, string requestUri, AuthenticatedUserContext authenticationInfo, HttpMethod method)
        {
            HttpRequestMessage request = await GenerateRequest(requestUri, authenticationInfo, method)
                                         .ConfigureAwait(continueOnCapturedContext: false);

            return(await client.SendAsync(request).ConfigureAwait(continueOnCapturedContext: false));
        }