This is an automated email from the ASF dual-hosted git repository.
jpirek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/netbeans-tools.git
The following commit(s) were added to refs/heads/master by this push:
new 903a47c Fetch SHA1 digest from maven central when version is created
and show for verification
new ed7991b Merge pull request #21 from
matthiasblaesing/hash_plugin_version
903a47c is described below
commit 903a47cf0e3ba292c94813c1b5172d09014504f7
Author: Matthias Bläsing <[email protected]>
AuthorDate: Wed Dec 25 22:29:59 2019 +0100
Fetch SHA1 digest from maven central when version is created and show for
verification
---
pp3/config/pp3.sql | 8 +++
.../Application/config/module.config.php.dist | 2 +-
.../Application/Controller/PluginController.php | 15 ----
.../src/Application/Entity/Base/PluginVersion.php | 11 +++
.../Entity/Base/PluginVersionDigest.php | 81 ++++++++++++++++++++++
.../Application/src/Application/Entity/Plugin.php | 76 ++++++++++----------
.../src/Application/Entity/PluginVersion.php | 10 ++-
.../src/Application/Entity/PluginVersionDigest.php | 31 +++++++++
.../Application/src/Application/Pp/Catalog.php | 17 ++++-
.../view/application/verification/list.phtml | 11 ++-
.../dtd/autoupdate-catalog-2_8.dtd} | 14 +++-
11 files changed, 215 insertions(+), 61 deletions(-)
diff --git a/pp3/config/pp3.sql b/pp3/config/pp3.sql
index 1dd2955..2b63cac 100644
--- a/pp3/config/pp3.sql
+++ b/pp3/config/pp3.sql
@@ -128,6 +128,14 @@ CREATE TABLE IF NOT EXISTS `verification_request` (
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;
+CREATE TABLE IF NOT EXISTS `plugin_version_digest` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `plugin_version_id` int(11) NOT NULL REFERENCES plugin_version(id),
+ `algorithm` varchar(50) NOT NULL,
+ `value` varchar(255) NOT NULL,
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;
+
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
diff --git a/pp3/module/Application/config/module.config.php.dist
b/pp3/module/Application/config/module.config.php.dist
index 0bb762b..b7bd6bd 100755
--- a/pp3/module/Application/config/module.config.php.dist
+++ b/pp3/module/Application/config/module.config.php.dist
@@ -33,7 +33,7 @@ return array(
'mavenRepoUrl' => 'https://repo1.maven.org/maven2/',
'catalogSavepath' => '/home/honza/checkout/pp3/public/data',
'catalogUrlPath' => 'http://localhost/checkout/pp3/public/data',
- 'dtdPath' =>
'http://localhost/checkout/pp3/public/data/autoupdate-catalog-2_6.dtd'
+ 'dtdPath' =>
'http://localhost/checkout/pp3/public/dtd/autoupdate-catalog-2_8.dtd'
),
'loginConfig' => array (
array(
diff --git
a/pp3/module/Application/src/Application/Controller/PluginController.php
b/pp3/module/Application/src/Application/Controller/PluginController.php
index dc21426..ddde60d 100644
--- a/pp3/module/Application/src/Application/Controller/PluginController.php
+++ b/pp3/module/Application/src/Application/Controller/PluginController.php
@@ -163,23 +163,8 @@ class PluginController extends AuthenticatedController {
$plugin->setHomepage($validatedData['homepage']);
$plugin->setAddedAt(new \DateTime('now'));
$plugin->setLastUpdatedAt(new \DateTime('now'));
- // save also versions
- if (!empty($plugin->tmpVersions)) {
- foreach($plugin->tmpVersions as $vers) {
- try {
- $v = new PluginVersion();
- $v->setVersion($vers);
- $v->setPlugin($plugin);
- $v->setupUrl();
- $plugin->addVersion($v);
- } catch (\Exception $e) {
-
$this->flashMessenger()->setNamespace('error')->addMessage($e->getMessage());
- }
- }
- }
// categ
$plugin->removeCategories();
- $this->_pluginRepository->persist($plugin);
$cat =
$this->_categoryRepository->find($validatedData['category']);
if ($cat) {
$plugin->addCategory($cat);
diff --git
a/pp3/module/Application/src/Application/Entity/Base/PluginVersion.php
b/pp3/module/Application/src/Application/Entity/Base/PluginVersion.php
index 9cc857b..7024176 100644
--- a/pp3/module/Application/src/Application/Entity/Base/PluginVersion.php
+++ b/pp3/module/Application/src/Application/Entity/Base/PluginVersion.php
@@ -22,6 +22,7 @@ namespace Application\Entity\Base;
use Doctrine\ORM\Mapping as ORM;
use Application\Entity\Plugin;
+use Application\Entity\PluginVersionDigest;
use Application\Entity\NbVersionPluginVersion;
use Doctrine\Common\Collections\ArrayCollection;
@@ -57,8 +58,14 @@ class PluginVersion {
*/
protected $plugin;
+ /**
+ * @ORM\OneToMany(targetEntity="PluginVersionDigest",
mappedBy="pluginVersion", cascade={"persist", "remove"})
+ */
+ protected $digests;
+
public function __construct() {
$this->nbVersionsPluginVersions = new ArrayCollection();
+ $this->digests = new ArrayCollection();
return $this;
}
@@ -113,4 +120,8 @@ class PluginVersion {
public function getNbVersionsPluginVersions() {
return $this->nbVersionsPluginVersions;
}
+
+ public function getDigests() {
+ return $this->digests;
+ }
}
diff --git
a/pp3/module/Application/src/Application/Entity/Base/PluginVersionDigest.php
b/pp3/module/Application/src/Application/Entity/Base/PluginVersionDigest.php
new file mode 100644
index 0000000..14a5e2f
--- /dev/null
+++ b/pp3/module/Application/src/Application/Entity/Base/PluginVersionDigest.php
@@ -0,0 +1,81 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace Application\Entity\Base;
+
+use Doctrine\ORM\Mapping as ORM;
+
+class PluginVersionDigest {
+
+ /**
+ * @ORM\Id
+ * @ORM\GeneratedValue(strategy="AUTO")
+ * @ORM\Column(type="integer")
+ */
+ protected $id;
+
+ /**
+ * @ORM\ManyToOne(targetEntity="PluginVersion",
inversedBy="nbVersionsPluginVersions")
+ * @ORM\JoinColumn(name="plugin_version_id", referencedColumnName="id")
+ */
+ protected $pluginVersion;
+
+ /** @ORM\Column(type="string", length=255) */
+ protected $algorithm;
+
+ /** @ORM\Column(type="string", length=255) */
+ protected $value;
+
+ public function __construct() {
+ return $this;
+ }
+
+ function getId() {
+ return $this->id;
+ }
+
+ function setId($id) {
+ $this->id = $id;
+ }
+
+ function getPluginVersion() {
+ return $this->pluginVersion;
+ }
+
+ function setPluginVersion($pluginVersion) {
+ $this->pluginVersion = $pluginVersion;
+ }
+
+ function getAlgorithm() {
+ return $this->algorithm;
+ }
+
+ function setAlgorithm($algorithm) {
+ $this->algorithm = $algorithm;
+ }
+
+ function getValue() {
+ return $this->value;
+ }
+
+ function setValue($value) {
+ $this->value = $value;
+ }
+}
\ No newline at end of file
diff --git a/pp3/module/Application/src/Application/Entity/Plugin.php
b/pp3/module/Application/src/Application/Entity/Plugin.php
index e1e56ea..ae4c033 100644
--- a/pp3/module/Application/src/Application/Entity/Plugin.php
+++ b/pp3/module/Application/src/Application/Entity/Plugin.php
@@ -33,8 +33,7 @@ class Plugin extends Base\Plugin {
const STATUS_PUBLIC = 2;
private $_dataLoader;
- public $tmpVersions;
-
+
public function setDataLoader($dl) {
$this->_dataLoader = $dl;
}
@@ -43,28 +42,7 @@ class Plugin extends Base\Plugin {
$data = $this->_dataLoader->getData($this);
if ($this->_validateData($data) && $this->artifactid ==
$data['artifactId']) {
if (!empty($data['versioning'])) {
- $versioning = $data['versioning'];
- if (!empty($versioning['latest'])) {
- $this->setLatestVersion($versioning['latest']);
- }
- if (!empty($versioning['release'])) {
- $this->setReleaseVersion($versioning['release']);
- }
- if (!empty($versioning['versions']['version'])) {
- $incomingVersions =
array_flip($versioning['versions']['version']);
- // check for new versions only
- foreach ($this->versions as $registeredVersion) {
-
unset($incomingVersions[$registeredVersion->getVersion()]);
- }
- $incomingVersions = array_flip($incomingVersions);
- foreach ($incomingVersions as $vers) {
- $v = new PluginVersion();
- $v->setVersion($vers);
- $v->setPlugin($this);
- $v->setupUrl();
- $this->addVersion($v);
- }
- }
+ $this->updateVersions($data['versioning']);
}
return true;
}
@@ -77,11 +55,8 @@ class Plugin extends Base\Plugin {
$this->setGroupId($data['groupId']);
if (!empty($data['versioning'])) {
$versioning = $data['versioning'];
- if (!empty($versioning['latest'])) {
- $this->setLatestVersion($versioning['latest']);
- }
- if (!empty($versioning['release'])) {
- $this->setReleaseVersion($versioning['release']);
+ $this->updateVersions($versioning);
+ if ($this->getReleaseVersion()) {
// load additional info from release
$releaseData = $this->_dataLoader->getReleaseData($this);
if(!empty($releaseData['name'])) {
@@ -99,14 +74,6 @@ class Plugin extends Base\Plugin {
$this->setLicense($releaseData['licenses']['license']['name']);
}
}
- if (!empty($versioning['versions'])) {
- // handle some issues with serialization of xml into array
- if (!is_array($versioning['versions']['version'])) {
- $this->tmpVersions =
array($versioning['versions']['version']);
- } else {
- $this->tmpVersions =
$versioning['versions']['version'];
- }
- }
}
return true;
} else {
@@ -114,6 +81,41 @@ class Plugin extends Base\Plugin {
}
}
+ private function updateVersions($versioning) {
+ if (!empty($versioning['latest'])) {
+ $this->setLatestVersion($versioning['latest']);
+ }
+ if (!empty($versioning['release'])) {
+ $this->setReleaseVersion($versioning['release']);
+ }
+ if (!empty($versioning['versions'])) {
+ if (!is_array($versioning['versions']['version'])) {
+ $versions = array($versioning['versions']['version']);
+ } else {
+ $versions = $versioning['versions']['version'];
+ }
+ $incomingVersions = array_flip($versions);
+ // check for new versions only
+ foreach ($this->versions as $registeredVersion) {
+ unset($incomingVersions[$registeredVersion->getVersion()]);
+ }
+ $incomingVersions = array_flip($incomingVersions);
+ foreach ($incomingVersions as $vers) {
+ $v = new PluginVersion();
+ $v->setVersion($vers);
+ $v->setPlugin($this);
+ $v->setupUrl();
+ // Fetch SHA1 sums from Maven central to make verified
downloads possible
+ // SHA1 is currently the best algorithm maven central supports
+ $sha1 = file_get_contents($v->getUrl() . ".sha1");
+ if ($sha1) {
+ $v->addDigest("SHA-1", $sha1);
+ $this->addVersion($v);
+ }
+ }
+ }
+ }
+
public function addVersion($version) {
$this->versions[] = $version;
}
diff --git a/pp3/module/Application/src/Application/Entity/PluginVersion.php
b/pp3/module/Application/src/Application/Entity/PluginVersion.php
index d02a48d..b2e8b76 100644
--- a/pp3/module/Application/src/Application/Entity/PluginVersion.php
+++ b/pp3/module/Application/src/Application/Entity/PluginVersion.php
@@ -40,7 +40,15 @@ class PluginVersion extends Base\PluginVersion {
public function addNbVersion($version) {
$this->nbVersionsPluginVersions[] = $version;
}
-
+
+ public function addDigest($algorithm, $value) {
+ $pvd = new PluginVersionDigest();
+ $pvd->setAlgorithm($algorithm);
+ $pvd->setValue($value);
+ $pvd->setPluginVersion($this);
+ $this->digests[] = $pvd;
+ }
+
private function _getBinaryExtension($baseUrl) {
// there could be either .nbm or .jar, so check both
$extension = array('.nbm', '.jar');
diff --git
a/pp3/module/Application/src/Application/Entity/PluginVersionDigest.php
b/pp3/module/Application/src/Application/Entity/PluginVersionDigest.php
new file mode 100644
index 0000000..cb54e91
--- /dev/null
+++ b/pp3/module/Application/src/Application/Entity/PluginVersionDigest.php
@@ -0,0 +1,31 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace Application\Entity;
+
+use Doctrine\ORM\Mapping as ORM;
+
+/**
+ * @ORM\Entity
+ * @ORM\Table(name="plugin_version_digest")
+ */
+class PluginVersionDigest extends Base\PluginVersionDigest {
+
+}
diff --git a/pp3/module/Application/src/Application/Pp/Catalog.php
b/pp3/module/Application/src/Application/Pp/Catalog.php
index 1bdc08d..7c1c2dc 100644
--- a/pp3/module/Application/src/Application/Pp/Catalog.php
+++ b/pp3/module/Application/src/Application/Pp/Catalog.php
@@ -20,6 +20,8 @@
namespace Application\Pp;
+use Applicaton\Entity\PluginVersion;
+
class Catalog {
const CATALOG_FILE_NAME = 'catalog.xml';
const CATALOG_FILE_NAME_EXPERIMENTAL = 'catalog-experimental.xml';
@@ -31,7 +33,10 @@ class Catalog {
const REQ_ATTRS_MANIFEST_OpenIDE_Module = 'OpenIDE-Module';
const REQ_ATTRS_MANIFEST_OpenIDE_Module_Name = 'OpenIDE-Module-Name';
const REQ_ATTRS_MANIFEST_OpenIDE_Module_Specification_Version =
'OpenIDE-Module-Specification-Version';
-
+
+ const REQ_ATTRS_MESSAGEDIGEST_algorithm = 'algorithm';
+ const REQ_ATTRS_MESSAGEDIGEST_value = 'value';
+
private $_items;
private $_version;
private $_isExperimental;
@@ -48,7 +53,7 @@ class Catalog {
public function asXml($valiadte = true) {
$implementation = new \DOMImplementation();
$dtd = $implementation->createDocumentType('module_updates',
- '-//NetBeans//DTD Autoupdate Catalog
2.6//EN',
+ '-//NetBeans//DTD Autoupdate Catalog
2.8//EN',
$this->_dtdPath);
$xml = $implementation->createDocument('', '', $dtd);
@@ -74,6 +79,14 @@ class Catalog {
$manifestElement->setAttribute('OpenIDE-Module-Long-Description',
$item->getPlugin()->getDescription());
$moduleElement->appendChild($manifestElement);
+
+ foreach($item->getDigests() as $digest) {
+ $messageDigest = $xml->createElement('message_digest');
+
$messageDigest->setAttribute(self::REQ_ATTRS_MESSAGEDIGEST_algorithm,
$digest->getAlgorithm());
+
$messageDigest->setAttribute(self::REQ_ATTRS_MESSAGEDIGEST_value,
$digest->getValue());
+ $moduleElement->appendChild($messageDigest);
+ }
+
$modulesEl->appendChild($moduleElement);
}
diff --git a/pp3/module/Application/view/application/verification/list.phtml
b/pp3/module/Application/view/application/verification/list.phtml
index a56b7be..95bcfe2 100644
--- a/pp3/module/Application/view/application/verification/list.phtml
+++ b/pp3/module/Application/view/application/verification/list.phtml
@@ -43,8 +43,15 @@
$plugin = $pluginVersion->getPlugin();
echo '<tr>
<td>
- <span class="text text-primary" style="font-size:1.2em"><a
href="'.$pluginVersion->getUrl().'">'.$plugin->getName().'</a></span>
- </td>
+ <div class="text text-primary" style="font-size:1.2em"><a
href="'.$pluginVersion->getUrl().'">'.$plugin->getName().'</a></div>';
+
+ echo '<table class="table" style="margin: 0">';
+ foreach($pluginVersion->getDigests() as $digest) {
+ printf("<tr><td>%s</td><td>%s</td></tr>\n",
$digest->getAlgorithm(), $digest->getValue());
+ }
+ echo '</table>';
+
+ echo '</td>
<td>
<span class="badge">'.$pluginVersion->getVersion().'</span>
<i class="fas fa-arrow-right"></i>
<span class="badge">NB '.$nbVersion->getVersion().'</span>
diff --git a/pp3/config/autoupdate-catalog-2_6.dtd
b/pp3/public/dtd/autoupdate-catalog-2_8.dtd
similarity index 88%
rename from pp3/config/autoupdate-catalog-2_6.dtd
rename to pp3/public/dtd/autoupdate-catalog-2_8.dtd
index dd3a985..93db722 100644
--- a/pp3/config/autoupdate-catalog-2_6.dtd
+++ b/pp3/public/dtd/autoupdate-catalog-2_8.dtd
@@ -18,10 +18,10 @@
under the License.
-->
-<!-- -//NetBeans//DTD Autoupdate Catalog 2.6//EN -->
+<!-- -//NetBeans//DTD Autoupdate Catalog 2.8//EN -->
<!-- XML representation of Autoupdate Modules/Updates Catalog -->
-<!ELEMENT module_updates ((notification?, (module_group|module)*,
license*)|error)>
+<!ELEMENT module_updates ((notification?, content_description?,
(module_group|module)*, license*)|error)>
<!ATTLIST module_updates timestamp CDATA #REQUIRED>
<!ELEMENT module_group ((module_group|module)*)>
@@ -30,7 +30,10 @@
<!ELEMENT notification (#PCDATA)>
<!ATTLIST notification url CDATA #IMPLIED>
-<!ELEMENT module (description?, module_notification?, external_package*,
(manifest | l10n) )>
+<!ELEMENT content_description (#PCDATA)>
+<!ATTLIST content_description url CDATA #IMPLIED>
+
+<!ELEMENT module (description?, module_notification?, external_package*,
(manifest | l10n), message_digest* )>
<!ATTLIST module codenamebase CDATA #REQUIRED
homepage CDATA #IMPLIED
distribution CDATA #REQUIRED
@@ -41,6 +44,7 @@
releasedate CDATA #IMPLIED
global (true|false) #IMPLIED
targetcluster CDATA #IMPLIED
+ preferredupdate (true|false) #IMPLIED
eager (true|false) #IMPLIED
autoload (true|false) #IMPLIED>
@@ -86,3 +90,7 @@
<!ELEMENT license (#PCDATA)>
<!ATTLIST license name CDATA #REQUIRED
url CDATA #IMPLIED>
+
+<!ELEMENT message_digest EMPTY>
+<!ATTLIST message_digest algorithm CDATA #REQUIRED
+ value CDATA #REQUIRED>
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists