public void PrivateCertificateProcessing_CreateCertificate_CngRsa2048_ClientServerAuth_ReturnedX509Certificate2HasClientServerAuthKeyUsage() { KeyUsage expected = KeyUsage.ServerAuthentication | KeyUsage.ClientAuthentication; CreatePrivateCertificateModel model = new CreatePrivateCertificateModel() { CipherAlgorithm = CipherAlgorithm.RSA, KeyUsage = expected.ToString(), HashAlgorithm = HashAlgorithm.SHA256, KeySize = 2048, Provider = WindowsApi.Cng, SubjectAlternativeNamesRaw = "integrationtestdomain.com,integrationtestdomain", SubjectCity = "Seattle", SubjectCommonName = "integrationtestdomain", SubjectCountry = "US", SubjectDepartment = "Engineering", SubjectState = "WA", SubjectOrganization = "IntegrationTestingCorp" }; PrivateCertificateProcessing processor = new PrivateCertificateProcessing(certDb, configDb, certProvider, GetAuthorizationLogic_Allow(), templateLogic, GetAuditLogic()); CreatePrivateCertificateResult result = processor.CreateCertificateWithPrivateKey(model, user.Object); X509Certificate2 cert = new X509Certificate2(result.PfxByte, result.Password); KeyUsage actualKeyUsage = x509Normalization.GetKeyUsage(cert); Assert.AreEqual(expected, actualKeyUsage); }
public void PrivateCertificateProcessing_CreateCertificate_CngRsa2048_ClientServerAuth_Success() { KeyUsage keyUsage = KeyUsage.ServerAuthentication | KeyUsage.ClientAuthentication; CreatePrivateCertificateModel model = new CreatePrivateCertificateModel() { CipherAlgorithm = CipherAlgorithm.RSA, KeyUsage = keyUsage.ToString(), HashAlgorithm = HashAlgorithm.SHA256, KeySize = 2048, Provider = WindowsApi.Cng, SubjectAlternativeNamesRaw = "integrationtestdomain.com,integrationtestdomain", SubjectCity = "Seattle", SubjectCommonName = "integrationtestdomain", SubjectCountry = "US", SubjectDepartment = "Engineering", SubjectState = "WA", SubjectOrganization = "IntegrationTestingCorp" }; PrivateCertificateProcessing processor = new PrivateCertificateProcessing(certDb, configDb, certProvider, GetAuthorizationLogic_Allow(), templateLogic, GetAuditLogic()); CreatePrivateCertificateResult result = processor.CreateCertificateWithPrivateKey(model, user.Object); Assert.AreEqual(PrivateCertificateRequestStatus.Success, result.Status); }
public JsonResult SignCertificaste(SignPrivateCertificateModel model) { PrivateCertificateProcessing processor = new PrivateCertificateProcessing(certificateRepository, configurationRepository, certificateProvider, authorizationLogic, templateLogic, audit); SignPrivateCertificateResult result = processor.SignCertificate(model, User); return(http.RespondSuccess(result)); }
public JsonResult IssuePendingCertificate(Guid id) { PrivateCertificateProcessing processor = new PrivateCertificateProcessing(certificateRepository, configurationRepository, certificateProvider, authorizationLogic, templateLogic, audit); CreatePrivateCertificateResult result = processor.IssuePendingCertificate(id, User); return(http.RespondSuccess(result)); }
private void InitializeApp(IServiceCollection services, AppSettings appSettings) { //singleton pattern here was a huge mistake, i'm going to fix this. LiteDbConfigurationRepository configurationRepository = new LiteDbConfigurationRepository(databaseLocator.GetConfigurationRepositoryConnectionString()); appConfig = configurationRepository.GetAppConfig(); ActiveDirectoryRepository activeDirectory = new ActiveDirectoryRepository(); EncryptionProvider cipher = new EncryptionProvider(appConfig.EncryptionKey); services.AddSingleton <EncryptionProvider>(cipher); services.AddSingleton <IActiveDirectoryAuthenticator>(activeDirectory); services.AddSingleton <IActiveDirectoryRepository>(activeDirectory); IdentityAuthenticationLogic identityAuthenticationLogic = new IdentityAuthenticationLogic(configurationRepository, activeDirectory); services.AddSingleton <IdentityAuthenticationLogic>(); ICertificateRepository certificateRepository = new LiteDbCertificateRepository(databaseLocator.GetCertificateRepositoryConnectionString()); RuntimeCacheRepository runtimeCacheRepository = null; LiteDbAuditRepository auditRepository = new LiteDbAuditRepository(databaseLocator.GetAuditRepositoryConnectionString()); IAuditLogic auditLogic = new AuditLogic(auditRepository, configurationRepository); services.AddSingleton <IAuditLogic>(auditLogic); IAuthorizationLogic authorizationLogic = new AuthorizationLogic(configurationRepository, auditLogic); IScriptManagementLogic scriptManagement = new ScriptManagementLogic(configurationRepository, authorizationLogic); services.AddSingleton <IScriptManagementLogic>(scriptManagement); IPowershellEngine powershellEngine = new PowershellEngine(auditLogic, scriptManagement); services.AddSingleton <IPowershellEngine>(powershellEngine); RoleManagementLogic roleManagementLogic = new RoleManagementLogic(configurationRepository, authorizationLogic); services.AddSingleton <RoleManagementLogic>(roleManagementLogic); UserManagementLogic userManagementLogic = new UserManagementLogic(configurationRepository, authorizationLogic); services.AddSingleton <UserManagementLogic>(userManagementLogic); SecurityPrincipalLogic securityPrincipalLogic = new SecurityPrincipalLogic(roleManagementLogic, userManagementLogic); services.AddSingleton <SecurityPrincipalLogic>(); AdcsTemplateLogic adcsTemplateLogic = new AdcsTemplateLogic(configurationRepository, activeDirectory); services.AddSingleton <AdcsTemplateLogic>(adcsTemplateLogic); services.AddSingleton <IAuthorizationLogic>(authorizationLogic); services.AddSingleton <IConfigurationRepository>(configurationRepository); ICertificateProvider certificateProvider = new Win32CertificateProvider(); services.AddSingleton <ICertificateProvider>(certificateProvider); services.AddSingleton <ICertificateRepository>(certificateRepository); ActiveDirectoryIdentityProviderLogic activeDirectoryIdentityProviderLogic = new ActiveDirectoryIdentityProviderLogic(configurationRepository); services.AddSingleton <ActiveDirectoryIdentityProviderLogic>(activeDirectoryIdentityProviderLogic); certificateManagementLogic = new CertificateManagementLogic( configurationRepository, certificateRepository, authorizationLogic, auditLogic, securityPrincipalLogic, cipher); services.AddSingleton <CertificateManagementLogic>(certificateManagementLogic); PrivateCertificateProcessing privateCertificateProcessing = new PrivateCertificateProcessing(certificateRepository, configurationRepository, certificateProvider, authorizationLogic, adcsTemplateLogic, auditLogic); services.AddSingleton <IPrivateCertificateProcessing>(privateCertificateProcessing); services.AddSingleton <NodeLogic>(new NodeLogic(configurationRepository, authorizationLogic, activeDirectoryIdentityProviderLogic, powershellEngine, auditLogic, certificateManagementLogic, privateCertificateProcessing)); services.AddSingleton <IRuntimeConfigurationState>( new RuntimeConfigurationState(configurationRepository, runtimeCacheRepository) { InitialSetupComplete = initialSetupComplete }); services.AddSingleton <IClientsideConfigurationProvider>(new ClientsideConfigurationProvider(configurationRepository)); services.AddSingleton <AnalyticsLogic>(new AnalyticsLogic(configurationRepository, certificateRepository, auditRepository)); services.AddSingleton <DataRenderingProvider>(new DataRenderingProvider()); oidcLogic = new OpenIdConnectIdentityProviderLogic(configurationRepository, authorizationLogic); services.AddSingleton <IOpenIdConnectIdentityProviderLogic>(oidcLogic); }