Example usage for java.lang System.Default System.Default

List of usage examples for java.lang System.Default System.Default

Introduction

In this page you can find the example usage for java.lang System.Default System.Default.

Prototype

System.Default

Source Link

Usage

From source file:it.lic.storage.FileStorage.java

public FileStorage(Key key) throws LicenseToolException {
    this(new File(key.fullpath()), new System.Default());
}

From source file:it.lic.storage.FileStorage.java

public FileStorage(File path) throws LicenseToolException {
    this(path, new System.Default());
}

From source file:it.lic.cli.Main.java

private void run(final CommandLine cli) throws Exception {
    final Wallet wallet = new Wallet.Default(new FileStorage(new System.Default()));
    if (cli.hasOption("h")) {
        this.help();
    } else if (cli.hasOption("l")) {
        final LicenseKeyPair lkp = wallet.licenseKeyPair(cli.getOptionValue("l"));
        java.lang.System.out.println(String.format("[%s] Public key: %s", lkp.name(),
                new String(Base64.getEncoder().encode(lkp.publicKey().getEncoded()))));
    } else if (cli.hasOption("L")) {
        final Iterator<License> licenses = wallet.licenses(wallet.licenseKeyPair(cli.getOptionValue("L")), "");
        while (licenses.hasNext()) {
            License current = licenses.next();
            java.lang.System.out.println(String.format("%s\t%s\t%s\t%s", current.name(), current.issuer(),
                    current.until(), current.encode()));
        }//  ww w.  j a  v a  2  s.  com
    } else if (cli.hasOption("k")) {
        final LicenseKeyPair lkp = wallet.newLicenseKeyPair(cli.getOptionValue("k"));
        java.lang.System.out.println(String.format("new keypair created: %s",
                new String(Base64.getEncoder().encode(lkp.publicKey().getEncoded()))));
    } else if (cli.hasOption("K")) {
        final Calendar expire = Calendar.getInstance();
        expire.add(Calendar.YEAR, 1);
        Optional<License> license = wallet.hasLicenseFor(wallet.licenseKeyPair("prometeo"),
                cli.getOptionValue("K"));
        if (license.isPresent()) {
            java.lang.System.out.println(String.format("license already esists: %s", license.get().encode()));
        } else {
            final License newlicense = wallet.newLicense(cli.getOptionValue("K"),
                    wallet.licenseKeyPair("prometeo"), cli.getOptionValue("K"), expire.getTime(),
                    Collections.emptyMap());
            java.lang.System.out.println(String.format("new license created: %s", newlicense.encode()));
        }
    }
}