Package rs.baselib.licensing.internal
Class OctetLicenseCreator
java.lang.Object
rs.baselib.licensing.internal.OctetLicenseCreator
- All Implemented Interfaces:
ILicenseCreator
public class OctetLicenseCreator extends java.lang.Object implements ILicenseCreator
Creates an Octet License.
- Author:
- ralph
-
Constructor Summary
Constructors Constructor Description OctetLicenseCreator()Constructor. -
Method Summary
Modifier and Type Method Description protected byte[]combine(int prefix, byte[] signature)Builds the combined license key (raw bytes).java.lang.StringcreateLicenseKey(ILicenseContext context, ILicense license)Generates a key from the given license.static java.lang.Stringgroup(java.lang.String s)Groups a string into 8-character blocks.protected byte[]sign(ILicenseContext context, byte[] bytes)Signs the given byte array.
-
Constructor Details
-
OctetLicenseCreator
public OctetLicenseCreator()Constructor.
-
-
Method Details
-
createLicenseKey
Generates a key from the given license.- Specified by:
createLicenseKeyin interfaceILicenseCreator- Parameters:
context- the licensing context.license- the license to be created.- Returns:
- the license key
-
sign
protected byte[] sign(ILicenseContext context, byte[] bytes) throws SigningException, java.security.NoSuchAlgorithmException, DecryptionExceptionSigns the given byte array.- Parameters:
context- - the licensing contextbytes- - the bytes to be signed- Returns:
- the signature
- Throws:
SigningException- - when signing failsjava.security.NoSuchAlgorithmException- - when the signing algorithm is invalidDecryptionException- - when other signing error occur
-
combine
protected byte[] combine(int prefix, byte[] signature)Builds the combined license key (raw bytes).- Parameters:
prefix- the integer prefix basically containing the expiry time in seconds since epoch timesignature- teh signature- Returns:
- the combined byte array
-
group
public static java.lang.String group(java.lang.String s)Groups a string into 8-character blocks.- Parameters:
s- the string to be grouped- Returns:
- the grouped string
-