Search in sources :

Example 21 with Path

use of com.reprezen.kaizen.oasparser.model3.Path in project ets-ogcapi-edr10 by opengeospatial.

the class CollectionsTime method corridorHeightParameterDefinition.

/**
 * <pre>
 * Abstract Test 120: Validate that the corridor-height query parameter is constructed correctly.
 * </pre>
 *
 * @param testPoint the testPoint under test, never <code>null</code>
 * @param model api definition, never <code>null</code>
 */
public void corridorHeightParameterDefinition(TestPoint testPoint, OpenApi3 model) {
    Parameter corridorHeight = null;
    String paramName = "corridor-height";
    for (Path path : model.getPaths().values()) {
        if (testPoint.getPath().equals(path.getPathString())) {
            for (Operation op : path.getOperations().values()) {
                for (Parameter param : op.getParameters()) {
                    if (hasName(param)) {
                        if (param.getName().equals(paramName)) {
                            corridorHeight = param;
                        }
                    }
                }
            }
        }
    }
    if (corridorHeight != null) {
        String msg = "Expected property '%s' with value '%s' but was '%s'";
        assertEquals(corridorHeight.getName(), paramName, String.format(msg, "name", paramName, corridorHeight.getName()));
        assertEquals(corridorHeight.getIn(), "query", String.format(msg, "in", "query", corridorHeight.getIn()));
        assertTrue(isRequired(corridorHeight), String.format(msg, "required", "true", corridorHeight.getRequired()));
        assertEquals(corridorHeight.getStyle(), "form", String.format(msg, "style", "form", corridorHeight.getStyle()));
        assertFalse(isExplode(corridorHeight), String.format(msg, "explode", "false", corridorHeight.getExplode()));
    }
}
Also used : Path(com.reprezen.kaizen.oasparser.model3.Path) Parameter(com.reprezen.kaizen.oasparser.model3.Parameter) Operation(com.reprezen.kaizen.oasparser.model3.Operation)

Example 22 with Path

use of com.reprezen.kaizen.oasparser.model3.Path in project ets-ogcapi-edr10 by opengeospatial.

the class CollectionsTime method resolutionzParameterDefinition.

/**
 * <pre>
 * Requirement A.30: /req/edr/resolution-z-definition Parameter resolution-z definition
 * </pre>
 * NOTE: Not referenced by ATS
 *
 * @param testPoint the testPoint under test, never <code>null</code>
 * @param model api definition, never <code>null</code>
 */
public void resolutionzParameterDefinition(TestPoint testPoint, OpenApi3 model) {
    Parameter resolutionz = null;
    String paramName = "resolution-z";
    for (Path path : model.getPaths().values()) {
        if (testPoint.getPath().equals(path.getPathString())) {
            for (Operation op : path.getOperations().values()) {
                for (Parameter param : op.getParameters()) {
                    if (hasName(param)) {
                        if (param.getName().equals(paramName)) {
                            resolutionz = param;
                        }
                    }
                }
            }
        }
    }
    if (resolutionz != null) {
        String msg = "Expected property '%s' with value '%s' but was '%s'";
        assertEquals(resolutionz.getName(), paramName, String.format(msg, "name", paramName, resolutionz.getName()));
        assertEquals(resolutionz.getIn(), "query", String.format(msg, "in", "query", resolutionz.getIn()));
        assertFalse(isRequired(resolutionz), String.format(msg, "required", "false", resolutionz.getRequired()));
        assertEquals(resolutionz.getStyle(), "form", String.format(msg, "style", "form", resolutionz.getStyle()));
        assertFalse(isExplode(resolutionz), String.format(msg, "explode", "false", resolutionz.getExplode()));
    }
}
Also used : Path(com.reprezen.kaizen.oasparser.model3.Path) Parameter(com.reprezen.kaizen.oasparser.model3.Parameter) Operation(com.reprezen.kaizen.oasparser.model3.Operation)

Example 23 with Path

use of com.reprezen.kaizen.oasparser.model3.Path in project jmulticard by ctt-gob-es.

the class CardOS method preloadCertificates.

private void preloadCertificates() throws FileNotFoundException, Iso7816FourCardException, IOException, Asn1Exception, TlvException {
    // Entramos en el directorio PKCS#15
    selectFileByName(PKCS15_NAME);
    // Seleccionamos el ODF, no nos devuelve FCI ni nada
    selectFileById(new byte[] { (byte) 0x50, (byte) 0x31 });
    // Leemos el ODF, que tiene esta estructura en cada uno de sus registros:
    // PKCS15Objects ::= CHOICE {
    // privateKeys         [0] PrivateKeys,
    // publicKeys          [1] PublicKeys,
    // trustedPublicKeys   [2] PublicKeys,
    // secretKeys          [3] SecretKeys,
    // certificates        [4] Certificates,
    // trustedCertificates [5] Certificates,
    // usefulCertificates  [6] Certificates,
    // dataObjects         [7] DataObjects,
    // authObjects         [8] AuthObjects,
    // ... -- For future extensions
    // }
    // A2
    final byte[] odfBytes = readBinaryComplete(162);
    final Odf odf = new Odf();
    odf.setDerValue(odfBytes);
    // Sacamos del ODF la ruta del CDF
    final Path cdfPath = odf.getCdfPath();
    // Seleccionamos el CDF
    selectFileById(cdfPath.getPathBytes());
    // Leemos el CDF mediante registros
    final List<byte[]> cdfRecords = readAllRecords();
    CertificateObject co;
    for (final byte[] b : cdfRecords) {
        try {
            co = new CertificateObject();
            co.setDerValue(HexUtils.subArray(b, 2, b.length - 2));
        } catch (final Exception e) {
            // $NON-NLS-1$
            LOGGER.warning("Omitido registro de certificado por no ser un CertificateObject de PKCS#15: " + e);
            continue;
        }
        final byte[] certPath = co.getPathBytes();
        if (certPath == null || certPath.length != 4) {
            // $NON-NLS-1$
            LOGGER.warning("Se omite una posicion de certificado porque su ruta no es de cuatro octetos: " + co.getAlias());
            continue;
        }
        final byte[] masterFile = { (byte) 0x50, (byte) 0x15 };
        sendArbitraryApdu(new CommandApdu(// CLA
        getCla(), // INS
        (byte) 0xA4, // P1
        (byte) 0x08, // P2
        (byte) 0x0C, new byte[] { masterFile[0], masterFile[1], certPath[0], certPath[1], certPath[2], certPath[3] }, null));
        final byte[] certBytes = readBinaryComplete(9999);
        final X509Certificate cert;
        try {
            cert = CertificateUtils.generateCertificate(certBytes);
        } catch (final CertificateException e) {
            LOGGER.severe(// $NON-NLS-1$ //$NON-NLS-2$
            "No ha sido posible generar el certificado para el alias " + co.getAlias() + ": " + e);
            continue;
        }
        CERTIFICATES_BY_ALIAS.put(co.getAlias(), cert);
    }
}
Also used : Odf(es.gob.jmulticard.asn1.der.pkcs15.Odf) Path(es.gob.jmulticard.asn1.der.pkcs15.Path) CommandApdu(es.gob.jmulticard.apdu.CommandApdu) CertificateObject(es.gob.jmulticard.asn1.der.pkcs15.CertificateObject) CertificateException(java.security.cert.CertificateException) ApduConnectionException(es.gob.jmulticard.apdu.connection.ApduConnectionException) FileNotFoundException(es.gob.jmulticard.card.iso7816four.FileNotFoundException) InvalidCardException(es.gob.jmulticard.card.InvalidCardException) CardNotPresentException(es.gob.jmulticard.apdu.connection.CardNotPresentException) IOException(java.io.IOException) CertificateException(java.security.cert.CertificateException) NoReadersFoundException(es.gob.jmulticard.apdu.connection.NoReadersFoundException) TlvException(es.gob.jmulticard.asn1.TlvException) Iso7816FourCardException(es.gob.jmulticard.card.iso7816four.Iso7816FourCardException) Asn1Exception(es.gob.jmulticard.asn1.Asn1Exception) X509Certificate(java.security.cert.X509Certificate)

Example 24 with Path

use of com.reprezen.kaizen.oasparser.model3.Path in project ets-ogcapi-edr10 by opengeospatial.

the class CollectionsTime method coordsParameterDefinition.

/**
 * <pre>
 * Abstract Test 38: Validate that the coords query parameters are constructed correctly. (position)
 * Abstract Test 54: Validate that the coords query parameters are constructed correctly. (area)
 * Abstract Test 70: Validate that the coords query parameters are constructed correctly. (cube)
 * Abstract Test 92: Validate that the coords query parameters are constructed correctly. (trajectory)
 * Abstract Test 116: Validate that the coords query parameters are constructed correctly. (corridor)
 * </pre>
 *
 * @param testPoint the testPoint under test, never <code>null</code>
 * @param model api definition, never <code>null</code>
 */
public void coordsParameterDefinition(TestPoint testPoint, OpenApi3 model) {
    Parameter coords = null;
    String paramName = "coords";
    boolean hasCoordsParameter = false;
    for (Path path : model.getPaths().values()) {
        if (path.getPathString().endsWith(testPoint.getPath())) {
            for (Operation op : path.getOperations().values()) {
                for (Parameter param : op.getParameters()) {
                    if (hasName(param)) {
                        if (param.getName().equals(paramName)) {
                            coords = param;
                        }
                    }
                }
            }
        }
    }
    if (!testPoint.getPath().endsWith("/locations")) {
        assertNotNull(coords, "Required " + paramName + " parameter for collections with path '" + testPoint.getPath() + "'  in OpenAPI document is missing");
        if (coords != null) {
            String msg = "Expected property '%s' with value '%s' but was '%s'";
            assertEquals(coords.getName(), paramName, String.format(msg, "name", paramName, coords.getName()));
            assertEquals(coords.getIn(), "query", String.format(msg, "in", "query", coords.getIn()));
            assertTrue(isRequired(coords), String.format(msg, "required", "true", coords.getRequired()));
            // assertEquals( coords.getStyle(), "form", String.format( msg, "style","form",
            // coords.getStyle() ) ); //TODO SHOULD BE Enabled
            assertFalse(isExplode(coords), String.format(msg, "explode", "false", coords.getExplode()));
            Schema schema = coords.getSchema();
            assertEquals(schema.getType(), "string", String.format(msg, "schema -> type", "string", schema.getType()));
        }
    }
}
Also used : Path(com.reprezen.kaizen.oasparser.model3.Path) Schema(com.reprezen.kaizen.oasparser.model3.Schema) Parameter(com.reprezen.kaizen.oasparser.model3.Parameter) Operation(com.reprezen.kaizen.oasparser.model3.Operation)

Example 25 with Path

use of com.reprezen.kaizen.oasparser.model3.Path in project ets-ogcapi-edr10 by opengeospatial.

the class CollectionsTime method withinUnitsParameterDefinition.

/**
 * <pre>
 * Requirement A.23: /req/edr/within-units-definition Parameter withinUnits
 * definition
 * </pre>
 * NOTE: Not referenced by ATS
 *
 * @param testPoint the testPoint under test, never <code>null</code>
 * @param model api definition, never <code>null</code>
 */
public void withinUnitsParameterDefinition(TestPoint testPoint, OpenApi3 model) {
    Parameter withinUnits = null;
    String paramName = "within-units";
    for (Path path : model.getPaths().values()) {
        if (testPoint.getPath().equals(path.getPathString())) {
            for (Operation op : path.getOperations().values()) {
                for (Parameter param : op.getParameters()) {
                    if (hasName(param)) {
                        if (param.getName().equals(paramName)) {
                            withinUnits = param;
                        }
                    }
                }
            }
        }
    }
    if (withinUnits != null) {
        String msg = "Expected property '%s' with value '%s' but was '%s'";
        assertEquals(withinUnits.getName(), paramName, String.format(msg, "name", paramName, withinUnits.getName()));
        assertEquals(withinUnits.getIn(), "query", String.format(msg, "in", "query", withinUnits.getIn()));
        assertFalse(isRequired(withinUnits), String.format(msg, "required", "false", withinUnits.getRequired()));
        assertEquals(withinUnits.getStyle(), "form", String.format(msg, "style", "form", withinUnits.getStyle()));
        assertFalse(isExplode(withinUnits), String.format(msg, "explode", "false", withinUnits.getExplode()));
    }
}
Also used : Path(com.reprezen.kaizen.oasparser.model3.Path) Parameter(com.reprezen.kaizen.oasparser.model3.Parameter) Operation(com.reprezen.kaizen.oasparser.model3.Operation)

Aggregations

Path (com.reprezen.kaizen.oasparser.model3.Path)24 Parameter (com.reprezen.kaizen.oasparser.model3.Parameter)21 Operation (com.reprezen.kaizen.oasparser.model3.Operation)16 ArrayList (java.util.ArrayList)8 Path (org.dishevelled.bio.assembly.gfa1.Path)7 Schema (com.reprezen.kaizen.oasparser.model3.Schema)6 BufferedReader (java.io.BufferedReader)5 OpenApi3 (com.reprezen.kaizen.oasparser.model3.OpenApi3)4 PrintWriter (java.io.PrintWriter)4 HashMap (java.util.HashMap)4 CommandLineParseException (org.dishevelled.commandline.CommandLineParseException)4 OpenApi3Parser (com.reprezen.kaizen.oasparser.OpenApi3Parser)3 LinkedList (java.util.LinkedList)3 Traversal (org.dishevelled.bio.assembly.gfa1.Traversal)3 Test (org.testng.annotations.Test)3 HashBasedTable (com.google.common.collect.HashBasedTable)2 Table (com.google.common.collect.Table)2 ApduConnectionException (es.gob.jmulticard.apdu.connection.ApduConnectionException)2 Asn1Exception (es.gob.jmulticard.asn1.Asn1Exception)2 TlvException (es.gob.jmulticard.asn1.TlvException)2