@Override public List<License> open() throws AccessDeniedException { final List<License> keys = super.open(); if(keys.isEmpty()) { System.exit(APPSTORE_VALIDATION_FAILURE); } return keys; }
@Override public License create() { try { final List<License> list = delegate.open(); if(list.isEmpty()) { return LicenseFactory.EMPTY_LICENSE; } return list.iterator().next(); } catch(AccessDeniedException e) { log.warn(String.format("Failure finding receipt %s", e.getMessage())); } return LicenseFactory.EMPTY_LICENSE; } }
public List<License> open() throws AccessDeniedException { final List<License> keys = new ArrayList<License>(); if(folder.exists()) { for(Local key : folder.list().filter(filter)) { keys.add(this.open(key)); } } return keys; }
public static License find(final LicenseVerifierCallback callback) { try { final String clazz = preferences.getProperty("factory.licensefactory.class"); try { final Class<LicenseFactory> name = (Class<LicenseFactory>) Class.forName(clazz); final List<License> list = new ArrayList<License>(name.newInstance().open()); list.removeIf(key -> !key.verify(callback)); if(list.isEmpty()) { return LicenseFactory.EMPTY_LICENSE; } return list.iterator().next(); } catch(InstantiationException | ClassNotFoundException | IllegalAccessException e) { throw new FactoryException(e.getMessage(), e); } } catch(AccessDeniedException e) { log.warn(String.format("Failure finding receipt %s", e.getMessage())); } return LicenseFactory.EMPTY_LICENSE; }
/** * @param file File to parse * @return Read license from file */ public static License get(final Local file) { final String clazz = preferences.getProperty("factory.licensefactory.class"); if(null == clazz) { throw new FactoryException(); } try { final Class<LicenseFactory> name = (Class<LicenseFactory>) Class.forName(clazz); return name.newInstance().open(file); } catch(InstantiationException | ClassNotFoundException | IllegalAccessException e) { throw new FactoryException(e.getMessage(), e); } }
@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 public List<License> open() throws AccessDeniedException { final List<License> keys = super.open(); if(keys.isEmpty()) { if(log.isInfoEnabled()) {