Java Code Examples for com.webauthn4j.converter.util.ObjectConverter#getCborConverter()

The following examples show how to use com.webauthn4j.converter.util.ObjectConverter#getCborConverter() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AuthenticatorTest.java    From webauthn4j with Apache License 2.0 6 votes vote down vote up
@Test
void serialization_deserialization_test() {
    ObjectConverter objectConverter = new ObjectConverter();
    CborConverter cborConverter = objectConverter.getCborConverter();

    TestAuthenticator original = new TestAuthenticator(
            TestDataUtil.createAttestedCredentialData(),
            TestAttestationStatementUtil.createFIDOU2FAttestationStatement(),
            0,
            Collections.emptySet(),
            null,
            null);
    byte[] serialized = cborConverter.writeValueAsBytes(original);
    Authenticator deserialized = cborConverter.readValue(serialized, TestAuthenticator.class);

    assertThat(deserialized).isEqualTo(original);
}
 
Example 2
Source File: AttestationObjectDeserializerTest.java    From webauthn4j with Apache License 2.0 6 votes vote down vote up
@Test
void test() {
    ObjectConverter objectConverter = new ObjectConverter();
    CborConverter cborConverter = objectConverter.getCborConverter();

    //Given
    //noinspection SpellCheckingInspection
    String input = "v2hhdXRoRGF0YVi6AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBAAAAAQAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAv2ExYTJhMvZhMyZhNPZhNfZiLTEBYi0yWCAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGItM1ggAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABhMQL_Z2F0dFN0bXS_Y3g1Y4FZAsswggLHMIIBr6ADAgECAhAg92PAQYOxBTfb6FBqIlDyMA0GCSqGSIb3DQEBCwUAMEoxEjAQBgNVBAoMCVNoYXJwTGFiLjE0MDIGA1UEAwwrc3ByaW5nLXNlY3VyaXR5LXdlYmF1dGhuIDJ0aWVyIHRlc3Qgcm9vdCBDQTAgFw0xODA1MjAwNzA5NTVaGA8yMTE4MDQyNjA3MDk1NVowfTELMAkGA1UEBhMCSlAxEjAQBgNVBAoMCVNoYXJwTGFiLjEgMB4GA1UECwwXQXR0ZXN0YXRpb24gQ2VydGlmaWNhdGUxODA2BgNVBAMML3dlYmF1dGhuNGogdGVzdCAydGllciBhdXRoZW50aWNhdG9yIGF0dGVzdGF0aW9uMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEYOdbrImOAgjZN3Xb8unfHHhJDINdIykolt-ypGxcrop4KwbujX2zvoRGZvdoQ9mu-rwjAZt4H3SMsSxPvB8z8KM_MD0wDAYDVR0TAQH_BAIwADAOBgNVHQ8BAf8EBAMCB4AwHQYDVR0OBBYEFNDrzrNaaa7sdMR9uzsvO8OohdjhMA0GCSqGSIb3DQEBCwUAA4IBAQCtHcryqNSHDyszLtIByc5AzPam37vl0AVchb0qOxLFbmdUu4Nhzk-87YdA_VZuvVLInsIGaCwkP3rdqGAFY1HllglMnmWIoG2sKjmT3vpJydlDODaha9F_fVG7cq2i5Zx2KMTeUtuTkNdZDjocUUHXYVShgNnggoUWkVeLBG1ckzK1tAkbUwyChWMv4PDmIUBNv6DwkYI9oBSCSAJHpUzyxzMvCRbAFAICwPl3g-SQEUeiNlnzJuGXHnHxu-DB6JD2b0hPeYD6XxWPuI0Pq1G_6hGQmsNv3SF2ye2y_HOKnw3L-fzRHl5ksOdVZbpy9xXzTdIBUpvTmFuwcBo4HwRMY3NpZ1ggAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD_Y2ZtdGhmaWRvLXUyZv8";

    //When
    AttestationObject result = cborConverter.readValue(Base64UrlUtil.decode(input), AttestationObject.class);

    //Then
    assertAll(
            () -> assertThat(result).isNotNull(),
            () -> assertThat(result.getAuthenticatorData()).isNotNull(),
            () -> assertThat(result.getFormat()).isEqualTo("fido-u2f"),
            () -> assertThat(result.getAttestationStatement()).isNotNull(),
            () -> assertThat(result.getAttestationStatement()).isInstanceOf(FIDOU2FAttestationStatement.class)
    );
}
 
Example 3
Source File: WebAuthnModelAuthenticator.java    From webauthn4j with Apache License 2.0 6 votes vote down vote up
public WebAuthnModelAuthenticator(
        AAGUID aaguid,
        KeyPair attestationKeyPair,
        CACertificatePath caCertificatePath,
        PrivateKey attestationIssuerPrivateKey,
        int counter,
        boolean capableOfUserVerification,
        ObjectConverter objectConverter) {
    this.aaguid = aaguid;
    this.attestationKeyPair = attestationKeyPair;
    this.caCertificatePath = caCertificatePath;
    this.attestationIssuerPrivateKey = attestationIssuerPrivateKey;
    this.credentialMap = new HashMap<>();
    this.counter = counter;
    this.capableOfUserVerification = capableOfUserVerification;
    this.objectConverter = objectConverter;
    this.cborConverter = objectConverter.getCborConverter();
    this.authenticatorDataConverter = new AuthenticatorDataConverter(objectConverter);
}
 
Example 4
Source File: X509CertificateDeserializerTest.java    From webauthn4j with Apache License 2.0 5 votes vote down vote up
@Test
void deserialize_empty_byte_array_test() {
    ObjectConverter objectConverter = new ObjectConverter();
    CborConverter cborConverter = objectConverter.getCborConverter();

    Map<String, byte[]> source = new HashMap<>();
    source.put("certificate", new byte[0]);
    byte[] input = cborConverter.writeValueAsBytes(source);

    X509CertificateDeserializerTestData result = cborConverter.readValue(input, X509CertificateDeserializerTestData.class);
    assertThat(result.getCertificate()).isNull();
}
 
Example 5
Source File: X509CertificateDeserializerTest.java    From webauthn4j with Apache License 2.0 5 votes vote down vote up
@Test
void deserialize_test() throws CertificateEncodingException {
    ObjectConverter objectConverter = new ObjectConverter();
    CborConverter cborConverter = objectConverter.getCborConverter();

    Map<String, byte[]> source = new HashMap<>();
    source.put("certificate", TestAttestationUtil.load2tierTestAuthenticatorAttestationCertificate().getEncoded());
    byte[] input = cborConverter.writeValueAsBytes(source);

    X509CertificateDeserializerTestData result = cborConverter.readValue(input, X509CertificateDeserializerTestData.class);
    assertThat(result.getCertificate()).isInstanceOf(X509Certificate.class);
}
 
Example 6
Source File: AuthenticatorDataConverter.java    From webauthn4j with Apache License 2.0 4 votes vote down vote up
public AuthenticatorDataConverter(ObjectConverter objectConverter) {
    AssertUtil.notNull(objectConverter, "objectConverter must not be null");
    this.cborConverter = objectConverter.getCborConverter();
    this.attestedCredentialDataConverter = new AttestedCredentialDataConverter(objectConverter);
}
 
Example 7
Source File: AttestationStatementConverter.java    From keycloak with Apache License 2.0 4 votes vote down vote up
public AttestationStatementConverter(ObjectConverter objectConverter) {
    this.cborConverter = objectConverter.getCborConverter();
}
 
Example 8
Source File: CredentialPublicKeyConverter.java    From keycloak with Apache License 2.0 4 votes vote down vote up
public CredentialPublicKeyConverter(ObjectConverter objectConverter) {
    this.cborConverter = objectConverter.getCborConverter();
}
 
Example 9
Source File: AttestedCredentialDataConverter.java    From webauthn4j with Apache License 2.0 4 votes vote down vote up
public AttestedCredentialDataConverter(ObjectConverter objectConverter) {
    AssertUtil.notNull(objectConverter, "objectConverter must not be null");
    this.cborConverter = objectConverter.getCborConverter();
}
 
Example 10
Source File: AttestationObjectConverter.java    From webauthn4j with Apache License 2.0 4 votes vote down vote up
public AttestationObjectConverter(ObjectConverter objectConverter) {
    AssertUtil.notNull(objectConverter, "objectConverter must not be null");
    this.cborConverter = objectConverter.getCborConverter();
}
 
Example 11
Source File: ServerEndpointFilterUtil.java    From webauthn4j-spring-security with Apache License 2.0 4 votes vote down vote up
ServerEndpointFilterUtil(ObjectConverter objectConverter) {
    this.jsonConverter = objectConverter.getJsonConverter();
    this.cborConverter = objectConverter.getCborConverter();
}
 
Example 12
Source File: AttestationStatementConverter.java    From webauthn4j-spring-security with Apache License 2.0 4 votes vote down vote up
public AttestationStatementConverter(ObjectConverter objectConverter) {
    this.cborConverter = objectConverter.getCborConverter();
}
 
Example 13
Source File: AuthenticatorExtensionsConverter.java    From webauthn4j-spring-security with Apache License 2.0 4 votes vote down vote up
public AuthenticatorExtensionsConverter(ObjectConverter objectConverter) {
    this.cborConverter = objectConverter.getCborConverter();
}
 
Example 14
Source File: COSEKeyConverter.java    From webauthn4j-spring-security with Apache License 2.0 4 votes vote down vote up
public COSEKeyConverter(ObjectConverter objectConverter) {
    this.cborConverter = objectConverter.getCborConverter();
}
 
Example 15
Source File: AttestationStatementConverter.java    From webauthn4j-spring-security with Apache License 2.0 4 votes vote down vote up
public AttestationStatementConverter(ObjectConverter objectConverter) {
    this.cborConverter = objectConverter.getCborConverter();
}
 
Example 16
Source File: AuthenticatorExtensionsConverter.java    From webauthn4j-spring-security with Apache License 2.0 4 votes vote down vote up
public AuthenticatorExtensionsConverter(ObjectConverter objectConverter) {
    this.cborConverter = objectConverter.getCborConverter();
}
 
Example 17
Source File: COSEKeyConverter.java    From webauthn4j-spring-security with Apache License 2.0 4 votes vote down vote up
public COSEKeyConverter(ObjectConverter objectConverter) {
    this.cborConverter = objectConverter.getCborConverter();
}