christian-schlichtherle / truelicense

An open source engine for license management on the Java Virtual Machine.
https://truelicense.namespace.global
Apache License 2.0
319 stars 66 forks source link

Question: How can I determine the edition of a License? #13

Closed GrahamLea closed 4 years ago

GrahamLea commented 4 years ago

Using the keymgr library in my app, I've gotten this far:

val lm = LicenseManager.get()
lm.install(file(licenseFile))
val license = lm.load()
lm.verify()

Now I want to do logic based on the edition:

if (/* license edition == "foo" */) {
    ...
} else {
    ...
}

What's the logic I need to write the if condition?

christian-schlichtherle commented 4 years ago

I finally came to write the updated documentation page for the API: https://truelicense.namespace.global/guide/using-the-api.html#verifying-the-license-key .

GrahamLea commented 4 years ago

Thanks!

Extra note for others who might land here from Google: to access the LicenseManager in my app while still using the Proguard-ed jar, I've added this proguard config to the keymgr's pom:

-keep class ${package}.keymgr.LicenseManager {
    public *;
}

Best practice will be to also obfuscate your own app.

christian-schlichtherle commented 4 years ago

Thanks!

Extra note for others who might land here from Google: to access the LicenseManager in my app while still using the Proguard-ed jar, I've added this proguard config to the keymgr's pom:

-keep class ${package}.keymgr.LicenseManager {
    public *;
}

Best practice will be to also obfuscate your own app.

Well, it's strongly encouraged to obfuscate the whole application so then you wouldn't need to "keep" the LicenseManager class. In fact, if it's kept, an attacker can simply replace it with a dummy substitute on the class path.