コード例 #1
0
        public override Task <Resource> RetrieveAsync(IResourceRetrievalParameters parameters, string correlationIdentifier)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            if (string.IsNullOrWhiteSpace(correlationIdentifier))
            {
                throw new ArgumentNullException(nameof(correlationIdentifier));
            }

            if (string.IsNullOrEmpty(parameters?.ResourceIdentifier?.Identifier))
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            string identifier = parameters.ResourceIdentifier.Identifier;

            if (int.TryParse(identifier, out int id) && _context.Users.Find(id) is MvcMovie.Models.User modelUser)
            {
                return(Task.FromResult <Resource>((Core2EnterpriseUser)modelUser));
            }

            throw new HttpResponseException(HttpStatusCode.NotFound);
        }
コード例 #2
0
        public override async Task <Resource> RetrieveAsync(IResourceRetrievalParameters parameters, string correlationIdentifier)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            if (string.IsNullOrWhiteSpace(correlationIdentifier))
            {
                throw new ArgumentNullException(nameof(correlationIdentifier));
            }

            if (string.IsNullOrEmpty(parameters?.ResourceIdentifier?.Identifier))
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            Resource result     = null;
            string   identifier = parameters.ResourceIdentifier.Identifier;

            Core2EnterpriseUser user = await this.context.Users.Where(u => u.Identifier == identifier)
                                       .Include(u => u.Addresses)
                                       .Include(u => u.ElectronicMailAddresses)
                                       .Include(u => u.InstantMessagings)
                                       .Include(u => u.PhoneNumbers)
                                       .AsNoTracking().FirstOrDefaultAsync();

            if (user == null)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }

            result = user as Resource;
            return(await Task.FromResult(result));
        }
コード例 #3
0
        public override Task <Resource> RetrieveAsync(IResourceRetrievalParameters parameters, string correlationIdentifier)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            if (string.IsNullOrWhiteSpace(correlationIdentifier))
            {
                throw new ArgumentNullException(nameof(correlationIdentifier));
            }

            if (string.IsNullOrEmpty(parameters?.ResourceIdentifier?.Identifier))
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            string identifier = parameters.ResourceIdentifier.Identifier;

            if (this.storage.Groups.ContainsKey(identifier))
            {
                if (this.storage.Groups.TryGetValue(identifier, out Core2Group group))
                {
                    Resource result = group as Resource;
                    return(Task.FromResult(result));
                }
            }

            throw new HttpResponseException(HttpStatusCode.NotFound);
        }
コード例 #4
0
        public override Task <Resource> RetrieveAsync(IResourceRetrievalParameters parameters, string correlationIdentifier)
        {
            if (null == parameters)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            if (null == parameters.ResourceIdentifier)
            {
                throw new ArgumentException(SystemForCrossDomainIdentityManagementServiceResources.ExceptionInvalidParameters);
            }

            Resource resource = null;

            if
            (
                string.Equals(
                    parameters.ResourceIdentifier.SchemaIdentifier,
                    SchemaIdentifiers.Core2EnterpriseUser,
                    StringComparison.Ordinal) &&
                string.Equals(
                    parameters.ResourceIdentifier.Identifier,
                    SampleProvider.IdentifierUser,
                    StringComparison.OrdinalIgnoreCase)
            )
            {
                resource = this.SampleUser;
            }

            Task <Resource> result = Task.FromResult(resource);

            return(result);
        }
コード例 #5
0
        public override Task <Resource> RetrieveAsync(IResourceRetrievalParameters parameters, string correlationIdentifier)
        {
            if (parameters.SchemaIdentifier.Equals(SchemaIdentifiers.Core2EnterpriseUser))
            {
                return(this.userProvider.RetrieveAsync(parameters, correlationIdentifier));
            }

            throw new NotImplementedException();
        }
コード例 #6
0
        public override Task <Resource> RetrieveAsync(IResourceRetrievalParameters parameters, string correlationIdentifier)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            if (string.IsNullOrWhiteSpace(correlationIdentifier))
            {
                throw new ArgumentNullException(nameof(correlationIdentifier));
            }

            if (string.IsNullOrEmpty(parameters?.ResourceIdentifier?.Identifier))
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            // call service
            TargetGroup result = null;

            try
            {
                result = _storageService.RetrieveGroup(new Guid(parameters.ResourceIdentifier.Identifier));
            }
            catch (Exception err)
            {
                switch (err.Message)
                {
                case "NotFound":
                    throw new HttpResponseException(HttpStatusCode.NotFound);

                default:
                    throw new HttpResponseException(HttpStatusCode.InternalServerError);
                }
            }

            return(Task.FromResult((Core2Group)result as Resource));
        }
 public override Task<Resource> Retrieve(IResourceRetrievalParameters parameters, string correlationIdentifier)
 {
     Task<Resource> result = Task.FromResult<Resource>(this.Resource);
     return result;
 }
コード例 #8
0
        public override async Task <Resource> RetrieveAsync(
            IResourceRetrievalParameters parameters,
            string correlationIdentifier)
        {
            if (null == parameters)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            if (string.IsNullOrWhiteSpace(correlationIdentifier))
            {
                throw new ArgumentNullException(nameof(correlationIdentifier));
            }

            if (null == parameters.ResourceIdentifier)
            {
                throw new ArgumentException(FileProviderResources.ExceptionInvalidParameters);
            }

            if (string.IsNullOrWhiteSpace(parameters.ResourceIdentifier.Identifier))
            {
                throw new ArgumentException(FileProviderResources.ExceptionInvalidResourceIdentifier);
            }

            if (string.IsNullOrWhiteSpace(parameters.SchemaIdentifier))
            {
                throw new ArgumentException(FileProviderResources.ExceptionInvalidParameters);
            }

            IInformationNotification notification =
                VerboseInformationNotificationFactory.Instance.FormatNotification(
                    FileProviderResources.InformationRetrieving,
                    correlationIdentifier,
                    FileProvider.NotificationIdentifierRetrievalStarting,
                    parameters.SchemaIdentifier,
                    parameters.ResourceIdentifier.Identifier);

            this.Monitor.Inform(notification);

            IReadOnlyCollection <string> columnNames = this.IdentifyRequestedColumns(parameters);

            IRow row = await this.file.ReadRow(parameters.ResourceIdentifier.Identifier);

            if (null == row || null == row.Columns)
            {
                return(null);
            }

            string rowSchema = null;

            if
            (
                !row.Columns.TryGetValue(AttributeNames.Schemas, out rowSchema) ||
                !string.Equals(rowSchema, parameters.SchemaIdentifier, StringComparison.Ordinal)
            )
            {
                return(null);
            }

            IRow            reducedRow      = FileProvider.FilterColumns(row, columnNames);
            ResourceFactory resourceFactory = FileProvider.SelectResourceFactoryFor(rowSchema, reducedRow);
            Resource        result          = resourceFactory.CreateResource();

            return(result);
        }
コード例 #9
0
 public override Task <Resource> RetrieveAsync(IResourceRetrievalParameters parameters, string correlationIdentifier)
 {
     throw new NotImplementedException();
 }
            public override Task <Resource> RetrieveAsync(IResourceRetrievalParameters parameters, string correlationIdentifier)
            {
                Task <Resource> result = Task.FromResult <Resource>(this.Resource);

                return(result);
            }
        public override async Task<Resource> Retrieve(
            IResourceRetrievalParameters parameters, 
            string correlationIdentifier)
        {
            if (null == parameters)
            {
                throw new ArgumentNullException(AmazonWebServicesProvider.ArgumentNameParameters);
            }

            if (string.IsNullOrWhiteSpace(correlationIdentifier))
            {
                throw new ArgumentNullException(AmazonWebServicesProvider.ArgumentNameCorrelationIdentifier);
            }

            if (null == parameters.ResourceIdentifier)
            {
                throw new ArgumentException(ProvisioningAgentResources.ExceptionInvalidParameters);
            }

            if (string.IsNullOrWhiteSpace(parameters.ResourceIdentifier.Identifier))
            {
                throw new ArgumentException(ProvisioningAgentResources.ExceptionInvalidResourceIdentifier);
            }

            if (string.IsNullOrWhiteSpace(parameters.SchemaIdentifier))
            {
                throw new ArgumentException(ProvisioningAgentResources.ExceptionInvalidParameters);
            }

            string informationStarting =
                string.Format(
                    CultureInfo.InvariantCulture,
                    AmazonProvisioningAgentResources.InformationRetrieving,
                    parameters.SchemaIdentifier,
                    parameters.ResourceIdentifier.Identifier);
            ProvisioningAgentMonitor.Instance.Inform(informationStarting, true, correlationIdentifier);

            AmazonWebServicesProvider.Validate(parameters);

             IAmazonIdentityManagementService proxy = null;
             try
             {
                 proxy = AWSClientFactory.CreateAmazonIdentityManagementServiceClient(this.credentials);

                 switch (parameters.SchemaIdentifier)
                 {
                     case SchemaIdentifiers.Core2EnterpriseUser:
                         Amazon.IdentityManagement.Model.User user = 
                             await this.RetrieveUser(parameters.ResourceIdentifier.Identifier, proxy);
                         Core2EnterpriseUser resourceUser =
                             new Core2EnterpriseUser()
                                 {
                                     Identifier = user.UserId,
                                     ExternalIdentifier = user.UserName
                                 };
                         return resourceUser;

                     case SchemaIdentifiers.WindowsAzureActiveDirectoryGroup:
                         Group group = 
                             await this.RetrieveGroup(parameters.ResourceIdentifier.Identifier, proxy);
                         WindowsAzureActiveDirectoryGroup resourceGroup =
                             new WindowsAzureActiveDirectoryGroup()
                                 {
                                     Identifier = group.GroupId,
                                     ExternalIdentifier = group.GroupName
                                 };
                         return resourceGroup;

                     default:
                         throw new NotSupportedException(parameters.SchemaIdentifier);
                 }
             }
             finally
             {
                 if (proxy != null)
                 {
                     proxy.Dispose();
                     proxy = null;
                 }
             }
        }
コード例 #12
0
 public abstract Task <Resource> RetrieveAsync(IResourceRetrievalParameters parameters, string correlationIdentifier);
コード例 #13
0
        public override async Task<Resource> Retrieve(IResourceRetrievalParameters parameters, string correlationIdentifier)
        {
            if (null == parameters)
            {
                throw new ArgumentNullException(FileProvider.ArgumentNameParameters);
            }

            if (string.IsNullOrWhiteSpace(correlationIdentifier))
            {
                throw new ArgumentNullException(FileProvider.ArgumentNameCorrelationIdentifier);
            }

            if (null == parameters.ResourceIdentifier)
            {
                throw new ArgumentException(ProvisioningAgentResources.ExceptionInvalidParameters);
            }

            if (string.IsNullOrWhiteSpace(parameters.ResourceIdentifier.Identifier))
            {
                throw new ArgumentException(ProvisioningAgentResources.ExceptionInvalidResourceIdentifier);
            }

            if (string.IsNullOrWhiteSpace(parameters.SchemaIdentifier))
            {
                throw new ArgumentException(ProvisioningAgentResources.ExceptionInvalidParameters);
            }

            string informationStarting =
                string.Format(
                    CultureInfo.InvariantCulture,
                    AzureTestProvisioningResources.InformationRetrieving,
                    parameters.SchemaIdentifier,
                    parameters.ResourceIdentifier.Identifier);
            ProvisioningAgentMonitor.Instance.Inform(informationStarting, true, correlationIdentifier);

            IReadOnlyCollection<string> columnNames = this.IdentifyRequestedColumns(parameters);
            
            IRow row = await this.file.ReadRow(parameters.ResourceIdentifier.Identifier);
            if (null == row || null == row.Columns)
            {
                return null;
            }

            string rowSchema = null;
            if
            (
                    !row.Columns.TryGetValue(AttributeNames.Schemas, out rowSchema)
                ||  !string.Equals(rowSchema, parameters.SchemaIdentifier, StringComparison.Ordinal)
            )
            {
                return null;
            }

            IRow reducedRow = FileProvider.FilterColumns(row, columnNames);

            ResourceFactory resourceFactory;
            switch (rowSchema)
            {
                case SchemaIdentifiers.Core2EnterpriseUser:
                    resourceFactory = new UserFactory(reducedRow);
                    break;
                case SchemaIdentifiers.WindowsAzureActiveDirectoryGroup:
                    resourceFactory = new GroupFactory(reducedRow);
                    break;
                default:
                    throw new NotSupportedException(parameters.SchemaIdentifier);
            }

            Resource result = resourceFactory.CreateResource();
            return result;
        }