use of org.eclipse.winery.accountability.model.ModelProvenanceElement in project winery by eclipse.
the class AccountabilityManagerImpl method getHistoryOfSingleFile.
protected List<FileProvenanceElement> getHistoryOfSingleFile(List<ModelProvenanceElement> historyElements, String fileId, AuthorizationInfo authorizationInfo) {
List<FileProvenanceElement> history = new ArrayList<>();
if (Objects.nonNull(historyElements) && historyElements.size() > 0) {
for (ModelProvenanceElement modelProvenanceElement : historyElements) {
if (Objects.nonNull(modelProvenanceElement.getFingerprint())) {
ManifestContents manifestContents = new RecoveringManifestParser().parse(modelProvenanceElement.getFingerprint());
for (String name : manifestContents.getSectionNames()) {
if (name.equals(fileId)) {
modelProvenanceElement.setAuthorizedFlag(authorizationInfo);
modelProvenanceElement.setAuthorName(authorizationInfo.getRealWorldIdentity(modelProvenanceElement.getAuthorAddress()).orElseGet(String::new));
FileProvenanceElement currentFile = new FileProvenanceElement(modelProvenanceElement);
currentFile.setAddressInImmutableStorage(manifestContents.getAttributesForSection(name).get(TOSCAMetaFileAttributes.IMMUTABLE_ADDRESS));
currentFile.setFileHash(TOSCAMetaFileAttributes.HASH + "-" + manifestContents.getAttributesForSection(name).get(TOSCAMetaFileAttributes.HASH));
currentFile.setFileName(fileId);
history.add(currentFile);
break;
}
}
}
}
}
if (history.size() > 0)
return history;
return null;
}
use of org.eclipse.winery.accountability.model.ModelProvenanceElement in project winery by eclipse.
the class AccountabilityManagerImpl method validateBlockchainInput.
protected Map<String, ProvenanceVerification> validateBlockchainInput(List<ModelProvenanceElement> historyElements, String manifestId, Map<String, File> files, AuthorizationInfo authorizationInfo) throws IOException, NoSuchAlgorithmException {
LOGGER.info("Start validating...");
Map<String, ProvenanceVerification> verificationMap = new HashMap<>();
ModelProvenanceElement validHistoryElement = verifyManifest(historyElements, manifestId, files, verificationMap, authorizationInfo);
if (Objects.nonNull(validHistoryElement) && verificationMap.get(manifestId) == VERIFIED) {
verifyFiles(validHistoryElement, files, verificationMap);
}
LOGGER.info("Completed validation.");
return verificationMap;
}
Aggregations