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

net.java.truelicense.core.LicenseApplicationContext Maven / Gradle / Ivy

There is a newer version: 2.6.6
Show newest version
/*
 * Copyright (C) 2005-2013 Schlichtherle IT Services.
 * All rights reserved. Use is subject to license terms.
 */
package net.java.truelicense.core;

import java.io.File;
import javax.annotation.CheckForNull;
import net.java.truelicense.core.auth.Authentication;
import net.java.truelicense.core.crypto.Encryption;
import net.java.truelicense.core.io.*;
import net.java.truelicense.core.util.Injection;
import net.java.truelicense.obfuscate.*;

/**
 * A context which has been derived from a
 * {@linkplain LicenseManagementContext license management context}.
 * 

* Applications have no need to implement this interface and should not do so * because it may be subject to expansion in future versions. * * @author Christian Schlichtherle */ public interface LicenseApplicationContext extends LicenseManagementContextProvider { /** * Returns the management context from which this application context * originated. */ @Override LicenseManagementContext context(); /** * Configures a Password Based Encryption (PBE). *

* If the given {@code algorithm} name is {@code null}, then it defaults to * a value which is specific to the license key format as if computed by * the expression * {@link #context()}.{@link LicenseManagementContext#pbeAlgorithm() pbeAlgorithm()}. * Otherwise, the string should be computed on demand from an obfuscated * form, e.g. by annotating a constant string value with the * @{@link Obfuscate} annotation and processing it with the TrueLicense * Maven Plugin. *

* Applications which require interoperability with V1 format license keys * need to specify the algorithm name {@code PBEWithMD5AndDES}. * All other applications should provide an algorithm name with stronger * encryption, e.g. {@code PBEWithSHA1AndDESede}. * If you choose a different PBE algorithm then you need to make sure that * it's supported by a security provider on all platforms, see * Java Cryptography Architeture Sun Providers Documentation. * * @param algorithm the nullable PBE algorithm name. * @param password the password. * @return A Password Based Encryption (PBE). */ Encryption pbe(@CheckForNull String algorithm, ObfuscatedString password); /** * Returns a source which loads the resource with the given {@code name}. * The provided string should be computed on demand from an obfuscated form, * e.g. by annotating a constant string value with the @{@link Obfuscate} * annotation and processing it with the TrueLicense Maven Plugin. *

* The resource will get loaded using the class loader as defined by the * root license management context. * * @param name the name of the resource to load. * @return A source which loads the resource with the given {@code name}. */ Source resource(String name); /** Returns a store for the given {@code file}. */ Store fileStore(File file); /** * Returns a store for the system preferences node for the package of the * given class. * Note that the class should be exempt from byte code obfuscation or * otherwise you might use an unintended store location and risk a * collision with third party software. */ Store systemNodeStore(Class classInPackage); /** * Returns a store for the user preferences node for the package of the * given class. * Note that the class should be exempt from byte code obfuscation or * otherwise you might use an unintended store location and risk a * collision with third party software. */ Store userNodeStore(Class classInPackage); /** * Injects a Key Store Based {@link Authentication} (KSBA) * into some target. */ interface KsbaInjection extends Injection { /** * Sets the source for the key store. * * @return {@code this} */ KsbaInjection loadFrom(Source source); /** * Sets the resource name of the key store. * * @return {@code this} */ KsbaInjection loadFromResource(String name); /** * Sets the type of the key store. * If this method is not called or a {@code null} value is provided, * then the * {@linkplain LicenseManagementContext#storeType default key store type} * is assumed. * * @return {@code this} */ KsbaInjection storeType(@CheckForNull String storeType); /** * Sets the store password. * * @return {@code this} */ KsbaInjection storePassword(ObfuscatedString storePassword); /** * Sets the alias name of the key entry. * * @return {@code this} */ KsbaInjection alias(String alias); /** * Sets the password for the private key in the entry, if any. * A private key entry is only required to create license keys, that is * for every {@linkplain LicenseVendorManager license vendor manager} * and for {@linkplain LicenseConsumerManager license consumer managers} * with an FTP. * * @return {@code this} */ KsbaInjection keyPassword(ObfuscatedString keyPassword); } /** * Injects a Password Based {@link Encryption} (PBE) * into some target. */ interface PbeInjection extends Injection { /** * Sets the algorithm name. * If this method is not called or a {@code null} value is provided, * then the * {@linkplain LicenseManagementContext#pbeAlgorithm default PBE algorithm} * for the license key format is assumed. * * @return {@code this} */ PbeInjection algorithm(@CheckForNull String algorithm); /** * Sets the password. * * @return {@code this} */ PbeInjection password(ObfuscatedString password); } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy