/** * @return If no license is installed a dummy license is returned. * @see #EMPTY_LICENSE */ public static License find() { return find(new DisabledLicenseVerifierCallback()); }
@Override public boolean verify(final LicenseVerifierCallback callback) { final String publicKey = this.getPublicKey(); try { this.verify(dictionary, publicKey); return true; } catch(InvalidLicenseException e) { callback.failure(e); return false; } }
@Override protected License open(final Local file) { return new DonationKey(file); } }
public static void print(final Preferences preferences) { final Console console = new Console(); final License l = LicenseFactory.find(); console.printf("%s %s (%s). %s%n", preferences.getProperty("application.name"), preferences.getProperty("application.version"), preferences.getProperty("application.revision"), l.verify(new DisabledLicenseVerifierCallback()) ? l.toString() : "Not registered. Purchase a donation key to support the development of this software."); } }
@Override public List<Header> headers() throws AccessDeniedException, MissingReceiptException, InvalidReceiptException { final List<License> receipts = factory.open(); if(receipts.isEmpty()) { throw new MissingReceiptException(); } final List<Header> headers = new ArrayList<Header>(); for(License receipt : receipts) { if(log.isInfoEnabled()) { log.info(String.format("Using voucher %s", receipt)); } if(!receipt.verify(new DisabledLicenseVerifierCallback())) { throw new InvalidReceiptException(); } headers.add(new Header(Headers.HEADER_VOUCHER, receipt.getValue("Voucher"))); } return headers; }
@Override protected License create() { return new DefaultLicenseFactory(this).create(); }
/** * Set name of key in menu item */ protected void updateLicenseMenu() { final License key = LicenseFactory.find(); if(key.isReceipt()) { this.applicationMenu.removeItemAtIndex(new NSInteger(5)); this.applicationMenu.removeItemAtIndex(new NSInteger(4)); } else { this.applicationMenu.itemAtIndex(new NSInteger(5)).setAttributedTitle( NSAttributedString.attributedStringWithAttributes(key.toString(), MENU_HELP_FONT_ATTRIBUTES) ); } }
@Override public List<License> open() throws AccessDeniedException { final List<License> keys = super.open(); if(keys.isEmpty()) { System.exit(APPSTORE_VALIDATION_FAILURE); } return keys; }
public ReceiptFactory(final Local folder) { super(folder, new ReceiptFilter()); }
public DictionaryLicense(final Local file) { super(file); this.file = file; this.dictionary = this.read(file); }
protected LicenseFactory(final Local folder) { this(folder, new LicenseFilter()); }
@Override public int hashCode() { int result = super.hashCode(); result = 31 * result + (guid != null ? guid.hashCode() : 0); return result; } }
@Override public int hashCode() { return this.toString().hashCode(); }
@Override public void failure(final InvalidLicenseException failure) { log.warn(String.format("Failure verifying registration key. %s", failure.getDetail())); } }
@Override public String toString() { return MessageFormat.format(LocaleFactory.localizedString("Registered to {0}", "License"), this.getName()); } }
@Override protected License create() { return new DefaultLicenseFactory(this).create(); }
@Override protected License open(final Local file) { return new DonationKey(file); }
public ReceiptFactory() { super(LocalFactory.get(PreferencesFactory.get().getProperty("application.receipt.path")), new ReceiptFilter()); }
@Override protected License create() { return new DefaultLicenseFactory(this).create(); }