Slide 19
Slide 19 text
Copyright © Yoshikazu Nojima 2018
テストサポート機能
• WebAuthnによるログインのテストを自動化する場合、
最大の問題は認証デバイスをどうするか
• WebAuthn4Jではテストサポート用に認証デバイスのエミュレータを用意
18
// 認証デバイスエミュレータの接続されたクライアントエミュレータを準備
private ClientPlatform clientPlatform = EmulatorUtil.createClientPlatform(new AndroidSafetyNetAuthenticator());
@Test
void validate_test(){
String rpId = “example.com”;
Challenge challenge = new DefaultChallenge();
AuthenticatorSelectionCriteria authenticatorSelectionCriteria =
new AuthenticatorSelectionCriteria(AuthenticatorAttachment.CROSS_PLATFORM, true, UserVerificationRequirement.REQUIRED);
PublicKeyCredentialParameters publicKeyCredentialParameters = new PublicKeyCredentialParameters(PublicKeyCredentialType.PUBLIC_KEY,
COSEAlgorithmIdentifier.ES256);
PublicKeyCredentialUserEntity publicKeyCredentialUserEntity = new PublicKeyCredentialUserEntity();
AuthenticationExtensionsClientInputs extensions = new AuthenticationExtensionsClientInputs<>();
PublicKeyCredentialCreationOptions credentialCreationOptions
= new PublicKeyCredentialCreationOptions(
new PublicKeyCredentialRpEntity(rpId, “example.com”), publicKeyCredentialUserEntity, challenge,
Collections.singletonList(publicKeyCredentialParameters), null, Collections.emptyList(),
authenticatorSelectionCriteria, AttestationConveyancePreference.DIRECT, extensions
);
// エミュレータによるCredentialの生成
PublicKeyCredential publicKeyCredential =
clientPlatform.create(credentialCreationOptions);
// 以下省略
}