/** * Decode the given byte array and create a {@link PasswordSpec} from it. * * @param encoded the byte array representing the encoded password * @return a {@link PasswordSpec} instance created from the encoded password or null if no decoder was capable to decode the given format. */ public static PasswordSpec decode(byte[] encoded) { ByteIterator iterator = ByteIterator.ofBytes(encoded); int identifier; try { identifier = iterator.next(); } catch (Exception e) { throw ElytronMessages.log.couldNotObtainKeySpecEncodingIdentifier(); } switch (identifier) { case CLEAR_PASSWORD_SPEC_ID: return decodeClearPasswordSpec(iterator); case DIGEST_PASSWORD_SPEC_ID: return decodeDigestPasswordSpec(iterator); case HASH_PASSWORD_SPEC_ID: return decodeHashPasswordSpec(iterator); case SALTED_HASH_PASSWORD_SPEC_ID: return decodeSaltedHashPasswordSpec(iterator); case ITERATED_SALTED_HASH_SPEC_ID: return decodeIteratedSaltedHashPasswordSpec(iterator); default: return null; } }
/** * Decode the given byte array and create a {@link PasswordSpec} from it. * * @param encoded the byte array representing the encoded password * @return a {@link PasswordSpec} instance created from the encoded password or null if no decoder was capable to decode the given format. */ public static PasswordSpec decode(byte[] encoded) { ByteIterator iterator = ByteIterator.ofBytes(encoded); int identifier; try { identifier = iterator.next(); } catch (Exception e) { throw ElytronMessages.log.couldNotObtainKeySpecEncodingIdentifier(); } switch (identifier) { case CLEAR_PASSWORD_SPEC_ID: return decodeClearPasswordSpec(iterator); case DIGEST_PASSWORD_SPEC_ID: return decodeDigestPasswordSpec(iterator); case HASH_PASSWORD_SPEC_ID: return decodeHashPasswordSpec(iterator); case SALTED_HASH_PASSWORD_SPEC_ID: return decodeSaltedHashPasswordSpec(iterator); case ITERATED_SALTED_HASH_SPEC_ID: return decodeIteratedSaltedHashPasswordSpec(iterator); default: return null; } }
/** * Decode the given byte array and create a {@link PasswordSpec} from it. * * @param encoded the byte array representing the encoded password * @return a {@link PasswordSpec} instance created from the encoded password or null if no decoder was capable to decode the given format. */ public static PasswordSpec decode(byte[] encoded) { ByteIterator iterator = ByteIterator.ofBytes(encoded); int identifier; try { identifier = iterator.next(); } catch (Exception e) { throw ElytronMessages.log.couldNotObtainKeySpecEncodingIdentifier(); } switch (identifier) { case CLEAR_PASSWORD_SPEC_ID: return decodeClearPasswordSpec(iterator); case DIGEST_PASSWORD_SPEC_ID: return decodeDigestPasswordSpec(iterator); case HASH_PASSWORD_SPEC_ID: return decodeHashPasswordSpec(iterator); case SALTED_HASH_PASSWORD_SPEC_ID: return decodeSaltedHashPasswordSpec(iterator); case ITERATED_SALTED_HASH_SPEC_ID: return decodeIteratedSaltedHashPasswordSpec(iterator); default: return null; } }
/** * Decode the given byte array and create a {@link PasswordSpec} from it. * * @param encoded the byte array representing the encoded password * @return a {@link PasswordSpec} instance created from the encoded password or null if no decoder was capable to decode the given format. */ public static PasswordSpec decode(byte[] encoded) { ByteIterator iterator = ByteIterator.ofBytes(encoded); int identifier; try { identifier = iterator.next(); } catch (Exception e) { throw ElytronMessages.log.couldNotObtainKeySpecEncodingIdentifier(); } switch (identifier) { case CLEAR_PASSWORD_SPEC_ID: return decodeClearPasswordSpec(iterator); case DIGEST_PASSWORD_SPEC_ID: return decodeDigestPasswordSpec(iterator); case HASH_PASSWORD_SPEC_ID: return decodeHashPasswordSpec(iterator); case SALTED_HASH_PASSWORD_SPEC_ID: return decodeSaltedHashPasswordSpec(iterator); case ITERATED_SALTED_HASH_SPEC_ID: return decodeIteratedSaltedHashPasswordSpec(iterator); default: return null; } }