Cipherpack v1.2.0-dirty
A Cryprographic Stream Processor
CPVersion.java
Go to the documentation of this file.
1/**
2 * Author: Sven Gothel <sgothel@jausoft.com>
3 * Copyright (c) 2022 Gothel Software e.K.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining
6 * a copy of this software and associated documentation files (the
7 * "Software"), to deal in the Software without restriction, including
8 * without limitation the rights to use, copy, modify, merge, publish,
9 * distribute, sublicense, and/or sell copies of the Software, and to
10 * permit persons to whom the Software is furnished to do so, subject to
11 * the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be
14 * included in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
25package org.cipherpack;
26
27import java.io.PrintStream;
28import java.util.Iterator;
29import java.util.Set;
30import java.util.jar.Attributes;
31import java.util.jar.Manifest;
32
33import org.jau.io.PrintUtil;
34import org.jau.util.JauVersion;
35import org.jau.util.VersionUtil;
36
37/**
38 * This {@code jaulib} derived version info class is only
39 * usable when having {@code jaulib} available, naturally.
40 */
41public class CPVersion extends JauVersion {
42
43 public static final void printVersionInfo(final PrintStream out) {
45
46 PrintUtil.println(out, "CPFactory: Jaulib: Available "+CPFactory.JAULIB_AVAILABLE+", JarCache in use "+CPFactory.JAULIB_JARCACHE_USED);
48 out.println(VersionUtil.getPlatformInfo());
49 PrintUtil.println(out, "Version Info:");
51 out.println(v.toString());
52 PrintUtil.println(out, "");
53 PrintUtil.println(out, "Full Manifest:");
54 out.println(v.getFullManifestInfo(null).toString());
55 } else {
56 PrintUtil.println(out, "Full Manifest:");
57 final Manifest manifest = CPFactory.getManifest(CPFactory.class.getClassLoader(), new String[] { "org.cipherpack" } );
58 final Attributes attr = manifest.getMainAttributes();
59 final Set<Object> keys = attr.keySet();
60 final StringBuilder sb = new StringBuilder();
61 for(final Iterator<Object> iter=keys.iterator(); iter.hasNext(); ) {
62 final Attributes.Name key = (Attributes.Name) iter.next();
63 final String val = attr.getValue(key);
64 sb.append(" ");
65 sb.append(key);
66 sb.append(" = ");
67 sb.append(val);
68 sb.append(System.lineSeparator());
69 }
70 out.println(sb.toString());
71 }
72
73 PrintUtil.println(out, "Cipherpack Native Version "+CPFactory.getNativeVersion()+" (API "+CPFactory.getNativeAPIVersion()+")");
74 PrintUtil.println(out, "Cipherpack Java Version "+CPFactory.getImplVersion()+" (API "+CPFactory.getAPIVersion()+")");
75 }
76
77 protected CPVersion(final String packageName, final Manifest mf) {
78 super(packageName, mf);
79 }
80
81 /**
82 * Returns a transient new instance.
83 */
84 public static CPVersion getInstance() {
85 final String packageNameCompileTime = "org.cipherpack";
86 final String packageNameRuntime = "org.cipherpack";
87 Manifest mf = VersionUtil.getManifest(CPVersion.class.getClassLoader(), packageNameRuntime);
88 if(null != mf) {
89 return new CPVersion(packageNameRuntime, mf);
90 } else {
91 mf = VersionUtil.getManifest(CPVersion.class.getClassLoader(), packageNameCompileTime);
92 return new CPVersion(packageNameCompileTime, mf);
93 }
94 }
95
96 public static void main(final String args[]) {
97 CPFactory.main(args);
98 }
99}
Cipherpack Factory, called by automatically to load the native library.
Definition: CPFactory.java:47
static final Manifest getManifest(final ClassLoader cl, final String[] extensions)
Helper function to retrieve a Manifest instance.
Definition: CPFactory.java:285
static native String getNativeVersion()
static final boolean JAULIB_JARCACHE_USED
True if jaulib JAULIB_AVAILABLE and its org.jau.sys.PlatformProps#USE_TEMP_JAR_CACHE is true,...
Definition: CPFactory.java:86
static final boolean JAULIB_AVAILABLE
True if jaulib org.jau.sys.PlatformProps has been detected.
Definition: CPFactory.java:80
static native String getNativeAPIVersion()
static final String getImplVersion()
Manifest's Attributes.Name#IMPLEMENTATION_VERSION or null if not available.
Definition: CPFactory.java:58
static final String getAPIVersion()
Manifest's Attributes.Name#SPECIFICATION_VERSION or null if not available.
Definition: CPFactory.java:52
static synchronized void initLibrary()
Definition: CPFactory.java:278
static void main(final String args[])
Definition: CPFactory.java:328
This jaulib derived version info class is only usable when having jaulib available,...
Definition: CPVersion.java:41
CPVersion(final String packageName, final Manifest mf)
Definition: CPVersion.java:77
static final void printVersionInfo(final PrintStream out)
Definition: CPVersion.java:43
static void main(final String args[])
Definition: CPVersion.java:96
static CPVersion getInstance()
Returns a transient new instance.
Definition: CPVersion.java:84