Package com.nuix.enginebaseline
Class NuixLicenseResolver
- java.lang.Object
-
- com.nuix.enginebaseline.NuixLicenseResolver
-
- All Implemented Interfaces:
LicenseResolver
public class NuixLicenseResolver extends java.lang.Object implements LicenseResolver
This class provides license resolution for aNuixEngine
instance. Use it to specify:- What license sources should be queried:
- Criteria to disqualify some licenses from being acquired when there are multiple to select from:
- Custom logic to ultimately pick the license acquired from candidates
withFinalDecisionMadeBy(Function)
- Configuration details that are part of obtaining a license:
Example usages:// Define a resolver which will resolve licenses from Cloud License Server (CLS), // authenticating using upon environment variable "NUIX_USERNAME" and "NUIX_PASSWORD", // that have at least 4 workers and the feature "CASE_CREATION". LicenseResolver cloud_4_workers = NuixLicenseResolver.fromCloud() .withLicenseCredentialsResolvedFromEnvVars() .withMinWorkerCount(4) .withRequiredFeatures("CASE_CREATION"); // Define a resolver which will attempt to resolve a license from a local physical dongle // that has the feature "CASE_CREATION". LicenseResolver anyDongle = NuixLicenseResolver.fromDongle() .withRequiredFeatures("CASE_CREATION");
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
NuixLicenseResolver.LicenseResolutionSource
An enum with options about how this license resolver should locate its license.
-
Field Summary
Fields Modifier and Type Field Description protected nuix.engine.CertificateTrustCallback
certificateTrustCallback
protected nuix.engine.CredentialsCallback
credentialsCallback
protected java.lang.String
customSource
protected java.util.function.Function<java.util.stream.Stream<nuix.engine.AvailableLicence>,java.util.Optional<nuix.engine.AvailableLicence>>
finalDecider
protected NuixLicenseResolver.LicenseResolutionSource
licenseSource
protected int
maxWorkerCount
protected int
minWorkerCount
protected java.util.Set<java.lang.String>
requiredFeatures
protected java.lang.String
serverHost
protected int
serverPort
protected java.lang.String
targetShortName
-
Constructor Summary
Constructors Modifier Constructor Description protected
NuixLicenseResolver()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static NuixLicenseResolver
fromAnySource()
Creates an instance which places no constraints on where the license is obtained from.static NuixLicenseResolver
fromCloud()
Creates an instance specifically for resolving a license from the Nuix Cloud License Server (CLS).static NuixLicenseResolver
fromCustomSource(@NonNull java.lang.String customSource)
Creates an instance that will specify a custom source.static NuixLicenseResolver
fromDongle()
Creates an instance specifically for resolving a physical dongle based license.static NuixLicenseResolver
fromServer(@NonNull java.lang.String host)
Creates an instance specifically for resolving a license from a Nuix Management Server (NMS) instance.static NuixLicenseResolver
fromServer(@NonNull java.lang.String host, int port)
Creates an instance specifically for resolving a license from a Nuix Management Server (NMS) instance.boolean
resolveLicense(@NonNull nuix.engine.Engine engine)
Attempts to license the provided Engine instance using resolution and filtering configuration of this instance.java.lang.String
toString()
NuixLicenseResolver
withCertificateTrustCallback(nuix.engine.CertificateTrustCallback certificateTrustCallback)
Specifies a certificate trust callback.NuixLicenseResolver
withFinalDecisionMadeBy(@NonNull java.util.function.Function<java.util.stream.Stream<nuix.engine.AvailableLicence>,java.util.Optional<nuix.engine.AvailableLicence>> finalDecider)
Allows you to provide a function which makes the final decision as to which available license to obtain.NuixLicenseResolver
withLicenseCredentials(java.lang.String userName, java.lang.String password)
Allows you to specify the specific username and password to use for license authentication (CLS/NMS)NuixLicenseResolver
withLicenseCredentialsProvider(nuix.engine.CredentialsCallback credentialsCallback)
Allows you to provider a license credentials callback used for license authentication (CLS/NMS).NuixLicenseResolver
withLicenseCredentialsResolvedFromEnvVars()
Specifies that license authentication credentials will be obtained from environment variables.NuixLicenseResolver
withLicenseCredentialsResolvedFromEnvVars(java.lang.String usernameEnvVar, java.lang.String passwordEnvVar)
Allows you to specify Environment variables to resolve the license authentication username and password from.NuixLicenseResolver
withMaxWorkerCount(int maxWorkerCount)
Specifies a maximum worker count a license can have to be acceptable.NuixLicenseResolver
withMinWorkerCount(int minWorkerCount)
Specifies a minimum worker count a given license must have to be acceptable.NuixLicenseResolver
withRequiredFeatures(java.lang.String... features)
Specifies a list of one or more features that a license must have to be acceptable.NuixLicenseResolver
withRequiredFeatures(java.util.Collection<java.lang.String> features)
Specifies a list of one or more features that a license must have to be acceptable.NuixLicenseResolver
withTrustAllCertificates()
Specifies a certificate trust callback that blindly accepts all certificates.
-
-
-
Field Detail
-
licenseSource
protected NuixLicenseResolver.LicenseResolutionSource licenseSource
-
customSource
protected java.lang.String customSource
-
serverHost
protected java.lang.String serverHost
-
serverPort
protected int serverPort
-
credentialsCallback
protected nuix.engine.CredentialsCallback credentialsCallback
-
certificateTrustCallback
protected nuix.engine.CertificateTrustCallback certificateTrustCallback
-
requiredFeatures
protected java.util.Set<java.lang.String> requiredFeatures
-
minWorkerCount
protected int minWorkerCount
-
maxWorkerCount
protected int maxWorkerCount
-
targetShortName
protected java.lang.String targetShortName
-
finalDecider
protected java.util.function.Function<java.util.stream.Stream<nuix.engine.AvailableLicence>,java.util.Optional<nuix.engine.AvailableLicence>> finalDecider
-
-
Method Detail
-
fromServer
public static NuixLicenseResolver fromServer(@NonNull @NonNull java.lang.String host, int port)
Creates an instance specifically for resolving a license from a Nuix Management Server (NMS) instance.- Parameters:
host
- The host/ip of the NMS server.port
- The port of the NMS server.- Returns:
- An NMS specific license resolver
-
fromServer
public static NuixLicenseResolver fromServer(@NonNull @NonNull java.lang.String host)
Creates an instance specifically for resolving a license from a Nuix Management Server (NMS) instance. Similar to callingfromServer(String, int)
with a port of 27443 (the default).- Parameters:
host
- The host/ip of the NMS server.- Returns:
- An NMS specific license resolver
-
fromDongle
public static NuixLicenseResolver fromDongle()
Creates an instance specifically for resolving a physical dongle based license.- Returns:
- A dongle specific license resolver.
-
fromCloud
public static NuixLicenseResolver fromCloud()
Creates an instance specifically for resolving a license from the Nuix Cloud License Server (CLS).- Returns:
- A CLS specific license resolver.
-
fromAnySource
public static NuixLicenseResolver fromAnySource()
Creates an instance which places no constraints on where the license is obtained from. When using this, no "sources" parameter is provided to the licensor, allowing for a license to be obtained from all sources that the engine is able to locate.- Returns:
- A license resolver that is indifferent to where the license comes from.
-
fromCustomSource
public static NuixLicenseResolver fromCustomSource(@NonNull @NonNull java.lang.String customSource)
Creates an instance that will specify a custom source.- Parameters:
customSource
- The custom source value to provide.- Returns:
- A license resolver that uses a custom license source.
-
withRequiredFeatures
public NuixLicenseResolver withRequiredFeatures(java.lang.String... features)
Specifies a list of one or more features that a license must have to be acceptable.- Parameters:
features
- The required features.- Returns:
- This license resolver for chained method calls.
-
withRequiredFeatures
public NuixLicenseResolver withRequiredFeatures(java.util.Collection<java.lang.String> features)
Specifies a list of one or more features that a license must have to be acceptable.- Parameters:
features
- The required features.- Returns:
- This license resolver for chained method calls.
-
withMinWorkerCount
public NuixLicenseResolver withMinWorkerCount(int minWorkerCount)
Specifies a minimum worker count a given license must have to be acceptable.- Parameters:
minWorkerCount
- The minimum worker count. A value of 0 means no minimum.- Returns:
- This license resolver for chained method calls.
-
withMaxWorkerCount
public NuixLicenseResolver withMaxWorkerCount(int maxWorkerCount)
Specifies a maximum worker count a license can have to be acceptable. This exists mostly to help in situations where you might have a license with a small amount of workers and another with a larger amount of workers to assist in preventing acquisition of the larger worker count license.- Parameters:
maxWorkerCount
- The maximum worker count. A value of 0 means no maximum.- Returns:
- This license resolver for chained method calls.
-
withFinalDecisionMadeBy
public NuixLicenseResolver withFinalDecisionMadeBy(@NonNull @NonNull java.util.function.Function<java.util.stream.Stream<nuix.engine.AvailableLicence>,java.util.Optional<nuix.engine.AvailableLicence>> finalDecider)
Allows you to provide a function which makes the final decision as to which available license to obtain. Supplied function will be provided Stream of AvailableLicenses after this license resolver has applied any filtering that it may have applied.- Parameters:
finalDecider
- A function that can make the final choice of which (if any) license to acquire.- Returns:
- This license resolver for chained method calls.
-
withLicenseCredentialsProvider
public NuixLicenseResolver withLicenseCredentialsProvider(nuix.engine.CredentialsCallback credentialsCallback)
Allows you to provider a license credentials callback used for license authentication (CLS/NMS).- Parameters:
credentialsCallback
- The custom credentials callback- Returns:
- This license resolver for chained method calls.
-
withLicenseCredentials
public NuixLicenseResolver withLicenseCredentials(java.lang.String userName, java.lang.String password)
Allows you to specify the specific username and password to use for license authentication (CLS/NMS)- Parameters:
userName
- The username to usepassword
- The password to use- Returns:
- This license resolver for chained method calls.
-
withLicenseCredentialsResolvedFromEnvVars
public NuixLicenseResolver withLicenseCredentialsResolvedFromEnvVars(java.lang.String usernameEnvVar, java.lang.String passwordEnvVar)
Allows you to specify Environment variables to resolve the license authentication username and password from.- Parameters:
usernameEnvVar
- The name of the environment variablepasswordEnvVar
- The password of the environment variable- Returns:
- This license resolver for chained method calls.
-
withLicenseCredentialsResolvedFromEnvVars
public NuixLicenseResolver withLicenseCredentialsResolvedFromEnvVars()
Specifies that license authentication credentials will be obtained from environment variables. The value of username will be pulled from "NUIX_USERNAME" and the value of password will be pulled from "NUIX_PASSWORD".- Returns:
- This license resolver for chained method calls.
-
withCertificateTrustCallback
public NuixLicenseResolver withCertificateTrustCallback(nuix.engine.CertificateTrustCallback certificateTrustCallback)
Specifies a certificate trust callback.- Parameters:
certificateTrustCallback
- The certificate trust callback.- Returns:
- This license resolver for chained method calls.
-
withTrustAllCertificates
public NuixLicenseResolver withTrustAllCertificates()
Specifies a certificate trust callback that blindly accepts all certificates. This is the default behavior of license resolver.- Returns:
- This license resolver for chained method calls.
-
resolveLicense
public boolean resolveLicense(@NonNull @NonNull nuix.engine.Engine engine) throws java.lang.Exception
Attempts to license the provided Engine instance using resolution and filtering configuration of this instance.- Specified by:
resolveLicense
in interfaceLicenseResolver
- Parameters:
engine
- The engine instance to attempt to license.- Returns:
- True if a license was obtained, false if not.
- Throws:
java.lang.Exception
- Exceptions thrown by any of the methods working to obtain a license will be uncaught and allowed to bubble up for caller to respond to.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-