public final class License extends Object
a license is a jwt (https://jwt.io/introduction/) that is
a jwt license may make a claim about support for "monitoring" (either true or false)
Modifier and Type | Class and Description |
---|---|
static class |
License.Type
The type of license.
|
Constructor and Description |
---|
License(org.jose4j.jwt.JwtClaims claims,
org.apache.kafka.common.utils.Time clock,
String serialized)
Create a license with the supplied
JWT Claims . |
License(org.jose4j.jwt.JwtClaims claims,
org.apache.kafka.common.utils.Time clock,
String serialized,
String platformId)
Create a license with the supplied
JWT Claims and cluster id. |
Modifier and Type | Method and Description |
---|---|
List<String> |
audience()
Get the audience for the license.
|
String |
audienceString()
Get a string with comma-separated
audience literals for the license. |
static org.jose4j.jwt.JwtClaims |
baseClaims(String audience,
long expiration,
boolean monitoring) |
boolean |
equals(Object obj) |
Date |
expirationDate()
Get the license's expiration date.
|
String |
expirationDateString()
Get the license's expiration date as a formatted string of the form .
|
boolean |
expiresBefore(License other)
Determine if this license expires before the specified license.
|
static String |
generateTrialLicense(org.jose4j.jwt.JwtClaims trialClaims) |
static List<String> |
getAudience(org.jose4j.jwt.JwtClaims claims) |
static long |
getExpiration(org.jose4j.jwt.JwtClaims claims) |
int |
hashCode() |
boolean |
isEquivalentTo(License other)
Determine if this license is equivalent to the specified license, using the
audience ,
expiration time ,
issuer ,
subject ,
and monitoring claim. |
boolean |
isExpired()
Determine whether this license has expired.
|
boolean |
isFreeTier()
Determine whether the license represents a free tier license that allows for
single-node clusters only.
|
boolean |
isRenewalOf(License other)
Determine if this license is a strict renewal of the specified license.
|
boolean |
isTrial()
Determine whether the license represents a trial, such that the
audience is simply "trial". |
boolean |
isValid()
Determine whether this license is currently valid.
|
String |
licenseId()
The license id.
|
static PrivateKey |
loadPrivateKey(InputStream is) |
static PublicKey |
loadPublicKey() |
static PublicKey |
loadPublicKey(InputStream is) |
String |
platformId()
The platform id for the licensing server.
|
String |
serializedForm()
Get the serialized form of this license.
|
static String |
sign(PrivateKey key,
String audience,
long expiration,
boolean monitoring) |
String |
subject()
Get the subject of the license.
|
long |
timeRemaining(TimeUnit unit)
Get the amount of time in the specified units that remains before the license expires.
|
String |
toString() |
License.Type |
type()
Get the type of license.
|
static org.jose4j.jwt.JwtClaims |
verify(PublicKey key,
String license) |
static boolean |
verifyMonitoring(org.jose4j.jwt.JwtClaims claims) |
static org.jose4j.jwt.JwtClaims |
verifyStored(PublicKey key,
String license) |
public License(org.jose4j.jwt.JwtClaims claims, org.apache.kafka.common.utils.Time clock, String serialized)
JWT Claims
.claims
- the JWT claimsclock
- the clock that can be used to compute the expirationDate()
;
may not be nullserialized
- the serialized form of the license; may not be nullpublic License(org.jose4j.jwt.JwtClaims claims, org.apache.kafka.common.utils.Time clock, String serialized, String platformId)
JWT Claims
and cluster id.claims
- the JWT claimsclock
- the clock that can be used to compute the expirationDate()
;
may not be nullserialized
- the serialized form of the license; may not be nullplatformId
- the id for the license clusterpublic static org.jose4j.jwt.JwtClaims baseClaims(String audience, long expiration, boolean monitoring)
public static String sign(PrivateKey key, String audience, long expiration, boolean monitoring) throws org.jose4j.lang.JoseException
org.jose4j.lang.JoseException
public static org.jose4j.jwt.JwtClaims verify(PublicKey key, String license) throws org.jose4j.jwt.consumer.InvalidJwtException
org.jose4j.jwt.consumer.InvalidJwtException
public static org.jose4j.jwt.JwtClaims verifyStored(PublicKey key, String license) throws org.jose4j.jwt.consumer.InvalidJwtException
org.jose4j.jwt.consumer.InvalidJwtException
public static long getExpiration(org.jose4j.jwt.JwtClaims claims) throws Throwable
Throwable
public static boolean verifyMonitoring(org.jose4j.jwt.JwtClaims claims)
public static PrivateKey loadPrivateKey(InputStream is) throws IOException, NoSuchAlgorithmException, InvalidKeySpecException
public static PublicKey loadPublicKey() throws NoSuchAlgorithmException, IOException, InvalidKeySpecException
public static PublicKey loadPublicKey(InputStream is) throws IOException, NoSuchAlgorithmException, InvalidKeySpecException
public static String generateTrialLicense(org.jose4j.jwt.JwtClaims trialClaims) throws InvalidLicenseException
InvalidLicenseException
public String platformId()
public String licenseId()
public String subject()
public boolean isTrial()
audience
is simply "trial".public boolean isFreeTier()
public License.Type type()
isFreeTier()
,
isTrial()
public Date expirationDate()
public String expirationDateString()
expirationDate()
; never nullpublic boolean isExpired()
public boolean isValid()
public boolean isEquivalentTo(License other)
audience
,
expiration time
,
issuer
,
subject
,
and monitoring claim.
This method does not consider the issued timestamp
,
not before
, and JWT ID
claims.other
- the other licenseother
are equivalent, or false otherwisepublic boolean isRenewalOf(License other)
isEquivalentTo(License)
except the
expiration time
of this license must be later than
the specified license.other
- the other licenseother
is a renewal of the previous
licensepublic long timeRemaining(TimeUnit unit)
unit
- the unit for the returned time; may not be nullpublic List<String> audience()
public String audienceString()
audience literals
for the license.
This corresponds to the customer information, or "trial" if the license is a trial.public boolean expiresBefore(License other)
other
- the other license; may be nullpublic String serializedForm()