/** * Get a credential from a String. If the credential String starts with a known Credential type (eg "CRYPT:" or "MD5:" ) then a Credential of that type is * returned. Otherwise, it tries to find a credential provider whose prefix matches with the start of the credential String. Else the credential is assumed * to be a Password. * * @param credential * String representation of the credential * @return A Credential or Password instance. */ public static Credential getCredential(String credential) { if (credential.startsWith(Crypt.__TYPE)) return new Crypt(credential); if (credential.startsWith(MD5.__TYPE)) return new MD5(credential); for (CredentialProvider cp : CREDENTIAL_PROVIDER_LOADER) { if (credential.startsWith(cp.getPrefix())) { final Credential credentialObj = cp.getCredential(credential); if (credentialObj != null) { return credentialObj; } } } return new Password(credential); }
/** * Get a credential from a String. If the credential String starts with a known Credential type (eg "CRYPT:" or "MD5:" ) then a Credential of that type is * returned. Otherwise, it tries to find a credential provider whose prefix matches with the start of the credential String. Else the credential is assumed * to be a Password. * * @param credential * String representation of the credential * @return A Credential or Password instance. */ public static Credential getCredential(String credential) { if (credential.startsWith(Crypt.__TYPE)) return new Crypt(credential); if (credential.startsWith(MD5.__TYPE)) return new MD5(credential); for (CredentialProvider cp : CREDENTIAL_PROVIDER_LOADER) { if (credential.startsWith(cp.getPrefix())) { final Credential credentialObj = cp.getCredential(credential); if (credentialObj != null) { return credentialObj; } } } return new Password(credential); }