class U2fPrimitives {

    public DeviceRegistration finishRegistration(RegisterRequest registerRequest, RegisterResponse response) throws U2fRegistrationException {
        return finishRegistration(registerRequest, response, null);
    }

}

class U2fPrimitivesTest {

    final HashSet<String> allowedOrigins;
     U2fPrimitives u2f;
    @Rule
    public ExpectedException expectedException;

    @Test
    public void finishRegistrationShouldDetectIncorrectClientDataOrigin() throws Exception {

        expectedException.expectCause(isA(U2fBadInputException.class));

        RegisterRequest registerRequest = new RegisterRequest(SERVER_CHALLENGE_REGISTER_BASE64, APP_ID_ENROLL);

        String clientDataBase64 = U2fB64Encoding.encode("{\"typ\":\"navigator.id.finishEnrollment\",\"challenge\":\"vqrS6WXDe1JUs5_c3i4-LkKIHRr-3XVb3azuA5TifHo\",\"origin\":\"http://evil.com\"}".getBytes("UTF-8"));

        u2f.finishRegistration(
            registerRequest,
            new RegisterResponse(
                TestVectors.REGISTRATION_DATA_BASE64,
                clientDataBase64
            )
        );

        fail("finishRegistration did not detect incorrect origin in client data");
    }

}