gluu
公開メンバ関数 | 非公開メンバ関数 | 非公開変数類 | 静的非公開変数類 | 全メンバ一覧
org.gluu.credmanager.plugins.authnmethod.service.otp.HOTPAlgorithmService クラス
org.gluu.credmanager.plugins.authnmethod.service.otp.HOTPAlgorithmService の継承関係図
Inheritance graph
org.gluu.credmanager.plugins.authnmethod.service.otp.HOTPAlgorithmService 連携図
Collaboration graph

公開メンバ関数

void init (HOTPConfig conf, String issuer)
 
byte [] generateSecretKey ()
 
String generateSecretKeyUri (byte[] secretKey, String displayName)
 
String getExternalUid (byte[] secretKey, String code)
 

非公開メンバ関数

Pair< Boolean, Long > validateKey (byte[] secretKey, String otpCode)
 
Pair< Boolean, Long > validateKey (byte[] secretKey, String otpCode, int movingFactor, Integer alternativeLookAheadWindow)
 

非公開変数類

Logger logger
 
HOTPConfig conf
 
String issuer
 

静的非公開変数類

static int MAX_LOOK_AHEAD_WINDOW = 25
 

詳解

Created by jgomer on 2018-06-28. An app. scoped bean that encapsulates logic related to generating and validating OTP keys. See https://tools.ietf.org/html/rfc6238 and https://tools.ietf.org/html/rfc4226.

関数詳解

◆ generateSecretKey()

byte [] org.gluu.credmanager.plugins.authnmethod.service.otp.HOTPAlgorithmService.generateSecretKey ( )
inline

org.gluu.credmanager.plugins.authnmethod.service.otp.IOTPAlgorithmを実装しています。

47  {
48  return Utils.randomBytes(conf.getKeyLength());
49  }
HOTPConfig conf
Definition: HOTPAlgorithmService.java:38
int getKeyLength()
Definition: BaseOTPConfig.java:16

◆ generateSecretKeyUri()

String org.gluu.credmanager.plugins.authnmethod.service.otp.HOTPAlgorithmService.generateSecretKeyUri ( byte []  secretKey,
String  displayName 
)
inline

org.gluu.credmanager.plugins.authnmethod.service.otp.IOTPAlgorithmを実装しています。

51  {
52 
53  String secretKeyBase32 = BaseEncoding.base32().omitPadding().encode(secretKey);
54  OTPKey otpKey = new OTPKey(secretKeyBase32, OTPType.HOTP);
55 
56  OTPAuthURIBuilder uribe = OTPAuthURIBuilder.fromKey(otpKey).label(displayName);
57  uribe = uribe.issuer(issuer).digits(conf.getDigits());
58 
59  logger.trace("Generating secret key URI");
60  return uribe.build().toUriString();
61 
62  }
HOTPConfig conf
Definition: HOTPAlgorithmService.java:38

◆ getExternalUid()

String org.gluu.credmanager.plugins.authnmethod.service.otp.HOTPAlgorithmService.getExternalUid ( byte []  secretKey,
String  code 
)
inline

org.gluu.credmanager.plugins.authnmethod.service.otp.IOTPAlgorithmを実装しています。

64  {
65  Pair<Boolean, Long> result = validateKey(secretKey, code);
66  return result.getX()
67  ? String.format("%s:%s;%s", OTPType.HOTP.getName().toLowerCase(), BaseEncoding.base64Url().encode(secretKey), result.getY())
68  : null;
69  }
Pair< Boolean, Long > validateKey(byte[] secretKey, String otpCode)
Definition: HOTPAlgorithmService.java:71

◆ init()

void org.gluu.credmanager.plugins.authnmethod.service.otp.HOTPAlgorithmService.init ( HOTPConfig  conf,
String  issuer 
)
inline
42  {
43  this.issuer = issuer;
44  this.conf = conf;
45  }
HOTPConfig conf
Definition: HOTPAlgorithmService.java:38

◆ validateKey() [1/2]

Pair<Boolean, Long> org.gluu.credmanager.plugins.authnmethod.service.otp.HOTPAlgorithmService.validateKey ( byte []  secretKey,
String  otpCode 
)
inlineprivate
71  {
72  //Use 1 as moving factor (assumes this is the very first use of the OTP hard token). In practice, this might not
73  //be the case, so a big value for look ahead window is used. This should not be done when validating an OTPs at
74  //login time, however, for enrollment is OK
75  return validateKey(secretKey, otpCode, 1, MAX_LOOK_AHEAD_WINDOW);
76  }
Pair< Boolean, Long > validateKey(byte[] secretKey, String otpCode)
Definition: HOTPAlgorithmService.java:71
static int MAX_LOOK_AHEAD_WINDOW
Definition: HOTPAlgorithmService.java:33

◆ validateKey() [2/2]

Pair<Boolean, Long> org.gluu.credmanager.plugins.authnmethod.service.otp.HOTPAlgorithmService.validateKey ( byte []  secretKey,
String  otpCode,
int  movingFactor,
Integer  alternativeLookAheadWindow 
)
inlineprivate
78  {
79  int window = alternativeLookAheadWindow == null ? conf.getLookAheadWindow() : alternativeLookAheadWindow;
80  HOTPValidationResult result = HOTPValidator.lookAheadWindow(window).validate(secretKey, movingFactor, conf.getDigits(), otpCode);
81  return result.isValid() ? new Pair<>(true, result.getNewMovingFactor()) : new Pair<>(false, null);
82  }
HOTPConfig conf
Definition: HOTPAlgorithmService.java:38
int getLookAheadWindow()
Definition: HOTPConfig.java:18

メンバ詳解

◆ conf

HOTPConfig org.gluu.credmanager.plugins.authnmethod.service.otp.HOTPAlgorithmService.conf
private

◆ issuer

String org.gluu.credmanager.plugins.authnmethod.service.otp.HOTPAlgorithmService.issuer
private

◆ logger

Logger org.gluu.credmanager.plugins.authnmethod.service.otp.HOTPAlgorithmService.logger
private

◆ MAX_LOOK_AHEAD_WINDOW

int org.gluu.credmanager.plugins.authnmethod.service.otp.HOTPAlgorithmService.MAX_LOOK_AHEAD_WINDOW = 25
staticprivate

このクラス詳解は次のファイルから抽出されました: