I’ve recently purchased a metered subscription but am having difficulty setting it up. A few questions in no particular order:
The documentation says “you should regularly check the license status”, but I don’t see a way to do this. The only relevant API, License.isLicensed(), seems to have been removed.
Does Aspose provide any way to configure logging? Does it log anything about its attempts to phone home? I didn’t see any log output, but my metered license instance switched into evaluation mode without warning.
Is there a way to force Aspose to phone home and switch to evaluation mode if it fails? I’d like to check that my configuration is working on my dev machine, but I can’t wait 24 hours to see if it happens to switch to evaluation mode.
What hostnames/IPs and ports does Aspose try to talk to?
The documentation suggests that I have to use a public/private key and not a file, but if I view my order on aspose.com, it offers to let me download a license file. Is there a difference? If I were to use the file for this metered subscription, I assume I use the License class instead of Metered?
How does the payment period relate to evaluation mode? Specifically, is there a grace period? It seems I pay the monthly fee ahead of time, but if that’s late for whatever reason does it immediately switch into evaluation mode?
Yes, License.isLicensed() has been removed from the public API due to the security reasons. You can use the following simple code to check whether the license is set or not. It assumes that Aspose.Words injects evaluation message into the document when work in evaluation mode:
private static boolean isLicensed() throws Exception
{
String testString = "test";
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.write(testString);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
doc.save(outputStream, SaveFormat.DOCX);
ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray());
doc = new Document(inputStream);
String test = doc.toString(SaveFormat.TEXT).trim();
return test.equals(testString);
}
Unfortunately, there is no way to enable logging in Aspose.Words or in Metered Licensing mechanism.
You can call License.setLicense method with an empty string as a parameter to switch Aspose.Words in evaluation mode:
License lic = new License();
lic.setLicense("C:\\Temp\\Aspose.Words.Java.lic");
// This will print 'true'
System.out.println(isLicensed());
lic.setLicense("");
// This will print 'false'
System.out.println(isLicensed());
It talks to https://purchase-api.dynabic.com/v1.2
If you have a license file, this is another licensing mechanist that does not require interaction with the server. You can simply set license once per application domain using code like the following:
License lic = new License();
lic.setLicense("C:\\Temp\\Aspose.Words.Java.lic");
I see this checks whether a license has been set, but not whether the license is valid. (I checked before/after when passing nonsense values for a metered key.) Among other things, I’m trying to debug whether the public/private keys are making it through to the licensing server unmangled. Is there a way to check that the license is valid, and not merely set?
To clarify, my request here was related to my response immediately above this quote: I want to see if the licensing server is accepting my license. I was hoping for a way to force the library to validate the license on demand so I could confirm without having to wait 24 hours to revert to evaluation mode in the case of failure.
The license file I downloaded from the order page is an XML file with a public/private key pair and nothing else in it. It’s very different structurally from the license file I had previously (which was not a metered license). It would be easier for me to use this file than pushing the public/private key pair around, which is why I asked about its validity. I’m unable to easily confirm whether it works on my own due to the aforementioned issues around confirming license validity with the licensing server.
Thanks for doing that. I wasn’t aware I could contact the sales department through this forum too; I’ll do that in the future.
Unfortunately, there is no other way to check validity of the license except setting it. If the license is invalid Aspose.Words will throw an exception.
You can read the values of the public/private key pair directly from XML file to make sure the values are not damaged.
I see, and thank you for your replies. One follow-up:
I think we’re talking past each other. I replaced my private key with the literal string garbage, and the library happily served up non-watermarked documents without any indication that something was wrong with the public or private keys. I assume that after 24 hours it would revert to trial mode – or are you saying that after 24 hours, it should throw an exception?
I’d like to request a feature, in that case: some kind of API call that validates a configured public/private key pair on-demand. Perhaps Metered.isValid()?
I’m assuming there is some misconfiguration on my part that is causing my issues, but without a way to reliably test the public/private key configuration end-to-end, I am reduced to making a guess and then waiting for 24 hours to see if it reverts to trial mode. Unless I am misunderstanding something, and there is a much faster way to test that it’s properly configured and the server is reachable?
Edit: replaced “license” with something clearer, I hope!
@epaulet-society Thank you for additional information. I will consult with the team responsible for the metered licensing mechanist development and get back to you once receive the answer from them.
Thank you. I’ve decided to roll back our licensing changes until you come back to me with a technique I can use to test more quickly.
Can you confirm if you are seeing any calls back to your licensing service with the keys from my account? My latest test was a failure: I was using the library successfully > 24 hours ago without watermarking, but as of ~20 minutes ago, it has again reverted to watermarking.
@epaulet-society I do not have access to licensing service so I cannot check. I still wait for response from the responsible team. Please accept our apologies for your inconvenience.
After some time spent testing with different configurations, I can confirm that the license appears to work in all my environments. Thanks for resolving that. I see now that my server will throw an exception if the license is obviously misconfigured, rather than silently work for 24 hours.
I’m concerned that what appears to have been a clerical error out of my control can have this effect. Furthermore, the documentation is unclear on what exactly happens when the license is not in a good state. As far as I was able to find, it doesn’t mention anything about throwing exceptions, only watermarking.
Can you clarify in which scenarios I would expect to see watermarking versus exceptions being thrown? Generally, I would prefer the latter, as a hard failure is quicker to identify and resolve than waiting for users to start asking questions about watermarks.