U2F { public DeviceRegistration finishRegistration(RegisterRequestData registerRequestData, RegisterResponse response) throws U2fRegistrationException { return finishRegistration(registerRequestData, response, null); } U2F(); private  U2F(boolean validateAppId); static U2F withoutAppIdValidation(); RegisterRequestData startRegistration(String appId, Iterable<? extends DeviceRegistration> devices); SignRequestData startSignature(String appId, Iterable<? extends DeviceRegistration> devices); DeviceRegistration finishRegistration(RegisterRequestData registerRequestData, RegisterResponse response); DeviceRegistration finishRegistration(RegisterRequestData registerRequestData, RegisterResponse response, Set<String> facets); DeviceRegistration finishSignature(SignRequestData signRequestData, SignResponse response, Iterable<? extends DeviceRegistration> devices); DeviceRegistration finishSignature(SignRequestData signRequestData, SignResponse response, Iterable<? extends DeviceRegistration> devices, Set<String> facets);  }
@Test public void finishRegistrationShouldReturnAMatchedDevice() throws Exception { DeviceRegistration deviceRegistration = new DeviceRegistration(KEY_HANDLE_BASE64, USER_PUBLIC_KEY_SIGN_HEX, ATTESTATION_CERTIFICATE, 0); DeviceRegistration deviceRegistration2 = new DeviceRegistration(KEY_HANDLE_BASE64, USER_PUBLIC_KEY_SIGN_HEX, ATTESTATION_CERTIFICATE, 0); RegisterRequest request = new RegisterRequest(SERVER_CHALLENGE_REGISTER_BASE64, APP_ID_ENROLL); RegisterResponse tokenResponse = new RegisterResponse( REGISTRATION_DATA_BASE64, CLIENT_DATA_REGISTRATION_BASE64 ); RegisterRequestData registerRequest = new RegisterRequestData( APP_ID_ENROLL, ImmutableList.<RegisteredKey>of(), ImmutableList.of(request) ); DeviceRegistration device = u2f.finishRegistration(registerRequest, tokenResponse, ImmutableSet.of(APP_ID_ENROLL)); DeviceRegistration overloadDevice = u2f.finishRegistration(registerRequest, tokenResponse); assertEquals(KEY_HANDLE_BASE64, device.getKeyHandle()); assertEquals(device, overloadDevice); }