//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void twoEncryptorsWithSamePrefixThrowError() public virtual void twoEncryptorsWithSamePrefixThrowError() { // given two algorithms with the same prefix IList <PasswordEncryptor> additionalEncryptorsForPasswordChecking = new LinkedList <PasswordEncryptor>(); additionalEncryptorsForPasswordChecking.Add(new ShaHashDigest()); PasswordEncryptor defaultEncryptor = new ShaHashDigest(); // then thrown.expect(typeof(PasswordEncryptionException)); thrown.expectMessage("Hash algorithm with the name 'SHA' was already added"); // when setEncryptors(defaultEncryptor, additionalEncryptorsForPasswordChecking); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void ensurePasswordIsCorrectlyHashedWithSHA1() public virtual void ensurePasswordIsCorrectlyHashedWithSHA1() { // given DefaultEncryptor = new ShaHashDigest(); processEngineConfiguration.SaltGenerator = new MyConstantSaltGenerator("12345678910"); User user = identityService.newUser(USER_NAME); user.Password = PASSWORD; identityService.saveUser(user); // when user = identityService.createUserQuery().userId(USER_NAME).singleResult(); // then // obtain the expected value on the command line like so: echo -n password12345678910 | openssl dgst -binary -sha1 | openssl base64 assertThat(user.Password, @is("{SHA}n3fE9/7XOmgD3BkeJlC+JLyb/Qg=")); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void useSeveralCustomEncryptors() public virtual void useSeveralCustomEncryptors() { // given three users with different hashed passwords processEngineConfiguration.SaltGenerator = new MyConstantSaltGenerator("12345678910"); string userName1 = "Kermit"; createUserWithEncryptor(userName1, new MyCustomPasswordEncryptor(PASSWORD, ALGORITHM_NAME)); string userName2 = "Fozzie"; string anotherAlgorithmName = "marvelousAlgorithm"; createUserWithEncryptor(userName2, new MyCustomPasswordEncryptor(PASSWORD, anotherAlgorithmName)); string userName3 = "Gonzo"; createUserWithEncryptor(userName3, new ShaHashDigest()); IList <PasswordEncryptor> additionalEncryptorsForPasswordChecking = new LinkedList <PasswordEncryptor>(); additionalEncryptorsForPasswordChecking.Add(new MyCustomPasswordEncryptor(PASSWORD, ALGORITHM_NAME)); additionalEncryptorsForPasswordChecking.Add(new MyCustomPasswordEncryptor(PASSWORD, anotherAlgorithmName)); PasswordEncryptor defaultEncryptor = new ShaHashDigest(); setEncryptors(defaultEncryptor, additionalEncryptorsForPasswordChecking); // when User user1 = identityService.createUserQuery().userId(userName1).singleResult(); User user2 = identityService.createUserQuery().userId(userName2).singleResult(); User user3 = identityService.createUserQuery().userId(userName3).singleResult(); // then assertThat(user1.Password, @is("{" + ALGORITHM_NAME + "}xxx")); assertThat(user2.Password, @is("{" + anotherAlgorithmName + "}xxx")); assertThat(user3.Password, @is("{SHA}n3fE9/7XOmgD3BkeJlC+JLyb/Qg=")); }