Jak magazynować i używać soli shiro z bazy danych

Używam shiro w aplikacji do uwierzytelniania. Używam hashowanego hasła z solą i przechowuję je w mojej bazie danych w ten sposób:

    private User createUserWithHashedPassword(String inName, String inFirstName, String inLastName, String inPassword){

    ByteSource salt  = randomNumberGenerator.nextBytes(32);

    byte[] byteTabSalt  = salt.getBytes();

    String strSalt = byteArrayToHexString(byteTabSalt);

    String hashedPasswordBase64 = new Sha256Hash(inPassword, salt, 1024).toBase64();

    return new User(inName,inFirstName,inLastName,hashedPasswordBase64,strSalt);
}

Przechowuję sól z łańcuchem w mojej bazie danych. Teraz w mojej dziedzinie chcę odzyskać moje dane z bazy danych, używam do tego usługi transakcyjnej. Ale moja sól jest Mocna, więc chcę, aby odwróciła się jako typ ByteSource za pomocą metody statycznej:

ByteSource byteSourceSalt = Util.bytes(salt); //where the salt is a String

Ale kiedy tworzę SaltedAuthenticationInfo, nie autoryzuje.

Myślę, że mój problem pochodzi z mojej metody konwersji:

private String byteArrayToHexString(byte[] bArray){

        StringBuffer buffer = new StringBuffer();

        for(byte b : bArray) {
            buffer.append(Integer.toHexString(b));
            buffer.append(" ");
        }

 return buffer.toString().toUpperCase();    
}

Dzięki za pomoc.

questionAnswers(4)

yourAnswerToTheQuestion