【问题标题】:ICredentialRepository service must be configured in order to use this feature必须配置 ICredentialRepository 服务才能使用此功能
【发布时间】:2017-02-16 01:12:08
【问题描述】:

来自https://github.com/wstrange/GoogleAuth

为用户设置凭据时:

GoogleAuthenticator gAuth = new GoogleAuthenticator(); final GoogleAuthenticatorKey key = gAuth.createCredentials("daryll123");

发生异常:

java.lang.UnsupportedOperationException: An instance of the com.warrenstrange.googleauth.ICredentialRepository service must be configured in order to use this feature.

如何使用ICredentialRepository 进行配置才能工作? 它在那里声明了 Java ServiceLoader API。不知道是怎么回事。

【问题讨论】:

    标签: java one-time-password


    【解决方案1】:

    您必须在某处实现 ICredentialRepository 接口方法,并将该类设置为 gAuth 变量上的凭据存储库,使用

    setCredentialRepository()
    

    如果你在当前类上实现了方法,你可以使用

    gAuth.setCredentialRepository(this)
    

    接口方法是

    String getSecretKey(String userName);
    

    void saveUserCredentials(String userName,
                             String secretKey,
                             int validationCode,
                             List<Integer> scratchCodes);
    

    该错误令人困惑,因为它没有提供您的凭据存储库未正确设置的上下文。希望这会有所帮助!

    【讨论】:

      猜你喜欢
      • 2015-06-29
      • 2016-03-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-04-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多