Esempio n. 1
0
        internal static IClientSecretIdentity ToDomain(this ClientSecretIdentityModel clientSecretIdentityModel, IConverter securityModelConverter)
        {
            NullGuard.NotNull(clientSecretIdentityModel, nameof(clientSecretIdentityModel))
            .NotNull(securityModelConverter, nameof(securityModelConverter));

            IEnumerable <Claim> claimCollection = securityModelConverter.Convert <IEnumerable <ClientSecretIdentityClaimModel>, IEnumerable <Claim> >(clientSecretIdentityModel.ClientSecretIdentityClaims);

            ClientSecretIdentityClaimModel latestClientSecretIdentityClaimModel = clientSecretIdentityModel.ClientSecretIdentityClaims.OrderByDescending(model => model.ModifiedUtcDateTime).FirstOrDefault();

            IClientSecretIdentity clientSecretIdentity = new ClientSecretIdentityBuilder(clientSecretIdentityModel.FriendlyName)
                                                         .WithIdentifier(clientSecretIdentityModel.ClientSecretIdentityIdentifier)
                                                         .WithClientId(clientSecretIdentityModel.ClientId)
                                                         .WithClientSecret(clientSecretIdentityModel.ClientSecret)
                                                         .AddClaims(claimCollection)
                                                         .Build();

            if (latestClientSecretIdentityClaimModel == null || latestClientSecretIdentityClaimModel.ModifiedUtcDateTime < clientSecretIdentityModel.ModifiedUtcDateTime)
            {
                clientSecretIdentity.AddAuditInformation(clientSecretIdentityModel.CreatedUtcDateTime, clientSecretIdentityModel.CreatedByIdentifier, clientSecretIdentityModel.ModifiedUtcDateTime, clientSecretIdentityModel.ModifiedByIdentifier);
            }
            else
            {
                clientSecretIdentity.AddAuditInformation(clientSecretIdentityModel.CreatedUtcDateTime, clientSecretIdentityModel.CreatedByIdentifier, latestClientSecretIdentityClaimModel.ModifiedUtcDateTime, latestClientSecretIdentityClaimModel.ModifiedByIdentifier);
            }

            return(clientSecretIdentity);
        }
        private void InsertClientSecretModels(MigrationBuilder migrationBuilder)
        {
            NullGuard.NotNull(migrationBuilder, nameof(migrationBuilder));

            IClientSecretIdentity clientSecretIdentity = new ClientSecretIdentityBuilder("OSDevGrp.OSIntranet.Test").Build();

            migrationBuilder.InsertData("ClientSecretIdentities", new[] { "FriendlyName", "ClientId", "ClientSecret" }, new object[] { clientSecretIdentity.FriendlyName, clientSecretIdentity.ClientId, clientSecretIdentity.ClientSecret });
        }