use of won.protocol.message.WonSignatureData in project webofneeds by researchstudio-sat.
the class SigningStage method extractSignatureData.
private void extractSignatureData(final String uri, final Model model) {
WonSignatureData wonSignatureData = WonRdfUtils.SignatureUtils.extractWonSignatureData(uri, model);
if (wonSignatureData != null && wonSignatureData.getSignatureValue() != null) {
graphUriToSigUri.put(wonSignatureData.getSignedGraphUri(), uri);
sigUriToSigReference.put(uri, wonSignatureData);
}
}
use of won.protocol.message.WonSignatureData in project webofneeds by researchstudio-sat.
the class WonVerifier method addSignatureReferenceToResult.
private void addSignatureReferenceToResult(final String graphURI, final Model model) {
RDFNode tempNode = null;
StmtIterator si = model.listStatements(null, WONMSG.CONTAINS_SIGNATURE_PROPERTY, tempNode);
while (si.hasNext()) {
WonSignatureData sigRef = WonRdfUtils.SignatureUtils.extractWonSignatureData(si.nextStatement().getObject().asResource());
verificationState.addSignatureData(sigRef);
}
}
use of won.protocol.message.WonSignatureData in project webofneeds by researchstudio-sat.
the class WonMessageSignerVerifier method signEnvelopes.
/**
* If the provided signing stage has unsigned content graphs, sign them, add signature graphs
* to the dataset, and add signatures to the envelope graph
* that has contains envelope property referencing signed by that signature envelope graph
* @param msgDataset
* @param sigStage
* @param signer
* @param privateKey
* @param privateKeyUri
*/
private static void signEnvelopes(final Dataset msgDataset, final SigningStage sigStage, final WonSigner signer, final PrivateKey privateKey, final String privateKeyUri, final PublicKey publicKey) throws Exception {
List<String> envUris = sigStage.getUnsignedEnvUrisOrderedByContainment();
WonSignatureData wonSignatureData = null;
String outerEnvUri = null;
for (String envUri : sigStage.getUnsignedEnvUrisOrderedByContainment()) {
if (wonSignatureData != null) {
// this is the signature of the envelope we signed in the last iteration.
// add it to the current one:
addSignature(wonSignatureData, envUri, msgDataset, true);
}
wonSignatureData = signer.sign(privateKey, privateKeyUri, publicKey, envUri).get(0);
outerEnvUri = envUri;
}
// this is the signature of the outermost envelopoe. put it in a new graph.
msgDataset.addNamedModel(wonSignatureData.getSignatureUri(), ModelFactory.createDefaultModel());
addSignature(wonSignatureData, wonSignatureData.getSignatureUri(), msgDataset, false);
}
use of won.protocol.message.WonSignatureData in project webofneeds by researchstudio-sat.
the class WonMessageSignerVerifier method signContents.
/**
* If the provided signing stage has unsigned content graphs, sign them.
* This adds the signature triples to the graph, add signature graphs
* to the dataset, and add signature references of those signatures into the envelope graph
* that has has content property referencing signed by that signature content graph
* @param msgDataset
* @param sigStage
* @param signer
* @param privateKey
* @param privateKeyUri
*/
private static void signContents(final Dataset msgDataset, final SigningStage sigStage, final WonSigner signer, final PrivateKey privateKey, final String privateKeyUri, final PublicKey publicKey) throws Exception {
List<WonSignatureData> sigRefs = signer.sign(privateKey, privateKeyUri, publicKey, sigStage.getUnsignedContentUris());
for (WonSignatureData sigRef : sigRefs) {
String envUri = sigStage.getEnvelopeUriContainingContent(sigRef.getSignedGraphUri());
addSignature(sigRef, envUri, msgDataset, true);
}
}
use of won.protocol.message.WonSignatureData in project webofneeds by researchstudio-sat.
the class WonMessageSignerVerifier method addUnreferencedSigReferences.
/**
* If the provided signing stage has signature graphs that are not referenced from any envelope graphs, they
* should be moved to the innermost not-signed envelope graph. The signature graph is to be deleted.
* @param msgDataset
* @param sigStage
*/
private static void addUnreferencedSigReferences(final Dataset msgDataset, final SigningStage sigStage) {
String innemostUnsignedEnvUri = null;
List<String> envUris = sigStage.getUnsignedEnvUrisOrderedByContainment();
if (envUris.isEmpty()) {
return;
} else {
innemostUnsignedEnvUri = envUris.get(0);
}
WonSignatureData sigRef = sigStage.getOutermostSignature();
if (sigRef != null) {
addSignature(sigRef, innemostUnsignedEnvUri, msgDataset, true);
msgDataset.removeNamedModel(sigRef.getSignatureUri());
}
}
Aggregations