Package io.confluent.license
Class License
java.lang.Object
io.confluent.license.License
- Direct Known Subclasses:
CSFLELicense
this class provides utility functions and a cli for creating/verifying licenses
a license is a jwt (https://jwt.io/introduction/) that is
- issued by "Confluent"
- has an expiration time
- has a subject
a jwt license may make a claim about support for "monitoring" (either true or false)
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumDefines the deployment scope where a license can be used.static enumSupported License Types: -
Constructor Summary
ConstructorsConstructorDescriptionLicense(org.jose4j.jwt.JwtClaims claims, org.apache.kafka.common.utils.Time clock, String serialized) Create a license with the suppliedJWT Claims.License(org.jose4j.jwt.JwtClaims claims, org.apache.kafka.common.utils.Time clock, String serialized, String platformId) Create a license with the suppliedJWT Claimsand cluster id. -
Method Summary
Modifier and TypeMethodDescriptionaudience()Get the audience for the license.Get a string with comma-separatedaudience literalsfor the license.static org.jose4j.jwt.JwtClaimsbaseClaims(String audience, long expiration, boolean monitoring) booleanGet the license's expiration date.Get the license's expiration date as a formatted string of the form "yyyy-MM-dd".booleanexpiresBefore(License other) Determine if this license expires before the specified license.static StringgenerateTrialLicense(org.jose4j.jwt.JwtClaims trialClaims) getAudience(org.jose4j.jwt.JwtClaims claims) static longgetExpiration(org.jose4j.jwt.JwtClaims claims) inthashCode()booleanDetermine if this license is an updated version of the specified license with the same expiration date.booleanDetermine whether the license represents a Enterprise license.booleanisEquivalentTo(License other) Determine if this license is equivalent to the specified license, using theaudience,expiration time,issuer,subject, and monitoring claim.booleanDetermine whether this license has expired.booleanDetermine whether the license represents a free tier license that allows for single-node clusters only.booleanbooleanisRenewalOf(License other) Determine if this license is a strict renewal of the specified license.booleanisTrial()Determine whether the license represents a trial, such that theaudienceis simply "trial".booleanisValid()Determine whether this license is currently valid.The license id.static PrivateKeystatic PublicKeystatic PublicKeyThe platform id for the licensing server.Get the serialized form of this license.static Stringsign(PrivateKey key, String audience, long expiration, boolean monitoring) subject()Get the subject of the license.longtimeRemaining(TimeUnit unit) Get the amount of time in the specified units that remains before the license expires.toString()type()Get the type of license.static org.jose4j.jwt.JwtClaimsstatic booleanverifyMonitoring(org.jose4j.jwt.JwtClaims claims) static org.jose4j.jwt.JwtClaimsverifyStored(PublicKey key, String license)
-
Constructor Details
-
License
public License(org.jose4j.jwt.JwtClaims claims, org.apache.kafka.common.utils.Time clock, String serialized) Create a license with the suppliedJWT Claims.- Parameters:
claims- the JWT claimsclock- the clock that can be used to compute theexpirationDate(); may not be nullserialized- the serialized form of the license; may not be null
-
License
public License(org.jose4j.jwt.JwtClaims claims, org.apache.kafka.common.utils.Time clock, String serialized, String platformId) Create a license with the suppliedJWT Claimsand cluster id.- Parameters:
claims- the JWT claimsclock- the clock that can be used to compute theexpirationDate(); may not be nullserialized- the serialized form of the license; may not be nullplatformId- the id for the license cluster
-
-
Method Details
-
baseClaims
public static org.jose4j.jwt.JwtClaims baseClaims(String audience, long expiration, boolean monitoring) -
sign
public static String sign(PrivateKey key, String audience, long expiration, boolean monitoring) throws org.jose4j.lang.JoseException - Throws:
org.jose4j.lang.JoseException
-
verify
public static org.jose4j.jwt.JwtClaims verify(PublicKey key, String license) throws org.jose4j.jwt.consumer.InvalidJwtException - Throws:
org.jose4j.jwt.consumer.InvalidJwtException
-
verifyStored
public static org.jose4j.jwt.JwtClaims verifyStored(PublicKey key, String license) throws org.jose4j.jwt.consumer.InvalidJwtException - Throws:
org.jose4j.jwt.consumer.InvalidJwtException
-
getExpiration
- Throws:
Throwable
-
getAudience
-
verifyMonitoring
public static boolean verifyMonitoring(org.jose4j.jwt.JwtClaims claims) -
loadPrivateKey
public static PrivateKey loadPrivateKey(InputStream is) throws IOException, NoSuchAlgorithmException, InvalidKeySpecException -
loadPublicKey
public static PublicKey loadPublicKey() throws NoSuchAlgorithmException, IOException, InvalidKeySpecException -
loadPublicKey
public static PublicKey loadPublicKey(InputStream is) throws IOException, NoSuchAlgorithmException, InvalidKeySpecException -
generateTrialLicense
public static String generateTrialLicense(org.jose4j.jwt.JwtClaims trialClaims) throws InvalidLicenseException - Throws:
InvalidLicenseException
-
platformId
The platform id for the licensing server. Currently, this is set to the cluster id but can change in the future.- Returns:
- License platform id
-
licenseId
The license id. This is the JWT token id aka 'jti' that is unique to each license- Returns:
- License id
-
isInvalidLicense
public boolean isInvalidLicense() -
subject
Get the subject of the license.- Returns:
- the subject, may be null or empty if the license is malformed
-
isTrial
public boolean isTrial()Determine whether the license represents a trial, such that theaudienceis simply "trial".- Returns:
- true if the license is know to be a trial, or false otherwise
-
isFreeTier
public boolean isFreeTier()Determine whether the license represents a free tier license that allows for single-node clusters only.- Returns:
- true if the license represents the free tier, or false otherwise
-
isEnterprise
public boolean isEnterprise()Determine whether the license represents a Enterprise license.- Returns:
- true if the license represents the Enterprise, or false otherwise
-
type
Get the type of license.- Returns:
- the license type; never null
- See Also:
-
deploymentScope
-
expirationDate
Get the license's expiration date.- Returns:
- the expiration date; never null
-
expirationDateString
Get the license's expiration date as a formatted string of the form "yyyy-MM-dd".- Returns:
- the string representation of the
expirationDate(); never null
-
isExpired
public boolean isExpired()Determine whether this license has expired.- Returns:
- true if the license is expired, or false otherwise
-
isValid
public boolean isValid()Determine whether this license is currently valid.- Returns:
- true if the license is valid, or false otherwise
-
isEquivalentTo
Determine if this license is equivalent to the specified license, using theaudience,expiration time,issuer,subject, and monitoring claim. This method does not consider theissued timestamp,not before, andJWT IDclaims.- Parameters:
other- the other license- Returns:
- true if this license and
otherare equivalent, or false otherwise
-
isRenewalOf
Determine if this license is a strict renewal of the specified license. This is essentially the same logic asisEquivalentTo(License)except theexpiration timeof this license must be later than the specified license.- Parameters:
other- the other license- Returns:
- true if
otheris a renewal of thepreviouslicense
-
timeRemaining
Get the amount of time in the specified units that remains before the license expires.- Parameters:
unit- the unit for the returned time; may not be null- Returns:
- the time remaining before the license expires; may be negative if the license is already expired
-
audience
Get the audience for the license. This corresponds to the customer information, or "trial" if the license is a trial.- Returns:
- the audience string(s); may be empty if the license has no valid audience
-
audienceString
Get a string with comma-separatedaudience literalsfor the license. This corresponds to the customer information, or "trial" if the license is a trial.- Returns:
- the string containing the comma-separated audience literals; may be empty if the license has no valid audience
-
expiresBefore
Determine if this license expires before the specified license.- Parameters:
other- the other license; may be null- Returns:
- true if the other license is null or this license expires before the other license
-
isAddonUpdatedWithSameExpiry
Determine if this license is an updated version of the specified license with the same expiration date. This method checks if the current license has addon claims and if the `updatedAt` timestamp is later than the specified license.- Parameters:
other- the other license to compare against- Returns:
- true if the current license is an updated version with the same expiration date, false otherwise
-
hashCode
public int hashCode() -
equals
-
toString
-
serializedForm
Get the serialized form of this license.- Returns:
- the serialized form; never null
-