@Test(expected = IllegalArgumentException.class) public void invalidCredential() { ScramCredentialUtils.credentialFromString("abc"); }
public static ScramCredential credentialFromString(String str) { Properties props = toProps(str); if (props.size() != 4 || !props.containsKey(SALT) || !props.containsKey(STORED_KEY) || !props.containsKey(SERVER_KEY) || !props.containsKey(ITERATIONS)) { throw new IllegalArgumentException("Credentials not valid: " + str); } byte[] salt = DatatypeConverter.parseBase64Binary(props.getProperty(SALT)); byte[] storedKey = DatatypeConverter.parseBase64Binary(props.getProperty(STORED_KEY)); byte[] serverKey = DatatypeConverter.parseBase64Binary(props.getProperty(SERVER_KEY)); int iterations = Integer.parseInt(props.getProperty(ITERATIONS)); return new ScramCredential(salt, storedKey, serverKey, iterations); }
ScramCredentialUtils { public static ScramCredential credentialFromString(String str) { Properties props = toProps(str); if (props.size() != 4 || !props.containsKey(SALT) || !props.containsKey(STORED_KEY) || !props.containsKey(SERVER_KEY) || !props.containsKey(ITERATIONS)) { throw new IllegalArgumentException("Credentials not valid: " + str); } byte[] salt = DatatypeConverter.parseBase64Binary(props.getProperty(SALT)); byte[] storedKey = DatatypeConverter.parseBase64Binary(props.getProperty(STORED_KEY)); byte[] serverKey = DatatypeConverter.parseBase64Binary(props.getProperty(SERVER_KEY)); int iterations = Integer.parseInt(props.getProperty(ITERATIONS)); return new ScramCredential(salt, storedKey, serverKey, iterations); } }
ScramCredentialUtils { public static ScramCredential credentialFromString(String str) { Properties props = toProps(str); if (props.size() != 4 || !props.containsKey(SALT) || !props.containsKey(STORED_KEY) || !props.containsKey(SERVER_KEY) || !props.containsKey(ITERATIONS)) { throw new IllegalArgumentException("Credentials not valid: " + str); } byte[] salt = DatatypeConverter.parseBase64Binary(props.getProperty(SALT)); byte[] storedKey = DatatypeConverter.parseBase64Binary(props.getProperty(STORED_KEY)); byte[] serverKey = DatatypeConverter.parseBase64Binary(props.getProperty(SERVER_KEY)); int iterations = Integer.parseInt(props.getProperty(ITERATIONS)); return new ScramCredential(salt, storedKey, serverKey, iterations); }  }
ScramCredentialUtils { public static ScramCredential credentialFromString(String str) { Properties props = toProps(str); if (props.size() != 4 || !props.containsKey(SALT) || !props.containsKey(STORED_KEY) || !props.containsKey(SERVER_KEY) || !props.containsKey(ITERATIONS)) { throw new IllegalArgumentException("Credentials not valid: " + str); } byte[] salt = DatatypeConverter.parseBase64Binary(props.getProperty(SALT)); byte[] storedKey = DatatypeConverter.parseBase64Binary(props.getProperty(STORED_KEY)); byte[] serverKey = DatatypeConverter.parseBase64Binary(props.getProperty(SERVER_KEY)); int iterations = Integer.parseInt(props.getProperty(ITERATIONS)); return new ScramCredential(salt, storedKey, serverKey, iterations); }  static String credentialToString(ScramCredential credential); static ScramCredential credentialFromString(String str); static void createCache(CredentialCache cache, Collection<String> enabledMechanisms); }
ScramCredentialUtils { public static ScramCredential credentialFromString(String str) { Properties props = toProps(str); if (props.size() != 4 || !props.containsKey(SALT) || !props.containsKey(STORED_KEY) || !props.containsKey(SERVER_KEY) || !props.containsKey(ITERATIONS)) { throw new IllegalArgumentException("Credentials not valid: " + str); } byte[] salt = DatatypeConverter.parseBase64Binary(props.getProperty(SALT)); byte[] storedKey = DatatypeConverter.parseBase64Binary(props.getProperty(STORED_KEY)); byte[] serverKey = DatatypeConverter.parseBase64Binary(props.getProperty(SERVER_KEY)); int iterations = Integer.parseInt(props.getProperty(ITERATIONS)); return new ScramCredential(salt, storedKey, serverKey, iterations); }  static String credentialToString(ScramCredential credential); static ScramCredential credentialFromString(String str); static void createCache(CredentialCache cache, Collection<String> enabledMechanisms);  }