@Test public void testWriteAtomPublicKey() throws Exception { Dataset testDataset = TestSigningUtils.prepareTestDatasetFromNamedGraphs(ATOM_FILE, new String[] { ATOM_CORE_DATA_URI }); Dataset datasetWithExpectedModel = TestSigningUtils.prepareTestDatasetFromNamedGraphs(RESOURCE_FILE, new String[] { ATOM_CORE_DATA_URI }); Model testModel = testDataset.getNamedModel(ATOM_CORE_DATA_URI); Resource keySubj = testModel.createResource(ATOM_URI); extractor.writeToModel(testModel, keySubj, keys.getPublicKey(TestSigningUtils.atomCertUri)); Assert.assertTrue(testModel.isIsomorphicWith(datasetWithExpectedModel.getNamedModel(ATOM_CORE_DATA_URI))); }
private void writeToModel(Model model, Resource keySubject, WonEccPublicKey pubKey) { Resource bn = model.createResource(); Statement stmt = model.createStatement(bn, RDF.type, WON.ECCPublicKey); model.add(stmt); stmt = model.createStatement(bn, WON.ecc_algorithm, pubKey.getAlgorithm()); model.add(stmt); stmt = model.createStatement(bn, WON.ecc_curveId, pubKey.getCurveId()); model.add(stmt); stmt = model.createStatement(bn, WON.ecc_qx, model.createLiteral(pubKey.getQx())); model.add(stmt); stmt = model.createStatement(bn, WON.ecc_qy, model.createLiteral(pubKey.getQy())); model.add(stmt); Resource bn2 = model.createResource(); stmt = model.createStatement(bn2, CERT.PUBLIC_KEY, bn); model.add(stmt); stmt = model.createStatement(keySubject, CERT.KEY, bn2); model.add(stmt); }
WonKeysReaderWriter { private void writeToModel(Model model, Resource keySubject, WonEccPublicKey pubKey) { Resource bn = model.createResource(); Statement stmt = model.createStatement(bn, RDF.type, WON.ECCPublicKey); model.add(stmt); stmt = model.createStatement(bn, WON.ecc_algorithm, pubKey.getAlgorithm()); model.add(stmt); stmt = model.createStatement(bn, WON.ecc_curveId, pubKey.getCurveId()); model.add(stmt); stmt = model.createStatement(bn, WON.ecc_qx, model.createLiteral(pubKey.getQx())); model.add(stmt); stmt = model.createStatement(bn, WON.ecc_qy, model.createLiteral(pubKey.getQy())); model.add(stmt); Resource bn2 = model.createResource(); stmt = model.createStatement(bn2, CERT.PUBLIC_KEY, bn); model.add(stmt); stmt = model.createStatement(keySubject, CERT.KEY, bn2); model.add(stmt); } }
WonKeysReaderWriter { private void writeToModel(Model model, Resource keySubject, WonEccPublicKey pubKey) { Resource bn = model.createResource(); Statement stmt = model.createStatement(bn, RDF.type, WON.ECCPublicKey); model.add(stmt); stmt = model.createStatement(bn, WON.ecc_algorithm, pubKey.getAlgorithm()); model.add(stmt); stmt = model.createStatement(bn, WON.ecc_curveId, pubKey.getCurveId()); model.add(stmt); stmt = model.createStatement(bn, WON.ecc_qx, model.createLiteral(pubKey.getQx())); model.add(stmt); stmt = model.createStatement(bn, WON.ecc_qy, model.createLiteral(pubKey.getQy())); model.add(stmt); Resource bn2 = model.createResource(); stmt = model.createStatement(bn2, CERT.PUBLIC_KEY, bn); model.add(stmt); stmt = model.createStatement(keySubject, CERT.KEY, bn2); model.add(stmt); } WonKeysReaderWriter(); }
WonKeysReaderWriter { private void writeToModel(Model model, Resource keySubject, WonEccPublicKey pubKey) { Resource bn = model.createResource(); Statement stmt = model.createStatement(bn, RDF.type, WON.ECCPublicKey); model.add(stmt); stmt = model.createStatement(bn, WON.ecc_algorithm, pubKey.getAlgorithm()); model.add(stmt); stmt = model.createStatement(bn, WON.ecc_curveId, pubKey.getCurveId()); model.add(stmt); stmt = model.createStatement(bn, WON.ecc_qx, model.createLiteral(pubKey.getQx())); model.add(stmt); stmt = model.createStatement(bn, WON.ecc_qy, model.createLiteral(pubKey.getQy())); model.add(stmt); Resource bn2 = model.createResource(); stmt = model.createStatement(bn2, CERT.PUBLIC_KEY, bn); model.add(stmt); stmt = model.createStatement(keySubject, CERT.KEY, bn2); model.add(stmt); } WonKeysReaderWriter(); Map<String, PublicKey> readFromDataset(Dataset dataset); Set<PublicKey> readFromDataset(Dataset dataset, String keyUri); Map<String, PublicKey> readFromModel(Model model); Set<String> readKeyReferences(Dataset dataset); Model writeToModel(Resource keySubject, WonEccPublicKey pubKey); void writeToModel(Model model, Resource keySubject, PublicKey publicKey); }
WonKeysReaderWriter { private void writeToModel(Model model, Resource keySubject, WonEccPublicKey pubKey) { Resource bn = model.createResource(); Statement stmt = model.createStatement(bn, RDF.type, WON.ECCPublicKey); model.add(stmt); stmt = model.createStatement(bn, WON.ecc_algorithm, pubKey.getAlgorithm()); model.add(stmt); stmt = model.createStatement(bn, WON.ecc_curveId, pubKey.getCurveId()); model.add(stmt); stmt = model.createStatement(bn, WON.ecc_qx, model.createLiteral(pubKey.getQx())); model.add(stmt); stmt = model.createStatement(bn, WON.ecc_qy, model.createLiteral(pubKey.getQy())); model.add(stmt); Resource bn2 = model.createResource(); stmt = model.createStatement(bn2, CERT.PUBLIC_KEY, bn); model.add(stmt); stmt = model.createStatement(keySubject, CERT.KEY, bn2); model.add(stmt); } WonKeysReaderWriter(); Map<String, PublicKey> readFromDataset(Dataset dataset); Set<PublicKey> readFromDataset(Dataset dataset, String keyUri); Map<String, PublicKey> readFromModel(Model model); Set<String> readKeyReferences(Dataset dataset); Model writeToModel(Resource keySubject, WonEccPublicKey pubKey); void writeToModel(Model model, Resource keySubject, PublicKey publicKey);  }