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

net.java.truelicense.core.BasicLicenseManagementContext 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-2015 Schlichtherle IT Services.
 * All rights reserved. Use is subject to license terms.
 */
package net.java.truelicense.core;

import java.util.Date;
import javax.annotation.CheckForNull;
import javax.annotation.concurrent.Immutable;
import net.java.truelicense.core.auth.*;
import net.java.truelicense.core.crypto.*;
import net.java.truelicense.core.policy.*;
import net.java.truelicense.core.util.*;

/**
 * A basic license management context.
 * 

* 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 abstract class BasicLicenseManagementContext implements LicenseManagementContext { private final String subject; protected BasicLicenseManagementContext(final String subject) { this.subject = Objects.requireNonNull(subject); } @Override public final LicenseVendorContext vendor() { return new BasicLicenseVendorContext(this); } @Override public final LicenseConsumerContext consumer() { return new BasicLicenseConsumerContext(this); } /** Returns a new license. */ @Override public abstract License license(); /** * Returns the licensing subject. */ @Override public final String subject() { return subject; } /** * {@inheritDoc} *

* The implementation in the class {@link BasicLicenseManagementContext} * returns an authorization which clears all operation requests. */ @Override public LicenseAuthorization authorization() { return new BasicLicenseAuthorization(); } /** * {@inheritDoc} *

* The implementation in the class {@link BasicLicenseManagementContext} * returns an initialization which initializes the license * {@linkplain License#getConsumerType consumer type}, * {@linkplain License#getHolder holder}, * {@linkplain License#getIssued issue date/time}, * {@linkplain License#getIssuer issuer} and * {@linkplain License#getSubject subject} * unless these properties are already set respectively. */ @Override public LicenseInitialization initialization() { return new BasicLicenseInitialization(this); } /** * {@inheritDoc} *

* The implementation in the class {@link BasicLicenseManagementContext} * returns a validation which validates the license * {@linkplain License#getConsumerAmount consumer amount}, * {@linkplain License#getConsumerType consumer type}, * {@linkplain License#getHolder holder}, * {@linkplain License#getIssued issue date/time}, * {@linkplain License#getIssuer issuer}, * {@linkplain License#getSubject subject}, * {@linkplain License#getNotAfter not after date/time} (if set) and * {@linkplain License#getNotBefore not before date/time} (if set). */ @Override public LicenseValidation validation() { return new BasicLicenseValidation(this); } /** * Returns a new repository to use for * {@linkplain #license licenses}. */ @Override public abstract Repository repository(); /** * Returns an authentication for the given key store parameters. *

* The implementation in the class {@link BasicLicenseManagementContext} * returns a new {@link Notary} for the given parameters. * * @param ksp the key store parameters. */ @Override public Authentication authentication(KeyStoreParameters ksp) { return new Notary(ksp); } /** * Returns an encryption for the given PBE parameters. * * @param pbe the PBE parameters. */ @Override public abstract Encryption encryption(PbeParameters pbe); /** * {@inheritDoc} *

* The implementation in the class {@link BasicLicenseManagementContext} * returns a new {@link PasswordPolicy}. */ @Override public PasswordPolicy policy() { return new PasswordPolicy(); } /** * {@inheritDoc} *

* The implementation in the class {@link BasicLicenseManagementContext} * returns a new {@link Date}. */ @Override public Date now() { return new Date(); } /** * {@inheritDoc} *

* The implementation in the class {@link BasicLicenseManagementContext} * returns the current thread's context class loader. */ @Override public @CheckForNull ClassLoader classLoader() { return Thread.currentThread().getContextClassLoader(); } /** * {@inheritDoc} *

* The implementation in the class {@link BasicLicenseManagementContext} * returns half an hour (in milliseconds) to account for external changes * to the configured store for the license key. */ @Override public long cachePeriodMillis() { return 30 * 60 * 1000; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy