wstrange / GoogleAuth

Google Authenticator Server side code

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

getTotpPasswordOfUser(String userName) does not call correct helper method

jfonte-accesso opened this issue · comments

The getTotpPasswordOfUser method with just the userName parameter does not appropriately call getTotpPasswordOfUser(String userName, long time). Instead, it calls the getTotpPassword helper with userName as the key.

Relevant code block:

    public int getTotpPassword(String secret)
    {
        return getTotpPassword(secret, new Date().getTime());
    }

    public int getTotpPassword(String secret, long time)
    {
        return calculateCode(decodeSecret(secret), getTimeWindowFromTime(time));
    }

    public int getTotpPasswordOfUser(String userName)
    {
        return getTotpPassword(userName, new Date().getTime());
    }

    public int getTotpPasswordOfUser(String userName, long time)
    {
        ICredentialRepository repository = getValidCredentialRepository();

        return calculateCode(
                decodeSecret(repository.getSecretKey(userName)),
                getTimeWindowFromTime(time));
    }

Opening PR.