All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.customware.license.support.feature.FeatureRestriction Maven / Gradle / Ivy

The newest version!
package net.customware.license.support.feature;

import de.schlichtherle.license.LicenseContent;
import de.schlichtherle.license.LicenseContentException;
import net.customware.license.support.Restriction;

/**
 * This validator will check if the specified feature is present.
 * 
 * 

* If the license either does not have a {@link FeatureSet} in it's 'extra' * value, or the FeatureSet does not have any specific features in it, it is * assumed that the license will allow all features for the product. * *

* In other words, if you wish to lock down to specific features in a product, * you must specify at least one feature in when generating your * license. * * @author David Peterson */ public class FeatureRestriction implements Restriction { private Feature feature; public FeatureRestriction( Feature feature ) { this.feature = feature; } public void checkRestriction( Object context, LicenseContent content ) throws LicenseContentException { Object extra = content.getExtra(); if ( extra instanceof FeatureSet ) { FeatureSet features = ( FeatureSet ) extra; if ( features.hasFeatures() && !features.hasFeature( feature ) ) throw new LicenseContentException( "License does permit use of " + feature ); } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy