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

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

Go to download

The TrueLicense Core module provides essential functionality for license management.

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 de.schlichtherle.license.LicenseContent;
import de.schlichtherle.xml.*;
import javax.annotation.concurrent.Immutable;
import net.java.truelicense.core.codec.X500PrincipalXmlCodec;
import net.java.truelicense.core.crypto.*;
import net.java.truelicense.core.io.Transformation;
import net.java.truelicense.obfuscate.Obfuscate;

/**
 * The root context for the management of Version 1 (V1) format license keys.
 * This class is provided to enable applications to create, install, verify
 * and uninstall license keys in the format for TrueLicense 1.X applications.
 * Since TrueLicense 2.0, this format is obsolete and should not get used in
 * new applications.
 * Note that there is no interoperability between different format license keys.
 * 

* Use this context to create a {@link LicenseVendorContext} or a * {@link LicenseConsumerContext}. * Here's an example for verifying the installed license key in a consumer * application: *


 * LicenseManagementContext mc = new V1LicenseManagementContext("MyApp 1");
 * LicenseConsumerContext cc = mc.consumer();
 * LicenseConsumerManager cm = cc.manager(...);
 * cm.verify();
 * 
*

* Or in a fluent API programming style: *


 * new V1LicenseManagementContext("MyApp 1").consumer().manager()...verify();
 * 
*

* Do not copy-paste this code! * Instead, use the TrueLicense Maven Archetype to generate a sample project * for you. *

* Where required, this class should get subclassed to customize license * {@linkplain #license creation}, * {@linkplain #initialization initialization} * or {@linkplain #validation validation}, * {@linkplain #codec encoding} or to implement an authoritative * {@linkplain #now clock} or to provide an alternative * {@linkplain #classLoader class loader} for loading key stores. *

* Note that this class is immutable. * Unless stated otherwise, all no-argument methods need to return consistent * objects so that caching them is not required. * A returned object is considered to be consistent if it compares * {@linkplain Object#equals(Object) equal} or at least behaves identical to * any previously returned object. * * @author Christian Schlichtherle */ @Immutable public class V1LicenseManagementContext extends BasicLicenseManagementContext { @Obfuscate private static final String STORE_TYPE = "JKS"; @Obfuscate private static final String PBE_ALGORITHM = "PBEWithMD5AndDES"; private final X500PrincipalXmlCodec codec = new X500PrincipalXmlCodec(); /** * Constructs a V1 license management context. * The provided string should get computed on demand from an obfuscated * form, e.g. by annotating a constant string value with the * {@literal @}{@link Obfuscate} annotation and processing it with the * TrueLicense Maven Plugin. * * @param subject the licensing subject, i.e. a product name with an * optional version range, e.g. {@code MyApp 1}. */ public V1LicenseManagementContext(String subject) { super(subject); } /** Returns a new license content. */ // This introduces a cyclic dependency between the packages // de.schlichtherle.license and this package. // However, this is tolerable. @Override public LicenseContent license() { return new LicenseContent(); } /** * {@inheritDoc} *

* The implementation in the class {@link V1LicenseManagementContext} * returns {@code "JKS"}. * Although this was the only supported key store type in TrueLicense 1 * you can use another one, e.g. {@code "JCEKS"} in order to benefit * from its improved integrity checks. */ @Override public final String storeType() { return STORE_TYPE; } /** * {@inheritDoc} *

* The implementation in the class {@link V1LicenseManagementContext} * returns a new {@link GenericCertificate}. */ @Override public final GenericCertificate repository() { return new GenericCertificate(); } /** * {@inheritDoc} *

* The implementation in the class {@link V1LicenseManagementContext} * returns an {@link X500PrincipalXmlCodec}. */ @Override public X500PrincipalXmlCodec codec() { return codec; } /** * {@inheritDoc} *

* The implementation in the class {@link V1LicenseManagementContext} * returns a compression for V1 format license keys. */ @Override public final Transformation compression() { return new V1Compression(); } /** * {@inheritDoc} *

* The implementation in the class {@link V1LicenseManagementContext} * returns {@code "PBEWithMD5AndDES"}. * This was the only supported PBE algorithm in TrueLicense 1 and its * not possible to use another one. */ @Override public final String pbeAlgorithm() { return PBE_ALGORITHM; } /** * {@inheritDoc} *

* The implementation in the class {@link V1LicenseManagementContext} * returns an encryption for V1 format license keys with the given * parameters. */ @Override public final Encryption encryption(PbeParameters pbe) { return new V1Encryption(pbe); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy