OTPでバインディングを有効化
最終更新
役に立ちましたか?
役に立ちましたか?
@Override
public void onIssuerAuthenticationRequired(PendingBindingSession pendingBindingSession) {
// OTP_SMS ID&Vメソッドを送信する
for (IDVMethod idvMethod : pendingBindingSession.getIdvMethods()) {
if (idvMethod.getType().equals(IDVType.OTP_SMS)) {
pendingBindingSession.submitIdvMethod(idvMethod);
}
}
}
@Override
public void onIssuerAuthenticationReady(PendingBindingSession pendingBindingSession,
@Nullable OtpActivationStatus status) {
}
@Override
public void onError(TMGClientException exception) {
// エラーがあるか確認する
int errorCode = exception.getErrorCode();
int errorMessage = exception.getMessage();
}guard let idvSession = VisaService.shared.idvSession else {
// idvセッションがない
return
}
// 1. idvメソッドの一覧を表示する
do {
let idvMethods = try idvSession.idvMethods
let selectedIdvMethod = idvMethods[0] // ユーザーがOTP idvメソッド(OTP_SMS)を選択
// 2. idvメソッドを送信する
idvSession.selectIDVMethod(selectedIdvMethod) { (result) in
if let otpActivationStatus = result {
let maxOtpVerificationAllowed = otpActivationStatus.maxOTPVerificationAllowed
let maxOtpRequestsAllowed = otpActivationStatus.maxOTPRequestsAllowed
let otpExpiration = otpActivationStatus.otpExpiration
// 3. OTPを入力するページを表示する
}
}
} catch let error {
// エラーを処理する
}
// 4. ステップ2(selectIDVMethod)の失敗はcompletionHandlerで処理されます。
VisaService.shared.completionHandler = { (session, error) in
// 5. selectIDVMethodのエラーか確認する。
if let session = session,
let error = error,
error.description == TMGError.invalidIdvMethod.description {
VisaService.shared.idvSession = session
// 6. IDVフローを再試行する。
}
}@Override
public void onIssuerAuthenticationReady(IDVSession idvSession,
@Nullable OtpActivationStatus status) {
// バインディングを有効化する
String otp;
idvSession.activateBinding(otp);
}
@Override
public void onIssuerAuthenticationError(@Nullable IDVSession idvSession,
TMGClientException tmgClientException) {
// エラーを確認するか再試行する
}// 1. ユーザー入力からのOTP値
let otp = ""
guard let idvSession = VisaService.shared.idvSession else {
// idvセッションがない
return
}
// 2. activateを呼ぶ
idvSession.activateBinding(withValue: otp)
VisaService.shared.completionHandler = { (session, error) in
// 2. バインディング成功
if error == nil {
} else if let error = error,
let session = session,
error.description == TMGError.serverErrorWrongOTP.description {
VisaService.shared.idvSession = session
// 3. OTP入力を再試行し、エラーメッセージを表示する
}
}