Search in sources :

Example 1 with MetadataBLOB

use of com.webauthn4j.metadata.data.MetadataBLOB in project webauthn4j by webauthn4j.

the class CachingMetadataBLOBProviderTest method createMetadataBLOB.

private MetadataBLOB createMetadataBLOB(LocalDate nextUpdate) {
    JWSFactory factory = new JWSFactory(new ObjectConverter());
    JWSHeader header = new JWSHeader(JWAIdentifier.ES256, null);
    MetadataBLOBPayload payload = new MetadataBLOBPayload("", 0, nextUpdate, Collections.emptyList());
    JWS<MetadataBLOBPayload> jws = factory.create(header, payload, new byte[32]);
    return new MetadataBLOB(jws);
}
Also used : ObjectConverter(com.webauthn4j.converter.util.ObjectConverter) MetadataBLOB(com.webauthn4j.metadata.data.MetadataBLOB) JWSFactory(com.webauthn4j.data.jws.JWSFactory) JWSHeader(com.webauthn4j.data.jws.JWSHeader) MetadataBLOBPayload(com.webauthn4j.metadata.data.MetadataBLOBPayload)

Example 2 with MetadataBLOB

use of com.webauthn4j.metadata.data.MetadataBLOB in project webauthn4j by webauthn4j.

the class FidoMDS3MetadataBLOBProviderTest method test.

@Test
void test() {
    X509Certificate rootCertificate = CertificateUtil.generateX509Certificate(Base64Util.decode("MIIDXzCCAkegAwIBAgILBAAAAAABIVhTCKIwDQYJKoZIhvcNAQELBQAwTDEgMB4G" + "A1UECxMXR2xvYmFsU2lnbiBSb290IENBIC0gUjMxEzARBgNVBAoTCkdsb2JhbFNp" + "Z24xEzARBgNVBAMTCkdsb2JhbFNpZ24wHhcNMDkwMzE4MTAwMDAwWhcNMjkwMzE4" + "MTAwMDAwWjBMMSAwHgYDVQQLExdHbG9iYWxTaWduIFJvb3QgQ0EgLSBSMzETMBEG" + "A1UEChMKR2xvYmFsU2lnbjETMBEGA1UEAxMKR2xvYmFsU2lnbjCCASIwDQYJKoZI" + "hvcNAQEBBQADggEPADCCAQoCggEBAMwldpB5BngiFvXAg7aEyiie/QV2EcWtiHL8" + "RgJDx7KKnQRfJMsuS+FggkbhUqsMgUdwbN1k0ev1LKMPgj0MK66X17YUhhB5uzsT" + "gHeMCOFJ0mpiLx9e+pZo34knlTifBtc+ycsmWQ1z3rDI6SYOgxXG71uL0gRgykmm" + "KPZpO/bLyCiR5Z2KYVc3rHQU3HTgOu5yLy6c+9C7v/U9AOEGM+iCK65TpjoWc4zd" + "QQ4gOsC0p6Hpsk+QLjJg6VfLuQSSaGjlOCZgdbKfd/+RFO+uIEn8rUAVSNECMWEZ" + "XriX7613t2Saer9fwRPvm2L7DWzgVGkWqQPabumDk3F2xmmFghcCAwEAAaNCMEAw" + "DgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFI/wS3+o" + "LkUkrk1Q+mOai97i3Ru8MA0GCSqGSIb3DQEBCwUAA4IBAQBLQNvAUKr+yAzv95ZU" + "RUm7lgAJQayzE4aGKAczymvmdLm6AC2upArT9fHxD4q/c2dKg8dEe3jgr25sbwMp" + "jjM5RcOO5LlXbKr8EpbsU8Yt5CRsuZRj+9xTaGdWPoO4zzUhw8lo/s7awlOqzJCK" + "6fBdRoyV3XpYKBovHd7NADdBj+1EbddTKJd+82cEHhXXipa0095MJ6RMG3NzdvQX" + "mcIfeg7jLQitChws/zyrVQ4PkX4268NXSb7hLi18YIvDQVETI53O9zJrlAGomecs" + "Mx86OyXShkDOOyyGeMlhLxS67ttVb9+E7gUJTb0o2HLO02JQZR7rkpeDMdmztcpH" + "WD9f"));
    FidoMDS3MetadataBLOBProvider target = new FidoMDS3MetadataBLOBProvider(new ObjectConverter(), rootCertificate);
    MetadataBLOB metadataBLOB = target.provide();
    assertThat(metadataBLOB).isNotNull();
}
Also used : ObjectConverter(com.webauthn4j.converter.util.ObjectConverter) MetadataBLOB(com.webauthn4j.metadata.data.MetadataBLOB) X509Certificate(java.security.cert.X509Certificate) Test(org.junit.jupiter.api.Test)

Example 3 with MetadataBLOB

use of com.webauthn4j.metadata.data.MetadataBLOB in project webauthn4j by webauthn4j.

the class FidoMDS3MetadataBLOBProvider method doProvide.

@Override
@NonNull
protected MetadataBLOB doProvide() {
    String responseBody = httpClient.fetch(blobEndpoint);
    MetadataBLOB metadataBLOB = metadataBLOBFactory.parse(responseBody);
    if (!metadataBLOB.isValidSignature()) {
        throw new MDSException("MetadataBLOB signature is invalid");
    }
    validateCertPath(metadataBLOB);
    return metadataBLOB;
}
Also used : MetadataBLOB(com.webauthn4j.metadata.data.MetadataBLOB) MDSException(com.webauthn4j.metadata.exception.MDSException) NonNull(org.checkerframework.checker.nullness.qual.NonNull)

Example 4 with MetadataBLOB

use of com.webauthn4j.metadata.data.MetadataBLOB in project webauthn4j by webauthn4j.

the class LocalFileMetadataBLOBProviderTest method test.

@Test
void test() throws IOException {
    Path blobPath = new File("src/test/resources/integration/component/blob.jwt").toPath();
    Path dstPath = tempDir.resolve("blob.jwt");
    Files.copy(blobPath, dstPath);
    LocalFileMetadataBLOBProvider target = new LocalFileMetadataBLOBProvider(new ObjectConverter(), dstPath);
    MetadataBLOB metadataBLOB = target.provide();
    assertThat(metadataBLOB).isNotNull();
}
Also used : Path(java.nio.file.Path) ObjectConverter(com.webauthn4j.converter.util.ObjectConverter) MetadataBLOB(com.webauthn4j.metadata.data.MetadataBLOB) File(java.io.File) Test(org.junit.jupiter.api.Test)

Aggregations

MetadataBLOB (com.webauthn4j.metadata.data.MetadataBLOB)4 ObjectConverter (com.webauthn4j.converter.util.ObjectConverter)3 Test (org.junit.jupiter.api.Test)2 JWSFactory (com.webauthn4j.data.jws.JWSFactory)1 JWSHeader (com.webauthn4j.data.jws.JWSHeader)1 MetadataBLOBPayload (com.webauthn4j.metadata.data.MetadataBLOBPayload)1 MDSException (com.webauthn4j.metadata.exception.MDSException)1 File (java.io.File)1 Path (java.nio.file.Path)1 X509Certificate (java.security.cert.X509Certificate)1 NonNull (org.checkerframework.checker.nullness.qual.NonNull)1