@Test public void testVerify() throws IOException { final String json = FileUtil.readFile("./src/test/resources/pypi_flask.json"); PyPiVerifier ppv = new PyPiVerifier(); assertTrue(ppv.containsMD5(json, "c1d30f51cff4a38f9454b23328a15c5a")); final Calendar c = Calendar.getInstance(TimeZone.getTimeZone("GMT")); c.setTimeInMillis(1482351732000L); assertEquals(c, ppv.getReleaseTimestamp()); ppv = new PyPiVerifier(); assertFalse(ppv.containsMD5(json, "c1d30f51cff4a38f9454b23328a15c5azzzzz")); assertEquals(null, ppv.getReleaseTimestamp()); }
@Override public List<LibraryId> verify(final Library _lib) throws VerificationException { if (_lib == null || _lib.getDigest() == null) throw new IllegalArgumentException("No library or digest provided: [" + _lib + "]"); if (_lib.getLibraryId() == null || _lib.getLibraryId().getMvnGroup() == null || _lib.getLibraryId().getVersion() == null) return null; this.url = "https: .replaceAll("<name>", _lib.getLibraryId().getMvnGroup()) .replaceAll("<version>", _lib.getLibraryId().getVersion()); String response_body = null; List<LibraryId> verified_lids = null; int sc = -1; try { final CloseableHttpClient httpclient = HttpClients.createDefault(); final HttpGet method = new HttpGet(this.url); if (ConnectionUtil.getProxyConfig() != null) method.setConfig(ConnectionUtil.getProxyConfig()); final CloseableHttpResponse response = httpclient.execute(method); try { sc = response.getStatusLine().getStatusCode(); HttpEntity entity = response.getEntity(); if (sc == HttpStatus.SC_OK && entity != null) { response_body = ConnectionUtil.readInputStream(entity.getContent()); verified_lids = new ArrayList<LibraryId>(); if (this.containsMD5(response_body, _lib.getDigest())) verified_lids.add(_lib.getLibraryId()); } } finally { response.close(); } } catch (Exception e) { throw new VerificationException(_lib, this.url, e); } return verified_lids; }
PyPiVerifier implements DigestVerifier { @Override public List<LibraryId> verify(final Library _lib) throws VerificationException { if (_lib == null || _lib.getDigest() == null) throw new IllegalArgumentException("No library or digest provided: [" + _lib + "]"); if (_lib.getLibraryId() == null || _lib.getLibraryId().getMvnGroup() == null || _lib.getLibraryId().getVersion() == null) return null; this.url = "https: .replaceAll("<name>", _lib.getLibraryId().getMvnGroup()) .replaceAll("<version>", _lib.getLibraryId().getVersion()); String response_body = null; List<LibraryId> verified_lids = null; int sc = -1; try { final CloseableHttpClient httpclient = HttpClients.createDefault(); final HttpGet method = new HttpGet(this.url); if (ConnectionUtil.getProxyConfig() != null) method.setConfig(ConnectionUtil.getProxyConfig()); final CloseableHttpResponse response = httpclient.execute(method); try { sc = response.getStatusLine().getStatusCode(); HttpEntity entity = response.getEntity(); if (sc == HttpStatus.SC_OK && entity != null) { response_body = ConnectionUtil.readInputStream(entity.getContent()); verified_lids = new ArrayList<LibraryId>(); if (this.containsMD5(response_body, _lib.getDigest())) verified_lids.add(_lib.getLibraryId()); } } finally { response.close(); } } catch (Exception e) { throw new VerificationException(_lib, this.url, e); } return verified_lids; } }
PyPiVerifier implements DigestVerifier { @Override public List<LibraryId> verify(final Library _lib) throws VerificationException { if (_lib == null || _lib.getDigest() == null) throw new IllegalArgumentException("No library or digest provided: [" + _lib + "]"); if (_lib.getLibraryId() == null || _lib.getLibraryId().getMvnGroup() == null || _lib.getLibraryId().getVersion() == null) return null; this.url = "https: .replaceAll("<name>", _lib.getLibraryId().getMvnGroup()) .replaceAll("<version>", _lib.getLibraryId().getVersion()); String response_body = null; List<LibraryId> verified_lids = null; int sc = -1; try { final CloseableHttpClient httpclient = HttpClients.createDefault(); final HttpGet method = new HttpGet(this.url); if (ConnectionUtil.getProxyConfig() != null) method.setConfig(ConnectionUtil.getProxyConfig()); final CloseableHttpResponse response = httpclient.execute(method); try { sc = response.getStatusLine().getStatusCode(); HttpEntity entity = response.getEntity(); if (sc == HttpStatus.SC_OK && entity != null) { response_body = ConnectionUtil.readInputStream(entity.getContent()); verified_lids = new ArrayList<LibraryId>(); if (this.containsMD5(response_body, _lib.getDigest())) verified_lids.add(_lib.getLibraryId()); } } finally { response.close(); } } catch (Exception e) { throw new VerificationException(_lib, this.url, e); } return verified_lids; } PyPiVerifier(); }
PyPiVerifier implements DigestVerifier { @Override public List<LibraryId> verify(final Library _lib) throws VerificationException { if (_lib == null || _lib.getDigest() == null) throw new IllegalArgumentException("No library or digest provided: [" + _lib + "]"); if (_lib.getLibraryId() == null || _lib.getLibraryId().getMvnGroup() == null || _lib.getLibraryId().getVersion() == null) return null; this.url = "https: .replaceAll("<name>", _lib.getLibraryId().getMvnGroup()) .replaceAll("<version>", _lib.getLibraryId().getVersion()); String response_body = null; List<LibraryId> verified_lids = null; int sc = -1; try { final CloseableHttpClient httpclient = HttpClients.createDefault(); final HttpGet method = new HttpGet(this.url); if (ConnectionUtil.getProxyConfig() != null) method.setConfig(ConnectionUtil.getProxyConfig()); final CloseableHttpResponse response = httpclient.execute(method); try { sc = response.getStatusLine().getStatusCode(); HttpEntity entity = response.getEntity(); if (sc == HttpStatus.SC_OK && entity != null) { response_body = ConnectionUtil.readInputStream(entity.getContent()); verified_lids = new ArrayList<LibraryId>(); if (this.containsMD5(response_body, _lib.getDigest())) verified_lids.add(_lib.getLibraryId()); } } finally { response.close(); } } catch (Exception e) { throw new VerificationException(_lib, this.url, e); } return verified_lids; } PyPiVerifier(); @Override Set<ProgrammingLanguage> getSupportedLanguages(); @Override Set<DigestAlgorithm> getSupportedDigestAlgorithms(); @Override String getVerificationUrl(); @Override java.util.Calendar getReleaseTimestamp(); @Override List<LibraryId> verify(final Library _lib); }
PyPiVerifier implements DigestVerifier { @Override public List<LibraryId> verify(final Library _lib) throws VerificationException { if (_lib == null || _lib.getDigest() == null) throw new IllegalArgumentException("No library or digest provided: [" + _lib + "]"); if (_lib.getLibraryId() == null || _lib.getLibraryId().getMvnGroup() == null || _lib.getLibraryId().getVersion() == null) return null; this.url = "https: .replaceAll("<name>", _lib.getLibraryId().getMvnGroup()) .replaceAll("<version>", _lib.getLibraryId().getVersion()); String response_body = null; List<LibraryId> verified_lids = null; int sc = -1; try { final CloseableHttpClient httpclient = HttpClients.createDefault(); final HttpGet method = new HttpGet(this.url); if (ConnectionUtil.getProxyConfig() != null) method.setConfig(ConnectionUtil.getProxyConfig()); final CloseableHttpResponse response = httpclient.execute(method); try { sc = response.getStatusLine().getStatusCode(); HttpEntity entity = response.getEntity(); if (sc == HttpStatus.SC_OK && entity != null) { response_body = ConnectionUtil.readInputStream(entity.getContent()); verified_lids = new ArrayList<LibraryId>(); if (this.containsMD5(response_body, _lib.getDigest())) verified_lids.add(_lib.getLibraryId()); } } finally { response.close(); } } catch (Exception e) { throw new VerificationException(_lib, this.url, e); } return verified_lids; } PyPiVerifier(); @Override Set<ProgrammingLanguage> getSupportedLanguages(); @Override Set<DigestAlgorithm> getSupportedDigestAlgorithms(); @Override String getVerificationUrl(); @Override java.util.Calendar getReleaseTimestamp(); @Override List<LibraryId> verify(final Library _lib);  }