Prevent ClassCastException if credentials are not of type PasswordCredential

In setPassword, if the current credential is not of type password then the final OR clause will still be executed causing a ClassCastException.