public DefaultDatabaseMigrator(Database database, CryptographicService crypto_provider, ConfigurationPropertyHolder configuration) { this.database = database; this.crypto_provider = crypto_provider; this.configuration = configuration; restoring_database = configuration.Restore; restore_path = configuration.RestoreFromPath; custom_restore_options = configuration.RestoreCustomOptions; output_path = configuration.OutputPath; error_on_one_time_script_changes = !configuration.WarnOnOneTimeScriptChanges; is_running_all_any_time_scripts = configuration.RunAllAnyTimeScripts; }
public void ValidateSubject() { var claim = new Claim("nameid", "homeorganization.nl:useridentifier"); var request = SamlService.CreateAuthnRequest(claim, Guid.NewGuid().ToString(), new Uri("https://mytest.nl")); using (var service = new CryptographicService()) { service.SignSamlRequest(request); } var requestXml = request.ToXElement(); var ns = XNamespace.Get("urn:oasis:names:tc:SAML:2.0:assertion"); var element = requestXml.Element(ns + "Subject"); Assert.IsNotNull(element); Assert.AreEqual(claim.Value, ((XElement)element.FirstNode).Value); }
public void InsertAdminUser(string emailAddress, string name, string jobTitle, string password) { if (!NHibernateSession.Current.Transaction.IsActive) { throw new InvalidOperationException("A transaction must be in progress before default data can be inserted"); } var cryptographyService = new CryptographicService(); var passwordSalt = cryptographyService.GenerateSalt(); var adminUser = new UserAccount { Id = Guid.NewGuid(), Name = name, EmailAddress = emailAddress, PasswordSalt = passwordSalt, PasswordHash = cryptographyService.ComputeHash(password, passwordSalt), Roles = UserRole.Admin | UserRole.JobApprover | UserRole.OrderApprover | UserRole.Member | UserRole.Manager, JobTitle = jobTitle, }; NHibernateSession.Current.Save(adminUser); }
/// <summary> /// Begins the authentication. /// </summary> /// <param name="identityClaim">The identity claim.</param> /// <param name="httpListenerRequest">The HTTP listener request.</param> /// <param name="context">The context.</param> /// <returns>A presentation form.</returns> public IAdapterPresentation BeginAuthentication(Claim identityClaim, HttpListenerRequest httpListenerRequest, IAuthenticationContext context) { try { this.InitializeLogger(); this.log.Debug("Enter BeginAuthentication"); this.log.DebugFormat("context.ActivityId='{0}'; context.ContextId='{1}'; conext.Lcid={2}", context.ActivityId, context.ContextId, context.Lcid); string authnRequestId = $"_{context.ContextId}"; var authRequest = SamlService.CreateAuthnRequest(identityClaim, authnRequestId, httpListenerRequest.Url); using (var cryptographicService = new CryptographicService()) { this.log.DebugFormat("Signing AuthnRequest with id {0}", authnRequestId); var signedXml = cryptographicService.SignSamlRequest(authRequest); return(new AuthForm(Settings.Default.SecondFactorEndpoint, signedXml)); } } catch (Exception ex) { this.log.ErrorFormat("Error while initiating authentication:{0}", ex); return(new AuthFailedForm()); } }
public void we_set_the_context() { md5_crypto = new MD5CryptographicService(); }
protected concern_for_hash_generator() { crypto_service = new MD5CryptographicService(); default_hash_generator = new DefaultHashGenerator(crypto_service); }
public Task <string> DecryptString([FromBody] test str) { return(Task.FromResult(CryptographicService.DecryptString(str.Str))); }
public OAuthController(CryptographicService cryptographicService, IConfigRepository configRepository, IAuthCodeGrantRepository accessTokenRepository) { _accessTokenRepository = accessTokenRepository; _config = configRepository.GetConfig(); _cryptoService = cryptographicService; }