Search in sources :

Example 1 with Md5Hash

use of com.fathomdb.hash.Md5Hash in project platformlayer by platformlayer.

the class SolrInstall method addChildren.

@Override
protected void addChildren() throws OpsException {
    addChild(JavaVirtualMachine.buildJava6());
    // addChild(injected(JettyInstall.class));
    addChild(injected(SupervisordInstall.class));
    {
        // TODO: Would be nice not to hard code this mirror
        String apacheMirror = "http://apache.osuosl.org/";
        // This probably does need to be hard-coded though
        // (though maybe selectable from a list of supported releases)
        String file = "lucene/solr/3.6.0/apache-solr-3.6.0.tgz";
        Md5Hash hash = new Md5Hash("ac11ef4408bb015aa3a5eefcb1047aec");
        File basePath = new File("/opt/");
        File zipFile = new File(basePath, "apache-solr-3.6.0.tgz");
        File extractPath = new File(basePath, "apache-solr-3.6.0");
        DownloadFileByHash download = injected(DownloadFileByHash.class);
        download.setUrl(apacheMirror + file);
        download.hash = hash;
        download.filePath = zipFile;
        addChild(download);
        // Needed for ExpandArchive
        addChild(PackageDependency.build("unzip"));
        // TODO: Only unzip if newly downloaded
        ExpandArchive unzip = injected(ExpandArchive.class);
        unzip.archiveFile = zipFile;
        unzip.extractPath = extractPath;
        addChild(unzip);
    }
    addChild(PosixGroup.build("solr"));
    addChild(PosixUser.build("solr", false, "solr"));
}
Also used : DownloadFileByHash(org.platformlayer.ops.filesystem.DownloadFileByHash) Md5Hash(com.fathomdb.hash.Md5Hash) File(java.io.File) SupervisordInstall(org.platformlayer.ops.supervisor.SupervisordInstall) ExpandArchive(org.platformlayer.ops.filesystem.ExpandArchive)

Example 2 with Md5Hash

use of com.fathomdb.hash.Md5Hash in project platformlayer by platformlayer.

the class ZookeeperInstall method buildDownload.

@Override
protected DownloadFileByHash buildDownload() {
    DownloadFileByHash download = super.buildDownload();
    // TODO: Would be nice not to hard code this mirror
    // String apacheMirror = "http://ftp.osuosl.org/pub/apache/";
    String apacheMirror = "http://apache.osuosl.org/";
    // This probably does need to be hard-coded though
    // (though maybe selectable from a list of supported releases)
    // String url = apacheMirror + "zookeeper/zookeeper-3.3.5/zookeeper-3.3.5.tar.gz";
    // download.setUrl(url);
    // download.hash = new Md5Hash("4c2c969bce8717d6443e184ff91dfdc7");
    String url = apacheMirror + "zookeeper/zookeeper-3.4.5/zookeeper-3.4.5.tar.gz";
    download.setUrl(url);
    download.hash = new Md5Hash("f64fef86c0bf2e5e0484d19425b22dcb");
    return download;
}
Also used : DownloadFileByHash(org.platformlayer.ops.filesystem.DownloadFileByHash) Md5Hash(com.fathomdb.hash.Md5Hash)

Example 3 with Md5Hash

use of com.fathomdb.hash.Md5Hash in project platformlayer by platformlayer.

the class MavenHashes method getMd5.

public static Md5Hash getMd5(Path artifactPath) throws IOException {
    String fileName = artifactPath.getFileName().toString();
    Path md5Path = artifactPath.resolveSibling(fileName + ".md5");
    InputStream is = null;
    try {
        is = Files.newInputStream(md5Path);
        String md5 = IoUtils.readAll(is);
        return new Md5Hash(md5);
    } finally {
        IoUtils.safeClose(is);
    }
}
Also used : Path(java.nio.file.Path) InputStream(java.io.InputStream) Md5Hash(com.fathomdb.hash.Md5Hash)

Example 4 with Md5Hash

use of com.fathomdb.hash.Md5Hash in project platformlayer by platformlayer.

the class OpsTargetBase method getFileHash.

@Override
public Md5Hash getFileHash(File filePath) throws OpsException {
    Command command = Command.build("md5sum {0}", filePath);
    ProcessExecution execution = executeCommandUnchecked(command);
    if (execution.getExitCode() == 1) {
        if (execution.getStdErr().contains("No such file or directory")) {
            return null;
        }
    }
    execution.checkExitCode();
    String stdout = execution.getStdOut();
    // Format is "hash filename"
    String[] items = stdout.split(" ");
    return new Md5Hash(items[0]);
}
Also used : ProcessExecution(org.platformlayer.ops.process.ProcessExecution) Md5Hash(com.fathomdb.hash.Md5Hash)

Example 5 with Md5Hash

use of com.fathomdb.hash.Md5Hash in project platformlayer by platformlayer.

the class CertificateChains method toModel.

public static CertificateChainInfo toModel(X509Certificate[] chain) {
    CertificateChainInfo chainInfo = new CertificateChainInfo();
    List<CertificateInfo> certificates = chainInfo.getCertificates();
    for (X509Certificate cert : chain) {
        CertificateInfo certificateInfo = new CertificateInfo();
        certificateInfo.setSubjectDN(Certificates.getSubject(cert));
        Md5Hash hash = OpenSshUtils.getSignature(cert.getPublicKey());
        certificateInfo.setPublicKeyHash(hash.toHex());
        byte[] data = cert.getPublicKey().getEncoded();
        certificateInfo.setPublicKey(Hex.toHex(data));
        certificates.add(certificateInfo);
    }
    return chainInfo;
}
Also used : CertificateChainInfo(org.platformlayer.auth.v1.CertificateChainInfo) CertificateInfo(org.platformlayer.auth.v1.CertificateInfo) Md5Hash(com.fathomdb.hash.Md5Hash) X509Certificate(java.security.cert.X509Certificate)

Aggregations

Md5Hash (com.fathomdb.hash.Md5Hash)15 File (java.io.File)6 OpsException (org.platformlayer.ops.OpsException)4 Command (org.platformlayer.ops.Command)3 DownloadFileByHash (org.platformlayer.ops.filesystem.DownloadFileByHash)3 IOException (java.io.IOException)2 X509Certificate (java.security.cert.X509Certificate)2 ProcessExecution (org.platformlayer.ops.process.ProcessExecution)2 InputStream (java.io.InputStream)1 InetAddress (java.net.InetAddress)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 UnknownHostException (java.net.UnknownHostException)1 Path (java.nio.file.Path)1 MessageDigest (java.security.MessageDigest)1 Callable (java.util.concurrent.Callable)1 ExecutionException (java.util.concurrent.ExecutionException)1 TimeoutException (java.util.concurrent.TimeoutException)1 CertificateChainInfo (org.platformlayer.auth.v1.CertificateChainInfo)1 CertificateInfo (org.platformlayer.auth.v1.CertificateInfo)1